bsc: Add statsd checker and use it in TC_assignment_sign

Related: SYS#4877
Change-Id: I8526b645dc4af59adcc1855699421a026f505c1d
diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index 22c94d4..003df49 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -45,6 +45,11 @@
 import from Osmocom_CTRL_Types all;
 import from Osmocom_CTRL_Adapter all;
 
+import from StatsD_Types all;
+import from StatsD_CodecPort all;
+import from StatsD_CodecPort_CtrlFunct all;
+import from StatsD_Checker all;
+
 import from Osmocom_VTY_Functions all;
 import from TELNETasp_PortType all;
 
@@ -471,6 +476,9 @@
 	var MGCP_Emulation_CT vc_MGCP;
 	port TELNETasp_PT BSCVTY;
 
+	/* StatsD */
+	var StatsD_Checker_CT vc_STATSD;
+
 	var RAN_Adapter g_bssap[NUM_MSC];
 	/* for old legacy-tests only */
 	port BSSAP_CODEC_PT BSSAP;
@@ -504,6 +512,8 @@
 	integer mp_bsc_rsl_port := 3003;
 	/* port number to which to establish the IPA CTRL connection */
 	integer mp_bsc_ctrl_port := 4249;
+	/* port number to which to listen for STATSD metrics */
+	integer mp_bsc_statsd_port := 8125;
 	/* IP address at which the test binds */
 	charstring mp_test_ip := "127.0.0.1";
 
@@ -898,6 +908,8 @@
 	}
 
 	var my_BooleanList allow_attach := { false, false, false };
+	f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
+
 	for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
 		allow_attach[bssap_idx] := true;
 		/* Call a function of our 'parent component' RAN_Adapter_CT to start the
@@ -2777,6 +2789,7 @@
 	connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
 	connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
 	connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
+	connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
 }
 
 function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
@@ -2938,7 +2951,15 @@
 	var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
 	var PDU_BSSAP ass_cmd := f_gen_ass_req();
 	ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
+
+	f_statsd_reset();
 	f_establish_fully(ass_cmd, exp_compl);
+
+	var StatsDExpects expect := {
+		{ name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
+		{ name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
+	};
+	f_statsd_expect(expect);
 }
 
 testcase TC_assignment_sign() runs on test_CT {