pespin has uploaded this change for review.

View Change

sgsn: Introduce test TC_stat_rnc_sctp_disconnected

The commit doesn't validate everything it should, because passing the
indication from osmo-iuh's iu_client to app (osmo-sgsn) is not
supported in current API, and hence the statsd metrics are not yet
implemented in osmo-sgsn.

Still, this test already validates that osmo-sgsn is capable of
surviving an sctp link down event in IuPS, and continue to work
afterwards. IT also allows easily debugging this scenario by inspecting
pcap files, logs, etc.

Related: OS#5917
Change-Id: I35888630ea9e9005e1252677c5d42f66f84e177b
---
M sgsn/SGSN_Tests.default
M sgsn/SGSN_Tests.ttcn
M sgsn/SGSN_Tests_Iu.ttcn
M sgsn/expected-results.xml
4 files changed, 78 insertions(+), 1 deletion(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/44/40644/1
diff --git a/sgsn/SGSN_Tests.default b/sgsn/SGSN_Tests.default
index e44e234..f8d3e46 100644
--- a/sgsn/SGSN_Tests.default
+++ b/sgsn/SGSN_Tests.default
@@ -17,6 +17,15 @@
*.SGSNVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes"
*.SGSNVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes"
*.SGSNVTY.PROMPT1 := "OsmoSGSN> "
+*.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]
diff --git a/sgsn/SGSN_Tests.ttcn b/sgsn/SGSN_Tests.ttcn
index b2d9731..d5f98ce 100644
--- a/sgsn/SGSN_Tests.ttcn
+++ b/sgsn/SGSN_Tests.ttcn
@@ -192,6 +192,7 @@
var GTP_Emulation_CT vc_GGSN_GTP;

port TELNETasp_PT SGSNVTY;
+ port TELNETasp_PT STPVTY;

var boolean g_initialized := false;
var boolean g_use_echo := false;
@@ -311,6 +312,26 @@
f_vty_config(SGSNVTY, "sgsn", "auth-policy remote");
}

+friend 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");
+}
+
+friend function f_vty_stp_sgsn_asp_cmd(charstring cmd) runs on test_CT
+{
+ var charstring asp_name := "sgsn0-0";
+ var charstring loc_port := int2str(1905);
+ 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_vty_enable_echo_interval(boolean enable) runs on test_CT {
if (enable) {
f_vty_config(SGSNVTY, "sgsn", "ggsn 0 echo-interval " & int2str(mp_echo_interval));
diff --git a/sgsn/SGSN_Tests_Iu.ttcn b/sgsn/SGSN_Tests_Iu.ttcn
index 53a1080..3de89b6 100644
--- a/sgsn/SGSN_Tests_Iu.ttcn
+++ b/sgsn/SGSN_Tests_Iu.ttcn
@@ -416,6 +416,45 @@
f_cleanup();
}

+/* When the last local IPA/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-sgsn should immediately mark the RNC as unusable.
+ * In AoIP, the SCCP N-PCSTATE is triggered by instructing the STP to
+ * shutdown the ASP serving the SGSN, which will close the SCTP assoc between
+ * itself and IUT (SGSN), which should then generate an N-PCSTATE.ind.
+ */
+/* TODO: OS#5917: Once we get rid of iu_client layer and handle SCCP SAP
+ * directly in osmo-sgsn, we'll be able to track IuPS status (eg RESET FSM) like
+ * we do in osmo-msc. Once that's in place we can add stats metrics to figure
+ * out connection status and use them here.
+ * See as a reference for improvement: MSC_Tests.TC_stat_rnc_sctp_disconnected
+ */
+testcase TC_stat_rnc_sctp_disconnected() runs on test_CT {
+ var BSSGP_ConnHdlr vc_conn;
+
+ f_init();
+ f_init_vty_stp();
+ f_sleep(1.0);
+ f_vty_config(SGSNVTY, "sgsn", "encryption uea 0");
+
+ vc_conn := f_start_handler(refers(f_TC_iu_attach), testcasename(), g_gb, 1008);
+ vc_conn.done;
+
+ f_logp(SGSNVTY, "Shutting down SGSN ASP in STP");
+ f_vty_stp_sgsn_asp_cmd("shutdown");
+
+ /* Wait for AS PENDING->INACTIVE transition (T(r) timeout after 2000msec): */
+ f_sleep(3.0);
+
+ f_logp(SGSNVTY, "Restarting SGSN ASP in STP");
+ f_vty_stp_sgsn_asp_cmd("no shutdown");
+
+ f_sleep(15.0);
+
+ vc_conn := f_start_handler(refers(f_TC_iu_attach), testcasename(), g_gb, 1009);
+ vc_conn.done;
+ f_cleanup();
+}
control {
execute( TC_iu_attach() );
execute( TC_iu_attach_encr() );
@@ -429,6 +468,13 @@
execute( TC_attach_pdp_act_pmm_idle() );
execute( TC_pmm_idle_rx_mt_data() );
execute( TC_update_ctx_err_ind_from_ggsn() );
+
+ /* 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_rnc_sctp_disconnected() );
+ }
}


diff --git a/sgsn/expected-results.xml b/sgsn/expected-results.xml
index bdd0f29..e2e099b 100644
--- a/sgsn/expected-results.xml
+++ b/sgsn/expected-results.xml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<testsuite name='Titan' tests='74' failures='4' errors='0' skipped='0' inconc='0' time='MASKED'>
+<testsuite name='Titan' tests='75' failures='4' errors='0' skipped='0' inconc='0' time='MASKED'>
<testcase classname='SGSN_Tests' name='TC_attach' time='MASKED'/>
<testcase classname='SGSN_Tests' name='TC_attach_mnc3' time='MASKED'/>
<testcase classname='SGSN_Tests' name='TC_attach_umts_aka_umts_res' time='MASKED'/>
@@ -101,6 +101,7 @@
<testcase classname='SGSN_Tests_Iu' name='TC_attach_pdp_act_pmm_idle_lost_pdp_status' time='MASKED'/>
<testcase classname='SGSN_Tests_Iu' name='TC_pmm_idle_rx_mt_data' time='MASKED'/>
<testcase classname='SGSN_Tests_Iu' name='TC_update_ctx_err_ind_from_ggsn' time='MASKED'/>
+ <testcase classname='SGSN_Tests_Iu' name='TC_stat_rnc_sctp_disconnected' time='MASKED'/>
<!-- SGSN_Tests_NS (handle_sns == true) testcases start here -->
<testcase classname='SGSN_Tests_NS' name='TC_SNS_size' time='MASKED'/>
<testcase classname='SGSN_Tests_NS' name='TC_SNS_size_too_big' time='MASKED'/>

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

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