laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36870?usp=email )

Change subject: asterisk: Delay test start until FullyBooted event is received 
in AMI
......................................................................

asterisk: Delay test start until FullyBooted event is received in AMI

Change-Id: I65f56bcee332f4ae9ffc71ad7119c378ca1649dc
---
M asterisk/AMI_Functions.ttcn
M asterisk/Asterisk_Tests.ttcn
2 files changed, 50 insertions(+), 1 deletion(-)

Approvals:
  osmith: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/asterisk/AMI_Functions.ttcn b/asterisk/AMI_Functions.ttcn
index c05403e..9fbe973 100644
--- a/asterisk/AMI_Functions.ttcn
+++ b/asterisk/AMI_Functions.ttcn
@@ -27,6 +27,7 @@

 const charstring AMI_FIELD_ACTION := "Action";
 const charstring AMI_FIELD_ACTION_ID := "ActionID";
+const charstring AMI_FIELD_EVENT := "Event";
 const charstring AMI_FIELD_USERNAME := "Username";
 const charstring AMI_FIELD_SECRET := "Secret";
 const charstring AMI_FIELD_RESPONSE := "Response";
@@ -76,6 +77,8 @@
 template (value) AMI_Field
 ts_AMI_Field_ActionId(template (value) charstring val) := 
ts_AMI_Field(AMI_FIELD_ACTION_ID, val);
 template (value) AMI_Field
+ts_AMI_Field_Event(template (value) charstring val) := 
ts_AMI_Field(AMI_FIELD_EVENT, val);
+template (value) AMI_Field
 ts_AMI_Field_Username(template (value) charstring val) := 
ts_AMI_Field(AMI_FIELD_USERNAME, val);
 template (value) AMI_Field
 ts_AMI_Field_Secret(template (value) charstring val) := 
ts_AMI_Field(AMI_FIELD_SECRET, val);
@@ -88,6 +91,8 @@
 template (present) AMI_Field
 tr_AMI_Field_ActionId(template (present) charstring val := ?) := 
tr_AMI_Field(pattern @nocase AMI_FIELD_ACTION_ID, val);
 template (present) AMI_Field
+tr_AMI_Field_Event(template (present) charstring val := ?) := 
tr_AMI_Field(pattern @nocase AMI_FIELD_EVENT, val);
+template (present) AMI_Field
 tr_AMI_Field_Username(template (present) charstring val := ?) := 
tr_AMI_Field(pattern @nocase AMI_FIELD_USERNAME, val);
 template (present) AMI_Field
 tr_AMI_Field_Secret(template (present) charstring val := ?) := 
tr_AMI_Field(pattern @nocase AMI_FIELD_SECRET, val);
@@ -173,6 +178,22 @@
        tr_AMI_Field_ActionId(action_id)
 );

+/*
+ * EVENTS
+ */
+template (present) AMI_Msg
+tr_AMI_Event(template (present) charstring ev_name := ?) := superset(
+       tr_AMI_Field_Event(ev_name)
+);
+
+/* Event: FullyBooted
+ * Privilege: system,all
+ * Status: Fully Booted
+ * Uptime: 4
+ * LastReload: 4 *
+ */
+template (present) AMI_Msg
+tr_AMI_Event_FullyBooted := tr_AMI_Event("FullyBooted");

 /***********************
  * Adapter:
@@ -420,6 +441,15 @@

 }

+altstep as_ami_rx_ignore(AMI_Msg_PT pt)
+{
+       var AMI_Msg msg;
+       [] pt.receive(AMI_Msg:?) -> value msg {
+               log("Ignoring AMI message := ", msg);
+               repeat;
+       }
+}
+
 private altstep as_ami_rx_fail(AMI_Msg_PT pt, template AMI_Msg exp_msg := *)
 {
        var AMI_Msg msg;
diff --git a/asterisk/Asterisk_Tests.ttcn b/asterisk/Asterisk_Tests.ttcn
index 8a124c1..a71bcad 100644
--- a/asterisk/Asterisk_Tests.ttcn
+++ b/asterisk/Asterisk_Tests.ttcn
@@ -100,8 +100,18 @@
        };
        vc_AMI.start(f_AMI_Adapter_main(ami_pars));

-
        f_ami_action_login(AMI_CLIENT, mp_ami_user, mp_ami_secret);
+
+       timer tReady;
+       tReady.start(10.0);
+       alt {
+       [] AMI_CLIENT.receive(tr_AMI_Event_FullyBooted);
+       [] as_ami_rx_ignore(AMI_CLIENT);
+       [] tReady.timeout {
+               Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+                                       log2str("AMI FullyBooted timeout: "));
+               }
+       }
 }

 /* Local SIP UAs */

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36870?usp=email
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: I65f56bcee332f4ae9ffc71ad7119c378ca1649dc
Gerrit-Change-Number: 36870
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pes...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-Reviewer: osmith <osm...@sysmocom.de>
Gerrit-MessageType: merged

Reply via email to