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

Change subject: hnbgw: Introduce test TC_stat_stp_sctp_disconnected
......................................................................

hnbgw: Introduce test TC_stat_stp_sctp_disconnected

Related: OS#5917
Depends: libosmo-sigtran.git Change-Id I7e4eedb65c4f2952f8b39ca4c539ca2f40e9946c
Change-Id: I079f2da09ff8d52e614ff6f5d267cd5429e4eb58
---
M hnbgw/HNBGW_Tests.default
M hnbgw/HNBGW_Tests.ttcn
M hnbgw/expected-results.xml
3 files changed, 110 insertions(+), 3 deletions(-)

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




diff --git a/hnbgw/HNBGW_Tests.default b/hnbgw/HNBGW_Tests.default
index b8a4863..174b012 100644
--- a/hnbgw/HNBGW_Tests.default
+++ b/hnbgw/HNBGW_Tests.default
@@ -20,6 +20,16 @@
 *.STATSVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes"
 *.STATSVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes"
 *.STATSVTY.PROMPT1 := "OsmoHNBGW> "
+*.STPVTY.CTRL_MODE := "client"
+*.STPVTY.CTRL_HOSTNAME := "127.0.0.1"
+*.STPVTY.CTRL_PORTNUM := "4239"
+*.STPVTY.CTRL_LOGIN_SKIPPED := "yes"
+*.STPVTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes"
+*.STPVTY.CTRL_READMODE := "buffered"
+*.STPVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes"
+*.STPVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes"
+*.STPVTY.PROMPT1 := "OsmoSTP> "
+

 [MODULE_PARAMETERS]
 Osmocom_VTY_Functions.mp_prompt_prefix := "OsmoHNBGW";
diff --git a/hnbgw/HNBGW_Tests.ttcn b/hnbgw/HNBGW_Tests.ttcn
index ef70948..76e364f 100644
--- a/hnbgw/HNBGW_Tests.ttcn
+++ b/hnbgw/HNBGW_Tests.ttcn
@@ -228,6 +228,7 @@

 function MSC_UnitdataCallback(RANAP_PDU ranap) runs on RAN_Emulation_CT return 
template RANAP_PDU {
        // TODO: Actually implement unitdata handling
+       log("MSC_UnitdataCallback: Ignoring RANAP msg: ", ranap);
        return omit;
 }

@@ -264,10 +265,12 @@

        var MGCP_Emulation_CT vc_MGCP;
        port TELNETasp_PT HNBGWVTY;
+       port TELNETasp_PT STPVTY;
        var StatsD_Checker_CT vc_STATSD;
        var PFCP_Emulation_CT vc_PFCP;
        /* global test case guard timer (actual timeout value is set in 
f_init()) */
        timer T_guard := 45.0;
+       var float g_statd_timeout := 5.0;

        /* The cnlink type 'msc' or 'sgsn', to be used in CTRL commands to 
obtain counters */
        var charstring g_ctr_cn_node_name;
@@ -298,6 +301,22 @@
        f_vty_transceive(HNBGWVTY, "enable");
 }

+private function f_init_vty_stp() runs on test_CT {
+       if (STPVTY.checkstate("Mapped")) {
+               /* skip initialization if already executed once */
+               return;
+       }
+       map(self:STPVTY, system:STPVTY);
+       f_vty_set_prompts(STPVTY, prompt_prefix := "OsmoSTP");
+       f_vty_transceive(STPVTY, "enable");
+}
+
+private function f_vty_stp_hnbgw_asp_cmd(charstring cmd) runs on test_CT
+{
+       var charstring asp_node := "asp hnbgw0-0 2906 2905 m3ua";
+       f_vty_config2(STPVTY, {"cs7 instance 0", asp_node}, cmd);
+}
+
 function f_init_mgcp(charstring id) runs on test_CT {
        id := id & "-MGCP";
        var MGCPOps ops := {
@@ -484,7 +503,7 @@

        vc_mutex_disp := f_MutexDisp_start();

-       f_init_statsd("VirtHNBGW", vc_STATSD, mp_local_statsd_ip, 
mp_local_statsd_port);
+       f_init_statsd("VirtHNBGW", vc_STATSD, mp_local_statsd_ip, 
mp_local_statsd_port, g_statd_timeout);
        f_init_vty("VirtHNBGW");
        f_ipa_ctrl_start_client(mp_hnbgw_ip, mp_hnbgw_ctrl_port);

@@ -2490,7 +2509,13 @@
        f_shutdown_helper();
 }

-/* When a peer point-code gets an SCCP N-PCSTATE saying it is unreachable, 
immediately mark the CN link as unusable. */
+/* When a peer point-code gets an SCCP N-PCSTATE saying it is unreachable,
+ * immediately mark the CN link as unusable.
+ * In this scenario, the SCCP N-PCSTATE is triggered by locally dropping the
+ * SCTP assoc at the virtual MSC (TTCN3). When STP osmo-hnbgw finds out about
+ * the SCTP conn STP<->MSC going down, it will send an M3UA DUNA to the IUT
+ * (HNBGW) which should then generate an N-PCSTATE.ind.
+ */
 testcase TC_mscpool_sccp_n_pcstate_detaches_cnlink() runs on test_CT {
        f_TC_cnpool_sccp_n_pcstate_detaches_cnlink(ps_domain := false);
 }
@@ -2701,6 +2726,70 @@
        f_TC_cnpool_L3Compl_no_cn(ps_domain := true);
 }

+/* When a peer point-code gets an SCCP N-PCSTATE saying it is unreachable,
+ * immediately mark the CN link as unusable.
+ * In this scenario, the SCCP N-PCSTATE is triggered by instructing the STP to
+ * shutdown the ASP serving the HNBGW, which will close the SCTP assoc between
+ * itself and IUT (HNBGW), which should then generate an N-PCSTATE.ind.
+ */
+function f_TC_stat_stp_sctp_disconnected_UnitdataCallback(RANAP_PDU ranap) 
runs on RAN_Emulation_CT return template RANAP_PDU {
+       if (match(ranap, tr_RANAP_Reset)) {
+               log("Answering RESET with RESET-ACK: ", ranap);
+               return 
valueof(ts_RANAP_ResetAck(ranap.initiatingMessage.value_.Reset.protocolIEs[1].value_.cN_DomainIndicator));
+       }
+       return omit;
+}
+testcase TC_stat_stp_sctp_disconnected() runs on test_CT
+{
+       var ConnHdlr vc_conn;
+
+       g_num_hnbs := 1;
+       g_statd_timeout := 15.0;
+       g_ran_ops.ranap_unitdata_cb := 
refers(f_TC_stat_stp_sctp_disconnected_UnitdataCallback);
+       f_init(nr_msc := 1, nr_sgsn := 1);
+       f_init_vty_stp();
+       f_sleep(1.0);
+
+       connect(self:STATSD_PROC, vc_STATSD:STATSD_PROC);
+       f_statsd_reset();
+
+       /* Expect stats to be 0 */
+       var charstring msc0_prefix := mp_statsd_prefix & "msc.0.";
+       var charstring sgsn0_prefix := mp_statsd_prefix & "sgsn.0.";
+       var StatsDExpects expect_connected := {
+               {name := msc0_prefix & "connected", mtype := "g", min := 1, max 
:= 1},
+               {name := sgsn0_prefix & "connected", mtype := "g", min := 1, 
max := 1}
+       };
+       var StatsDExpects expect_disconnected := {
+               {name := msc0_prefix & "connected", mtype := "g", min := 0, max 
:= 0},
+               {name := sgsn0_prefix & "connected", mtype := "g", min := 0, 
max := 0}
+       };
+       f_statsd_expect(expect_connected);
+       disconnect(self:STATSD_PROC, vc_STATSD:STATSD_PROC);
+
+       vc_conn := f_start_handler_with_pars(refers(f_tc_rab_assignment), 
f_TestHdlrParams(3));
+       vc_conn.done;
+
+       f_logp(HNBGWVTY, "Shutting down HNBGW ASP in STP");
+       f_vty_stp_hnbgw_asp_cmd("shutdown");
+
+       connect(self:STATSD_PROC, vc_STATSD:STATSD_PROC);
+       f_statsd_expect(expect_disconnected, wait_converge := true);
+       disconnect(self:STATSD_PROC, vc_STATSD:STATSD_PROC);
+
+       f_logp(HNBGWVTY, "Restarting HNBGW ASP in STP");
+       f_vty_stp_hnbgw_asp_cmd("no shutdown");
+
+       connect(self:STATSD_PROC, vc_STATSD:STATSD_PROC);
+       f_statsd_expect(expect_connected, wait_converge := true);
+       disconnect(self:STATSD_PROC, vc_STATSD:STATSD_PROC);
+
+       vc_conn := f_start_handler_with_pars(refers(f_tc_rab_assignment), 
f_TestHdlrParams(4));
+       vc_conn.done;
+
+       f_shutdown_helper();
+}
+
 control {
        execute(TC_hnb_register());
        execute(TC_hnb_register_duplicate());
@@ -2768,6 +2857,13 @@
        execute(TC_second_rab_assignment());
        execute(TC_hnb_reregister_reuse_sctp_assoc());

+       /* This "nightly" if can be removed once libosmo-sigtran (osmo-stp) > 
2.1.0 is released.
+        * Currently released osmo-stp 2.1.0 ends up in in broken 
AS-ACTIVE+ASP-DOWN state when
+        * restarting the ASP after exiting the related asp node through VTY: */
+       if (Misc_Helpers.f_osmo_repo_is("nightly")) {
+               execute(TC_stat_stp_sctp_disconnected());
+       }
+
        /* Run at the end since it messes with the SCCP config */
        execute( TC_apply_sccp() );
 }
diff --git a/hnbgw/expected-results.xml b/hnbgw/expected-results.xml
index c04876d..f1fe858 100644
--- a/hnbgw/expected-results.xml
+++ b/hnbgw/expected-results.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<testsuite name='Titan' tests='62' failures='0' errors='0' skipped='0' 
inconc='0' time='MASKED'>
+<testsuite name='Titan' tests='63' failures='0' errors='0' skipped='0' 
inconc='0' time='MASKED'>
   <testcase classname='HNBGW_Tests' name='TC_hnb_register' time='MASKED'/>
   <testcase classname='HNBGW_Tests' name='TC_hnb_register_duplicate' 
time='MASKED'/>
   <testcase classname='HNBGW_Tests' 
name='TC_hnb_register_duplicate_reuse_sctp_assoc' time='MASKED'/>
@@ -63,5 +63,6 @@
   <testcase classname='HNBGW_Tests' 
name='TC_sgsnpool_sccp_n_pcstate_attaches_cnlink' time='MASKED'/>
   <testcase classname='HNBGW_Tests' name='TC_second_rab_assignment' 
time='MASKED'/>
   <testcase classname='HNBGW_Tests' name='TC_hnb_reregister_reuse_sctp_assoc' 
time='MASKED'/>
+  <testcase classname='HNBGW_Tests' name='TC_stat_stp_sctp_disconnected' 
time='MASKED'/>
   <testcase classname='HNBGW_Tests' name='TC_apply_sccp' time='MASKED'/>
 </testsuite>

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40592?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: I079f2da09ff8d52e614ff6f5d267cd5429e4eb58
Gerrit-Change-Number: 40592
Gerrit-PatchSet: 5
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: lynxis lazus <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to