[asterisk-dev] Change in testsuite[master]: Add SIP attended transfer for Asterisk 11.
Mark Michelson has abandoned this change. Change subject: Add SIP attended transfer for Asterisk 11. .. Abandoned -- To view, visit https://gerrit.asterisk.org/20 To unsubscribe, visit https://gerrit.asterisk.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I48c7b6a9298552aa756d0c2f26afbd6a96d553b5 Gerrit-PatchSet: 1 Gerrit-Project: testsuite Gerrit-Branch: master Gerrit-Owner: Mark Michelson Gerrit-Reviewer: Ashley Sanders Gerrit-Reviewer: Corey Farrell Gerrit-Reviewer: Mark Michelson -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-dev mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-dev
[asterisk-dev] Change in testsuite[master]: Add SIP attended transfer for Asterisk 11.
Mark Michelson has posted comments on this change. Change subject: Add SIP attended transfer for Asterisk 11. .. Patch Set 1: I am abandoning this change in favor of change /c/29/ -- To view, visit https://gerrit.asterisk.org/20 To unsubscribe, visit https://gerrit.asterisk.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I48c7b6a9298552aa756d0c2f26afbd6a96d553b5 Gerrit-PatchSet: 1 Gerrit-Project: testsuite Gerrit-Branch: master Gerrit-Owner: Mark Michelson Gerrit-Reviewer: Ashley Sanders Gerrit-Reviewer: Corey Farrell Gerrit-Reviewer: Mark Michelson Gerrit-HasComments: No -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-dev mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-dev
[asterisk-dev] Change in testsuite[master]: Add SIP attended transfer for Asterisk 11.
Ashley Sanders has posted comments on this change. Change subject: Add SIP attended transfer for Asterisk 11. .. Patch Set 1: Code-Review-1 (1 comment) I think that most of this could be collapsed into the logic for the test for 12+. The AMI/bridging logic seems to be the only difference between the two versions. I think applying the strategy pattern will solve the problem of needing two tests for two disparate AMI APIs. This will help future-proof your code in that if any maintenance is required in the future, it will be a lot easier to apply that logic to one place rather than to n places :) https://gerrit.asterisk.org/#/c/20/1/tests/channels/SIP/sip_attended_transfer_11/attended_transfer.py File tests/channels/SIP/sip_attended_transfer_11/attended_transfer.py: After comparing this version against the version for the 12+ branch, the only significant difference is with respect to the ami bridging logic. I think you could just pull that piece out into it's own module and inject one strategy or the other based on the currently running asterisk version. This approach would greatly reduce the amount of code needed to test this feature. -- To view, visit https://gerrit.asterisk.org/20 To unsubscribe, visit https://gerrit.asterisk.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I48c7b6a9298552aa756d0c2f26afbd6a96d553b5 Gerrit-PatchSet: 1 Gerrit-Project: testsuite Gerrit-Branch: master Gerrit-Owner: Mark Michelson Gerrit-Reviewer: Ashley Sanders Gerrit-Reviewer: Corey Farrell Gerrit-HasComments: Yes -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-dev mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-dev
[asterisk-dev] Change in testsuite[master]: Add SIP attended transfer for Asterisk 11.
Corey Farrell has posted comments on this change. Change subject: Add SIP attended transfer for Asterisk 11. .. Patch Set 1: This is nearly identical to the test for 12+, couldn't they be combined with attended_transfer.py using conditionals to watch the correct AMI events for the version running? -- To view, visit https://gerrit.asterisk.org/20 To unsubscribe, visit https://gerrit.asterisk.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I48c7b6a9298552aa756d0c2f26afbd6a96d553b5 Gerrit-PatchSet: 1 Gerrit-Project: testsuite Gerrit-Branch: master Gerrit-Owner: Mark Michelson Gerrit-Reviewer: Corey Farrell Gerrit-HasComments: No -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-dev mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-dev
[asterisk-dev] Change in testsuite[master]: Add SIP attended transfer for Asterisk 11.
Mark Michelson has uploaded a new change for review.
https://gerrit.asterisk.org/20
Change subject: Add SIP attended transfer for Asterisk 11.
..
Add SIP attended transfer for Asterisk 11.
The structure of this is similar to the new Asterisk 12+ SIP attended
transfer test, except that the method of determining if channels are
bridged is different.
Like the 12+ version, the two major changes to the original test are
the use of the PJSUA testsuite module and waiting to move forward
with test actions until PJSUA has informed us of state changes.
The logic used for determining bridgedness is the same as was used
in the sip_attended_transfer test that is being replaced.
Change-Id: I48c7b6a9298552aa756d0c2f26afbd6a96d553b5
---
A tests/channels/SIP/sip_attended_transfer_11/attended_transfer.py
A tests/channels/SIP/sip_attended_transfer_11/configs/ast1/extensions.conf
A tests/channels/SIP/sip_attended_transfer_11/configs/ast1/sip.conf
A tests/channels/SIP/sip_attended_transfer_11/test-config.yaml
M tests/channels/SIP/tests.yaml
5 files changed, 273 insertions(+), 0 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/20/20/1
diff --git a/tests/channels/SIP/sip_attended_transfer_11/attended_transfer.py
b/tests/channels/SIP/sip_attended_transfer_11/attended_transfer.py
new file mode 100644
index 000..5f22af4
--- /dev/null
+++ b/tests/channels/SIP/sip_attended_transfer_11/attended_transfer.py
@@ -0,0 +1,187 @@
+"""
+Copyright (C) 2015, Digium, Inc.
+Mark Michelson
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+"""
+
+import logging
+import pjsua as pj
+
+from twisted.internet import reactor
+
+LOGGER = logging.getLogger(__name__)
+
+INIT = 0
+BOB_CALLED = 1
+CAROL_CALLED = 2
+TRANSFERRED = 3
+
+
+class TransferAccountCallback(pj.AccountCallback):
+'''Generic Account callback for Bob and Carol.
+
+The sole purpose of this callback is to auto-answer
+incoming calls
+'''
+
+def __init__(self, account):
+pj.AccountCallback.__init__(self, account)
+
+def on_incoming_call(self, call):
+call.answer(200)
+
+
+class BobCallCallback(pj.CallCallback):
+'''Call Callback used for Alice's call to Bob
+
+When we get told the call state is CONFIRMED, we signal
+to the test that the call is answered
+'''
+
+def __init__(self, call, transfer_object):
+pj.CallCallback.__init__(self, call)
+self.transfer_object = transfer_object
+
+def on_state(self):
+if self.call.info().state == pj.CallState.CONFIRMED:
+reactor.callFromThread(self.transfer_object.bob_call_answered)
+
+
+class CarolCallCallback(pj.CallCallback):
+'''Call Callback for Alice's call to Carol
+
+When we get told the call state is CONFIRMED we signal to the test that the
+call has been answered. This is very important, because if we attempt to
+perform the transfer before PJSUA has set the call state to CONFIRMED, then
+the REFER request that PJSUA sends will have a blank to-tag in the Refer-To
+header. Waiting ensures that all information is present in the REFER
+request.
+'''
+
+def __init__(self, call, transfer_object):
+pj.CallCallback.__init__(self, call)
+self.transfer_object = transfer_object
+
+def on_state(self):
+if self.call.info().state == pj.CallState.CONFIRMED:
+reactor.callFromThread(self.transfer_object.carol_call_answered)
+
+
+class Transfer(object):
+'''Controller for attended transfer test
+
+This contains all the methods for advancing the test, such as placing calls
+and performing transfers. It also has several state variables that help to
+determine the proper timing for performing actions.
+'''
+
+def __init__(self, test_object, accounts):
+super(Transfer, self).__init__()
+self.ami = test_object.ami[0]
+self.ami.registerEvent('Bridge', self.bridge)
+self.ami.registerEvent('VarSet', self.bridge_peer)
+
+self.chans = []
+self.final_bridge = 0
+self.bob_call_up = False
+self.carol_call_up = False
+self.bridge1_bridged = False
+self.bridge2_bridged = False
+
+bob = accounts.get('bob').account
+bob.set_callback(TransferAccountCallback(bob))
+
+carol = accounts.get('carol').account
+carol.set_callback(TransferAccountCallback(carol))
+
+self.alice = accounts.get('alice').account
+self.call_to_bob = None
+self.call_to_carol = None
+
+self.test_object = test_object
+self.state = INIT
+
+def bridge(self, ami, event):
+if event['channel2'] in self.chans:
+return
+
+self.chans.append(event['channel2'])
+numchans = len(self.chans)
+if numchans == 1:
+self.bridge1_bridged = True
+
