[asterisk-commits] dlee: branch dlee/ari-bridge-tests r4017 - in /asterisk/team/dlee/ari-bridge-...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Aug 14 12:14:22 CDT 2013


Author: dlee
Date: Wed Aug 14 12:14:20 2013
New Revision: 4017

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4017
Log:
Add test for moving channels from bridge to bridge.

This test currently fails, b/c of a bug in Asterisk.

Added:
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/bridge_move.py   (with props)
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/configs/
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/configs/ast1/
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/configs/ast1/extensions.conf   (with props)
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/test-config.yaml   (with props)
Modified:
    asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/TestCase.py
    asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/ari.py
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/tests.yaml

Modified: asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/TestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/TestCase.py?view=diff&rev=4017&r1=4016&r2=4017
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/TestCase.py (original)
+++ asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/TestCase.py Wed Aug 14 12:14:20 2013
@@ -384,7 +384,14 @@
         has occurred.
         """
         logger.warning("Reactor timeout: '%s' seconds" % self.reactor_timeout)
+        self.on_reactor_timeout()
         self.stop_reactor()
+
+    def on_reactor_timeout(self):
+        """
+        Override to run when reactor times out
+        """
+        pass
 
     def __run(self):
         """

Modified: asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/ari.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/ari.py?view=diff&rev=4017&r1=4016&r2=4017
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/ari.py (original)
+++ asterisk/team/dlee/ari-bridge-tests/lib/python/asterisk/ari.py Wed Aug 14 12:14:20 2013
@@ -69,6 +69,7 @@
         self.test_iteration = 0
         self.channels = []
         self._ws_event_handlers = []
+        self.timed_out = False
 
         if self.iterations is None:
             self.iterations = []
@@ -93,11 +94,21 @@
         '''
         self._ws_event_handlers.append(callback)
 
+    def on_reactor_timeout(self):
+        self.timed_out = True
+        # Fail the tests if we have timed out
+        self.set_passed(False)
+
     def on_ws_event(self, message):
         ''' Handler for WebSocket events
 
         :param message The WS event payload
         '''
+        if self.timed_out:
+            # Ignore messages received after timeout
+            LOGGER.debug("Ignoring message received after timeout")
+            return
+
         for handler in self._ws_event_handlers:
             handler(message)
 

Added: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/bridge_move.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/bridge_move.py?view=auto&rev=4017
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/bridge_move.py (added)
+++ asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/bridge_move.py Wed Aug 14 12:14:20 2013
@@ -1,0 +1,53 @@
+'''
+Copyright (C) 2013, Digium, Inc.
+David M. Lee, II <dlee at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import logging
+
+LOGGER = logging.getLogger(__name__)
+
+class TestLogic(object):
+    def on_start(self, ari, event):
+        LOGGER.debug("on_start(%r)" % event)
+        self.channel_id = event['channel']['id']
+        self.bridge1_id = ari.post('bridges').json()['id']
+        self.bridge2_id = ari.post('bridges').json()['id']
+        ari.post('channels', self.channel_id, 'answer')
+        ari.post('bridges', self.bridge1_id, 'addChannel', channel=self.channel_id)
+        return True
+
+    def on_enter(self, ari, event):
+        channel_id = event['channel']['id']
+        bridge_id = event['bridge']['id']
+        assert self.channel_id == channel_id
+        if self.bridge1_id == bridge_id:
+            # Move to the next bridge
+            ari.post('bridges', self.bridge2_id, 'addChannel', channel=self.channel_id)
+        elif self.bridge2_id == bridge_id:
+            # Hangup
+            ari.delete('channels', channel_id)
+        else:
+            assert False, "Unexpected bridge id %s" % bridge_id
+        return True
+
+    def on_leave(self, ari, event):
+        channel_id = event['channel']['id']
+        bridge_id = event['bridge']['id']
+        assert self.channel_id == channel_id
+        assert self.bridge1_id == bridge_id or self.bridge2_id == bridge_id
+        return True
+
+TEST = TestLogic()
+
+def on_start(ari, event):
+    return TEST.on_start(ari, event)
+
+def on_enter(ari, event):
+    return TEST.on_enter(ari, event)
+
+def on_leave(ari, event):
+    return TEST.on_leave(ari, event)

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/bridge_move.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/bridge_move.py
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/bridge_move.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/configs/ast1/extensions.conf?view=auto&rev=4017
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/configs/ast1/extensions.conf (added)
+++ asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/configs/ast1/extensions.conf Wed Aug 14 12:14:20 2013
@@ -1,0 +1,6 @@
+[default]
+
+exten => s,1,NoOp()
+	same => n,Answer()
+	same => n,Stasis(testsuite)
+	same => n,Hangup()

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/test-config.yaml?view=auto&rev=4017
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/test-config.yaml (added)
+++ asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/test-config.yaml Wed Aug 14 12:14:20 2013
@@ -1,0 +1,61 @@
+testinfo:
+    summary: Test expected events moving a channel from one bridge to another.
+    description: |
+        Put a channel into a bridge, put it directly into another bridge.
+
+test-modules:
+    add-test-to-search-path: True
+    test-object:
+        config-section: test-object-config
+        typename: ari.AriTestObject
+    modules:
+        -   config-section: ari-config
+            typename: ari.WebSocketEventModule
+
+test-object-config:
+
+ari-config:
+    apps: testsuite
+    events:
+        -   conditions:
+                match:
+                    type: StasisStart
+                    application: testsuite
+                    args: []
+            count: 1
+            callback:
+                module: bridge_move
+                method: on_start
+        -   conditions:
+                match:
+                    type: ChannelEnteredBridge
+                    application: testsuite
+            count: 2
+            callback:
+                module: bridge_move
+                method: on_enter
+        -   conditions:
+                match:
+                    type: ChannelLeftBridge
+                    application: testsuite
+            count: 2
+            callback:
+                module: bridge_move
+                method: on_leave
+        -   conditions:
+                match:
+                    type: StasisEnd
+                    application: testsuite
+            count: 1
+
+properties:
+    minversion: '12.0.0'
+    dependencies:
+        - python : autobahn.websocket
+        - python : requests
+        - python : twisted
+        - python : starpy
+        - asterisk : res_ari_channels
+        - asterisk : app_echo
+    tags:
+        - ARI

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/move/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/tests.yaml?view=diff&rev=4017&r1=4016&r2=4017
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/tests.yaml (original)
+++ asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/tests.yaml Wed Aug 14 12:14:20 2013
@@ -1,3 +1,4 @@
 tests:
     - test: 'happy'
     - test: 'hangup'
+    - test: 'move'




More information about the asterisk-commits mailing list