pespin has submitted this change. (
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40486?usp=email )
Change subject: bsc: generic: Introduce test TC_stat_msc_sctp_disconnected
......................................................................
bsc: generic: Introduce test TC_stat_msc_sctp_disconnected
Take the chance to properly configure all ASP/AS data statically, in
order to be able to access them through VTY as well as have the setup
properly documented in the config files.
Change-Id: I028a16e2742ff0c58bf3b51ee1233ccf947a5a6a
Related: OS#5917
Related: SYS#7501
---
M bsc/BSC_Tests.default
M bsc/BSC_Tests.ttcn
M bsc/BSC_Tests_SCCPlite.cfg
M bsc/expected-results.xml
M bsc/osmo-bsc-sccplite.cfg
M bsc/osmo-bsc.cfg
M bsc/osmo-stp.cfg
7 files changed, 147 insertions(+), 16 deletions(-)
Approvals:
osmith: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/bsc/BSC_Tests.default b/bsc/BSC_Tests.default
index 50c5c0a..65cc7c2 100644
--- a/bsc/BSC_Tests.default
+++ b/bsc/BSC_Tests.default
@@ -26,6 +26,15 @@
*.STATSVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes"
*.STATSVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes"
*.STATSVTY.PROMPT1 := "OsmoBSC> "
+*.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 := "OsmoBSC";
diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index ec1e983..d246b90 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -634,11 +634,14 @@
var MGCP_Emulation_CT vc_MGCP[NUM_MGW];
var integer g_nr_mgw; /* number of vc_MGCP to initialize */
port TELNETasp_PT BSCVTY;
+ port TELNETasp_PT STPVTY;
/* StatsD */
var StatsD_Checker_CT vc_STATSD;
var RAN_Adapter g_bssap[NUM_MSC];
+ /* Configure/manage IPA_Emulation RAN_Adapter: */
+ port IPA_CFG_PT SCCPLITE_IPA_CFG_PORT[NUM_MSC];
var BSSAP_LE_Adapter g_bssap_le;
/* for old legacy-tests only */
port BSSAP_CODEC_PT BSSAP;
@@ -1131,6 +1134,34 @@
"sccp-timer iar " & int2str(g_bsc_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_bsc_asp_cmd(charstring cmd) runs on test_CT
+{
+ var charstring asp_name;
+ var charstring loc_port;
+ var charstring rem_port;
+ var charstring asp_proto;
+ if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
+ asp_name := "bsc0-0";
+ loc_port := int2str(1905);
+ rem_port := int2str(2905);
+ asp_proto := "m3ua";
+ } else {
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "osmo-stp not used in
SCCPLite!");
+ }
+ 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_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
{
if (rsl_idx >= lengthof(g_system_information)) {
@@ -1212,10 +1243,16 @@
var RanOps ranops := MSC_RanOps;
ranops.use_osmux := g_osmux_enabled_cn;
f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC",
ranops);
+ if (isbound(g_bssap[bssap_idx].vc_IPA)) {
+ connect(self:SCCPLITE_IPA_CFG_PORT[bssap_idx], g_bssap[bssap_idx].vc_IPA:CFG_PORT);
+ }
connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
f_ran_adapter_start(g_bssap[bssap_idx]);
} else {
f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC",
omit);
+ if (isbound(g_bssap[bssap_idx].vc_IPA)) {
+ connect(self:SCCPLITE_IPA_CFG_PORT[bssap_idx], g_bssap[bssap_idx].vc_IPA:CFG_PORT);
+ }
connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
f_ran_adapter_start(g_bssap[bssap_idx]);
f_legacy_bssap_reset();
@@ -1223,7 +1260,21 @@
}
private function f_bssap_idx_disconnect(integer bssap_idx) runs on test_CT {
- f_ran_adapter_cleanup(g_bssap[bssap_idx]);
+ var IPL4asp_Types.Result res := {
+ errorCode := omit,
+ connId := omit,
+ os_error_code := omit,
+ os_error_text := omit
+ };
+
+ if (isbound(g_bssap[bssap_idx].vc_IPA)) {
+ /* Alive components don't finish sockets (TCP FIN) when they are
+ * stopped. Hence, we need to manually call close() on them to make sure
+ * the IUT knows about it. */
+ f_ipa_cfg_disconnect(SCCPLITE_IPA_CFG_PORT[bssap_idx], res);
+ } else {
+ f_ran_adapter_cleanup(g_bssap[bssap_idx]);
+ }
}
/* global initialization function
@@ -3221,6 +3272,62 @@
f_tc_stat_num_msc_connected_test_ct(refers(f_tc_stat_num_msc_connected_3), 3);
}
+/* 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-bsc should immediately mark the MSC link as unusable.
+ * The scenario is slightly different in AoIP and SCCPLite:
+ * - AoIP: the SCCP N-PCSTATE is triggered by instructing the STP to
+ * shutdown the ASP serving the BSC, which will close the SCTP assoc between
+ * itself and IUT (BSC), which should then generate an N-PCSTATE.ind.
+ * - SCCPLite: Since osmo-bsc is connected directly to us (TTCN3), terminate our
+ * local SCTP conn to trigger the actions.
+ */
+testcase TC_stat_msc_sctp_disconnected() runs on test_CT {
+ var MSC_ConnHdlr vc_conn;
+ var integer exp_total_num_msc;
+
+ f_init(nr_bts := 1, handler_mode := true, nr_msc := 1);
+ if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
+ exp_total_num_msc := NUM_MSC;
+ f_init_vty_stp();
+ } else {
+ exp_total_num_msc := 1;
+ }
+ f_sleep(1.0);
+
+ f_ctrs_msc_init();
+
+ f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_msc:connected",
int2str(1));
+ f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_msc:total",
int2str(exp_total_num_msc));
+
+ if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
+ f_logp(BSCVTY, "Shutting down BSC ASP in STP");
+ f_vty_stp_bsc_asp_cmd("shutdown");
+ } else {
+ f_logp(BSCVTY, "Disconnecting msc0");
+ f_bssap_idx_disconnect(0);
+ }
+
+ /* Wait for AS PENDING ->INACTIVE transition (T(r) timeout after 2000msec): */
+
+ f_ctrl_exp_trap(IPA_CTRL, "msc." & int2str(0) &
".connection_status", "disconnected", timeout_val := 5.0);
+ f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_msc:connected",
int2str(0));
+ f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_msc:total",
int2str(exp_total_num_msc));
+
+ if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
+ f_logp(BSCVTY, "Restarting BSC ASP in STP");
+ f_vty_stp_bsc_asp_cmd("no shutdown");
+ } else {
+ f_logp(BSCVTY, "Waiting for bsc to reconnect to msc0");
+ }
+
+ f_ctrl_exp_trap(IPA_CTRL, "msc." & int2str(0) &
".connection_status", "connected", timeout_val := 10.0);
+ f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_msc:connected",
int2str(1));
+ f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_msc:total",
int2str(exp_total_num_msc));
+
+ f_shutdown_helper();
+}
+
/* Verify correct stats on the number of configured and connected MSCs */
private function f_tc_stat_num_bts_connected_msc_connhdlr(integer
expect_num_bts_connected) runs on MSC_ConnHdlr {
var integer num_trx_connected := 0;
@@ -9266,7 +9373,13 @@
f_shutdown_helper();
}
-/* When an MSC point-code gets an SCCP N-PCSTATE saying it is unreachable, immediately
mark the MSC as unusable. */
+/* When a peer point-code gets an SCCP N-PCSTATE saying it is unreachable,
+ * immediately mark the MSC 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-bsc finds out about
+ * the SCTP conn STP<->MSC going down, it will send an M3UA DUNA to the IUT
+ * (BSC) which should then generate an N-PCSTATE.ind.
+ */
testcase TC_mscpool_sccp_n_pcstate_detaches_msc() runs on test_CT {
f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
@@ -12588,6 +12701,7 @@
execute( TC_stat_num_bts_connected_1() );
execute( TC_stat_num_bts_connected_2() );
execute( TC_stat_num_bts_connected_3() );
+ execute( TC_stat_msc_sctp_disconnected() );
execute( TC_ctrl() );
if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
execute( TC_ctrl_location() );
diff --git a/bsc/BSC_Tests_SCCPlite.cfg b/bsc/BSC_Tests_SCCPlite.cfg
index 00f44b3..db0b4cd 100644
--- a/bsc/BSC_Tests_SCCPlite.cfg
+++ b/bsc/BSC_Tests_SCCPlite.cfg
@@ -17,7 +17,7 @@
{
transport := BSSAP_TRANSPORT_SCCPlite_SERVER,
sccp_service_type := "mtp3_itu",
- sctp_addr := { 5000, "127.0.0.1", -1, "" },
+ sctp_addr := { 5000, "127.0.0.1", 4000, "" },
own_pc := 185, /* 0.23.1 first MSC emulation */
own_ssn := 254,
peer_pc := 187, /* 0.23.3 osmo-bsc */
diff --git a/bsc/expected-results.xml b/bsc/expected-results.xml
index 93432b9..7569056 100644
--- a/bsc/expected-results.xml
+++ b/bsc/expected-results.xml
@@ -8,6 +8,7 @@
<testcase classname='BSC_Tests' name='TC_stat_num_bts_connected_1'
time='MASKED'/>
<testcase classname='BSC_Tests' name='TC_stat_num_bts_connected_2'
time='MASKED'/>
<testcase classname='BSC_Tests' name='TC_stat_num_bts_connected_3'
time='MASKED'/>
+ <testcase classname='BSC_Tests' name='TC_stat_msc_sctp_disconnected'
time='MASKED'/>
<testcase classname='BSC_Tests' name='TC_ctrl'
time='MASKED'/>
<testcase classname='BSC_Tests' name='TC_ctrl_location'
time='MASKED'/>
<testcase classname='BSC_Tests' name='TC_si_default'
time='MASKED'/>
diff --git a/bsc/osmo-bsc-sccplite.cfg b/bsc/osmo-bsc-sccplite.cfg
index f8dc619..8e6c72f 100644
--- a/bsc/osmo-bsc-sccplite.cfg
+++ b/bsc/osmo-bsc-sccplite.cfg
@@ -27,14 +27,14 @@
no e1_line 0 keepalive
cs7 instance 0
point-code 0.23.3
- asp asp-clnt-msc-0 5000 0 ipa
+ asp asp-clnt-msc-0 5000 4000 ipa
remote-ip 127.0.0.1
role asp
sctp-role client
as as-clnt-msc-0 ipa
asp asp-clnt-msc-0
routing-key 0 0.23.3
- point-code override dpc 0.23.1
+ point-code override dpc 0.23.3
network
network country code 1
mobile network code 1
diff --git a/bsc/osmo-bsc.cfg b/bsc/osmo-bsc.cfg
index a03aeaf..6722fea 100644
--- a/bsc/osmo-bsc.cfg
+++ b/bsc/osmo-bsc.cfg
@@ -58,9 +58,11 @@
remote-ip 127.0.0.1
role asp
sctp-role client
- sccp-address msc2
+ sccp-address msc0
+ point-code 0.23.1
+ sccp-address msc1
point-code 0.0.2
- sccp-address msc3
+ sccp-address msc2
point-code 0.0.3
network
network country code 1
@@ -481,6 +483,7 @@
timeslot 7
phys_chan_config PDCH
msc 0
+ msc-addr msc0
allow-emergency allow
amr-config 12_2k forbidden
amr-config 10_2k forbidden
@@ -493,9 +496,9 @@
codec-list fr1 fr2 fr3 hr1 hr3
lcls-mode mgw-loop
msc 1
- msc-addr msc2
+ msc-addr msc1
msc 2
- msc-addr msc3
+ msc-addr msc2
network
nri bitlen 10
diff --git a/bsc/osmo-stp.cfg b/bsc/osmo-stp.cfg
index 14b7a29..861e75d 100644
--- a/bsc/osmo-stp.cfg
+++ b/bsc/osmo-stp.cfg
@@ -27,14 +27,20 @@
!
cs7 instance 0
xua rkm routing-key-allocation dynamic-permitted
+ asp bsc0-0 1905 2905 m3ua
+ local-ip 127.0.0.1
+ remote-ip 127.0.0.1
+ role sg
+ sctp-role server
+ as bsc0 m3ua
+ routing-key 0 0.23.3
+ asp bsc0-0
+
asp virt-msc0-0 23905 2905 m3ua
local-ip 127.0.0.1
remote-ip 127.0.0.1
role sg
sctp-role server
- as mahlzeit ipa
- routing-key 0 0.23.4
- point-code override dpc 0.23.1
as virt-msc0 m3ua
asp virt-msc0-0
routing-key 1 0.23.1
@@ -67,13 +73,11 @@
routing-key 6 0.23.6
route-table system
+ update route 0.23.3 7.255.7 linkset bsc0
update route 0.23.1 7.255.7 linkset virt-msc0
update route 0.0.2 7.255.7 linkset virt-msc1
update route 0.0.3 7.255.7 linkset virt-msc2
update route 0.23.6 7.255.7 linkset virt-smlc
listen m3ua 2905
- accept-asp-connections dynamic-permitted
- local-ip 127.0.0.1
- listen ipa 5000
- accept-asp-connections dynamic-permitted
+ accept-asp-connections pre-configured
local-ip 127.0.0.1
--
To view, visit
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40486?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: I028a16e2742ff0c58bf3b51ee1233ccf947a5a6a
Gerrit-Change-Number: 40486
Gerrit-PatchSet: 5
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>