[Asterisk-code-review] pjsip: Handle initial NOTIFY in MWI aggregate test. (testsuite[master])
Matt Jordan
asteriskteam at digium.com
Sat Jul 25 11:18:30 CDT 2015
Matt Jordan has submitted this change and it was merged.
Change subject: pjsip: Handle initial NOTIFY in MWI aggregate test.
......................................................................
pjsip: Handle initial NOTIFY in MWI aggregate test.
The PJSIP MWI aggregate test currently assumes that all NOTIFY
messages each pjsua receives will follow the expected results.
While this was true in the past this is no longer true. This is
due to the act of registration causing an initial NOTIFY to be
sent. What makes this problem worse is that the callback is
registered after the SIP registration is done, causing a window
where the initial NOTIFY may or may not be received by the test.
This change makes it so that if a NOTIFY is received that does
not match the expected result and the expected result is the first
one the NOTIFY is ignored. Since the test requires that all results
be received and that they come in order this works fine. If
unexpected NOTIFY messages continue to be received while expecting
the first result the test will eventually time out and fail.
ASTERISK-25278 #close
Change-Id: If5382e91575a771324a1462489c416f0e4e3d8ee
---
M tests/channels/pjsip/subscriptions/mwi/mwi_aggregate/mwi_check.py
1 file changed, 17 insertions(+), 0 deletions(-)
Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Mark Michelson: Looks good to me, but someone else must approve
Matt Jordan: Looks good to me, approved; Verified
diff --git a/tests/channels/pjsip/subscriptions/mwi/mwi_aggregate/mwi_check.py b/tests/channels/pjsip/subscriptions/mwi/mwi_aggregate/mwi_check.py
index 1940cde..b78ade7 100644
--- a/tests/channels/pjsip/subscriptions/mwi/mwi_aggregate/mwi_check.py
+++ b/tests/channels/pjsip/subscriptions/mwi/mwi_aggregate/mwi_check.py
@@ -45,10 +45,27 @@
self.results[self.result_pos]['msgs']
if waiting not in body:
+ # On the first MWI NOTIFY it is possible for the contents to not be
+ # what we expect as Asterisk will send an initial NOTIFY on REGISTER.
+ # Since we attach our MWI callback after the registration has started
+ # we may or may not even get the NOTIFY (depending on timing).
+ # Due to this we don't treat the match failure as fatal when expecting
+ # the first result. If it is indeed incorrect then either the next
+ # NOTIFY will also fail to match or the reactor will time out.
+ if self.result_pos == 0:
+ LOGGER.info("Could not find pattern %s in MWI body %s but treating as initial" %
+ (waiting, body))
+ return
+
LOGGER.error("Could not find pattern %s in MWI body %s" %
(waiting, body))
self.controller.fail_test()
if msgs not in body:
+ if self.result_pos == 0:
+ LOGGER.info("Could not find pattern %s in MWI body %s but treating as initial" %
+ (msgs, body))
+ return
+
LOGGER.error("Could not find pattern %s in MWI body %s" %
(msgs, body))
self.controller.fail_test()
--
To view, visit https://gerrit.asterisk.org/960
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If5382e91575a771324a1462489c416f0e4e3d8ee
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
More information about the asterisk-code-review
mailing list