<p>dexter has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/9962">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">BSC_Tests: count MGCP operations in as_media<br><br>as_media handles the MGCP interaction for most of the tests. However,<br>it does not make sure if transactions are missing or if too many<br>transactions are performed (e.g. if an SCCP-Lite tests still creates<br>the connections pointing to the core network, even if they must not<br>created by the BSC in this case). So lets make sure that the MGCP<br>transactions are performed as expected by counting them.<br><br>- Add counters to count CRCX and MDCX transactions<br>- Check those counters after call establishment and handover<br><br>Change-Id: Ib073b097a840ca3a8ee99c4ed41f59f574191d98<br>Related: OS#3292<br>---<br>M bsc/BSC_Tests.ttcn<br>M bsc/MSC_ConnectionHandler.ttcn<br>2 files changed, 74 insertions(+), 7 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/62/9962/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn</span><br><span>index 149d5b7..2897a0b 100644</span><br><span>--- a/bsc/BSC_Tests.ttcn</span><br><span>+++ b/bsc/BSC_Tests.ttcn</span><br><span>@@ -2122,10 +2122,19 @@</span><br><span> f_vty_handover(0, 0, g_chan_nr, 1);</span><br><span> /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */</span><br><span> f_rslem_suspend(RSL1_PROC);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* From the MGW perspective, a handover is is characterized by</span><br><span style="color: hsl(120, 100%, 40%);">+ * performing one MDCX operation with the MGW. So we expect to see</span><br><span style="color: hsl(120, 100%, 40%);">+ * one more MDCX during handover. */</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> alt {</span><br><span> [] as_handover(hs);</span><br><span style="color: hsl(0, 100%, 40%);">- /* FIXME: somehow determine that the hand-over has completed, by MGCP MDCX? */</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Check the amount of MGCP transactions is still consistant with the</span><br><span style="color: hsl(120, 100%, 40%);">+ * test expectation */</span><br><span style="color: hsl(120, 100%, 40%);">+ f_check_mgcp_expectations()</span><br><span> }</span><br><span> </span><br><span> testcase TC_ho_int() runs on test_CT {</span><br><span>diff --git a/bsc/MSC_ConnectionHandler.ttcn b/bsc/MSC_ConnectionHandler.ttcn</span><br><span>index f38a3e9..ba4d19d 100644</span><br><span>--- a/bsc/MSC_ConnectionHandler.ttcn</span><br><span>+++ b/bsc/MSC_ConnectionHandler.ttcn</span><br><span>@@ -58,7 +58,10 @@</span><br><span> </span><br><span> /* State encapsulating one MGCP Connection */</span><br><span> type record MgcpConnState {</span><br><span style="color: hsl(0, 100%, 40%);">- boolean crcx_seen,</span><br><span style="color: hsl(120, 100%, 40%);">+ integer crcx_seen, /* Counts how many CRCX operations happend */</span><br><span style="color: hsl(120, 100%, 40%);">+ integer mdcx_seen, /* Counts how many MDCX operations happend C */</span><br><span style="color: hsl(120, 100%, 40%);">+ integer crcx_seen_exp, /* Sets the expected number of CRCX operations */</span><br><span style="color: hsl(120, 100%, 40%);">+ integer mdcx_seen_exp, /* Sets the expected number of MDCX operations */</span><br><span> MgcpConnectionId conn_id,</span><br><span> charstring mime_type, /* e.g. AMR */</span><br><span> integer sample_rate, /* 8000 */</span><br><span>@@ -115,7 +118,10 @@</span><br><span> g_media.mgcp_conn[i].sample_rate := 8000;</span><br><span> g_media.mgcp_conn[i].ptime := 20;</span><br><span> g_media.mgcp_conn[i].rtp_pt := enum2int(f_get_mgcp_pt(codecType));</span><br><span style="color: hsl(0, 100%, 40%);">- g_media.mgcp_conn[i].crcx_seen := false;</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[i].crcx_seen := 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[i].mdcx_seen := 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[i].crcx_seen_exp := 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[i].mdcx_seen_exp := 0;</span><br><span> g_media.mgcp_conn[i].conn_id := f_mgcp_alloc_conn_id();</span><br><span> }</span><br><span> </span><br><span>@@ -129,9 +135,11 @@</span><br><span> }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* Helper function to get the next free MGCP connection identifier. We can</span><br><span style="color: hsl(120, 100%, 40%);">+ * recognize free connection identifiers by the fact that no CRCX happend yet */</span><br><span> private function f_get_free_mgcp_conn() runs on MSC_ConnHdlr return integer {</span><br><span> for (var integer i:= 0; i < sizeof(g_media.mgcp_conn); i := i+1) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (not g_media.mgcp_conn[i].crcx_seen) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (not g_media.mgcp_conn[i].crcx_seen >= 1) {</span><br><span> return i;</span><br><span> }</span><br><span> }</span><br><span>@@ -139,9 +147,12 @@</span><br><span> self.stop;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* Helper function to pick a specific connection by its cid. Since we reach out</span><br><span style="color: hsl(120, 100%, 40%);">+ * for a connection that is in-use we also check if there was already exactly</span><br><span style="color: hsl(120, 100%, 40%);">+ * one CRCX happening on that connection. */</span><br><span> private function f_get_mgcp_conn(MgcpConnectionId cid) runs on MSC_ConnHdlr return integer {</span><br><span> for (var integer i:= 0; i < sizeof(g_media.mgcp_conn); i := i+1) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (g_media.mgcp_conn[i].conn_id == cid and g_media.mgcp_conn[i].crcx_seen) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (g_media.mgcp_conn[i].conn_id == cid and g_media.mgcp_conn[i].crcx_seen == 1) {</span><br><span> return i;</span><br><span> }</span><br><span> }</span><br><span>@@ -278,7 +289,7 @@</span><br><span> mgcp_resp := ts_CRCX_ACK(mgcp_cmd.line.trans_id, mgcp_conn.conn_id, sdp);</span><br><span> f_mgcp_par_append(mgcp_resp.params, ts_MgcpParSpecEP(g_media.mgcp_ep));</span><br><span> MGCP.send(mgcp_resp);</span><br><span style="color: hsl(0, 100%, 40%);">- g_media.mgcp_conn[cid].crcx_seen := true;</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[cid].crcx_seen := g_media.mgcp_conn[cid].crcx_seen + 1;</span><br><span> repeat;</span><br><span> }</span><br><span> [] MGCP.receive(tr_MDCX) -> value mgcp_cmd {</span><br><span>@@ -299,7 +310,7 @@</span><br><span> int2str(mgcp_conn.sample_rate))),</span><br><span> valueof(ts_SDP_ptime(mgcp_conn.ptime)) } ));</span><br><span> MGCP.send(ts_MDCX_ACK(mgcp_cmd.line.trans_id, mgcp_conn.conn_id, sdp));</span><br><span style="color: hsl(0, 100%, 40%);">- //g_media.mgcp_mdcx_seen := true;</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[cid].mdcx_seen := g_media.mgcp_conn[cid].mdcx_seen + 1;</span><br><span> repeat;</span><br><span> }</span><br><span> }</span><br><span>@@ -781,11 +792,31 @@</span><br><span> }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* Helper function to check if the activity on the MGCP matches what we</span><br><span style="color: hsl(120, 100%, 40%);">+ * expected */</span><br><span style="color: hsl(120, 100%, 40%);">+function f_check_mgcp_expectations() runs on MSC_ConnHdlr {</span><br><span style="color: hsl(120, 100%, 40%);">+ for (var integer i:= 0; i < sizeof(g_media.mgcp_conn); i := i+1) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if(g_media.mgcp_conn[i].crcx_seen != g_media.mgcp_conn[i].crcx_seen_exp) {</span><br><span style="color: hsl(120, 100%, 40%);">+ setverdict(fail, "unexpected number of MGW-CRCX transactions");</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ if(g_media.mgcp_conn[i].mdcx_seen != g_media.mgcp_conn[i].mdcx_seen_exp) {</span><br><span style="color: hsl(120, 100%, 40%);">+ setverdict(fail, "unexpected number of MGW-MDCX transactions");</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* establish a channel fully, expecting an assignment matching 'exp' */</span><br><span> function f_establish_fully(template (omit) PDU_BSSAP ass_tpl, template PDU_BSSAP exp_ass_cpl)</span><br><span> runs on MSC_ConnHdlr {</span><br><span> </span><br><span> var BSSMAP_FIELD_CodecType codecType;</span><br><span style="color: hsl(120, 100%, 40%);">+ var boolean sccplite := false;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Check if we run on SCCPLITE instead of SCCP by looking if a CIC is</span><br><span style="color: hsl(120, 100%, 40%);">+ * present or not. */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (isvalue(ass_tpl.pdu.bssmap.assignmentRequest.circuitIdentityCode)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ sccplite := true;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> </span><br><span> if (isvalue(ass_tpl.pdu.bssmap.assignmentRequest.codecList)) {</span><br><span> codecType := valueof(ass_tpl.pdu.bssmap.assignmentRequest.codecList.codecElements[0].codecType);</span><br><span>@@ -847,6 +878,31 @@</span><br><span> exp_modify := f_channel_needs_modify(ass_cmd.pdu.bssmap.assignmentRequest.channelType, g_chan_nr);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Some test situations will involve MGCP transactions on a media</span><br><span style="color: hsl(120, 100%, 40%);">+ * gateway. Depending on the situation, we set up how many of each MGCP</span><br><span style="color: hsl(120, 100%, 40%);">+ * message type are expected to be exchanged. */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (isbound(exp_ass_cpl.pdu.bssmap.assignmentFailure)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* For tests that expect the assignment to fail, assume that</span><br><span style="color: hsl(120, 100%, 40%);">+ * there will be no MGW communication as well. */</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[0].crcx_seen_exp := 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[0].mdcx_seen_exp := 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[1].crcx_seen_exp := 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[1].mdcx_seen_exp := 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (st.voice_call) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* For voice calls we expect the following MGCP activity */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (sccplite) {</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[0].crcx_seen_exp := 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[0].mdcx_seen_exp := 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[1].crcx_seen_exp := 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[1].mdcx_seen_exp := 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[0].crcx_seen_exp := 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[0].mdcx_seen_exp := 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[1].crcx_seen_exp := 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ g_media.mgcp_conn[1].mdcx_seen_exp := 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> f_create_mgcp_expect(mgcpcrit);</span><br><span> BSSAP.send(ass_cmd);</span><br><span> </span><br><span>@@ -890,6 +946,8 @@</span><br><span> if (not isbound(bssap)) {</span><br><span> self.stop;</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ f_check_mgcp_expectations();</span><br><span> }</span><br><span> </span><br><span> type record HandoverState {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/9962">change 9962</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/9962"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: osmo-ttcn3-hacks </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ib073b097a840ca3a8ee99c4ed41f59f574191d98 </div>
<div style="display:none"> Gerrit-Change-Number: 9962 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>