MGCP_Test: add testcase TC_e1_dlcx_wildcarded

We are currently testing the behaviour of wildcarded DLCX on the virtual
trunk. Lets run a similar test on the E1 trunk as well.

Change-Id: I6cfbd24982d1e72206f8237b2eaea52cdaebf9dc
Related: OS#5572
diff --git a/mgw/MGCP_Test.ttcn b/mgw/MGCP_Test.ttcn
index 0242db9..6d23c10 100644
--- a/mgw/MGCP_Test.ttcn
+++ b/mgw/MGCP_Test.ttcn
@@ -2404,6 +2404,69 @@
 		setverdict(pass);
 	}
 
+	/* test valid wildcarded DLCX on an E1 trunk */
+	testcase TC_e1_dlcx_wildcarded() runs on dummy_CT {
+		var template MgcpCommand cmd;
+		var MgcpEndpoint ep;
+		var MgcpCallId call_id := '8376F297'H;
+		var integer n_e1_ts := 4;
+		var StatsDExpects expect;
+
+		f_init();
+
+		/* Open a few E1 timeslots */
+		for (var integer i := 0; i < n_e1_ts; i := i+1) {
+			ep := "ds/e1-1/s-" & int2str(i+1) & "/su16-0@" & c_mgw_domain;
+			cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id);
+			mgcp_transceive_mgw(cmd, tr_CRCX_ACK);
+			ep := "ds/e1-1/s-" & int2str(i+1) & "/su16-2@" & c_mgw_domain;
+			cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id);
+			mgcp_transceive_mgw(cmd, tr_CRCX_ACK);
+			ep := "ds/e1-1/s-" & int2str(i+1) & "/su16-4@" & c_mgw_domain;
+			cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id);
+			mgcp_transceive_mgw(cmd, tr_CRCX_ACK);
+			ep := "ds/e1-1/s-" & int2str(i+1) & "/su16-6@" & c_mgw_domain;
+			cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id);
+			mgcp_transceive_mgw(cmd, tr_CRCX_ACK);
+		}
+
+		/* Wait until the stats items have seteled and then check if we get the expected number (all) of
+		 * occupied endpoints */
+		f_sleep(1.0)
+		expect := {
+			{ name := "TTCN3.trunk.e1-1.common.endpoints.used", mtype := "g", min := n_e1_ts * 4, max := n_e1_ts * 4}
+		};
+		f_statsd_expect(expect);
+
+		/* Send wildcarded DLCX */
+		var template MgcpResponse rtmpl := {
+			line := {
+				code := "200",
+				string := ?
+			},
+			params:= { },
+			sdp := omit
+		};
+		ep := "ds/e1-1/*@" & c_mgw_domain;
+		cmd := ts_DLCX(get_next_trans_id(), ep);
+		mgcp_transceive_mgw(cmd, rtmpl);
+
+		/* Query a the statsd once to ensure that intermediate results are pulled from the
+		 * pipeline. The second query (below) will return the actual result. */
+		expect := {
+			{ name := "TTCN3.trunk.e1-1.common.endpoints.used", mtype := "g", min := 0, max := n_e1_ts * 4}
+		};
+		f_statsd_expect(expect);
+
+		/* The second query must resturn a result with 0 endpoints in use. */
+		expect := {
+			{ name := "TTCN3.trunk.e1-1.common.endpoints.used", mtype := "g", min := 0, max := 0}
+		};
+		f_statsd_expect(expect);
+
+		setverdict(pass);
+	}
+
 	/* test valid CRCX then MDCX with IPv4 address, MGW provides a local IPv4 too */
 	testcase TC_crcx_mdcx_ip4() runs on dummy_CT {
 		var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain;
@@ -2803,6 +2866,7 @@
 		execute(TC_e1_crcx_and_dlcx_ep());
 		execute(TC_e1_crcx_with_overlap());
 		execute(TC_e1_crcx_loopback());
+		execute(TC_e1_dlcx_wildcarded());
 
 		execute(TC_crcx_mdcx_ip4());
 		execute(TC_crcx_mdcx_ip6());