[asterisk-dev] Change in testsuite[master]: tests/rest_api/channels: Add a channel hold intercept test

Matt Jordan (Code Review) asteriskteam at digium.com
Fri Mar 27 22:21:05 CDT 2015


Matt Jordan has uploaded a new change for review.

  https://gerrit.asterisk.org/16

Change subject: tests/rest_api/channels: Add a channel hold intercept test
......................................................................

tests/rest_api/channels: Add a channel hold intercept test

This test verifies that a channel that initiates a call hold with the
HOLD_INTERCEPT function enabled on it will have the hold frame intercepte
and turned into an event for ARI clients.

A Local channel enters the Stasis application, and the HOLD_INTERCEPT function
is placed on the channel. A POST /hold operation is then used to simulate a
call hold on the channel. The test verifies that a ChannelHold event is raised
with the channel initating the hold. A DELETE /hold operation is then used, and
a ChannelUnhold event is raised with the channel initiating the unhold.

ASTERISK-24922
Reported by: Matt Jordan

Change-Id: If8bdbc74e0789d0c13ffbc5cb0c852f5f3a04012
---
A tests/rest_api/channels/hold/hold_intercept/configs/ast1/extensions.conf
A tests/rest_api/channels/hold/hold_intercept/hold_intercept.py
A tests/rest_api/channels/hold/hold_intercept/test-config.yaml
A tests/rest_api/channels/hold/tests.yaml
M tests/rest_api/channels/tests.yaml
5 files changed, 126 insertions(+), 0 deletions(-)


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

diff --git a/tests/rest_api/channels/hold/hold_intercept/configs/ast1/extensions.conf b/tests/rest_api/channels/hold/hold_intercept/configs/ast1/extensions.conf
new file mode 100644
index 0000000..aa88cf3
--- /dev/null
+++ b/tests/rest_api/channels/hold/hold_intercept/configs/ast1/extensions.conf
@@ -0,0 +1,6 @@
+[default]
+
+exten => s,1,NoOp()
+	same => n,Answer()
+	same => n,Stasis(testsuite)
+	same => n,Hangup()
diff --git a/tests/rest_api/channels/hold/hold_intercept/hold_intercept.py b/tests/rest_api/channels/hold/hold_intercept/hold_intercept.py
new file mode 100644
index 0000000..d738c5f
--- /dev/null
+++ b/tests/rest_api/channels/hold/hold_intercept/hold_intercept.py
@@ -0,0 +1,40 @@
+"""
+Copyright (C) 2015, Digium, Inc.
+Matt Jordan <mjordan 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__)
+
+CHANNEL_ID = None
+
+
+def on_start(ari, event, test_object):
+    global CHANNEL_ID
+    LOGGER.debug("on_start(%r)" % event)
+
+    CHANNEL_ID = event['channel']['id']
+
+    ari.post('channels', CHANNEL_ID, 'variable',
+             variable='HOLD_INTERCEPT(set)')
+
+    ari.post('channels', CHANNEL_ID, 'hold')
+    return True
+
+
+def on_hold(ari, event, test_object):
+    LOGGER.debug("on_hold(%r)" % event)
+
+    ari.delete('channels', CHANNEL_ID, 'hold')
+    return True
+
+
+def on_unhold(ari, event, test_object):
+    LOGGER.debug("on_unhold(%r)" % event)
+
+    ari.delete('channels', CHANNEL_ID)
+    return True
diff --git a/tests/rest_api/channels/hold/hold_intercept/test-config.yaml b/tests/rest_api/channels/hold/hold_intercept/test-config.yaml
new file mode 100644
index 0000000..94bcf1e
--- /dev/null
+++ b/tests/rest_api/channels/hold/hold_intercept/test-config.yaml
@@ -0,0 +1,77 @@
+testinfo:
+    summary: "Verify that Hold can be intercepted"
+    description: |
+        "This test verifies that a channel that initiates a call hold
+        with the HOLD_INTERCEPT function enabled on it will have the
+        hold frame intercepted and turned into an event for ARI clients.
+        A Local channel enters the Stasis application, and the HOLD_INTERCEPT
+        function is placed on the channel. A POST /hold operation is then
+        used to simulate a call hold on the channel. The test verifies
+        that a ChannelHold event is raised with the channel initating
+        the hold. A DELETE /hold operation is then used, and a ChannelUnhold
+        event is raised with the channel initiating the unhold."
+
+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:
+    apps: testsuite
+
+ari-config:
+    apps: testsuite
+    events:
+        -
+            conditions:
+                match:
+                    type: StasisStart
+                    application: testsuite
+                    args: []
+            count: 1
+            callback:
+                module: hold_intercept
+                method: on_start
+        -
+            conditions:
+                match:
+                    type: ChannelHold
+                    application: testsuite
+                    initiator: 1
+                    channel:
+                        name: 'Local/s at default-.*'
+            count: 1
+            callback:
+                module: hold_intercept
+                method: on_hold
+        -
+            conditions:
+                match:
+                    type: ChannelUnhold
+                    application: testsuite
+                    initiator: 1
+                    channel:
+                        name: 'Local/s at default-.*'
+            count: 1
+            callback:
+                module: hold_intercept
+                method: on_unhold
+
+properties:
+    minversion: '13.4.0'
+    dependencies:
+        - python : autobahn.websocket
+        - python : requests
+        - python : twisted
+        - python : starpy
+        - asterisk : app_stasis
+        - asterisk : res_ari_channels
+        - asterisk : res_ari_bridges
+        - asterisk : func_holdintercept
+    tags:
+        - ARI
diff --git a/tests/rest_api/channels/hold/tests.yaml b/tests/rest_api/channels/hold/tests.yaml
new file mode 100644
index 0000000..799f1b3
--- /dev/null
+++ b/tests/rest_api/channels/hold/tests.yaml
@@ -0,0 +1,2 @@
+tests:
+    - test: 'hold_intercept'
diff --git a/tests/rest_api/channels/tests.yaml b/tests/rest_api/channels/tests.yaml
index 522e493..a6a5801 100644
--- a/tests/rest_api/channels/tests.yaml
+++ b/tests/rest_api/channels/tests.yaml
@@ -11,3 +11,4 @@
     - dir: 'redirect'
     - test: 'connected_line_update'
     - test: 'originate_to_dialplan'
+    - dir: 'hold'

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If8bdbc74e0789d0c13ffbc5cb0c852f5f3a04012
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>



More information about the asterisk-dev mailing list