Change in osmo-ttcn3-hacks[master]: attempt to fix a race condition in BSC test's f_ts_dyn_mode_get

Stefan Sperling gerrit-no-reply at lists.osmocom.org
Thu Nov 15 13:02:20 UTC 2018


Stefan Sperling has submitted this change and it was merged. ( https://gerrit.osmocom.org/11763 )

Change subject: attempt to fix a race condition in BSC test's f_ts_dyn_mode_get
......................................................................

attempt to fix a race condition in BSC test's f_ts_dyn_mode_get

Add two helper functions which retry a VTY command until the
result matches a regular expression or a configurable timeout
expires.

Use these functions in BSC test's f_ts_dyn_mode_get, which has
seen sporadic failures due to a race condition during channel
reconfiguration, in order to hopefully close this race.

Change-Id: I308ddb06e440c165fe1e73fe2c1fb78be2e1d510
Related: OS#3690
---
M bsc/BSC_Tests.ttcn
M library/Osmocom_VTY_Functions.ttcn
2 files changed, 24 insertions(+), 2 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index e06f496..21ec0ff 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -2761,8 +2761,7 @@
 runs on test_CT return charstring {
 	var charstring cmd, resp;
 	cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
-	resp := f_vty_transceive_ret(BSCVTY, cmd);
-	return regexp(resp, "*\((*)\)*", 0);
+	return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
 }
 
 private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
diff --git a/library/Osmocom_VTY_Functions.ttcn b/library/Osmocom_VTY_Functions.ttcn
index 86f58f1..4f795ad 100644
--- a/library/Osmocom_VTY_Functions.ttcn
+++ b/library/Osmocom_VTY_Functions.ttcn
@@ -1,5 +1,6 @@
 module Osmocom_VTY_Functions {
 	import from TELNETasp_PortType all;
+	import from Osmocom_Types all;
 
 	modulepar {
 		charstring mp_prompt_prefix := "OpenBSC";
@@ -153,5 +154,27 @@
 	}
 }
 
+function f_vty_transceive_match_regex(TELNETasp_PT pt, charstring cmd, charstring regex, integer groupno) return charstring
+{
+	var charstring resp := f_vty_transceive_ret(pt, cmd);
+	return regexp(resp, regex, groupno);
+}
+
+function f_vty_transceive_match_regexp_retry(TELNETasp_PT pt, charstring cmd, charstring regex,
+					     integer groupno, integer num_attempts, float retry_delay) return charstring
+{
+	 while (num_attempts > 0) {
+		var charstring ret := f_vty_transceive_match_regex(pt, cmd, regex, groupno);
+		if (ret != "") {
+			return ret;
+		}
+		f_sleep(retry_delay);
+		num_attempts := num_attempts - 1;
+	}
+
+	setverdict(fail, "No matching VTY response for regular expression '", regex,
+		   "' after ", num_attempts, " attempts." );
+	mtc.stop;
+}
 
 }

-- 
To view, visit https://gerrit.osmocom.org/11763
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I308ddb06e440c165fe1e73fe2c1fb78be2e1d510
Gerrit-Change-Number: 11763
Gerrit-PatchSet: 2
Gerrit-Owner: Stefan Sperling <ssperling at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Stefan Sperling <ssperling at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181115/7c4a7fd6/attachment.html>


More information about the gerrit-log mailing list