[svn-commits] mmichelson: testsuite/asterisk/trunk r4311 - in /asterisk/trunk/tests/rest_ap...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Nov 1 09:12:59 CDT 2013


Author: mmichelson
Date: Fri Nov  1 09:12:57 2013
New Revision: 4311

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4311
Log:
Add delete test for ARI bridges.

This test creates a bridge, places a channel inside, and then deletes the bridge.
The test then checks that the bridge has been deleted and that the channel has not.

(issue ASTERISK-22634)
reported by Kevin Harwell

Review: https://reviewboard.asterisk.org/r/2918


Added:
    asterisk/trunk/tests/rest_api/bridges/delete/
    asterisk/trunk/tests/rest_api/bridges/delete/bridge_delete.py   (with props)
    asterisk/trunk/tests/rest_api/bridges/delete/configs/
    asterisk/trunk/tests/rest_api/bridges/delete/configs/ast1/
    asterisk/trunk/tests/rest_api/bridges/delete/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/rest_api/bridges/delete/test-config.yaml   (with props)
Modified:
    asterisk/trunk/tests/rest_api/bridges/tests.yaml

Added: asterisk/trunk/tests/rest_api/bridges/delete/bridge_delete.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/delete/bridge_delete.py?view=auto&rev=4311
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/delete/bridge_delete.py (added)
+++ asterisk/trunk/tests/rest_api/bridges/delete/bridge_delete.py Fri Nov  1 09:12:57 2013
@@ -1,0 +1,69 @@
+'''
+Copyright (C) 2013, Digium, Inc.
+Mark Michelson <mmichelson 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 BridgeSimple(object):
+    """
+    Struct-like class to track the channel and bridge we care about
+    """
+    def __init__(self):
+        self.channel_id = None
+        self.bridge_id = None
+
+
+TEST = BridgeSimple()
+
+
+def on_start(ari, event):
+    """
+    Called when the channel enters the Stasis application. This function will
+    create a bridge and add the channel to the bridge.
+    """
+    LOGGER.debug("on_start(%r)" % event)
+    TEST.channel_id = event['channel']['id']
+    TEST.bridge_id = ari.post('bridges').json()['id']
+    ari.post('channels', TEST.channel_id, 'answer')
+    ari.post('bridges', TEST.bridge_id, 'addChannel', channel=TEST.channel_id)
+    return True
+
+
+def on_enter(ari, event):
+    """
+    Called when the channel enters the bridge. This function will remove the
+    bridge from the system.
+    """
+    channel_id = event['channel']['id']
+    bridge_id = event['bridge']['id']
+    assert TEST.channel_id == channel_id
+    assert TEST.bridge_id == bridge_id
+    ari.delete('bridges', bridge_id)
+    return True
+
+
+def on_destroy(ari, event):
+    """
+    Called when the bridge is destroyed. This function checks that the bridge
+    no longer exists in the system but that the channel that was in the bridge
+    still does exist.
+    """
+    bridge_id = event['bridge']['id']
+    assert TEST.bridge_id == bridge_id
+    result = True
+    if not ari.get('channels', TEST.channel_id):
+        LOGGER.error("Channel %s no longer exists after bridge deletion" %
+                     TEST.channel_id)
+        result = False
+    if ari.get('bridges').json():
+        LOGGER.error("Bridges exist on system after deletion")
+        result = False
+    ari.delete('channels', TEST.channel_id)
+    return result

Propchange: asterisk/trunk/tests/rest_api/bridges/delete/bridge_delete.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/rest_api/bridges/delete/bridge_delete.py
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/rest_api/bridges/delete/bridge_delete.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/rest_api/bridges/delete/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/delete/configs/ast1/extensions.conf?view=auto&rev=4311
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/delete/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/rest_api/bridges/delete/configs/ast1/extensions.conf Fri Nov  1 09:12:57 2013
@@ -1,0 +1,6 @@
+[default]
+
+exten => s,1,NoOp()
+	same => n,Answer()
+	same => n,Stasis(testsuite)
+	same => n,Hangup()

Propchange: asterisk/trunk/tests/rest_api/bridges/delete/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/rest_api/bridges/delete/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/rest_api/bridges/delete/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/rest_api/bridges/delete/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/delete/test-config.yaml?view=auto&rev=4311
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/delete/test-config.yaml (added)
+++ asterisk/trunk/tests/rest_api/bridges/delete/test-config.yaml Fri Nov  1 09:12:57 2013
@@ -1,0 +1,64 @@
+testinfo:
+    summary: Test deleting a bridge with a channel in it.
+    description: |
+        Place a channel into a bridge. Delete the bridge. Ensure that the
+        channel still exists but the bridge does not.
+
+test-modules:
+    add-test-to-search-path: True
+    test-object:
+        typename: ari.AriTestObject
+    modules:
+        -   config-section: ari-config
+            typename: ari.WebSocketEventModule
+
+ari-config:
+    apps: testsuite
+    events:
+        -   conditions:
+                match:
+                    type: StasisStart
+                    application: testsuite
+                    args: []
+            count: 1
+            callback:
+                module: bridge_delete
+                method: on_start
+        -   conditions:
+                match:
+                    type: ChannelEnteredBridge
+                    application: testsuite
+            count: 1
+            callback:
+                module: bridge_delete
+                method: on_enter
+        -   conditions:
+                match:
+                    type: ChannelLeftBridge
+                    application: testsuite
+            count: 1
+        -   conditions:
+                match:
+                    type: BridgeDestroyed
+                    application: testsuite
+            count: 1
+            callback:
+                module: bridge_delete
+                method: on_destroy
+        -   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/trunk/tests/rest_api/bridges/delete/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/rest_api/bridges/delete/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/rest_api/bridges/delete/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/trunk/tests/rest_api/bridges/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/tests.yaml?view=diff&rev=4311&r1=4310&r2=4311
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/tests.yaml (original)
+++ asterisk/trunk/tests/rest_api/bridges/tests.yaml Fri Nov  1 09:12:57 2013
@@ -3,3 +3,4 @@
     - test: 'unhappy'
     - test: 'hangup'
     - test: 'move'
+    - test: 'delete'




More information about the svn-commits mailing list