[Asterisk-code-review] res pjsip pubsub/exten state: state changes sometimes initia... (testsuite[master])

Kevin Harwell asteriskteam at digium.com
Mon Jun 18 14:47:20 CDT 2018


Kevin Harwell has uploaded this change for review. ( https://gerrit.asterisk.org/9199


Change subject: res_pjsip_pubsub/exten_state: state changes sometimes initiated too soon
......................................................................

res_pjsip_pubsub/exten_state: state changes sometimes initiated too soon

There is a race condition in the test where the state changes could be triggered
before the subscription was finalized. If this happened then the test would time
out and fail due to not receiving the expected NOTIFY's.

This patch ensures that the test does not trigger the state changes until the
subscription has been fully established.

ASTERISK-27765 #close

Change-Id: I3ae529d475a8b148eb06b536d9f37d4778b40c52
---
M tests/channels/pjsip/subscriptions/presence/presencestate_repeat_okay/repeat_presence_state.py
1 file changed, 5 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/99/9199/1

diff --git a/tests/channels/pjsip/subscriptions/presence/presencestate_repeat_okay/repeat_presence_state.py b/tests/channels/pjsip/subscriptions/presence/presencestate_repeat_okay/repeat_presence_state.py
index 917be67..172ca45 100644
--- a/tests/channels/pjsip/subscriptions/presence/presencestate_repeat_okay/repeat_presence_state.py
+++ b/tests/channels/pjsip/subscriptions/presence/presencestate_repeat_okay/repeat_presence_state.py
@@ -26,14 +26,17 @@
             'Value': INIT_STATE
         }
         test_object.register_ami_observer(self.ami_connect)
-        test_object.register_scenario_started_observer(self.scenario_started)
 
     def ami_connect(self, ami):
         self.ami = ami
+        self.ami.registerEvent('TestEvent', self.handle_sub_established)
         # Set initial presence state
         self.ami.sendMessage(self.ami_message)
 
-    def scenario_started(self, scenario):
+    def handle_sub_established(self, ami, event):
+        if event['state'] != 'SUBSCRIPTION_ESTABLISHED':
+            return
+
         # Set new presence subvalues. These should result in SIP NOTIFYs
         self.ami_message['Value'] = NEW_SUBTYPE
         self.ami.sendMessage(self.ami_message)

-- 
To view, visit https://gerrit.asterisk.org/9199
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3ae529d475a8b148eb06b536d9f37d4778b40c52
Gerrit-Change-Number: 9199
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180618/71993672/attachment.html>


More information about the asterisk-code-review mailing list