Change in osmo-ttcn3-hacks[master]: stp: Refactor STP_Tests_IPA tests and introduce new TC_tmt_loadshare

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Tue Nov 12 12:07:59 UTC 2019


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16042 )


Change subject: stp: Refactor STP_Tests_IPA tests and introduce new TC_tmt_loadshare
......................................................................

stp: Refactor STP_Tests_IPA tests and introduce new TC_tmt_loadshare

Infrastructure in STP_Tests_IPA changed to be more similar to what is
done in STP_Tests_M3UA, which already contain more advanced tests.

Array of AS names mp_ipa_as_names is added in order to let TTCN3 port
which AS is configured in STP for each src port.

Change-Id: Iae213c58598cc0207503fd10f09d2d57aab941fe
---
M stp/STP_Tests.ttcn
M stp/STP_Tests_IPA.ttcn
M stp/osmo-stp.cfg
3 files changed, 136 insertions(+), 15 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/42/16042/1

diff --git a/stp/STP_Tests.ttcn b/stp/STP_Tests.ttcn
index 82bc03b..032a900 100644
--- a/stp/STP_Tests.ttcn
+++ b/stp/STP_Tests.ttcn
@@ -156,6 +156,7 @@
 	f_init_m3ua();
 	f_init_ipa();
 
+	f_connect_ipa(3);
 	f_M3UA_asp_up_act(0, omit, omit); // TODO: rctx
 
 	/* send a well-formed, encoded SCCP message via M3UA */
@@ -169,7 +170,7 @@
 	f_M3UA_send(0, ts_M3UA_DATA(rctx_sender, tx_pd), 1);
 
 	/* expect to receive it via IPA */
-	f_IPA_exp(0, sccp_enc);
+	f_IPA_exp(3, sccp_enc);
 
 	f_clear_m3ua();
 }
@@ -181,12 +182,13 @@
 	var OCT4 pc_receiver := int2oct(23, 4);
 
 	f_init_common();
-	f_vty_config2(VTY, {"cs7 instance 0", "as mahlzeit ipa"},
+	f_vty_config2(VTY, {"cs7 instance 0", "as ipa-as-dynamic-asp ipa"},
 		      "point-code override patch-sccp disabled");
 
 	f_init_m3ua();
 	f_init_ipa();
 
+	f_connect_ipa(3);
 	f_M3UA_asp_up_act(0, omit, omit); // TODO: rctx
 
 	/* send a well-formed, encoded SCCP message via IPA */
@@ -195,7 +197,7 @@
 	var SCCP_PAR_Address calling := valueof(ts_SccpAddr_GT('5678'H));
 	var PDU_SCCP sccp := valueof(ts_SCCP_UDT(called, calling, data));
 	var octetstring sccp_enc := enc_PDU_SCCP(sccp);
-	f_IPA_send(0, sccp_enc);
+	f_IPA_send(3, sccp_enc);
 
 	/* expect to receive it via M3UA */
 	var template (present) M3UA_Protocol_Data rx_pd;
@@ -212,12 +214,13 @@
 	var OCT4 pc_receiver := int2oct(23, 4);
 
 	f_init_common();
-	f_vty_config2(VTY, {"cs7 instance 0", "as mahlzeit ipa"},
+	f_vty_config2(VTY, {"cs7 instance 0", "as ipa-as-dynamic-asp ipa"},
 			"point-code override patch-sccp both");
 
 	f_init_m3ua();
 	f_init_ipa();
 
+	f_connect_ipa(3);
 	f_M3UA_asp_up_act(0, omit, omit); // TODO: rctx
 
 	/* send a well-formed, encoded SCCP message via IPA */
@@ -225,7 +228,7 @@
 	var SCCP_PAR_Address called := valueof(ts_SccpAddr_GT('1234'H));
 	var SCCP_PAR_Address calling := valueof(ts_SccpAddr_GT('5678'H));
 	var PDU_SCCP sccp := valueof(ts_SCCP_UDT(called, calling, data));
-	f_IPA_send(0, enc_PDU_SCCP(sccp));
+	f_IPA_send(3, enc_PDU_SCCP(sccp));
 
 	/* patch point codes into addresses */
 	called := valueof(ts_SccpAddr_PC_GT(oct2int(pc_receiver), '83'O, "mtp3_itu", '1234'H));
diff --git a/stp/STP_Tests_IPA.ttcn b/stp/STP_Tests_IPA.ttcn
index 0a36921..f7273dc 100644
--- a/stp/STP_Tests_IPA.ttcn
+++ b/stp/STP_Tests_IPA.ttcn
@@ -33,11 +33,18 @@
 
 import from STP_Tests_Common all;
 
-private const integer NR_IPA := 1;
+private const integer NR_IPA := 4;
+
+type record of charstring AspNameArray;
 
 modulepar {
 	integer mp_stp_ipa_port := 5000;
 	integer mp_local_ipa_port := 20000;
+	AspNameArray mp_ipa_as_names := {"ipa-as-loadshare-sender",
+					 "ipa-as-loadshare-receiver",
+					 "ipa-as-loadshare-receiver",
+					 "ipa-as-dynamic-asp"
+					 };
 }
 
 type component IPA_CT extends Test_CT {
@@ -45,6 +52,7 @@
 	 * having to re-invent IPA CCM handling here */
 	port MTP3asp_PT IPA[NR_IPA];
 	var IPA_Emulation_CT vc_IPA[NR_IPA];
+	var IPA_CCM_Parameters g_ccm_pars[NR_IPA];
 }
 
 friend function f_IPA_send(integer idx, octetstring data) runs on IPA_CT {
@@ -53,7 +61,6 @@
 }
 
 friend function f_IPA_exp(integer idx, template (present) octetstring data) runs on IPA_CT {
-	var M3UA_RecvFrom rx;
 	alt {
 	[] IPA[idx].receive(t_ASP_MTP3_TRANSFERind(?, ?, ?, ?, data)) {
 		setverdict(pass);
@@ -65,6 +72,23 @@
 	}
 }
 
+private function f_rnd_ipa_len() runs on IPA_CT return integer {
+	var integer rnd_len := f_rnd_int(100);
+	/* We need at least 1 byte of data, othewise osmocom IPA stack will discard and close the socket */
+	if (rnd_len == 0) {
+		rnd_len := 1;
+	}
+	return rnd_len;
+}
+
+/* Test if traffic is routed from idx_tx to idx_rx */
+private function f_test_traffic(integer idx_tx, integer idx_rx)
+runs on IPA_CT {
+	var octetstring data := f_rnd_octstring(f_rnd_ipa_len());
+	f_IPA_send(idx_tx, data);
+	f_IPA_exp(idx_rx, data);
+}
+
 friend function f_init_ipa() runs on IPA_CT {
 	var integer i;
 
@@ -74,11 +98,15 @@
 		vc_IPA[i] := IPA_Emulation_CT.create("IPA" & int2str(i));
 		map(vc_IPA[i]:IPA_PORT, system:IPA_CODEC_PT);
 		connect(self:IPA[i], vc_IPA[i]:MTP3_SP_PORT);
-		vc_IPA[i].start(IPA_Emulation.main_client(mp_stp_ip, mp_stp_ipa_port, mp_local_ip,
-				mp_local_ipa_port+i));
+		g_ccm_pars[i] := c_IPA_default_ccm_pars;
+		g_ccm_pars[i].name := mp_ipa_as_names[i];
 	}
 }
 
+friend function f_connect_ipa(integer idx) runs on IPA_CT {
+	vc_IPA[idx].start(IPA_Emulation.main_client(mp_stp_ip, mp_stp_ipa_port, mp_local_ip,
+			mp_local_ipa_port+idx, g_ccm_pars[idx]));
+}
 
 
 /* "accept-asp-connections pre-configured" and client from unknown source */
@@ -87,6 +115,10 @@
 	f_vty_config2(VTY, {"cs7 instance 0", "listen ipa 5000"},
 		      "accept-asp-connections pre-configured");
 	f_init_ipa();
+	/* Add 100 to the port since we know that port is not configured in any
+	  ASP only up to NR_IPA are configured. */
+	vc_IPA[0].start(IPA_Emulation.main_client(mp_stp_ip, mp_stp_ipa_port, mp_local_ip,
+			mp_local_ipa_port+100, g_ccm_pars[0]));
 	f_sleep(1.0);
 	if (IPA[0].checkstate("Connected")) {
 		setverdict(fail, "Expected IPA port to be disconnected");
@@ -103,9 +135,8 @@
 	f_init_common();
 	f_vty_config2(VTY, {"cs7 instance 0", "listen ipa 5000"},
 		      "accept-asp-connections pre-configured");
-	f_vty_config2(VTY, {"cs7 instance 0"}, "asp ipa-mahlzeit0 20000 5000 ipa");
-	f_vty_config2(VTY, {"cs7 instance 0", "as mahlzeit ipa"}, "asp ipa-mahlzeit0");
 	f_init_ipa();
+	f_connect_ipa(0);
 	f_sleep(1.0);
 	if (not IPA[0].checkstate("Connected")) {
 		setverdict(fail, "Expected IPA port to be connected");
@@ -115,7 +146,6 @@
 	/* switch back to default */
 	f_vty_config2(VTY, {"cs7 instance 0", "listen ipa 5000"},
 		      "accept-asp-connections dynamic-permitted");
-	f_vty_config2(VTY, {"cs7 instance 0"}, "no asp ipa-mahlzeit0");
 }
 
 
@@ -123,6 +153,10 @@
 testcase TC_unknown_client_dynamic() runs on IPA_CT {
 	f_init_common();
 	f_init_ipa();
+	/* Add 100 to the port since we know that port is not configured in any
+	  ASP only up to NR_IPA are configured. */
+	vc_IPA[0].start(IPA_Emulation.main_client(mp_stp_ip, mp_stp_ipa_port, mp_local_ip,
+			mp_local_ipa_port+100, g_ccm_pars[0]));
 	f_sleep(1.0);
 	if (not IPA[0].checkstate("Connected")) {
 		setverdict(fail, "Expected IPA port to be connected");
@@ -131,11 +165,61 @@
 	}
 }
 
+private altstep as_count_rx(integer idx, template (present) octetstring exp, inout integer counter)
+runs on IPA_CT {
+	[] IPA[idx].receive(t_ASP_MTP3_TRANSFERind(?, ?, ?, ?, exp)) {
+		counter := counter + 1;
+		}
+}
+
+/* test "traffic-mode load-share" behavior */
+testcase TC_tmt_loadshare() runs on IPA_CT {
+	var integer i;
+
+	f_init_ipa();
+
+	/* bring up the 'sender' side (single ASP in AS) */
+	f_connect_ipa(0);
+	/* activate the first 'receiver' side ASP */
+	f_connect_ipa(1);
+	f_sleep(1.0);
+
+	/* verify traffic is routed from sender to [sole] receiver */
+	for (i := 0; i < 10; i := i+1) {
+		f_test_traffic(0, 1);
+	}
+
+	/* activate the second 'receiver' side ASP */
+	f_connect_ipa(2);
+	f_sleep(1.0);
+
+	/* verify traffic is routed from sender to new receiver */
+	const integer iter_per_asp := 5;
+	var integer num_rx[3] := { 0, 0, 0 };
+	for (i := 0; i < 2*iter_per_asp; i := i+1) {
+		var octetstring data := f_rnd_octstring(f_rnd_ipa_len());
+		f_IPA_send(0, data);
+		alt {
+		[] as_count_rx(1, data, num_rx[1])
+		[] as_count_rx(2, data, num_rx[2])
+		}
+	}
+	/* FIXME: check for extraneous messages? */
+	for (i := 1; i <= 2; i := i+1) {
+		if (num_rx[i] != iter_per_asp) {
+			setverdict(fail, "Received ", num_rx[i], " out of expected ", iter_per_asp,
+				   "DATA messages at IPA port ", i);
+		}
+	}
+	setverdict(pass);
+}
+
 
 control {
 	execute( TC_unknown_client_nodynamic() );
 	execute( TC_known_client_nodynamic() );
 	execute( TC_unknown_client_dynamic() );
+	execute( TC_tmt_loadshare() );
 }
 
 
diff --git a/stp/osmo-stp.cfg b/stp/osmo-stp.cfg
index 5a1741f..26ab7f6 100644
--- a/stp/osmo-stp.cfg
+++ b/stp/osmo-stp.cfg
@@ -36,6 +36,9 @@
 !
 cs7 instance 0
  point-code format 24
+!
+!M3UA AS/ASP:
+!
  asp asp-sender 9999 2905 m3ua
   local-ip 127.0.0.1
   remote-ip 127.0.0.1
@@ -57,16 +60,47 @@
   asp asp-receiver0
   asp asp-receiver1
   routing-key 1042 42
- as mahlzeit ipa
-  routing-key 0 5
-  point-code override dpc 23
  as as-client m3ua
   routing-key 1055 55
   asp asp-client0
+!
+! IPA AS/ASP:
+!
+ asp ipa-asp-loadshare-sender 20000 5000 ipa
+  local-ip 127.0.0.1
+  remote-ip 127.0.0.1
+ as ipa-as-loadshare-sender ipa
+  routing-key 0 6
+  point-code override dpc 31
+  asp ipa-asp-loadshare-sender
+ asp ipa-asp-loadshare-receiver0 20001 5000 ipa
+  local-ip 127.0.0.1
+  remote-ip 127.0.0.1
+ asp ipa-asp-loadshare-receiver1 20002 5000 ipa
+  local-ip 127.0.0.1
+  remote-ip 127.0.0.1
+ as ipa-as-loadshare-receiver ipa
+  traffic-mode loadshare
+  routing-key 0 7
+  point-code override dpc 32
+  asp ipa-asp-loadshare-receiver0
+  asp ipa-asp-loadshare-receiver1
+ !Used by STP_Tests.ttcn:
+ as ipa-as-dynamic-asp ipa
+  routing-key 0 5
+  point-code override dpc 23
+!
+! ROUTING TABLE:
+!
  route-table system
   update route 23 16777215 linkset as-sender
   update route 42 16777215 linkset as-receiver
   update route 55 16777215 linkset as-client
+  update route 31 16777215 linkset ipa-as-loadshare-receiver
+  update route 5  16777215 linkset ipa-as-dynamic-asp
+!
+!SERVERS:
+!
  listen m3ua 2905
   accept-asp-connections dynamic-permitted
  listen ipa 5000

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16042
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Iae213c58598cc0207503fd10f09d2d57aab941fe
Gerrit-Change-Number: 16042
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191112/62d394e2/attachment.htm>


More information about the gerrit-log mailing list