[asterisk-commits] file: testsuite/asterisk/trunk r4647 - in /asterisk/trunk/tests/rest_api/brid...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Feb 1 10:29:13 CST 2014


Author: file
Date: Sat Feb  1 10:29:10 2014
New Revision: 4647

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4647
Log:
Add tests for blind and attended transfers involving an ARI bridge.

(closes issue ASTERISK-22984)
Reported by: David M. Lee

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

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

Added: asterisk/trunk/tests/rest_api/bridges/attended_transfer/attended_transfer.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/attended_transfer/attended_transfer.py?view=auto&rev=4647
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/attended_transfer/attended_transfer.py (added)
+++ asterisk/trunk/tests/rest_api/bridges/attended_transfer/attended_transfer.py Sat Feb  1 10:29:10 2014
@@ -1,0 +1,74 @@
+'''
+Copyright (C) 2014, Digium, Inc.
+Joshua Colp <jcolp at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import logging
+import subprocess
+import time
+
+LOGGER = logging.getLogger(__name__)
+
+class TestLogic(object):
+	def __init__(self):
+		self.channels = 0
+		self.bridge_id = None
+		self.pja = subprocess.Popen(['pjsua', '--local-port=5065', '--null-audio',
+			'--id=sip:bob at 127.0.0.1'],
+			stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+		self.pjb = subprocess.Popen(['pjsua', '--local-port=5066', '--null-audio',
+			'--id=sip:alice at 127.0.0.1'],
+			stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+
+TEST = TestLogic()
+
+def a_call_stasis():
+	TEST.pja.stdin.write("m\n")
+	TEST.pja.stdin.write("sip:stasis at 127.0.0.1:5060\n")
+
+def b_call_stasis():
+	TEST.pjb.stdin.write("m\n")
+	TEST.pjb.stdin.write("sip:stasis at 127.0.0.1:5060\n")
+
+def on_third_leg(ami, event):
+	TEST.pja.stdin.write("X\n")
+	TEST.pja.stdin.write("1\n")
+	return True
+
+def a_call_app():
+	TEST.pja.stdin.write("H\n")
+	TEST.pja.stdin.write("m\n")
+	TEST.pja.stdin.write("sip:1000 at 127.0.0.1:5060\n")
+
+def on_kickoff_start(ari, event, test_object):
+    LOGGER.debug("on_kickoff_start(%r)" % event)
+    TEST.bridge_id = ari.post('bridges').json()['id']
+    a_call_stasis()
+    b_call_stasis()
+    ari.delete('channels', event['channel']['id'])
+    return True
+
+def on_test_start(ari, event, test_object):
+    LOGGER.debug("on_test_start(%r)" % event)
+    ari.post('bridges', TEST.bridge_id, 'addChannel', channel=event['channel']['id'])
+
+    TEST.channels += 1
+    if TEST.channels == 2:
+        a_call_app()
+
+    return True
+
+def on_attended_transfer(ari, event, test_object):
+	LOGGER.debug("on_attended_transfer(%r)" % event)
+	ari.delete('bridges', TEST.bridge_id)
+	TEST.pjb.stdin.write("h\n")
+
+	if not event['transferer_first_leg']['name'].startswith('PJSIP/bob-'):
+		return False
+	elif event['transferer_first_leg_bridge']['id'] != TEST.bridge_id:
+		return False
+
+	return True

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

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

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

Added: asterisk/trunk/tests/rest_api/bridges/attended_transfer/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/attended_transfer/configs/ast1/extensions.conf?view=auto&rev=4647
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/attended_transfer/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/rest_api/bridges/attended_transfer/configs/ast1/extensions.conf Sat Feb  1 10:29:10 2014
@@ -1,0 +1,14 @@
+[default]
+
+exten => s,1,NoOp()
+	same => n,Answer()
+	same => n,Stasis(testsuite)
+	same => n,Hangup()
+
+exten => 1000,1,Answer
+	same => n,Echo()
+	same => n,Hangup
+
+exten => stasis,1,NoOp()
+	same => n,Answer()
+	same => n,Stasis(testsuite,test)

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

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

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

Added: asterisk/trunk/tests/rest_api/bridges/attended_transfer/configs/ast1/pjsip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/attended_transfer/configs/ast1/pjsip.conf?view=auto&rev=4647
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/attended_transfer/configs/ast1/pjsip.conf (added)
+++ asterisk/trunk/tests/rest_api/bridges/attended_transfer/configs/ast1/pjsip.conf Sat Feb  1 10:29:10 2014
@@ -1,0 +1,19 @@
+[local]
+type=transport
+protocol=udp
+bind=127.0.0.1:5060
+
+[bob]
+type=endpoint
+context=default
+disallow=all
+allow=ulaw
+direct_media=no
+
+[alice]
+type=endpoint
+context=default
+disallow=all
+allow=ulaw
+direct_media=no
+

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

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

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

Added: asterisk/trunk/tests/rest_api/bridges/attended_transfer/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/attended_transfer/test-config.yaml?view=auto&rev=4647
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/attended_transfer/test-config.yaml (added)
+++ asterisk/trunk/tests/rest_api/bridges/attended_transfer/test-config.yaml Sat Feb  1 10:29:10 2014
@@ -1,0 +1,71 @@
+testinfo:
+    summary: Test originating calls to a Stasis application using ARI and then attended transferring.
+    description: |
+        Originate two external SIP calls into Stasis and then have one attended transfer the other.
+
+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
+        -
+            config-section: ami-config
+            typename: 'ami.AMIEventModule'
+
+ari-config:
+    apps: testsuite
+    events:
+        -   conditions:
+                match:
+                    type: StasisStart
+                    application: testsuite
+                    args: []
+            count: 1
+            callback:
+                module: attended_transfer
+                method: on_kickoff_start
+        -   conditions:
+                match:
+                    type: StasisStart
+                    application: testsuite
+                    args: ['test']
+            count: 2
+            callback:
+                module: attended_transfer
+                method: on_test_start
+        -   conditions:
+                match:
+                    type: BridgeAttendedTransfer
+                    application: testsuite
+            count: 1
+            callback:
+                module: attended_transfer
+                method: on_attended_transfer
+
+ami-config:
+    -
+        type: 'callback'
+        conditions:
+            match:
+                Event: 'Newexten'
+                Context: 'default'
+                Extension: '1000'
+                Application: 'Echo'
+        callbackModule: 'attended_transfer'
+        callbackMethod: 'on_third_leg'
+
+properties:
+    minversion: '12.1.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/attended_transfer/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Added: asterisk/trunk/tests/rest_api/bridges/blind_transfer/blind_transfer.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/blind_transfer/blind_transfer.py?view=auto&rev=4647
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/blind_transfer/blind_transfer.py (added)
+++ asterisk/trunk/tests/rest_api/bridges/blind_transfer/blind_transfer.py Sat Feb  1 10:29:10 2014
@@ -1,0 +1,67 @@
+'''
+Copyright (C) 2014, Digium, Inc.
+Joshua Colp <jcolp at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import logging
+import subprocess
+
+LOGGER = logging.getLogger(__name__)
+
+class TestLogic(object):
+	def __init__(self):
+		self.channels = 0
+		self.bridge_id = None
+		self.pja = subprocess.Popen(['pjsua', '--local-port=5065', '--null-audio',
+			'--id=sip:bob at 127.0.0.1'],
+			stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+		self.pjb = subprocess.Popen(['pjsua', '--local-port=5066', '--null-audio',
+			'--id=sip:alice at 127.0.0.1'],
+			stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+
+TEST = TestLogic()
+
+def a_call_stasis():
+	TEST.pja.stdin.write("m\n")
+	TEST.pja.stdin.write("sip:stasis at 127.0.0.1:5060\n")
+
+def b_call_stasis():
+	TEST.pjb.stdin.write("m\n")
+	TEST.pjb.stdin.write("sip:stasis at 127.0.0.1:5060\n")
+
+def a_call_transfer():
+	TEST.pja.stdin.write("x\n")
+	TEST.pja.stdin.write("sip:1000 at 127.0.0.1:5060\n")
+
+def on_kickoff_start(ari, event, test_object):
+    LOGGER.debug("on_kickoff_start(%r)" % event)
+    TEST.bridge_id = ari.post('bridges').json()['id']
+    a_call_stasis()
+    b_call_stasis()
+    ari.delete('channels', event['channel']['id'])
+    return True
+
+def on_test_start(ari, event, test_object):
+    LOGGER.debug("on_test_start(%r)" % event)
+    ari.post('bridges', TEST.bridge_id, 'addChannel', channel=event['channel']['id'])
+
+    TEST.channels += 1
+    if TEST.channels == 2:
+        a_call_transfer()
+
+    return True
+
+def on_blind_transfer(ari, event, test_object):
+	LOGGER.debug("on_blind_transfer(%r)" % event)
+	ari.delete('bridges', TEST.bridge_id)
+	TEST.pjb.stdin.write("h\n")
+
+	if not event['channel']['name'].startswith('PJSIP/bob-'):
+		return False
+	elif event['bridge']['id'] != TEST.bridge_id:
+		return False
+
+	return True

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

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

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

Added: asterisk/trunk/tests/rest_api/bridges/blind_transfer/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/blind_transfer/configs/ast1/extensions.conf?view=auto&rev=4647
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/blind_transfer/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/rest_api/bridges/blind_transfer/configs/ast1/extensions.conf Sat Feb  1 10:29:10 2014
@@ -1,0 +1,14 @@
+[default]
+
+exten => s,1,NoOp()
+	same => n,Answer()
+	same => n,Stasis(testsuite)
+	same => n,Hangup()
+
+exten => 1000,1,Answer
+	same => n,Echo()
+	same => n,Hangup
+
+exten => stasis,1,NoOp()
+	same => n,Answer()
+	same => n,Stasis(testsuite,test)

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

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

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

Added: asterisk/trunk/tests/rest_api/bridges/blind_transfer/configs/ast1/pjsip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/blind_transfer/configs/ast1/pjsip.conf?view=auto&rev=4647
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/blind_transfer/configs/ast1/pjsip.conf (added)
+++ asterisk/trunk/tests/rest_api/bridges/blind_transfer/configs/ast1/pjsip.conf Sat Feb  1 10:29:10 2014
@@ -1,0 +1,19 @@
+[local]
+type=transport
+protocol=udp
+bind=127.0.0.1:5060
+
+[bob]
+type=endpoint
+context=default
+disallow=all
+allow=ulaw
+direct_media=no
+
+[alice]
+type=endpoint
+context=default
+disallow=all
+allow=ulaw
+direct_media=no
+

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

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

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

Added: asterisk/trunk/tests/rest_api/bridges/blind_transfer/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/bridges/blind_transfer/test-config.yaml?view=auto&rev=4647
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/blind_transfer/test-config.yaml (added)
+++ asterisk/trunk/tests/rest_api/bridges/blind_transfer/test-config.yaml Sat Feb  1 10:29:10 2014
@@ -1,0 +1,55 @@
+testinfo:
+    summary: Test originating calls to a Stasis application using ARI and then blind transferring.
+    description: |
+        Originate two external SIP calls into Stasis and then have one blind transfer the other.
+
+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
+
+ari-config:
+    apps: testsuite
+    events:
+        -   conditions:
+                match:
+                    type: StasisStart
+                    application: testsuite
+                    args: []
+            count: 1
+            callback:
+                module: blind_transfer
+                method: on_kickoff_start
+        -   conditions:
+                match:
+                    type: StasisStart
+                    application: testsuite
+                    args: ['test']
+            count: 2
+            callback:
+                module: blind_transfer
+                method: on_test_start
+        -   conditions:
+                match:
+                    type: BridgeBlindTransfer
+                    application: testsuite
+            count: 1
+            callback:
+                module: blind_transfer
+                method: on_blind_transfer
+
+properties:
+    minversion: '12.1.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/blind_transfer/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: asterisk/trunk/tests/rest_api/bridges/blind_transfer/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=4647&r1=4646&r2=4647
==============================================================================
--- asterisk/trunk/tests/rest_api/bridges/tests.yaml (original)
+++ asterisk/trunk/tests/rest_api/bridges/tests.yaml Sat Feb  1 10:29:10 2014
@@ -5,3 +5,5 @@
     - test: 'move'
     - test: 'delete'
     - test: 'add_recording_channel'
+    - test: 'blind_transfer'
+    - test: 'attended_transfer'




More information about the asterisk-commits mailing list