[asterisk-commits] jrose: testsuite/asterisk/trunk r4908 - in /asterisk/trunk/tests/rest_api/bri...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 28 15:29:45 CDT 2014


Author: jrose
Date: Fri Mar 28 15:29:37 2014
New Revision: 4908

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4908
Log:
testsuite: Add tests for ARI bridge playback and record functions

Tests receipt of playback/record start and stop events when using
playback and record operations on bridges

(closes issue ASTERISK-23444)
Reported by: Ben Merrills
Review: https://reviewboard.asterisk.org/r/3353/

Added:
    asterisk/trunk/tests/rest_api/bridges/bridge_play/
    asterisk/trunk/tests/rest_api/bridges/bridge_play/bridges_play.py   (with props)
    asterisk/trunk/tests/rest_api/bridges/bridge_play/configs/
    asterisk/trunk/tests/rest_api/bridges/bridge_play/configs/ast1/
    asterisk/trunk/tests/rest_api/bridges/bridge_play/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/rest_api/bridges/bridge_play/test-config.yaml   (with props)
    asterisk/trunk/tests/rest_api/bridges/bridge_record/
    asterisk/trunk/tests/rest_api/bridges/bridge_record/bridges_record.py   (with props)
    asterisk/trunk/tests/rest_api/bridges/bridge_record/configs/
    asterisk/trunk/tests/rest_api/bridges/bridge_record/configs/ast1/
    asterisk/trunk/tests/rest_api/bridges/bridge_record/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/rest_api/bridges/bridge_record/test-config.yaml   (with props)
Modified:
    asterisk/trunk/tests/rest_api/bridges/tests.yaml

Added: asterisk/trunk/tests/rest_api/bridges/bridge_play/bridges_play.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/bridge_play/bridges_play.py?view=auto&rev=4908
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/bridge_play/bridges_play.py (added)
+++ asterisk/trunk/tests/rest_api/bridges/bridge_play/bridges_play.py Fri Mar 28 15:29:37 2014
@@ -1,0 +1,62 @@
+'''
+Copyright (C) 2014, Digium, Inc.
+Jonathan R. Rose <jrose 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 SubscribeBridge(object):
+    def __init__(self):
+        self.channels = None
+        self.bridge_id = None
+
+
+TEST = SubscribeBridge()
+
+
+def on_start(ari, event, test_object):
+    # When the channel enters stasis, create a bridge and add the channel.
+    TEST.channel_id = event['channel']['id']
+    TEST.bridge_id = ari.post('bridges').json()['id']
+
+    ari.post('bridges', TEST.bridge_id, 'addChannel',
+             channel=TEST.channel_id)
+
+    return True
+
+
+def on_enter_testsuite(ari, event, test_object):
+    # When the channel enters the bridge, start the playback operation.
+    assert TEST.bridge_id == event['bridge']['id']
+    assert TEST.channel_id == event['channel']['id']
+
+    # Start playback on the bridge
+    ari.post('bridges', TEST.bridge_id, 'play',
+             media='sound:tt-weasels')
+
+    return True
+
+
+def on_playback_finished(ari, event, test_object):
+    # When the PlaybackFinished event is received, remove the channel.
+    ari.post('bridges', TEST.bridge_id, 'removeChannel',
+             channel=TEST.channel_id)
+
+    return True
+
+
+def on_channel_left_bridge(ari, event, test_object):
+    # testsuite received a ChannelLeftBridge event, wrap the test up.
+    assert TEST.bridge_id == event['bridge']['id']
+    assert TEST.channel_id == event['channel']['id']
+
+    ari.delete('channels', TEST.channel_id)
+    ari.delete('bridges', TEST.bridge_id)
+
+    return True

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

Propchange: asterisk/trunk/tests/rest_api/bridges/bridge_play/bridges_play.py
------------------------------------------------------------------------------
    svn:executable = *

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

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

Added: asterisk/trunk/tests/rest_api/bridges/bridge_play/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/bridge_play/configs/ast1/extensions.conf?view=auto&rev=4908
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/bridge_play/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/rest_api/bridges/bridge_play/configs/ast1/extensions.conf Fri Mar 28 15:29:37 2014
@@ -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/bridge_play/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Added: asterisk/trunk/tests/rest_api/bridges/bridge_play/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/bridge_play/test-config.yaml?view=auto&rev=4908
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/bridge_play/test-config.yaml (added)
+++ asterisk/trunk/tests/rest_api/bridges/bridge_play/test-config.yaml Fri Mar 28 15:29:37 2014
@@ -1,0 +1,77 @@
+testinfo:
+    summary: Test detection of PlaybackStarted and PlaybackFinished events
+             from bridge topic during bridges/play
+    description: |
+        This creates a bridge and places a channel in the bridge implicitly
+        subscribing to it. Then the test executes the bridges/play ARI command
+        to the bridge. The PlaybackStarted and PlaybackFinished events must be
+        received in order for the test to be considered successful.
+
+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
+
+apps: testsuite
+
+ari-config:
+    events:
+        -   conditions:
+                match:
+                    type: StasisStart
+                    application: testsuite
+                    args: []
+            count: 1
+            callback:
+                module: bridges_play
+                method: on_start
+        -   conditions:
+                match:
+                    type: ChannelEnteredBridge
+                    application: testsuite
+                    bridge:
+                    channel:
+            count: 1
+            callback:
+                module: bridges_play
+                method: on_enter_testsuite
+        -   conditions:
+                match:
+                    type: PlaybackStarted
+                    application: testsuite
+                    playback:
+            count: 1
+        -   conditions:
+                match:
+                    type: PlaybackFinished
+                    application: testsuite
+                    playback:
+            count: 1
+            callback:
+                module: bridges_play
+                method: on_playback_finished
+        -   conditions:
+                match:
+                    type: ChannelLeftBridge
+                    application: testsuite
+                    bridge:
+                    channel:
+            count: 1
+            callback:
+                module: bridges_play
+                method: on_channel_left_bridge
+
+properties:
+    minversion: '12.2.0'
+    dependencies:
+        - python : autobahn.websocket
+        - python : requests
+        - python : twisted
+        - python : starpy
+        - asterisk : res_ari_channels
+    tags:
+        - ARI

Propchange: asterisk/trunk/tests/rest_api/bridges/bridge_play/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Added: asterisk/trunk/tests/rest_api/bridges/bridge_record/bridges_record.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/bridge_record/bridges_record.py?view=auto&rev=4908
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/bridge_record/bridges_record.py (added)
+++ asterisk/trunk/tests/rest_api/bridges/bridge_record/bridges_record.py Fri Mar 28 15:29:37 2014
@@ -1,0 +1,70 @@
+'''
+Copyright (C) 2014, Digium, Inc.
+Jonathan R. Rose <jrose 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 SubscribeBridge(object):
+    def __init__(self):
+        self.channels = None
+        self.bridge_id = None
+
+
+TEST = SubscribeBridge()
+
+
+def on_start(ari, event, test_object):
+    # When the channel enters stasis, create a bridge and add the channel.
+    TEST.channel_id = event['channel']['id']
+    TEST.bridge_id = ari.post('bridges').json()['id']
+
+    ari.post('bridges', TEST.bridge_id, 'addChannel',
+             channel=TEST.channel_id)
+
+    return True
+
+
+def on_enter_testsuite(ari, event, test_object):
+    # When the channel enters the bridge, start the recording operation.
+
+    assert TEST.bridge_id == event['bridge']['id']
+    assert TEST.channel_id == event['channel']['id']
+
+    # Start recording on the bridge
+    ari.post('bridges', TEST.bridge_id, 'record',
+             name='test_recording', format='wav')
+
+    return True
+
+
+def on_recording_started(ari, event, test_object):
+    # When the RecordingStarted event is received, stop the recording.
+    ari.post('recordings/live', 'test_recording', 'stop')
+
+    return True
+
+
+def on_recording_finished(ari, event, test_object):
+    # When the RecordingFinished Event is received, remove the channel.
+    ari.post('bridges', TEST.bridge_id, 'removeChannel',
+             channel=TEST.channel_id)
+
+    return True
+
+
+def on_channel_left_bridge(ari, event, test_object):
+    # testsuite received a ChannelLeftBridge event, wrap the test up.
+    assert TEST.bridge_id == event['bridge']['id']
+    assert TEST.channel_id == event['channel']['id']
+
+    ari.delete('channels', TEST.channel_id)
+    ari.delete('bridges', TEST.bridge_id)
+
+    return True

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

Propchange: asterisk/trunk/tests/rest_api/bridges/bridge_record/bridges_record.py
------------------------------------------------------------------------------
    svn:executable = *

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

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

Added: asterisk/trunk/tests/rest_api/bridges/bridge_record/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/bridge_record/configs/ast1/extensions.conf?view=auto&rev=4908
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/bridge_record/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/rest_api/bridges/bridge_record/configs/ast1/extensions.conf Fri Mar 28 15:29:37 2014
@@ -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/bridge_record/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Added: asterisk/trunk/tests/rest_api/bridges/bridge_record/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/bridge_record/test-config.yaml?view=auto&rev=4908
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/bridge_record/test-config.yaml (added)
+++ asterisk/trunk/tests/rest_api/bridges/bridge_record/test-config.yaml Fri Mar 28 15:29:37 2014
@@ -1,0 +1,83 @@
+testinfo:
+    summary: Test detection of RecordingStarted and RecordingFinished events
+             from bridge topic during bridges/record
+    description: |
+        This creates a bridgeand places a channel in the bridge implicitly
+        subscribing to it. Then the test executes the bridges/record ARI
+        command to it. Upon receiving the RecordingStarted event, the
+        recording will be stopped. The RecordingStarted and RecordingFinished
+        events must be received in order for the test to be considered
+        successful.
+
+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
+
+apps: testsuite
+
+ari-config:
+    events:
+        -   conditions:
+                match:
+                    type: StasisStart
+                    application: testsuite
+                    args: []
+            count: 1
+            callback:
+                module: bridges_record
+                method: on_start
+        -   conditions:
+                match:
+                    type: ChannelEnteredBridge
+                    application: testsuite
+                    bridge:
+                    channel:
+            count: 1
+            callback:
+                module: bridges_record
+                method: on_enter_testsuite
+        -   conditions:
+                match:
+                    type: RecordingStarted
+                    application: testsuite
+                    recording:
+            count: 1
+            callback:
+                module: bridges_record
+                method: on_recording_started
+        -   conditions:
+                match:
+                    type: RecordingFinished
+                    application: testsuite
+            count: 1
+            callback:
+                module: bridges_record
+                method: on_recording_finished
+        -   conditions:
+                match:
+                    type: ChannelLeftBridge
+                    application: testsuite
+                    bridge:
+                    channel:
+            count: 1
+            callback:
+                module: bridges_record
+                method: on_channel_left_bridge
+
+properties:
+    minversion: '12.2.0'
+    dependencies:
+        - python : autobahn.websocket
+        - python : requests
+        - python : twisted
+        - python : starpy
+        - asterisk : res_ari_channels
+    tags:
+        - ARI
+
+

Propchange: asterisk/trunk/tests/rest_api/bridges/bridge_record/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: asterisk/trunk/tests/rest_api/bridges/bridge_record/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=4908&r1=4907&r2=4908
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/tests.yaml (original)
+++ asterisk/trunk/tests/rest_api/bridges/tests.yaml Fri Mar 28 15:29:37 2014
@@ -8,3 +8,5 @@
     - test: 'blind_transfer'
     - test: 'attended_transfer'
     - test: 'bridge_by_id'
+    - test: 'bridge_play'
+    - test: 'bridge_record'




More information about the asterisk-commits mailing list