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

Jenkins2 asteriskteam at digium.com
Wed Jun 20 04:56:50 CDT 2018


Jenkins2 has submitted this change and it was merged. ( 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(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved
  Jenkins2: Approved for Submit



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: merged
Gerrit-Change-Id: I3ae529d475a8b148eb06b536d9f37d4778b40c52
Gerrit-Change-Number: 9199
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180620/bdacdfeb/attachment-0001.html>


More information about the asterisk-code-review mailing list