From 829dac4358bb691e288ba9e8a3ede0d717ea3a17 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 5 Nov 2019 16:55:30 +0100 Subject: stp: Add tests for running STP in M3UA ASP role Change-Id: Ifec443858256ad79fbe29e26c609322809dd07b1 Related: OS#2005 --- stp/STP_Tests_M3UA.ttcn | 143 +++++++++++++++++++++++++++++++++++++++++++++++- stp/osmo-stp.cfg | 9 +++ 2 files changed, 149 insertions(+), 3 deletions(-) (limited to 'stp') diff --git a/stp/STP_Tests_M3UA.ttcn b/stp/STP_Tests_M3UA.ttcn index 3415e525..5c15c6f0 100644 --- a/stp/STP_Tests_M3UA.ttcn +++ b/stp/STP_Tests_M3UA.ttcn @@ -36,14 +36,20 @@ import from STP_Tests_Common all; modulepar { integer mp_stp_m3ua_port := 2905; + integer mp_stp_m3ua_clnt_port := 2906; integer mp_local_m3ua_port := 9999; } -private const integer NR_M3UA := 3; +private const integer NR_M3UA := 3; /* number of M3UA clients in ATS */ +private const integer NR_M3UA_SRV := 1; /* number of M3UA servres in ATS */ + +private function M3UA_SRV(integer idx) return integer { + return NR_M3UA+idx; +} type component RAW_M3UA_CT extends Test_CT { - port M3UA_CODEC_PT M3UA[NR_M3UA]; - var integer g_m3ua_conn_id[NR_M3UA]; + port M3UA_CODEC_PT M3UA[NR_M3UA+NR_M3UA_SRV]; + var integer g_m3ua_conn_id[NR_M3UA+NR_M3UA_SRV]; } private template PortEvent tr_SctpAssocChange := { @@ -56,6 +62,10 @@ private template PortEvent tr_SctpPeerAddrChange := { sctpPeerAddrChange := ? } } +private template PortEvent tr_SctpConnOpened := { + connOpened := ? +} + private altstep as_m3ua_sctp() runs on RAW_M3UA_CT { [] any from M3UA.receive(tr_SctpAssocChange) { repeat; } @@ -93,6 +103,16 @@ friend function f_M3UA_connect(integer i) runs on RAW_M3UA_CT { g_m3ua_conn_id[i] := res.connId; } +friend function f_M3UA_listen(integer i) runs on RAW_M3UA_CT { + var Result res; + res := M3UA_CodecPort_CtrlFunct.f_IPL4_listen(M3UA[i], mp_local_ip, mp_local_m3ua_port+i, + {sctp:=valueof(ts_SCTP)}); + if (not ispresent(res.connId)) { + setverdict(fail, "Could not bind M3UA socket, check your configuration"); + mtc.stop; + } +} + friend function f_init_m3ua() runs on RAW_M3UA_CT { var integer i; @@ -106,6 +126,26 @@ friend function f_init_m3ua() runs on RAW_M3UA_CT { } } +friend function f_init_m3ua_srv() runs on RAW_M3UA_CT { + var integer i; + var PortEvent sctp_evt; + + for (i := NR_M3UA; i < NR_M3UA+NR_M3UA_SRV; i:=i+1) { + map(self:M3UA[i], system:M3UA_CODEC_PT); + /* bind+ listen */ + f_M3UA_listen(i); + /* wait for accept() */ + M3UA[i].receive(tr_SctpConnOpened) -> value sctp_evt { + g_m3ua_conn_id[i] := sctp_evt.connOpened.connId; + } + } +} + + +/*********************************************************************** + * Test the STP in M3UA SG role (we are ASP) + ***********************************************************************/ + /* perform an outbound ASP-UP procedure */ friend function f_M3UA_asp_up(integer idx, template (omit) OCT4 aspid := omit) runs on RAW_M3UA_CT { f_M3UA_send(idx, ts_M3UA_ASPUP(aspid)); @@ -417,6 +457,97 @@ testcase TC_rkm_unreg_active() runs on RAW_M3UA_CT { /* FIXME: we now may have changed the state on the STP side! */ } +/*********************************************************************** + * Test the STP in M3UA ASP role (we are SG) + ***********************************************************************/ + +/* expect/perform an inbound ASP-UP procedure */ +friend function f_M3UA_CLNT_asp_up(integer idx, template OCT4 aspid := omit) runs on RAW_M3UA_CT { + f_M3UA_exp(idx, tr_M3UA_ASPUP(aspid)); + f_M3UA_send(idx, ts_M3UA_ASPUP_ACK); +} + +/* expect/perform an inbound ASP-ACTIVATE procedure */ +friend function f_M3UA_CLNT_asp_act(integer idx, template M3UA_Traffic_Mode_Type tmt := omit, + template (omit) OCT4 rctx := omit) runs on RAW_M3UA_CT { + f_M3UA_exp(idx, tr_M3UA_ASPAC(tmt, rctx)); + f_M3UA_send(idx, ts_M3UA_ASPAC_ACK(tmt, rctx)); +} + +/* expect/perform inbound ASP-UP and ASP-ACT, optionally send interemittent NOTIFY */ +friend function f_M3UA_CLNT_asp_up_act(integer idx, template M3UA_Traffic_Mode_Type tmt := omit, + template OCT4 rctx := omit, + template (omit) OCT2 ntfy_after_up := c_M3UA_ST_I_AS_INACTIVE, + template (omit) OCT2 ntfy_after_act := c_M3UA_ST_I_AS_ACTIVE) +runs on RAW_M3UA_CT { + f_M3UA_CLNT_asp_up(idx, omit); + if (not istemplatekind(ntfy_after_up, "omit")) { + f_M3UA_send(idx, ts_M3UA_NOTIFY(c_M3UA_ST_T_STATE_CHG, ntfy_after_up, rctx)); + } + f_M3UA_CLNT_asp_act(idx, tmt, rctx); + if (not istemplatekind(ntfy_after_act, "omit")) { + f_M3UA_send(idx, ts_M3UA_NOTIFY(c_M3UA_ST_T_STATE_CHG, ntfy_after_act, rctx)); + } +} + + +/* Expect inbound connection from ASP/SCTP-client, followed by ASP-UP */ +testcase TC_clnt_connect_asp_up() runs on RAW_M3UA_CT { + f_init_m3ua(); + f_init_m3ua_srv(); + + f_M3UA_CLNT_asp_up(M3UA_SRV(0)); +} + +/* Expect inbound connection from ASP/SCTP-client, followed by ASP-UP + ASP-ACT */ +testcase TC_clnt_asp_act() runs on RAW_M3UA_CT { + f_init_m3ua(); + f_init_m3ua_srv(); + + f_M3UA_CLNT_asp_up_act(M3UA_SRV(0)); +} + +/* Test traffic being routed through "server" side STP (M3UA SG), coming back in "client" + * side STP (M3UA ASP) */ +testcase TC_clnt_sg_to_asp() runs on RAW_M3UA_CT { + var OCT4 rctx_sender := int2oct(1023, 4); + var OCT4 pc_sender := int2oct(23, 4); + var OCT4 rctx_receiver := int2oct(1055, 4); + var OCT4 pc_receiver := int2oct(55, 4); + + f_init_m3ua(); + f_M3UA_asp_up_act(0); + + f_init_m3ua_srv(); + f_M3UA_CLNT_asp_up_act(M3UA_SRV(0)); + + f_sleep(1.0); + + /* verify traffic is routed from sender to [sole] receiver */ + f_test_traffic(0, rctx_sender, pc_sender, M3UA_SRV(0), rctx_receiver, pc_receiver); +} + +/* Test traffic being routed through "client" side STP (M3UA ASP), coming back in "server" + * side STP (M3UA SG) */ +testcase TC_clnt_asp_to_sg() runs on RAW_M3UA_CT { + var OCT4 rctx_sender := int2oct(1055, 4); + var OCT4 pc_sender := int2oct(55, 4); + var OCT4 rctx_receiver := int2oct(1023, 4); + var OCT4 pc_receiver := int2oct(23, 4); + + f_init_m3ua(); + f_M3UA_asp_up_act(0); + + f_init_m3ua_srv(); + f_M3UA_CLNT_asp_up_act(M3UA_SRV(0)); + + f_sleep(1.0); + + /* verify traffic is routed from sender to [sole] receiver */ + f_test_traffic(M3UA_SRV(0), rctx_sender, pc_sender, 0, rctx_receiver, pc_receiver); +} + + control { /* M3UA Tests */ @@ -442,6 +573,12 @@ control { /* TODO: test RKM with unsupported routing keys: NA, SI, OPC */ /* TODO: register/unregister multiple routing contexts in one message; including mixed success/failure situations */ + + /* Test STP as SCTP client + M3UA ASP role */ + execute( TC_clnt_connect_asp_up() ); + execute( TC_clnt_asp_act() ); + execute( TC_clnt_sg_to_asp() ); + execute( TC_clnt_asp_to_sg() ); } diff --git a/stp/osmo-stp.cfg b/stp/osmo-stp.cfg index d5eccbab..d8630d21 100644 --- a/stp/osmo-stp.cfg +++ b/stp/osmo-stp.cfg @@ -45,6 +45,11 @@ cs7 instance 0 asp asp-receiver1 10001 2905 m3ua local-ip 127.0.0.1 remote-ip 127.0.0.1 + asp asp-client0 10002 2906 m3ua + local-ip 127.0.0.1 + remote-ip 127.0.0.1 + sctp-role client + role asp as as-sender m3ua asp asp-sender routing-key 1023 23 @@ -54,9 +59,13 @@ cs7 instance 0 as mahlzeit ipa routing-key 0 5 point-code override dpc 23 + as as-client m3ua + routing-key 1055 55 + asp asp-client0 route-table system update route 23 16777215 linkset as-sender update route 42 16777215 linkset as-receiver + update route 55 16777215 linkset as-client listen m3ua 2905 accept-asp-connections dynamic-permitted listen ipa 5000 -- cgit v1.2.3