[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 Apr 10 11:22:11 CDT 2015


Matt Jordan has submitted this change and it was merged.

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, 157 insertions(+), 0 deletions(-)

Approvals:
  Matt Jordan: Looks good to me, approved; Verified
  Jared K. Smith: Looks good to me, but someone else must approve



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..4597db2
--- /dev/null
+++ b/tests/rest_api/channels/hold/hold_intercept/hold_intercept.py
@@ -0,0 +1,73 @@
+"""
+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):
+    """StasisStart handler
+
+    Keyword Arguments:
+    ari         - ARI client object
+    event       - StasisStart event data
+    test_object - The one and only test object
+
+    Returns:
+    True if the event was handled successfully
+    False if the event handling failed
+    """
+    global CHANNEL_ID
+    LOGGER.debug("on_start({0})".format(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):
+    """ChannelHold handler
+
+    Keyword Arguments:
+    ari         - ARI client object
+    event       - ChannelHold event data
+    test_object - The one and only test object
+
+    Returns:
+    True if the event was handled successfully
+    False if the event handling failed
+    """
+    LOGGER.debug("on_hold({0})".format(event))
+
+    ari.delete('channels', CHANNEL_ID, 'hold')
+    return True
+
+
+def on_unhold(ari, event, test_object):
+    """ChannelUnhold handler
+
+    Keyword Arguments:
+    ari         - ARI client object
+    event       - ChannelUnhold event data
+    test_object - The one and only test object
+
+    Returns:
+    True if the event was handled successfully
+    False if the event handling failed
+    """
+    LOGGER.debug("on_unhold({0})".format(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..704d53a
--- /dev/null
+++ b/tests/rest_api/channels/hold/hold_intercept/test-config.yaml
@@ -0,0 +1,75 @@
+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
+                    channel:
+                        name: 'Local/s at default-.*'
+            count: 1
+            callback:
+                module: hold_intercept
+                method: on_hold
+        -
+            conditions:
+                match:
+                    type: ChannelUnhold
+                    application: testsuite
+                    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: merged
Gerrit-Change-Id: If8bdbc74e0789d0c13ffbc5cb0c852f5f3a04012
Gerrit-PatchSet: 4
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Jared K. Smith <jaredsmith at jaredsmith.net>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-dev mailing list