From 1ec1d3bc5b64edb68e59aeb418e14558e24f6bd6 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Tue, 25 Jun 2019 12:09:01 +0200 Subject: WIP: mgw: conn timeout tests Change-Id: I020b682b347045818fd28de240daa0aa33fe43b4 --- library/RTP_Emulation.ttcn | 54 ++++++++++++++++++++++++++++++++++++++++++++-- mgw/MGCP_Test.cfg | 3 ++- mgw/MGCP_Test.ttcn | 42 ++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 3 deletions(-) diff --git a/library/RTP_Emulation.ttcn b/library/RTP_Emulation.ttcn index 31bf68a8..3847f17f 100644 --- a/library/RTP_Emulation.ttcn +++ b/library/RTP_Emulation.ttcn @@ -105,6 +105,9 @@ type component RTP_Emulation_CT { var uint32_t g_rx_last_ts; var IuUP_Entity g_iuup_ent; // := valueof(t_IuUP_Entity(1)); + + var boolean g_conn_refuse_expect := false; + var boolean g_conn_refuse_received := false; } type enumerated RtpemMode { @@ -175,9 +178,12 @@ signature RTPEM_connect(in HostName remote_host, in PortNumber remote_port); signature RTPEM_mode(in RtpemMode mode); signature RTPEM_configure(in RtpemConfig cfg); signature RTPEM_stats_get(out RtpemStats stats, in boolean rtcp); +signature RTPEM_conn_refuse_expect(in boolean expect); +signature RTPEM_conn_refuse_received(out boolean received); type port RTPEM_CTRL_PT procedure { - inout RTPEM_bind, RTPEM_connect, RTPEM_mode, RTPEM_configure, RTPEM_stats_get; + inout RTPEM_bind, RTPEM_connect, RTPEM_mode, RTPEM_configure, RTPEM_stats_get, RTPEM_conn_refuse_expect, + RTPEM_conn_refuse_received; } with { extension "internal" }; function f_rtpem_bind(RTPEM_CTRL_PT pt, in HostName local_host, inout PortNumber local_port) { @@ -299,6 +305,21 @@ function f_rtpem_stats_err_check(RtpemStats s) { } } +function f_rtpem_conn_refuse_expect(RTPEM_CTRL_PT pt) { + pt.call(RTPEM_conn_refuse_expect:{true}) { + [] pt.getreply(RTPEM_conn_refuse_expect:{true}) {}; + } +} + +function f_rtpem_conn_refuse_verify(RTPEM_CTRL_PT pt) { + pt.call(RTPEM_conn_refuse_received:{?}) { + [] pt.getreply(RTPEM_conn_refuse_received:{true}) {}; + [] pt.getreply(RTPEM_conn_refuse_received:{false}) { + setverdict(fail, "Expected to receive connection refused"); + }; + } +} + template PDU_RTP ts_RTP(BIT32_BO_LAST ssrc, INT7b pt, LIN2_BO_LAST seq, uint32_t ts, octetstring payload, BIT1 marker := '0'B) := { version := 2, @@ -348,6 +369,13 @@ function f_main() runs on RTP_Emulation_CT tr_rtp.msg := { rtp := ? }; tr_rtcp.msg := { rtcp := ? }; + var ASP_Event rx_asp; + var template ASP_Event tr_asp := ?; + var template ASP_Event tr_conn_refuse := {result := { errorCode := ?, + connId := ?, + os_error_code := ?, + os_error_text := "Connection refused"}}; + g_iuup_ent := valueof(t_IuUP_Entity(g_cfg.iuup_tx_init)); while (true) { @@ -448,7 +476,12 @@ function f_main() runs on RTP_Emulation_CT CTRL.reply(RTPEM_stats_get:{g_stats_rtp, is_rtcp}); } } - + [] CTRL.getcall(RTPEM_conn_refuse_expect:{?}) -> param(g_conn_refuse_expect) { + CTRL.reply(RTPEM_conn_refuse_expect:{g_conn_refuse_expect}); + } + [] CTRL.getcall(RTPEM_conn_refuse_received:{?}) { + CTRL.reply(RTPEM_conn_refuse_received:{g_conn_refuse_received}); + } /* simply ignore any RTTP/RTP if receiver not enabled */ @@ -491,7 +524,24 @@ function f_main() runs on RTP_Emulation_CT lengthof(g_cfg.tx_fixed_payload); } + [g_conn_refuse_expect] RTP.receive(tr_conn_refuse) { + log("Connection refused (expected)"); + g_conn_refuse_received := true; + } + [not g_conn_refuse_expect] RTP.receive(tr_conn_refuse) { + setverdict(fail, "Connection refused unexpectedly"); + mtc.stop; + } + /* fail on any unexpected messages */ + [] RTP.receive(tr_rtp) -> value rx_rtp { + setverdict(fail, "Received unexpected type from RTP: ", rx_rtp); + mtc.stop; + } + [] RTP.receive(tr_asp) -> value rx_asp { + setverdict(fail, "Received unexpected type from RTP (ASP): ", rx_asp); + mtc.stop; + } [] RTP.receive { setverdict(fail, "Received unexpected type from RTP"); mtc.stop; diff --git a/mgw/MGCP_Test.cfg b/mgw/MGCP_Test.cfg index 90d736be..2d46e9c7 100644 --- a/mgw/MGCP_Test.cfg +++ b/mgw/MGCP_Test.cfg @@ -15,7 +15,8 @@ [MAIN_CONTROLLER] [EXECUTE] -MGCP_Test.control +#MGCP_Test.control +MGCP_Test.TC_conn_timeout #MGCP_Test.TC_selftest ##MGCP_Test.TC_crcx #MGCP_Test.TC_crcx_noprefix diff --git a/mgw/MGCP_Test.ttcn b/mgw/MGCP_Test.ttcn index 31c2a1db..82429b95 100644 --- a/mgw/MGCP_Test.ttcn +++ b/mgw/MGCP_Test.ttcn @@ -2066,6 +2066,45 @@ module MGCP_Test { /* TODO: AUCX (various) */ /* TODO: invalid verb (various) */ + + testcase TC_conn_timeout() runs on dummy_CT { + var RtpFlowData flow; + var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "1@" & c_mgw_domain; + var MgcpCallId call_id := '1225'H; + var MGCP_RecvFrom mrf; + + f_init(ep); + log("Setting conn-timeout to 1s"); + f_vty_config(MGWVTY, "mgcp", "conn-timeout 1"); + + log("Sending UDP data for 1.5s"); + flow := valueof(t_RtpFlow(mp_local_ip, mp_remote_ip, 111, "GSM-HR-08/8000/1")); + flow.em.portnr := 10000; + f_flow_create(RTPEM[0], ep, call_id, "loopback", flow); + f_rtpem_mode(RTPEM[0], RTPEM_MODE_BIDIR); + f_sleep(1.5); + + log("Stopping for 0.5s and resuming"); + f_rtpem_mode(RTPEM[0], RTPEM_MODE_NONE); + f_sleep(0.5); + f_rtpem_mode(RTPEM[0], RTPEM_MODE_BIDIR); + f_sleep(0.1); + + log("Stopping for 1.5s, expecting to run into timeout"); + f_rtpem_mode(RTPEM[0], RTPEM_MODE_NONE); + f_sleep(1.5); + + log("Resuming should fail now"); + f_rtpem_conn_refuse_expect(RTPEM[0]); + f_rtpem_mode(RTPEM[0], RTPEM_MODE_BIDIR); + f_sleep(0.2); + f_rtpem_conn_refuse_verify(RTPEM[0]); + + f_vty_config(MGWVTY, "mgcp", "no conn-timeout"); + + setverdict(pass); + } + control { execute(TC_selftest()); execute(TC_crcx()); @@ -2119,5 +2158,8 @@ module MGCP_Test { execute(TC_amr_oa_bwe_rtp_conversion()); execute(TC_amr_oa_oa_rtp_conversion()); execute(TC_amr_bwe_bwe_rtp_conversion()); + + execute(TC_conn_timeout()); + /* execute(TC_conn_timeout_rtp_keepalive()); */ } } -- cgit v1.2.3