MSC_Tests: Add testcase to simulate VLR/HLR failure (SGsAP)

Currently we do not simulate a situation where the HLR is unreachable to
the MSC. Lets add a test wehere the HLR is disconnected and an LU via
SGsAP is tried. The SGs interface should then carry out a reset
procedure.

Change-Id: I830d0b936cbe9d73d1e0b1f4792c2be3d0b08cb9
Related: OS#3859
diff --git a/msc/MSC_Tests.ttcn b/msc/MSC_Tests.ttcn
index 1a6e8f7..13d1ddb 100644
--- a/msc/MSC_Tests.ttcn
+++ b/msc/MSC_Tests.ttcn
@@ -4627,6 +4627,43 @@
 	vc_conn.done;
 }
 
+/* Simulate an HLR/VLR failure */
+private function f_tc_sgsap_vlr_failure(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
+	var octetstring mme_name := f_enc_dns_hostname(mp_mme_name);
+	var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name);
+
+	var PDU_SGsAP lur;
+
+	f_init_handler(pars);
+
+	/* Attempt location update (which is expected to fail) */
+	lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach,
+					ts_SGsAP_LAI('901'H, '70'H, 2342)));
+	SGsAP.send(lur);
+
+	/* Respond to SGsAP-RESET-INDICATION from VLR */
+	alt {
+	[] SGsAP.receive(tr_SGsAP_RESET_IND_VLR(vlr_name)); {
+		SGsAP.send(valueof(ts_SGsAP_RESET_ACK_MME(mme_name)));
+		setverdict(pass);
+		}
+	[] SGsAP.receive {
+		setverdict(fail, "Received unexpected message on SGs");
+		}
+	}
+
+	f_sleep(1.0);
+	setverdict(pass);
+}
+testcase TC_sgsap_vlr_failure() runs on MTC_CT {
+	var BSC_ConnHdlrPars pars;
+	var BSC_ConnHdlr vc_conn;
+	f_init(1, true, false);
+	pars := f_init_pars(11811, true, false);
+	vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_vlr_failure), pars);
+	vc_conn.done;
+}
+
 /* SGs TODO:
    * LU attempt for IMSI without NAM_PS in HLR
    * LU attempt with AUTH FAIL due to invalid RES/SRES
@@ -4729,6 +4766,7 @@
 	execute( TC_sgsap_unsol_ud() );
 	execute( TC_bssap_lu_sgsap_lu_and_mt_call() );
 	execute( TC_sgsap_lu_and_mt_call() );
+	execute( TC_sgsap_vlr_failure() );
 
 	/* Run this last: at the time of writing this test crashes the MSC */
 	execute( TC_lu_imsi_auth_tmsi_encr_3_1_log_msc_debug() );