[asterisk-commits] Change in testsuite[master]: Testsuite: Caller & callee initiated local attended transfer...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Apr 10 10:25:21 CDT 2015
Joshua Colp has submitted this change and it was merged.
Change subject: Testsuite: Caller & callee initiated local attended transfers to application.
......................................................................
Testsuite: Caller & callee initiated local attended transfers to application.
This adds two tests for caller and callee initiated local attended transfers
using PJSIP. The transfer target for both tests is a dialplan application.
ASTERISK-23695 #close
Change-Id: I61b70f83013b8d37de3fe1eea53c8dd2d026d2e0
---
M lib/python/asterisk/phones.py
A tests/channels/pjsip/transfers/attended_transfer/nominal/callee_local_app/configs/ast1/extensions.conf
A tests/channels/pjsip/transfers/attended_transfer/nominal/callee_local_app/configs/ast1/pjsip.conf
A tests/channels/pjsip/transfers/attended_transfer/nominal/callee_local_app/test-config.yaml
A tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_app/configs/ast1/extensions.conf
A tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_app/configs/ast1/pjsip.conf
A tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_app/test-config.yaml
M tests/channels/pjsip/transfers/attended_transfer/nominal/tests.yaml
8 files changed, 494 insertions(+), 0 deletions(-)
Approvals:
Matt Jordan: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved; Verified
diff --git a/lib/python/asterisk/phones.py b/lib/python/asterisk/phones.py
index 3941bfb..a1278cd 100755
--- a/lib/python/asterisk/phones.py
+++ b/lib/python/asterisk/phones.py
@@ -152,6 +152,20 @@
raise Exception("Exception occurred while transferring: '%s'" %
str(err))
+ def hold_call(self):
+ """Place call on hold.
+
+ The first call will be placed on hold.
+ """
+ LOGGER.info("'%s' is putting '%s' on hold." %
+ (self.name, self.calls[0].info().remote_uri))
+ try:
+ self.calls[0].hold()
+ except pj.Error as err:
+ msg = ("Exception occurred while putting call on hold: '%s'" %
+ str(err))
+ raise Exception(msg)
+
class AccCallback(pj.AccountCallback):
"""Derived callback class for accounts."""
@@ -282,6 +296,26 @@
test_object.stop_reactor()
raise Exception("Exception: '%s'" % str(sys.exc_info()))
+def hold(test_object, triggered_by, ari, event, args):
+ """Pluggable action module callback to place a call on hold"""
+ controller = PjsuaPhoneController.get_instance()
+ phone = controller.get_phone_obj(name=args['pjsua_account'])
+ if len(phone.calls) < 1:
+ msg = "'%s' must have 1 active call to put on hold!" % phone.name
+ test_object.stop_reactor()
+ raise Exception(msg)
+ if phone.calls[0].info().state != pj.CallState.CONFIRMED:
+ LOGGER.debug("Call is not fully established. Retrying hold shortly.")
+ reactor.callLater(.25, hold, test_object, triggered_by, ari, event,
+ args)
+ return
+
+ try:
+ phone.hold_call()
+ except:
+ test_object.stop_reactor()
+ raise Exception("Exception: '%s'" % str(sys.exc_info()))
+
def transfer(test_object, triggered_by, ari, event, args):
"""Pluggable action module callback to transfer a call"""
controller = PjsuaPhoneController.get_instance()
diff --git a/tests/channels/pjsip/transfers/attended_transfer/nominal/callee_local_app/configs/ast1/extensions.conf b/tests/channels/pjsip/transfers/attended_transfer/nominal/callee_local_app/configs/ast1/extensions.conf
new file mode 100644
index 0000000..342d047
--- /dev/null
+++ b/tests/channels/pjsip/transfers/attended_transfer/nominal/callee_local_app/configs/ast1/extensions.conf
@@ -0,0 +1,9 @@
+[default]
+
+exten => 101,1,Dial(PJSIP/bob)
+
+exten => echo,1,NoOp()
+ same => n,Answer()
+ same => n,Echo()
+ same => n,Hangup()
+
diff --git a/tests/channels/pjsip/transfers/attended_transfer/nominal/callee_local_app/configs/ast1/pjsip.conf b/tests/channels/pjsip/transfers/attended_transfer/nominal/callee_local_app/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..0264f4d
--- /dev/null
+++ b/tests/channels/pjsip/transfers/attended_transfer/nominal/callee_local_app/configs/ast1/pjsip.conf
@@ -0,0 +1,38 @@
+[global]
+type=global
+debug=yes
+
+[system]
+type=system
+
+[local]
+type=transport
+protocol=udp
+bind=127.0.0.1:5060
+
+[alice]
+type=endpoint
+context=default
+disallow=all
+allow=ulaw
+direct_media=no
+media_address=127.0.0.1
+aors=alice
+
+[alice]
+type=aor
+max_contacts=1
+
+[bob]
+type=endpoint
+context=default
+disallow=all
+allow=ulaw
+direct_media=no
+media_address=127.0.0.1
+aors=bob
+
+[bob]
+type=aor
+max_contacts=1
+
diff --git a/tests/channels/pjsip/transfers/attended_transfer/nominal/callee_local_app/test-config.yaml b/tests/channels/pjsip/transfers/attended_transfer/nominal/callee_local_app/test-config.yaml
new file mode 100644
index 0000000..e64a00e
--- /dev/null
+++ b/tests/channels/pjsip/transfers/attended_transfer/nominal/callee_local_app/test-config.yaml
@@ -0,0 +1,182 @@
+testinfo:
+ summary: "Callee initiated attended transfer to a dialplan application."
+ description: |
+ "Alice calls Bob via extension '101' and Bob answers. Bob places Alice
+ on hold and begins an attended transfer by making another call to the
+ Echo() application via extension 'echo'. Bob then completes the
+ attended transfer to put Alice into the Echo() application.
+
+ This test verifies that a caller channel can be transferred to a
+ dialplan application via an attended transfer initiated by the
+ callee."
+
+test-modules:
+ test-object:
+ config-section: test-object-config
+ typename: 'test_case.TestCaseModule'
+ modules:
+ -
+ config-section: 'pjsua-config'
+ typename: 'phones.PjsuaPhoneController'
+ -
+ config-section: pluggable-config
+ typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+ connect-ami: True
+
+pjsua-config:
+ transports:
+ -
+ name: 'local-ipv4-1'
+ bind: '127.0.0.1'
+ bindport: '5061'
+ -
+ name: 'local-ipv4-2'
+ bind: '127.0.0.1'
+ bindport: '5062'
+ accounts:
+ -
+ name: 'alice'
+ username: 'alice'
+ domain: '127.0.0.1'
+ transport: 'local-ipv4-1'
+ -
+ name: 'bob'
+ username: 'bob'
+ domain: '127.0.0.1'
+ transport: 'local-ipv4-2'
+
+pluggable-config:
+ # Ensure our pjsua phones are ready. Then alice calls bob via exten 101.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'UserEvent'
+ UserEvent: 'PJsuaPhonesReady'
+ count: 1
+ pjsua_phone:
+ action: 'call'
+ pjsua_account: 'alice'
+ call_uri: 'sip:101 at 127.0.0.1'
+ # Ensure alice and bob are in a bridge. Then bob places alice on hold.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'BridgeEnter'
+ BridgeNumChannels: '2'
+ count: 1
+ pjsua_phone:
+ action: 'hold'
+ pjsua_account: 'bob'
+ # Ensure MOH starts on alice's channel. Then bob calls echo to enter the
+ # Echo application.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'MusicOnHoldStart'
+ Channel: 'PJSIP/alice-.*'
+ count: 1
+ pjsua_phone:
+ action: 'call'
+ pjsua_account: 'bob'
+ call_uri: 'sip:echo at 127.0.0.1'
+ # Ensure bob enters the Echo application. Then transfer alice to the Echo
+ # application.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/bob-.*'
+ Application: 'Echo'
+ count: 1
+ pjsua_phone:
+ action: 'transfer'
+ pjsua_account: 'bob'
+ transfer_type: 'attended'
+ # Ensure the attended transfer occurs with the proper info.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'AttendedTransfer'
+ OrigTransfererChannel: 'PJSIP/bob-.*'
+ Result: 'Success'
+ SecondTransfererChannel: 'PJSIP/bob-.*'
+ TransfereeChannel: 'PJSIP/alice-.*'
+ DestType: 'App'
+ DestApp: 'Echo'
+ count: 1
+ # Ensure MOH stops on alice's channel.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'MusicOnHoldStop'
+ Channel: 'PJSIP/alice-.*'
+ count: 1
+ # Ensure alice leaves the bridge.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'BridgeLeave'
+ Channel: 'PJSIP/alice-.*'
+ count: 1
+ # Ensure bob leaves the bridge.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'BridgeLeave'
+ Channel: 'PJSIP/bob-.*'
+ count: 1
+ # Ensure alice enters the Echo application.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/alice-.*'
+ Application: 'Echo'
+ count: 1
+ # Ensure bob's second call to echo is hung up.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'Hangup'
+ Channel: 'PJSIP/bob-.*'
+ nomatch:
+ Exten: '101'
+ count: 1
+ # Ensure bob's first call from alice is hung up. Then hang up alice's channel
+ # and stop the test.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'Hangup'
+ Channel: 'PJSIP/bob-.*'
+ Exten: '101'
+ count: 1
+ ami-actions:
+ action:
+ action: 'Hangup'
+ channel: '/^PJSIP/alice-.*$/'
+ stop_test:
+
+properties:
+ minversion: '13.0.0'
+ dependencies:
+ - python : twisted
+ - python : starpy
+ - python : pjsua
+ - asterisk : res_pjsip
+ tags:
+ - pjsip
+
diff --git a/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_app/configs/ast1/extensions.conf b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_app/configs/ast1/extensions.conf
new file mode 100644
index 0000000..342d047
--- /dev/null
+++ b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_app/configs/ast1/extensions.conf
@@ -0,0 +1,9 @@
+[default]
+
+exten => 101,1,Dial(PJSIP/bob)
+
+exten => echo,1,NoOp()
+ same => n,Answer()
+ same => n,Echo()
+ same => n,Hangup()
+
diff --git a/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_app/configs/ast1/pjsip.conf b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_app/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..0264f4d
--- /dev/null
+++ b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_app/configs/ast1/pjsip.conf
@@ -0,0 +1,38 @@
+[global]
+type=global
+debug=yes
+
+[system]
+type=system
+
+[local]
+type=transport
+protocol=udp
+bind=127.0.0.1:5060
+
+[alice]
+type=endpoint
+context=default
+disallow=all
+allow=ulaw
+direct_media=no
+media_address=127.0.0.1
+aors=alice
+
+[alice]
+type=aor
+max_contacts=1
+
+[bob]
+type=endpoint
+context=default
+disallow=all
+allow=ulaw
+direct_media=no
+media_address=127.0.0.1
+aors=bob
+
+[bob]
+type=aor
+max_contacts=1
+
diff --git a/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_app/test-config.yaml b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_app/test-config.yaml
new file mode 100644
index 0000000..c5e218d
--- /dev/null
+++ b/tests/channels/pjsip/transfers/attended_transfer/nominal/caller_local_app/test-config.yaml
@@ -0,0 +1,182 @@
+testinfo:
+ summary: "Caller initiated attended transfer to a dialplan application."
+ description: |
+ "Alice calls Bob via extension '101' and Bob answers. Alice places Bob
+ on hold and begins an attended transfer by making another call to the
+ Echo() application via extension 'echo'. Alice then completes the
+ attended transfer to put Bob into the Echo() application.
+
+ This test verifies that a callee channel can be transferred to a
+ dialplan application via an attended transfer initiated by the
+ caller."
+
+test-modules:
+ test-object:
+ config-section: test-object-config
+ typename: 'test_case.TestCaseModule'
+ modules:
+ -
+ config-section: 'pjsua-config'
+ typename: 'phones.PjsuaPhoneController'
+ -
+ config-section: pluggable-config
+ typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+ connect-ami: True
+
+pjsua-config:
+ transports:
+ -
+ name: 'local-ipv4-1'
+ bind: '127.0.0.1'
+ bindport: '5061'
+ -
+ name: 'local-ipv4-2'
+ bind: '127.0.0.1'
+ bindport: '5062'
+ accounts:
+ -
+ name: 'alice'
+ username: 'alice'
+ domain: '127.0.0.1'
+ transport: 'local-ipv4-1'
+ -
+ name: 'bob'
+ username: 'bob'
+ domain: '127.0.0.1'
+ transport: 'local-ipv4-2'
+
+pluggable-config:
+ # Ensure our pjsua phones are ready. Then alice calls bob via exten 101.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'UserEvent'
+ UserEvent: 'PJsuaPhonesReady'
+ count: 1
+ pjsua_phone:
+ action: 'call'
+ pjsua_account: 'alice'
+ call_uri: 'sip:101 at 127.0.0.1'
+ # Ensure alice and bob are in a bridge. Then alice places bob on hold.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'BridgeEnter'
+ BridgeNumChannels: '2'
+ count: 1
+ pjsua_phone:
+ action: 'hold'
+ pjsua_account: 'alice'
+ # Ensure MOH starts on bob's channel. Then alice calls echo to enter the
+ # Echo application.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'MusicOnHoldStart'
+ Channel: 'PJSIP/bob-.*'
+ count: 1
+ pjsua_phone:
+ action: 'call'
+ pjsua_account: 'alice'
+ call_uri: 'sip:echo at 127.0.0.1'
+ # Ensure alice enters the Echo application. Then transfer bob to the Echo
+ # application.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/alice-.*'
+ Application: 'Echo'
+ count: 1
+ pjsua_phone:
+ action: 'transfer'
+ pjsua_account: 'alice'
+ transfer_type: 'attended'
+ # Ensure the attended transfer occurs with the proper info.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'AttendedTransfer'
+ OrigTransfererChannel: 'PJSIP/alice-.*'
+ Result: 'Success'
+ SecondTransfererChannel: 'PJSIP/alice-.*'
+ TransfereeChannel: 'PJSIP/bob-.*'
+ DestType: 'App'
+ DestApp: 'Echo'
+ count: 1
+ # Ensure MOH stops on bob's channel.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'MusicOnHoldStop'
+ Channel: 'PJSIP/bob-.*'
+ count: 1
+ # Ensure bob leaves the bridge.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'BridgeLeave'
+ Channel: 'PJSIP/bob-.*'
+ count: 1
+ # Ensure alice leaves the bridge.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'BridgeLeave'
+ Channel: 'PJSIP/alice-.*'
+ count: 1
+ # Ensure bob enters the Echo application.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/bob-.*'
+ Application: 'Echo'
+ count: 1
+ # Ensure alice's second call to echo is hung up.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'Hangup'
+ Channel: 'PJSIP/alice-.*'
+ nomatch:
+ Exten: '101'
+ count: 1
+ # Ensure alice's first call to bob is hung up. Then hang up bob's channel
+ # and stop the test.
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'Hangup'
+ Channel: 'PJSIP/alice-.*'
+ Exten: '101'
+ count: 1
+ ami-actions:
+ action:
+ action: 'Hangup'
+ channel: '/^PJSIP/bob-.*$/'
+ stop_test:
+
+properties:
+ minversion: '13.0.0'
+ dependencies:
+ - python : twisted
+ - python : starpy
+ - python : pjsua
+ - asterisk : res_pjsip
+ tags:
+ - pjsip
+
diff --git a/tests/channels/pjsip/transfers/attended_transfer/nominal/tests.yaml b/tests/channels/pjsip/transfers/attended_transfer/nominal/tests.yaml
index 70cc078..0fed3be 100644
--- a/tests/channels/pjsip/transfers/attended_transfer/nominal/tests.yaml
+++ b/tests/channels/pjsip/transfers/attended_transfer/nominal/tests.yaml
@@ -3,3 +3,5 @@
- test: 'caller_local'
- test: 'callee_local'
- test: 'callee_remote'
+ - test: 'caller_local_app'
+ - test: 'callee_local_app'
--
To view, visit https://gerrit.asterisk.org/34
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I61b70f83013b8d37de3fe1eea53c8dd2d026d2e0
Gerrit-PatchSet: 2
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: John Bigelow <jbigelow at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
More information about the asterisk-commits
mailing list