sgsn: Proper shutdown of RAN_Adapter components

Otherwise TTCN3 errors sproadically during shutdown:
""""
SCCP_Emulation.ttcn:5661 Receive operation on port SCCP_SP_PORT succeeded, message from SGSN_Test_0-RAN(414)
...
SCCP_Emulation.ttcn:5293 Sent on MTP3_SCCP_PORT to SGSN_Test_0-M3UA(415) @SCCP_Types.ASP_MTP3_TRANSFERreq_sccp
SCCP_Emulation.ttcn:5293 Outgoing message was mapped to @MTP3asp_Types.ASP_MTP3_TRANSFERreq
SCCP_Emulation.ttcn:5293 Dynamic test case error: Sending data on the connection of port MTP3_SCCP_PORT to 415:MTP3_SP_PORT failed. (Broken pipe)
SCCP_Emulation.ttcn:5293 setverdict(error): none -> error
"""

Similar shutdown is already done in f_cleanup() of SCCP_Tests.ttcn.

Related: OS#4176
Change-Id: I471eb851e5d41de5d8d974ec81be27024d7d313a
This commit is contained in:
Pau Espin 2019-08-27 19:07:27 +02:00 committed by laforge
parent aac9b9ceca
commit ce0d615e12
2 changed files with 88 additions and 0 deletions

View File

@ -47,6 +47,7 @@ type record RAN_Adapter {
MSC_SCCP_MTP3_parameters sccp_pars,
SCCP_PAR_Address sccp_addr_own,
SCCP_PAR_Address sccp_addr_peer,
RAN_Transport transport,
/* handler mode */
RAN_Emulation_CT vc_RAN
@ -79,6 +80,7 @@ private function init_pars(inout RAN_Adapter ba, in RAN_Configuration cfg) {
};
ba.sccp_addr_own := valueof(ts_SccpAddr_PC_SSN(cfg.own_pc, cfg.own_ssn, cfg.sio, cfg.sccp_service_type));
ba.sccp_addr_peer := valueof(ts_SccpAddr_PC_SSN(cfg.peer_pc, cfg.peer_ssn, cfg.sio, cfg.sccp_service_type));
ba.transport := cfg.transport;
}
@ -92,6 +94,8 @@ function f_ran_adapter_init(inout RAN_Adapter ba, in RAN_Configuration cfg, char
ba.vc_SCCP := SCCP_CT.create(id & "-SCCP");
if (isvalue(ops)) {
ba.vc_RAN := RAN_Emulation_CT.create(id & "-RAN");
} else {
ba.vc_RAN := null;
}
select (cfg.transport) {
case (BSSAP_TRANSPORT_AoIP, RANAP_TRANSPORT_IuCS) {
@ -186,5 +190,27 @@ function f_ran_adapter_start(inout RAN_Adapter ba) {
ba.vc_SCCP.start(SCCPStart(ba.sccp_pars));
}
function f_ran_adapter_cleanup(inout RAN_Adapter ba) {
if (ba.vc_RAN != null) {
if (ba.transport == RANAP_TRANSPORT_IuCS) {
#ifdef RAN_EMULATION_RANAP
disconnect(ba.vc_RAN:RANAP, ba.vc_SCCP:SCCP_SP_PORT);
#endif
} else {
#ifdef RAN_EMULATION_BSSAP
disconnect(ba.vc_RAN:BSSAP, ba.vc_SCCP:SCCP_SP_PORT);
#endif
}
ba.vc_RAN.stop;
}
if (ba.transport == BSSAP_TRANSPORT_AoIP or
ba.transport == RANAP_TRANSPORT_IuCS) {
unmap(ba.vc_M3UA:SCTP_PORT, system:sctp);
disconnect(ba.vc_M3UA:MTP3_SP_PORT, ba.vc_SCCP:MTP3_SCCP_PORT);
ba.vc_M3UA.stop;
}
ba.vc_SCCP.stop;
}
}

View File

@ -332,6 +332,14 @@ function f_init(BcdMccMnc mcc_mnc := '262F42'H) runs on test_CT {
f_vty_enable_echo_interval(g_use_echo);
}
function f_cleanup() runs on test_CT {
var integer i;
for (i := 0; i < NUM_RNC; i := i+1) {
f_ran_adapter_cleanup(g_ranap[i]);
}
self.stop;
}
private function RncUnitdataCallback(RANAP_PDU ranap)
runs on RAN_Emulation_CT return template RANAP_PDU {
var template RANAP_PDU resp := omit;
@ -458,6 +466,7 @@ runs on BSSGP_ConnHdlr {
testcase TC_wait_ns_up() runs on test_CT {
f_init();
f_sleep(20.0);
f_cleanup();
}
function f_send_llc(template (value) PDU_LLC llc_pdu, integer gb_index := 0) runs on BSSGP_ConnHdlr {
@ -688,6 +697,7 @@ testcase TC_attach() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_attach), testcasename(), g_gb, 1);
vc_conn.done;
f_cleanup();
}
testcase TC_attach_mnc3() runs on test_CT {
@ -696,6 +706,7 @@ testcase TC_attach_mnc3() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_attach), testcasename(), g_gb, 1001);
vc_conn.done;
f_cleanup();
}
private function f_TC_attach_umts_aka_umts_res(charstring id) runs on BSSGP_ConnHdlr {
@ -708,6 +719,7 @@ testcase TC_attach_umts_aka_umts_res() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_attach_umts_aka_umts_res), testcasename(), g_gb, 1002);
vc_conn.done;
f_cleanup();
}
private function f_TC_attach_umts_aka_gsm_sres(charstring id) runs on BSSGP_ConnHdlr {
@ -720,6 +732,7 @@ testcase TC_attach_umts_aka_gsm_sres() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_attach_umts_aka_gsm_sres), testcasename(), g_gb, 1003);
vc_conn.done;
f_cleanup();
}
/* MS never responds to ID REQ, expect ATTACH REJECT */
@ -746,6 +759,7 @@ testcase TC_attach_auth_id_timeout() runs on test_CT {
f_init();
vc_conn := f_start_handler(refers(f_TC_attach_auth_id_timeout), testcasename(), g_gb, 2, 40.0);
vc_conn.done;
f_cleanup();
}
/* HLR never responds to SAI REQ, expect ATTACH REJECT */
@ -766,6 +780,7 @@ testcase TC_attach_auth_sai_timeout() runs on test_CT {
f_init();
vc_conn := f_start_handler(refers(f_TC_attach_auth_sai_timeout), testcasename(), g_gb, 3);
vc_conn.done;
f_cleanup();
}
/* HLR rejects SAI, expect ATTACH REJECT */
@ -787,6 +802,7 @@ testcase TC_attach_auth_sai_reject() runs on test_CT {
f_init();
vc_conn := f_start_handler(refers(f_TC_attach_auth_sai_reject), testcasename(), g_gb, 4);
vc_conn.done;
f_cleanup();
}
/* HLR never responds to UL REQ, expect ATTACH REJECT */
@ -816,6 +832,7 @@ testcase TC_attach_gsup_lu_timeout() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_attach_gsup_lu_timeout), testcasename(), g_gb, 5);
vc_conn.done;
f_cleanup();
}
/* HLR rejects UL REQ, expect ATTACH REJECT */
@ -846,6 +863,7 @@ testcase TC_attach_gsup_lu_reject() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_attach_gsup_lu_reject), testcasename(), g_gb, 6);
vc_conn.done;
f_cleanup();
}
@ -871,6 +889,7 @@ testcase TC_attach_combined() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_attach_combined), testcasename(), g_gb, 7);
vc_conn.done;
f_cleanup();
}
/* Attempt of GPRS ATTACH in 'accept all' mode */
@ -895,6 +914,7 @@ testcase TC_attach_accept_all() runs on test_CT {
f_vty_config(SGSNVTY, "sgsn", "auth-policy accept-all");
vc_conn := f_start_handler(refers(f_TC_attach_accept_all), testcasename(), g_gb, 8);
vc_conn.done;
f_cleanup();
}
/* Attempt of GPRS ATTACH in 'accept all' mode */
@ -933,6 +953,7 @@ testcase TC_attach_closed() runs on test_CT {
/* test with home IMSI: Must Accept */
vc_conn := f_start_handler(refers(f_TC_attach_accept_all), testcasename(), g_gb, 10);
vc_conn.done;
f_cleanup();
}
/* Routing Area Update from Unknown TLLI -> REJECT */
@ -954,6 +975,7 @@ testcase TC_rau_unknown() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_rau_unknown), testcasename(), g_gb, 11);
vc_conn.done;
f_cleanup();
}
private function f_TC_attach_rau(charstring id) runs on BSSGP_ConnHdlr {
@ -969,6 +991,7 @@ testcase TC_attach_rau() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_attach_rau), testcasename(), g_gb, 12);
vc_conn.done;
f_cleanup();
}
/* general GPRS DETACH helper */
@ -1022,6 +1045,7 @@ testcase TC_detach_unknown_nopoweroff() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_detach_unknown_nopoweroff), testcasename(), g_gb, 13);
vc_conn.done;
f_cleanup();
}
/* IMSI DETACH (power-off) for unknown TLLI */
@ -1034,6 +1058,7 @@ testcase TC_detach_unknown_poweroff() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_detach_unknown_poweroff), testcasename(), g_gb, 14);
vc_conn.done;
f_cleanup();
}
/* IMSI DETACH (non-power-off) for known TLLI */
@ -1049,6 +1074,7 @@ testcase TC_detach_nopoweroff() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_detach_nopoweroff), testcasename(), g_gb, 15);
vc_conn.done;
f_cleanup();
}
/* IMSI DETACH (power-off) for known TLLI */
@ -1064,6 +1090,7 @@ testcase TC_detach_poweroff() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_detach_poweroff), testcasename(), g_gb, 16);
vc_conn.done;
f_cleanup();
}
type record PdpActPars {
@ -1364,6 +1391,7 @@ testcase TC_attach_pdp_act() runs on test_CT {
f_init();
vc_conn := f_start_handler(refers(f_TC_attach_pdp_act), testcasename(), g_gb, 17);
vc_conn.done;
f_cleanup();
}
/* PDP Context activation for not-attached subscriber; expect fail */
@ -1392,6 +1420,7 @@ testcase TC_pdp_act_unattached() runs on test_CT {
f_init();
vc_conn := f_start_handler(refers(f_TC_pdp_act_unattached), testcasename(), g_gb, 18);
vc_conn.done;
f_cleanup();
}
/* ATTACH + PDP CTX ACT + user plane traffic */
@ -1411,6 +1440,7 @@ testcase TC_attach_pdp_act_user() runs on test_CT {
f_init();
vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_user), testcasename(), g_gb, 19);
vc_conn.done;
f_cleanup();
}
/* ATTACH + PDP CTX ACT; reject from GGSN */
@ -1430,6 +1460,7 @@ testcase TC_attach_pdp_act_ggsn_reject() runs on test_CT {
f_init();
vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_ggsn_reject), testcasename(), g_gb, 20);
vc_conn.done;
f_cleanup();
}
/* ATTACH + PDP CTX ACT + user plane traffic + PDP CTX DEACT in MO direction */
@ -1451,6 +1482,7 @@ testcase TC_attach_pdp_act_user_deact_mo() runs on test_CT {
f_init();
vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_user_deact_mo), testcasename(), g_gb, 21);
vc_conn.done;
f_cleanup();
}
/* ATTACH + PDP CTX ACT + user plane traffic + PDP CTX DEACT in MT direction */
@ -1472,6 +1504,7 @@ testcase TC_attach_pdp_act_user_deact_mt() runs on test_CT {
f_init();
vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_user_deact_mt), testcasename(), g_gb, 22);
vc_conn.done;
f_cleanup();
}
/* Test MS sending a duplicate Deact PDP Ctx (OS#3956). */
@ -1522,6 +1555,7 @@ testcase TC_attach_pdp_act_deact_dup() runs on test_CT {
f_init();
vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_deact_dup), testcasename(), g_gb, 46);
vc_conn.done;
f_cleanup();
}
/* ATTACH + ATTACH (2nd) */
@ -1541,6 +1575,7 @@ testcase TC_attach_second_attempt() runs on test_CT {
f_init();
vc_conn := f_start_handler(refers(f_TC_attach_forget_tlli_attach), testcasename(), g_gb, 22);
vc_conn.done;
f_cleanup();
}
private function f_TC_attach_echo_timeout(charstring id) runs on BSSGP_ConnHdlr {
@ -1600,6 +1635,7 @@ testcase TC_attach_echo_timeout() runs on test_CT {
vc_conn := f_start_handler(refers(f_TC_attach_echo_timeout), testcasename(), g_gb, 67, 50.0);
vc_conn.done;
g_use_echo := false;
f_cleanup();
}
private function f_TC_attach_restart_ctr_echo(charstring id) runs on BSSGP_ConnHdlr {
@ -1641,6 +1677,7 @@ testcase TC_attach_restart_ctr_echo() runs on test_CT {
vc_conn := f_start_handler(refers(f_TC_attach_restart_ctr_echo), testcasename(), g_gb, 23, 30.0);
vc_conn.done;
g_use_echo := false
f_cleanup();
}
private function f_TC_attach_restart_ctr_create(charstring id) runs on BSSGP_ConnHdlr {
@ -1680,6 +1717,7 @@ testcase TC_attach_restart_ctr_create() runs on test_CT {
f_init();
vc_conn := f_start_handler(refers(f_TC_attach_restart_ctr_create), testcasename(), g_gb, 24, 30.0);
vc_conn.done;
f_cleanup();
}
/* ATTACH + PDP CTX ACT + user plane traffic + PDP CTX DEACT in MT direction + trigger T3395 */
@ -1716,6 +1754,7 @@ testcase TC_attach_pdp_act_deact_mt_t3395_expire() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_deact_mt_t3395_expire), testcasename(), g_gb, 25, 60.0);
vc_conn.done;
f_cleanup();
}
/* ATTACH + PDP CTX ACT dropped + retrans */
@ -1774,6 +1813,7 @@ testcase TC_attach_pdp_act_deact_gtp_retrans() runs on test_CT {
f_init();
vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_deact_gtp_retrans), testcasename(), g_gb, 27);
vc_conn.done;
f_cleanup();
}
/* Test that SGSN GTP response retransmit queue works fine */
@ -1833,6 +1873,7 @@ testcase TC_attach_pdp_act_deact_gtp_retrans_resp() runs on test_CT {
f_init();
vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_deact_gtp_retrans_resp), testcasename(), g_gb, 28);
vc_conn.done;
f_cleanup();
}
private function f_TC_hlr_location_cancel_request_update(charstring id) runs on BSSGP_ConnHdlr {
@ -1881,6 +1922,7 @@ testcase TC_attach_pdp_act_user_error_ind_ggsn() runs on test_CT {
f_init();
vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_user_error_ind_ggsn), testcasename(), g_gb, 26);
vc_conn.done;
f_cleanup();
}
testcase TC_hlr_location_cancel_request_update() runs on test_CT {
@ -1893,6 +1935,7 @@ testcase TC_hlr_location_cancel_request_update() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_hlr_location_cancel_request_update), testcasename(), g_gb, 31);
vc_conn.done;
f_cleanup();
}
@ -1924,6 +1967,7 @@ testcase TC_hlr_location_cancel_request_withdraw() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_hlr_location_cancel_request_withdraw), testcasename(), g_gb, 29);
vc_conn.done;
f_cleanup();
}
@ -1954,6 +1998,7 @@ testcase TC_hlr_location_cancel_request_unknown_subscriber_withdraw() runs on te
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_hlr_location_cancel_request_unknown_subscriber_withdraw), testcasename(), g_gb, 30);
vc_conn.done;
f_cleanup();
}
private function f_TC_hlr_location_cancel_request_unknown_subscriber_update(charstring id) runs on BSSGP_ConnHdlr {
@ -1970,6 +2015,7 @@ testcase TC_hlr_location_cancel_request_unknown_subscriber_update() runs on test
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_hlr_location_cancel_request_unknown_subscriber_update), testcasename(), g_gb, 30);
vc_conn.done;
f_cleanup();
}
private function f_TC_attach_detach_check_subscriber_list(charstring id) runs on BSSGP_ConnHdlr {
@ -1991,6 +2037,7 @@ testcase TC_attach_detach_check_subscriber_list() runs on test_CT {
vc_conn.done;
f_vty_transceive_not_match(SGSNVTY, "show subscriber cache", pattern "* IMSI: {imsi}*");
f_cleanup();
}
/* Attempt an attach, but loose the Identification Request (IMEI) */
@ -2036,6 +2083,7 @@ testcase TC_attach_no_imei_response() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_attach_no_imei_response), testcasename(), g_gb, 32, 60.0);
vc_conn.done;
f_cleanup();
}
/* Attempt an attach, but loose the Identification Request (IMSI) */
@ -2084,6 +2132,7 @@ testcase TC_attach_no_imsi_response() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_attach_no_imsi_response), testcasename(), g_gb, 35, 60.0);
vc_conn.done;
f_cleanup();
}
private function f_sgsn_vty_destroy_subscriber_imsi(TELNETasp_PT pt, charstring imsi) {
@ -2105,6 +2154,7 @@ testcase TC_attach_check_subscriber_list() runs on test_CT {
f_vty_transceive_match(SGSNVTY, "show subscriber cache", pattern "* IMSI: {imsi}*");
f_sgsn_vty_destroy_subscriber_imsi(SGSNVTY, imsi);
f_cleanup();
}
private function f_TC_attach_closed_imsi_added(charstring id) runs on BSSGP_ConnHdlr {
@ -2167,6 +2217,7 @@ testcase TC_attach_closed_add_vty() runs on test_CT {
/* test with foreign IMSI: Must Reject */
vc_conn := f_start_handler(refers(f_TC_attach_closed_add_vty), testcasename(), g_gb, 9);
vc_conn.done;
f_cleanup();
}
/* Attempt an attach, but never answer a Attach Complete */
@ -2207,6 +2258,7 @@ testcase TC_attach_check_complete_resend() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_attach_check_complete_resend), testcasename(), g_gb, 36, 60.0);
vc_conn.done;
f_cleanup();
}
private function f_routing_area_update(RoutingAreaIdentificationV ra, integer bssgp := 0) runs on BSSGP_ConnHdlr {
@ -2254,6 +2306,7 @@ testcase TC_attach_rau_a_a() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_attach_rau_a_a), testcasename(), g_gb, 37);
vc_conn.done;
f_cleanup();
}
private function f_TC_attach_rau_a_b(charstring id) runs on BSSGP_ConnHdlr {
@ -2285,6 +2338,7 @@ testcase TC_attach_rau_a_b() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_attach_rau_a_b), testcasename(), g_gb, 38);
vc_conn.done;
f_cleanup();
}
private function f_TC_attach_gmm_attach_req_while_gmm_attach(charstring id) runs on BSSGP_ConnHdlr {
@ -2357,6 +2411,7 @@ testcase TC_attach_gmm_attach_req_while_gmm_attach() runs on test_CT {
f_vty_config(SGSNVTY, "sgsn", "auth-policy accept-all");
vc_conn := f_start_handler(refers(f_TC_attach_gmm_attach_req_while_gmm_attach), testcasename(), g_gb, 39);
vc_conn.done;
f_cleanup();
}
private function f_TC_attach_usim_resync(charstring id) runs on BSSGP_ConnHdlr {
@ -2485,6 +2540,7 @@ testcase TC_attach_usim_resync() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_attach_usim_resync), testcasename(), g_gb, 40);
vc_conn.done;
f_cleanup();
}
@ -2502,6 +2558,7 @@ testcase TC_llc_null() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_llc_null), testcasename(), g_gb, 41);
vc_conn.done;
f_cleanup();
}
/* Send LLC SABM to see if the SGSN rejects it properly with DM */
@ -2518,6 +2575,7 @@ testcase TC_llc_sabm_dm_llgmm() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_llc_sabm_dm_llgmm), testcasename(), g_gb, 42);
vc_conn.done;
f_cleanup();
}
/* Send LLC SABM to see if the SGSN rejects it properly with DM */
@ -2534,6 +2592,7 @@ testcase TC_llc_sabm_dm_ll5() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_llc_sabm_dm_ll5), testcasename(), g_gb, 43);
vc_conn.done;
f_cleanup();
}
/* test XID handshake with empty L3 info: expect empty return (some phones require that, OS#3426 */
@ -2563,6 +2622,7 @@ testcase TC_xid_empty_l3() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_xid_empty_l3), testcasename(), g_gb, 44);
vc_conn.done;
f_cleanup();
}
private function f_TC_xid_n201u(charstring id) runs on BSSGP_ConnHdlr {
@ -2591,6 +2651,7 @@ testcase TC_xid_n201u() runs on test_CT {
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_TC_xid_n201u), testcasename(), g_gb, 45);
vc_conn.done;
f_cleanup();
}
private function f_TC_attach_pdp_act_gmm_detach(charstring id) runs on BSSGP_ConnHdlr {
@ -2617,6 +2678,7 @@ testcase TC_attach_pdp_act_gmm_detach() runs on test_CT {
f_init();
vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_gmm_detach), testcasename(), g_gb, 26);
vc_conn.done;
f_cleanup();
}