bsc: Fix TC_rsl_drop_counter due to IPA_Emulation component being alive-type
IPA_Emulation component was marked with the "alive" type recently, in
order to avoid race conditions leading to errors during tear down of the
test.
It turns out, the way "alive" keeps the component alive is by means of
not closing the sockets when the component is stopped. As a result,
TC_rsl_drop_counter test stopped working properly because it was
specting a TCP FIN to be sent to osmo-bsc when the component was
stopped.
In order to fix it, add a new CFG port to the IPA_Emulation component on
which one can operate. Add a a new method to tell the component to close
the socket.
Then, put that in BSC_Tests into a function which was actually unsued
until now, and use it in the test in order to have the specific logic
enclosed in a function helper.
Fixes: 7138913d664c33b2404e3d293ab820fb3516ff73
Change-Id: I68163b053313d9907ba8e40954a5933d14cb7db6
diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index c485ec5..7bfc387 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -595,6 +595,8 @@
port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
/* CTRL muxed over IPA in SCCPlite conn BSC<->MSC (or BSC-NAT) */
port IPA_CTRL_PT SCCPLITE_IPA_CTRL;
+ /* Configure/manage IPA_Emulation: */
+ port IPA_CFG_PT IPA_CFG_PORT;
var MGCP_Emulation_CT vc_MGCP;
port TELNETasp_PT BSCVTY;
@@ -926,6 +928,7 @@
}
map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
+ connect(clnt.vc_IPA:CFG_PORT, self:IPA_CFG_PORT);
if (handler_mode) {
connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
} else {
@@ -955,9 +958,22 @@
}
function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
+ var IPL4asp_Types.Result res := {
+ errorCode := omit,
+ connId := omit,
+ os_error_code := omit,
+ os_error_text := omit
+ };
+
if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
return;
}
+
+ /* 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(IPA_CFG_PORT, res);
+
clnt.vc_IPA.stop;
if (isbound(clnt.vc_RSL)) {
clnt.vc_RSL.stop;
@@ -3555,7 +3571,7 @@
rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
- bts[0].rsl.vc_IPA.stop;
+ f_ipa_rsl_stop(bts[0].rsl);
f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
diff --git a/library/IPA_Emulation.ttcnpp b/library/IPA_Emulation.ttcnpp
index 5cdf324..0cd7314 100644
--- a/library/IPA_Emulation.ttcnpp
+++ b/library/IPA_Emulation.ttcnpp
@@ -206,6 +206,9 @@
type component IPA_Emulation_CT {
/* down-facing port to IPA codec port */
port IPA_CODEC_PT IPA_PORT;
+ /* Down facing port to configure the component */
+ port IPA_CFG_PT CFG_PORT;
+
#ifdef IPA_EMULATION_SCCP
/* up-facing port to SCCP */
port MTP3asp_SP_PT MTP3_SP_PORT;
@@ -286,6 +289,17 @@
osmo_rand := ""
};
+signature IPA_CFG_disconnect(inout IPL4asp_Types.Result res);
+type port IPA_CFG_PT procedure {
+ inout IPA_CFG_disconnect;
+} with { extension "internal" };
+
+function f_ipa_cfg_disconnect(IPA_CFG_PT pt, inout IPL4asp_Types.Result res) {
+ pt.call(IPA_CFG_disconnect:{res}) {
+ [] pt.getreply(IPA_CFG_disconnect:{?}) -> param (res) {};
+ }
+}
+
/* Function to use to connect as client to a remote IPA Server */
function f_connect(charstring remote_host, IPL4asp_Types.PortNumber remote_port,
charstring local_host, IPL4asp_Types.PortNumber local_port,
@@ -318,6 +332,25 @@
g_is_bsc_mgw := false;
}
+private function f_close() runs on IPA_Emulation_CT return IPL4asp_Types.Result {
+ var IPL4asp_Types.Result res;
+ select (g_mode) {
+ case (IPA_MODE_CLIENT) {
+ res := IPA_CodecPort_CtrlFunct.f_IPL4_close(IPA_PORT, g_self_conn_id, {tcp := {}});
+ g_self_conn_id := -1;
+ }
+ case (IPA_MODE_SERVER) {
+ res := IPA_CodecPort_CtrlFunct.f_IPL4_close(IPA_PORT, g_last_conn_id, {tcp := {}});
+ g_last_conn_id := -1;
+ }
+ case else {
+ setverdict(fail, "Unknown mode");
+ mtc.stop;
+ }
+ }
+ return res;
+}
+
#ifdef IPA_EMULATION_SCCP
template ASP_MTP3_TRANSFERind ts_MTP3_XFER_ind(integer opc, octetstring data) := {
sio := { '10'B, '00'B, '0011'B },
@@ -661,6 +694,7 @@
var Socket_API_Definitions.PortEvent port_evt;
var octetstring payload;
var ASP_IPA_Unitdata ipa_ud;
+ var IPL4asp_Types.Result res;
#ifdef IPA_EMULATION_CTRL
var CtrlMessage ctrl_msg;
#endif
@@ -888,6 +922,11 @@
IPA_PORT.send(f_from_asp(f_ipa_conn_id(), ipa_ud));
}
+ /* Received call to configure/operate the component */
+ [] CFG_PORT.getcall(IPA_CFG_disconnect:{?}) {
+ res := f_close();
+ CFG_PORT.reply(IPA_CFG_disconnect:{res});
+ }
}
}