From 55b905446c43daf0af94fa2a525fd587e0a8d676 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Fri, 2 Jul 2021 12:33:19 +0200 Subject: [PATCH] MGCP_Test: upgrade expected behavior for TC_dlcx_wildcarded The testcase TC_dlcx_wildcarded expect osmo-mgw to reject wildcarded DLCX requests but osmo-mgw now implements wildcarded DLCX Depends: osmo-mgw I6d3a74f6087512130d85002348787bffc672de81 Depends: docker-playground I693cc17dbf6836e7a74b34111671b6e589744a63 Change-Id: I61e23e264bc85eb36d07431c7839fb445c110947 Related: SYS#5535 --- mgw/MGCP_Test.default | 9 +++++++ mgw/MGCP_Test.ttcn | 56 ++++++++++++++++++++++++++++++++++++------- mgw/gen_links.sh | 1 + mgw/regen_makefile.sh | 2 +- 4 files changed, 59 insertions(+), 9 deletions(-) diff --git a/mgw/MGCP_Test.default b/mgw/MGCP_Test.default index 35f7ed0d1..54bf9afe4 100644 --- a/mgw/MGCP_Test.default +++ b/mgw/MGCP_Test.default @@ -11,6 +11,15 @@ FileMask := LOG_ALL | TTCN_MATCHING; *.MGWVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes" *.MGWVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes" *.MGWVTY.PROMPT1 := "OsmoMGW> " +*.STATSVTY.CTRL_MODE := "client" +*.STATSVTY.CTRL_HOSTNAME := "127.0.0.1" +*.STATSVTY.CTRL_PORTNUM := "4243" +*.STATSVTY.CTRL_LOGIN_SKIPPED := "yes" +*.STATSVTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes" +*.STATSVTY.CTRL_READMODE := "buffered" +*.STATSVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes" +*.STATSVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes" +*.STATSVTY.PROMPT1 := "OsmoMGW> " [MODULE_PARAMETERS] mp_local_udp_port := 2727; diff --git a/mgw/MGCP_Test.ttcn b/mgw/MGCP_Test.ttcn index 307f0a8d4..699067970 100644 --- a/mgw/MGCP_Test.ttcn +++ b/mgw/MGCP_Test.ttcn @@ -30,6 +30,10 @@ module MGCP_Test { import from IP_Types all; import from Osmocom_VTY_Functions all; import from TELNETasp_PortType all; + import from StatsD_Types all; + import from StatsD_CodecPort all; + import from StatsD_CodecPort_CtrlFunct all; + import from StatsD_Checker all; const charstring c_mgw_domain := "mgw"; const charstring c_mgw_ep_rtpbridge := "rtpbridge/"; @@ -37,7 +41,7 @@ module MGCP_Test { /* any variables declared in the component will be available to * all functions that 'run on' the named component, similar to * class members in C++ */ - type component dummy_CT { + type component dummy_CT extends StatsD_ConnHdlr { port MGCP_CODEC_PT MGCP; var boolean initialized := false; var ConnectionId g_mgcp_conn_id := -1; @@ -50,6 +54,8 @@ module MGCP_Test { port OsmuxEM_CTRL_PT OsmuxEM; port TELNETasp_PT MGWVTY; + + var StatsD_Checker_CT vc_STATSD; }; function get_next_trans_id() runs on dummy_CT return MgcpTransId { @@ -71,6 +77,8 @@ module MGCP_Test { charstring mp_remote_ipv6 := "::1"; PortNumber mp_local_rtp_port_base := 10000; PortNumber mp_local_osmux_port := 1985; + PortNumber mp_mgw_statsd_port := 8125; + charstring mp_test_ip := "127.0.0.1"; } private function f_vty_enable_osmux(boolean osmux_on) runs on dummy_CT { @@ -141,6 +149,11 @@ module MGCP_Test { f_osmuxem_init(vc_OsmuxEM); connect(vc_OsmuxEM:CTRL, self:OsmuxEM); } + + f_init_statsd("VirtCallAgent", vc_STATSD, mp_test_ip, mp_mgw_statsd_port); + connect(self:STATSD_PROC, vc_STATSD:STATSD_PROC); + + f_statsd_reset(); } if (isvalue(ep)) { @@ -1043,25 +1056,52 @@ module MGCP_Test { /* test valid wildcarded DLCX */ testcase TC_dlcx_wildcarded() runs on dummy_CT { - /* Note: A wildcarded DLCX is specified, but our MGW does not - * support this feature so we expect the MGW to reject the - * request */ var template MgcpCommand cmd; var MgcpResponse resp; var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "*@" & c_mgw_domain; + const integer n_endpoints := 31; + var integer i; + var MgcpCallId call_id := '1234'H; + var StatsDExpects expect; + f_init(ep); + + /* Allocate a few endpoints */ + for (i := 0; i < n_endpoints; i := i+1) { + cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); + resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); + } + + expect := { + { name := "TTCN3.trunk.virtual-0.common.endpoints.used", mtype := "g", min := n_endpoints, max := n_endpoints} + }; + f_statsd_expect(expect); + + /* Send wildcarded DLCX */ var template MgcpResponse rtmpl := { line := { - code := "507", + code := "200", string := ? }, params:= { }, sdp := omit }; + cmd := ts_DLCX(get_next_trans_id(), ep); + mgcp_transceive_mgw(cmd, rtmpl); - f_init(ep); + /* The stats reporter collects multiple samples during the reporting interval and + * reports the highest back to the user. This means we will not immediately get + * the 0 endpoints but an intermediate result instead. */ + expect := { + { name := "TTCN3.trunk.virtual-0.common.endpoints.used", mtype := "g", min := 0, max := n_endpoints} + }; + f_statsd_expect(expect); + + /* The second interval must resturn a result with 0 endpoints in use. */ + expect := { + { name := "TTCN3.trunk.virtual-0.common.endpoints.used", mtype := "g", min := 0, max := 0} + }; + f_statsd_expect(expect); - cmd := ts_DLCX(get_next_trans_id(), ep, '41234'H); - resp := mgcp_transceive_mgw(cmd, rtmpl); setverdict(pass); } diff --git a/mgw/gen_links.sh b/mgw/gen_links.sh index 8893954c6..6ca53a68f 100755 --- a/mgw/gen_links.sh +++ b/mgw/gen_links.sh @@ -45,6 +45,7 @@ FILES+="OSMUX_CodecPort.ttcn OSMUX_Emulation.ttcn OSMUX_Types.ttcn OSMUX_CodecPo FILES+="Native_Functions.ttcn Native_FunctionDefs.cc IPCP_Types.ttcn " FILES+="Osmocom_VTY_Functions.ttcn " FILES+="RTP_CodecPort_CtrlFunct.ttcn RTP_CodecPort_CtrlFunctDef.cc " +FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcn " gen_links $DIR $FILES ignore_pp_results diff --git a/mgw/regen_makefile.sh b/mgw/regen_makefile.sh index 4662933d0..2368c77d7 100755 --- a/mgw/regen_makefile.sh +++ b/mgw/regen_makefile.sh @@ -1,5 +1,5 @@ #!/bin/sh -FILES="*.ttcn SDP_EncDec.cc *.c MGCP_CodecPort_CtrlFunctDef.cc IPL4asp_PT.cc IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc RTP_EncDec.cc RTP_CodecPort_CtrlFunctDef.cc OSMUX_CodecPort_CtrlFunctDef.cc IuUP_EncDec.cc Native_FunctionDefs.cc TELNETasp_PT.cc IP_EncDec.cc " +FILES="*.ttcn SDP_EncDec.cc *.c MGCP_CodecPort_CtrlFunctDef.cc IPL4asp_PT.cc IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc RTP_EncDec.cc RTP_CodecPort_CtrlFunctDef.cc OSMUX_CodecPort_CtrlFunctDef.cc IuUP_EncDec.cc Native_FunctionDefs.cc TELNETasp_PT.cc IP_EncDec.cc StatsD_CodecPort_CtrlFunctdef.cc " ../regen-makefile.sh MGCP_Test.ttcn $FILES