pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40474?usp=email )
Change subject: stp: Introduce test TC_(m3ua_tcp(clnt_))beat_timeout ......................................................................
stp: Introduce test TC_(m3ua_tcp(clnt_))beat_timeout
Related: SYS#7501 Related: OS#4072 Change-Id: Ie0c430b7992881e8ae506fe6434f06946f8f6278 --- M stp/STP_Tests_M3UA.ttcn M stp/STP_Tests_M3UA_TCP.ttcn M stp/expected-results.xml 3 files changed, 97 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/74/40474/1
diff --git a/stp/STP_Tests_M3UA.ttcn b/stp/STP_Tests_M3UA.ttcn index 40fee55..269bec5 100644 --- a/stp/STP_Tests_M3UA.ttcn +++ b/stp/STP_Tests_M3UA.ttcn @@ -158,12 +158,12 @@ } }
-friend function f_M3UA_exp(integer idx, template (present) PDU_M3UA msg) runs on RAW_M3UA_CT { +friend function f_M3UA_exp(integer idx, template (present) PDU_M3UA msg, float timeout_val := 5.0, boolean answer_beat := true) runs on RAW_M3UA_CT return M3UA_RecvFrom { var M3UA_RecvFrom rx; - timer T := 5.0; + timer T := timeout_val; T.start; alt { - [] M3UA[idx].receive(t_M3UA_RecvFrom(msg)) { + [] M3UA[idx].receive(t_M3UA_RecvFrom(msg)) -> value rx { setverdict(pass); } [answer_beat] as_m3ua_beat_answer(idx); @@ -177,6 +177,7 @@ log2str("Timeout waiting for M3UA[", idx, "] ", msg)); } } + return rx; }
/* flush any number of queued messages matching 'msg' */ @@ -495,6 +496,71 @@ f_clear_m3ua(); }
+friend function f_TC_beat_timeout(Misc_Helpers.ro_charstring asps) runs on RAW_M3UA_CT +{ + var M3uaConfigs m3ua_configs := m3ua_build_configs(asps); + var M3UA_RecvFrom rx; + var template (omit) M3UA_Heartbeat_Data hbd := omit; + var float timeout_val := 3.0 + 1.0; + + f_init_m3ua(answer_beat := false, m3ua_configs := m3ua_configs); + f_vty_cs7_asp_cmd(g_m3ua_configs[0], "timer xua beat 3"); + + if (m3ua_configs[0].is_server) { + f_init_m3ua_srv(); + f_M3UA_CLNT_asp_up_act(0, rctx := int2oct(m3ua_configs[0].routing_ctx, 4)); + } else { + f_M3UA_asp_up(0); + f_M3UA_exp(0, tr_M3UA_NOTIFY(c_M3UA_ST_T_STATE_CHG, c_M3UA_ST_I_AS_INACTIVE, *)); + } + + rx := f_M3UA_exp(0, tr_M3UA_BEAT(*), timeout_val := timeout_val, answer_beat := false); + log("1st BEAT received"); + if (ispresent(rx.msg.m3UA_BEAT.messageParameters.heartbeat_Data)) { + hbd := rx.msg.m3UA_BEAT.messageParameters.heartbeat_Data; + } + f_M3UA_send(0, ts_M3UA_BEAT_ACK(hbd)); + /* Make sure next HEARBEAT arrives around the time we configured. + * Do not answer this nor next heardbeat: */ + rx := f_M3UA_exp(0, tr_M3UA_BEAT(*), timeout_val := timeout_val, answer_beat := false); + log("2nd BEAT received"); + rx := f_M3UA_exp(0, tr_M3UA_BEAT(*), timeout_val := timeout_val, answer_beat := false); + log("3rd BEAT received"); + + /* After 2*T(beat), IUT should figure out peer is not responding and terminate the conn: */ + timer T := timeout_val; + T.start; + alt { + [] M3UA[0].receive(PortEvent:{connClosed := ?}) { + setverdict(pass); /* TCP */ + } + [] M3UA[0].receive(tr_SctpShutDownEvent(g_m3ua_conn_id[0])) { + setverdict(pass); /* SCTP */ + } + [] M3UA[0].receive(tr_SctpAssocChange) { repeat; } + [] M3UA[0].receive(tr_SctpPeerAddrChange) { repeat; } + [] M3UA[0].receive(t_M3UA_RecvFrom(?)) -> value rx { + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, + log2str("Received unexpected M3UA ", rx, " while waiting for SctpShutDownEvent")); + } + [] T.timeout { + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, + log2str("Timeout waiting for M3UA SctpShutDownEvent")); + } + } + + /* return to default value: */ + f_vty_cs7_asp_cmd(g_m3ua_configs[0], "timer xua beat 30"); + + f_clear_m3ua(); +} + +/* Test the IUT sends heartbeat procedure when needed. */ +testcase TC_beat_timeout() runs on RAW_M3UA_CT { + var Misc_Helpers.ro_charstring asps := { "asp-sender" }; + f_TC_beat_timeout(asps); +} + /* Test the ASP-ACTIVATE procedure (without traffic-mode or routing ctx) */ testcase TC_asp_act() runs on RAW_M3UA_CT { f_init_m3ua(); @@ -1137,6 +1203,12 @@ f_clear_m3ua(); }
+/* Test the IUT sends heartbeat procedure when needed. */ +testcase TC_clnt_beat_timeout() runs on RAW_M3UA_CT { + var Misc_Helpers.ro_charstring asps := { "asp-client0" }; + f_TC_beat_timeout(asps); +} + /* Expect inbound connection from ASP/SCTP-client, followed by ASP-UP + ASP-ACT */ testcase TC_clnt_asp_act() runs on RAW_M3UA_CT { var Misc_Helpers.ro_charstring asps := { "asp-client0" }; @@ -1586,6 +1658,7 @@ execute( TC_connect_asp_up() ); execute( TC_beat() ); execute( TC_beat_payload() ); + execute( TC_beat_timeout() ); execute( TC_asp_act() ); execute( TC_asp_act_override() ); execute( TC_asp_act_loadshare() ); @@ -1616,6 +1689,7 @@
/* Test STP as SCTP client + M3UA ASP role */ execute( TC_clnt_connect_asp_up() ); + execute( TC_clnt_beat_timeout() ); execute( TC_clnt_asp_act() ); execute( TC_clnt_sg_to_asp() ); execute( TC_clnt_asp_to_sg() ); diff --git a/stp/STP_Tests_M3UA_TCP.ttcn b/stp/STP_Tests_M3UA_TCP.ttcn index a5e4c2a..1da65cc 100644 --- a/stp/STP_Tests_M3UA_TCP.ttcn +++ b/stp/STP_Tests_M3UA_TCP.ttcn @@ -116,12 +116,27 @@ f_TC_m3ua_tcp(0, 1); }
+/* Test the IUT sends heartbeat procedure when needed. */ +testcase TC_m3ua_tcp_beat_timeout() runs on RAW_M3UA_CT { + var Misc_Helpers.ro_charstring asps := { "asp-sender-tcp" }; + f_TC_beat_timeout(asps); +} + +/* Test the IUT sends heartbeat procedure when needed. */ +testcase TC_m3ua_tcp_clnt_beat_timeout() runs on RAW_M3UA_CT { + var Misc_Helpers.ro_charstring asps := { "asp-client0-tcp" }; + f_TC_beat_timeout(asps); +} + control { /* M3UA TCP Tests */ execute( TC_m3ua_tcp_cli() ); execute( TC_m3ua_tcp_cli_srv() ); execute( TC_m3ua_tcp_srv() ); execute( TC_m3ua_tcp_srv_cli() ); + + execute( TC_m3ua_tcp_beat_timeout() ); + execute( TC_m3ua_tcp_clnt_beat_timeout() ); }
} \ No newline at end of file diff --git a/stp/expected-results.xml b/stp/expected-results.xml index db36ab4..0fb7c17 100644 --- a/stp/expected-results.xml +++ b/stp/expected-results.xml @@ -1,8 +1,9 @@ <?xml version="1.0"?> -<testsuite name='STP_Tests' tests='54' failures='0' errors='0' skipped='0' inconc='0' time='MASKED'> +<testsuite name='STP_Tests' tests='58' failures='0' errors='0' skipped='0' inconc='0' time='MASKED'> <testcase classname='STP_Tests_M3UA' name='TC_connect_asp_up' time='MASKED'/> <testcase classname='STP_Tests_M3UA' name='TC_beat' time='MASKED'/> <testcase classname='STP_Tests_M3UA' name='TC_beat_payload' time='MASKED'/> + <testcase classname='STP_Tests_M3UA' name='TC_beat_timeout' time='MASKED'/> <testcase classname='STP_Tests_M3UA' name='TC_asp_act' time='MASKED'/> <testcase classname='STP_Tests_M3UA' name='TC_asp_act_override' time='MASKED'/> <testcase classname='STP_Tests_M3UA' name='TC_asp_act_loadshare' time='MASKED'/> @@ -23,6 +24,7 @@ <testcase classname='STP_Tests_M3UA' name='TC_dyn_asp_as_rkm_permitted' time='MASKED'/> <testcase classname='STP_Tests_M3UA' name='TC_dyn_2asp_as_rkm_permitted' time='MASKED'/> <testcase classname='STP_Tests_M3UA' name='TC_clnt_connect_asp_up' time='MASKED'/> + <testcase classname='STP_Tests_M3UA' name='TC_clnt_beat_timeout' time='MASKED'/> <testcase classname='STP_Tests_M3UA' name='TC_clnt_asp_act' time='MASKED'/> <testcase classname='STP_Tests_M3UA' name='TC_clnt_sg_to_asp' time='MASKED'/> <testcase classname='STP_Tests_M3UA' name='TC_clnt_asp_to_sg' time='MASKED'/> @@ -44,6 +46,8 @@ <testcase classname='STP_Tests_M3UA_TCP' name='TC_m3ua_tcp_cli_srv' time='MASKED'/> <testcase classname='STP_Tests_M3UA_TCP' name='TC_m3ua_tcp_srv' time='MASKED'/> <testcase classname='STP_Tests_M3UA_TCP' name='TC_m3ua_tcp_srv_cli' time='MASKED'/> + <testcase classname='STP_Tests_M3UA' name='TC_m3ua_tcp_beat_timeout' time='MASKED'/> + <testcase classname='STP_Tests_M3UA' name='TC_m3ua_tcp_clnt_beat_timeout' time='MASKED'/> <testcase classname='STP_Tests_IPA' name='TC_unknown_client_nodynamic' time='MASKED'/> <testcase classname='STP_Tests_IPA' name='TC_unknown_as_client_nodynamic' time='MASKED'/> <testcase classname='STP_Tests_IPA' name='TC_known_client_nodynamic' time='MASKED'/>