[Asterisk-code-review] pjsip: Handle initial NOTIFY in MWI unsolicited mailbox coun... (testsuite[master])
Joshua Colp
asteriskteam at digium.com
Wed Aug 12 06:05:30 CDT 2015
Joshua Colp has uploaded a new change for review.
https://gerrit.asterisk.org/1076
Change subject: pjsip: Handle initial NOTIFY in MWI unsolicited mailbox count changes test.
......................................................................
pjsip: Handle initial NOTIFY in MWI unsolicited mailbox count changes test.
The PJSIP MWI unsolicited mailbox count changes test currently
assumes that all NOTIFY messages 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-25298 #close
Change-Id: Ie8d5a46c350497fc77de5eff34c4bef7c00bbdd3
---
M tests/channels/pjsip/subscriptions/mwi/unsolicited/mailbox_count_changes/mwi_check.py
1 file changed, 17 insertions(+), 0 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/76/1076/1
diff --git a/tests/channels/pjsip/subscriptions/mwi/unsolicited/mailbox_count_changes/mwi_check.py b/tests/channels/pjsip/subscriptions/mwi/unsolicited/mailbox_count_changes/mwi_check.py
index b04a362..54699ff 100644
--- a/tests/channels/pjsip/subscriptions/mwi/unsolicited/mailbox_count_changes/mwi_check.py
+++ b/tests/channels/pjsip/subscriptions/mwi/unsolicited/mailbox_count_changes/mwi_check.py
@@ -40,11 +40,28 @@
self.results[self.result_pos]['msgs']
if not waiting 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.test_object.set_passed(False)
self.test_object.stop_reactor()
if not msgs 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.test_object.set_passed(False)
--
To view, visit https://gerrit.asterisk.org/1076
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie8d5a46c350497fc77de5eff34c4bef7c00bbdd3
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
More information about the asterisk-code-review
mailing list