pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40786?usp=email )

Change subject: 5gc: Introduce test TC_ng_register_ping4_256
......................................................................

5gc: Introduce test TC_ng_register_ping4_256

open5gs-dbctl tool is called in batches of multiple IMSIs to speed up
setup, since each call takes fractions of seconds to complete.
mongosh called by open5gs-dbctl actually uses quite a lot of CPU and RAM
resources, hence limit the amount of parallel runs to a fair amount (eg.
running the 256 of them in parallel froze my workstation with 16GB of
RAM).

Change-Id: I7282fa3c1a474c4b7dceeb5e358547dcdbd1fea6
---
M 5gc/C5G_Tests.ttcn
M 5gc/ConnHdlr.ttcn
M 5gc/create_test_subscribers.sh
M 5gc/expected-results.xml
M library/NGAP_Emulation.ttcn
5 files changed, 51 insertions(+), 29 deletions(-)

Approvals:
  Jenkins Builder: Verified
  osmith: Looks good to me, but someone else must approve
  fixeria: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved




diff --git a/5gc/C5G_Tests.ttcn b/5gc/C5G_Tests.ttcn
index 4cda45f..9eb6f30 100644
--- a/5gc/C5G_Tests.ttcn
+++ b/5gc/C5G_Tests.ttcn
@@ -49,9 +49,6 @@

 import from ConnHdlr all;

-/* (maximum) number of emulated UEs */
-const integer NUM_UE := 1;
-
 modulepar {
        /* NG-C interface */
        charstring mp_5gc_ngap_ip := "127.0.0.1";
@@ -81,16 +78,17 @@
        ping_hostname := mp_ping_hostname
 }

-template (value) UeParams ts_UeParams(integer imsi_suffix) :=
+template (value) UeParams ts_UeParams(integer idx) :=
 {
-       imsi := f_concat_pad(lengthof(mp_imsi), substr(mp_imsi, 0, 
lengthof(mp_imsi) - 6), imsi_suffix),
+       idx := idx,
+       imsi := f_concat_pad(lengthof(mp_imsi), substr(mp_imsi, 0, 
lengthof(mp_imsi) - 6), idx),
        imeisv := f_rnd_imeisv(),
        usim_key := mp_usim_key,
        usim_opc := mp_usim_opc,
        apn := mp_apn,
-       run_prog_pars := ts_RunProgParams(imsi_suffix),
+       run_prog_pars := ts_RunProgParams(idx),
        ran_gtpu_ip := mp_local_gtpu_ip,
-       ran_gtpu_teid := int2oct(imsi_suffix + 1, 4),
+       ran_gtpu_teid := int2oct(idx + 1, 4),
        cn_gtpu_ip := omit,
        cn_gtpu_teid := omit,
        qfi := omit,
@@ -108,8 +106,6 @@
        port GTP1UEM_PT TEID0;

        timer g_Tguard := 30.0;
-
-       var UeParams g_ue_pars[NUM_UE];
 }

 /* send incoming unit data messages (like reset) to global NGAP_UNIT port */
@@ -156,19 +152,11 @@
        NGAP_UNIT[num].receive(NGAPEM_Event:{up_down:=NGAPEM_EVENT_UP});
 }

-private function f_init_one_ue(inout UeParams uep, integer imsi_suffix) {
-
-       uep := valueof(ts_UeParams(imsi_suffix));
-}
-
 private function f_init_ngap(integer imsi_suffix := 0) runs on MTC_CT {
        var integer i;
        for (i := 0; i < NUM_NGRAN; i := i+1) {
                f_init_one_ngran(i);
        }
-       for (i := 0; i < NUM_UE; i := i+1) {
-               f_init_one_ue(g_ue_pars[i], 1000*imsi_suffix + i);
-       }
 }

 private function f_init_gtp1u() runs on MTC_CT {
@@ -198,7 +186,7 @@
 runs on MTC_CT return ConnHdlrPars {
        var ConnHdlrPars pars := {
                ngran_pars := g_ngran_pars,
-               ue_pars := g_ue_pars[ue_idx],
+               ue_pars := valueof(ts_UeParams(ue_idx)),
                c5g_idx := 0,
                kset_id := valueof(cs_NAS_KeySetIdentifier_lv(tsc_NasKsi_NoKey, 
'0'B))
        };
@@ -329,6 +317,23 @@
        vc_conn := f_start_handler_with_pars(refers(f_TC_register_ping4), pars);
        vc_conn.done;
 }
+testcase TC_ng_register_ping4_256() runs on MTC_CT {
+       var ConnHdlr vc_conn[256];
+       var integer i;
+
+       f_init();
+       f_ngap_setup(0);
+
+       for (i := 0; i < sizeof(vc_conn); i := i + 1) {
+               var ConnHdlrPars pars := f_init_pars(ue_idx := i);
+               vc_conn[i] := 
f_start_handler_with_pars(refers(f_TC_register_ping4), pars);
+       }
+
+       for (i := 0; i < sizeof(vc_conn); i := i + 1) {
+               vc_conn[i].done;
+       }
+}
+

 control {
        execute( TC_ng_setup() );
@@ -336,6 +341,7 @@
        execute( TC_ng_setup_wrong_tac() );
        execute( TC_ng_register() );
        execute( TC_ng_register_ping4() );
+       execute( TC_ng_register_ping4_256() );
 }


diff --git a/5gc/ConnHdlr.ttcn b/5gc/ConnHdlr.ttcn
index 6c816fe..144b00b 100644
--- a/5gc/ConnHdlr.ttcn
+++ b/5gc/ConnHdlr.ttcn
@@ -67,6 +67,7 @@

 /* parameters of emulated UE */
 type record UeParams {
+       integer idx,
        HEX15n imsi,
        HEX16n imeisv,
        octetstring usim_key,
@@ -367,7 +368,7 @@
                                                                          
f_SUCI_IMSI()),
                                                 p_UESecurityCap := 
f_UE_SecurityCapability());
        nas_pdu := enc_NG_NAS_UL_Message_Type(valueof(nas_ul_msg));
-       tx_pdu := m_ngap_initMsg(m_n2_initialUeMessage(g_pars.c5g_idx,
+       tx_pdu := m_ngap_initMsg(m_n2_initialUeMessage(g_pars.ue_pars.idx,
                                                       nas_pdu, /* Registration 
request */
                                                       f_ULI(),
                                                       mo_Signalling));
diff --git a/5gc/create_test_subscribers.sh b/5gc/create_test_subscribers.sh
index a400e0f..28a7b6f 100755
--- a/5gc/create_test_subscribers.sh
+++ b/5gc/create_test_subscribers.sh
@@ -17,11 +17,25 @@
        sleep 1
 done

-# Create a test subscriber with IMSI=001010000000000
-$DBCTL_CMD add 999700000000000 3c6e0b8a9c15224a8228b9a98ca1531d 
762a2206fe0b4151ace403c86a11e479
+NUM_SUBCRS=256
+get_subscr_imsi() {
+       subscr_idx=$1
+       printf "999700000000%03u" "$subscr_idx"
+}

-# Mark test subscriber with IMSI=001010000000001 as:
-# Subscriber-Status=OPERATOR_DETERMINED_BARRING (1)
-# Operator-Determined-Barring="Barring of all outgoing inter-zonal calls 
except those directed to the home PLMN country" (7)
-$DBCTL_CMD add 999700000000001 3c6e0b8a9c15224a8228b9a98ca1531d 
762a2206fe0b4151ace403c86a11e479
-$DBCTL_CMD subscriber_status 999700000000001 1 7
+# Create a test subscriber with IMSI=001010000000000
+DBCTL_PARALLEL_JOBS=20
+idx=0
+while test "$idx" -lt "$NUM_SUBCRS"; do
+       remain="$((NUM_SUBCRS - idx))"
+       if test "$remain" -gt "$DBCTL_PARALLEL_JOBS"; then
+               iterations=$DBCTL_PARALLEL_JOBS
+       else
+               iterations=$remain
+       fi
+       for it in $(seq "$iterations"); do
+               $DBCTL_CMD add "$(get_subscr_imsi $idx)" 
3c6e0b8a9c15224a8228b9a98ca1531d 762a2206fe0b4151ace403c86a11e479 &
+               idx=$((idx + 1))
+       done
+       wait $(jobs -p)
+done
diff --git a/5gc/expected-results.xml b/5gc/expected-results.xml
index 01d53a1..98dee58 100644
--- a/5gc/expected-results.xml
+++ b/5gc/expected-results.xml
@@ -5,4 +5,5 @@
   <testcase classname='C5G_Tests' name='TC_ng_setup' time='MASKED'/>
   <testcase classname='C5G_Tests' name='TC_ng_register' time='MASKED'/>
   <testcase classname='C5G_Tests' name='TC_ng_register_ping4' time='MASKED'/>
+  <testcase classname='C5G_Tests' name='TC_ng_register_ping4_256' 
time='MASKED'/>
 </testsuite>
diff --git a/library/NGAP_Emulation.ttcn b/library/NGAP_Emulation.ttcn
index 9fbaddc..1fb571b 100644
--- a/library/NGAP_Emulation.ttcn
+++ b/library/NGAP_Emulation.ttcn
@@ -168,11 +168,11 @@
         * to send where with CLIENT.send() to vc_conn */
        port NGAP_Conn_PT NGAP_CLIENT;
        /* currently tracked connections */
-       var AssociationData NGapAssociationTable[16];
+       var AssociationData NGapAssociationTable[256];
        /* pending expected NGAP Association (UE oriented) */
-       var ExpectData NGapExpectTable[8];
+       var ExpectData NGapExpectTable[256];
        /* pending expected NGAP PDU */
-       var ExpectDataProc NGapExpectTableProc[8];
+       var ExpectDataProc NGapExpectTableProc[256];
        /* procedure based port to register for incoming connections */
        port NGAPEM_PROC_PT NGAP_PROC;
        /* test port for unit data messages */

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40786?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I7282fa3c1a474c4b7dceeb5e358547dcdbd1fea6
Gerrit-Change-Number: 40786
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to