pespin has uploaded this change for review.

View Change

sctp: Introduce test TC_stat_bsc_sctp_disconnected

Change-Id: Ic67d9d8120e9bd09b0e54b237e93f49f79262be0
Related: OS#5917
Depends: osmo-smlc.git Change-Id Ib01576036f34ac7f21c5bce0155b50932eb9b72a
---
M smlc/SMLC_Tests.default
M smlc/SMLC_Tests.ttcn
M smlc/expected-results.xml
3 files changed, 101 insertions(+), 0 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/81/40681/1
diff --git a/smlc/SMLC_Tests.default b/smlc/SMLC_Tests.default
index 4fa1adc..c9cabe8 100644
--- a/smlc/SMLC_Tests.default
+++ b/smlc/SMLC_Tests.default
@@ -21,6 +21,15 @@
*.STATSVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes"
*.STATSVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes"
*.STATSVTY.PROMPT1 := "OsmoSMLC> "
+*.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 := "OsmoSMLC";
diff --git a/smlc/SMLC_Tests.ttcn b/smlc/SMLC_Tests.ttcn
index 7bd7c26..be69c7d 100644
--- a/smlc/SMLC_Tests.ttcn
+++ b/smlc/SMLC_Tests.ttcn
@@ -64,6 +64,7 @@
port BSSAP_LE_CODEC_PT BSSAP_LE;

port TELNETasp_PT SMLCVTY;
+ port TELNETasp_PT STPVTY;

/* StatsD */
var StatsD_Checker_CT vc_STATSD;
@@ -207,6 +208,31 @@
"sccp-timer iar " & int2str(g_smlc_sccp_timer_iar)});
}

+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_smlc_asp_cmd(charstring cmd) runs on test_CT
+{
+ var charstring asp_name := "smlc0-0";
+ var charstring loc_port := int2str(2905);
+ var charstring rem_port := int2str(2905);
+ var charstring asp_proto := "m3ua";
+ var charstring asp_node := "asp " & asp_name & " " & loc_port & " " & rem_port & " " & asp_proto;
+ f_vty_config2(STPVTY, {"cs7 instance 0", asp_node}, cmd);
+}
+
+private function f_smlc_stats_prefix() return charstring
+{
+ return mp_statsd_prefix & "smlc.0.";
+}
+
type function void_fn(charstring id) runs on BSC_ConnHdlr;

private function f_connect_handler(inout BSC_ConnHdlr vc_conn, integer bssap_le_idx := 0) runs on test_CT {
@@ -495,12 +521,77 @@
vc_conn.done;
}

+/* When the last local SCTP link/ASP is terminated, last AS goes inactive
+ * and a SCCP N-PCSTATE.ind (unavailable) should arrive to upper layers.
+ * As a result, osmo-smlc should immediately mark the ran_peer as unusable.
+ * In Lb, the SCCP N-PCSTATE is triggered by instructing the STP to
+ * shutdown the ASP serving the SMLC, which will close the SCTP assoc between
+ * itself and IUT (SMLC), which should then generate an N-PCSTATE.ind.
+ */
+testcase TC_stat_bsc_sctp_disconnected() runs on test_CT {
+ var BSC_ConnHdlr vc_conn;
+ var TestHdlrParams pars := f_gen_test_hdlr_pars();
+
+ var charstring smlc_stats_prefix := f_smlc_stats_prefix();
+
+ var StatsDExpects expect_connected := {
+ {name := smlc_stats_prefix & "lb_peers.total", mtype := "g", min := 1, max := 1},
+ {name := smlc_stats_prefix & "lb_peers.active", mtype := "g", min := 1, max := 1}
+ };
+ var StatsDExpects expect_disconnected := {
+ {name := smlc_stats_prefix & "lb_peers.total", mtype := "g", min := 1, max := 1},
+ {name := smlc_stats_prefix & "lb_peers.active", mtype := "g", min := 0, max := 0}
+ };
+
+ g_statd_timeout := 15.0;
+ f_init();
+ f_init_vty_stp();
+ f_sleep(1.0);
+
+ pars.sccp_addr_bsc := g_bssap_le[0].sccp_addr_own;
+ pars.sccp_addr_smlc := g_bssap_le[0].sccp_addr_peer;
+
+ connect(self:STATSD_PROC, vc_STATSD:STATSD_PROC);
+ f_statsd_reset();
+ f_statsd_expect(expect_connected, wait_converge := true);
+ disconnect(self:STATSD_PROC, vc_STATSD:STATSD_PROC);
+
+ vc_conn := f_start_handler(refers(f_tc_smlc_location_request_with_ta_l3), pars);
+ vc_conn.done;
+
+ f_logp(SMLCVTY, "Shutting down SMLC ASP in STP");
+ f_vty_stp_smlc_asp_cmd("shutdown");
+
+ /* Wait for AS PENDING->INACTIVE transition (T(r) timeout after 2000msec): */
+ 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(SMLCVTY, "Restarting SMLC ASP in STP");
+ f_vty_stp_smlc_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(refers(f_tc_smlc_location_request_with_ta_l3), pars);
+ vc_conn.done;
+ setverdict(pass);
+}
+
control {
execute( TC_smlc_location_request_with_ta_l3() );
execute( TC_smlc_location_request_without_ta_l3() );
execute( TC_smlc_location_request_bsslap_reset() );
execute( TC_smlc_location_request_bsslap_abort() );
execute( TC_smlc_location_request_abort() );
+
+ /* 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_bsc_sctp_disconnected() );
+ }
}

}
diff --git a/smlc/expected-results.xml b/smlc/expected-results.xml
index 7834ebd..438bfe1 100644
--- a/smlc/expected-results.xml
+++ b/smlc/expected-results.xml
@@ -5,4 +5,5 @@
<testcase classname='SMLC_Tests' name='TC_smlc_location_request_bsslap_reset' time='MASKED'/>
<testcase classname='SMLC_Tests' name='TC_smlc_location_request_bsslap_abort' time='MASKED'/>
<testcase classname='SMLC_Tests' name='TC_smlc_location_request_abort' time='MASKED'/>
+ <testcase classname='SMLC_Tests' name='TC_stat_bsc_sctp_disconnected' time='MASKED'/>
</testsuite>

To view, visit change 40681. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ic67d9d8120e9bd09b0e54b237e93f49f79262be0
Gerrit-Change-Number: 40681
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>