[asterisk-commits] jrose: testsuite/asterisk/trunk r3877 - in /asterisk/trunk/tests: ./ feature_...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jul 2 18:02:24 CDT 2013
Author: jrose
Date: Tue Jul 2 18:02:17 2013
New Revision: 3877
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3877
Log:
tests/features: Add a test for basic call pickup
(closes issue ASTERISK-21544)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2592/
Added:
asterisk/trunk/tests/feature_call_pickup/
asterisk/trunk/tests/feature_call_pickup/configs/
asterisk/trunk/tests/feature_call_pickup/configs/ast1/
asterisk/trunk/tests/feature_call_pickup/configs/ast1/extensions.conf (with props)
asterisk/trunk/tests/feature_call_pickup/configs/ast1/features.conf (with props)
asterisk/trunk/tests/feature_call_pickup/configs/ast1/sip.conf (with props)
asterisk/trunk/tests/feature_call_pickup/configs/ast2/
asterisk/trunk/tests/feature_call_pickup/configs/ast2/extensions.conf (with props)
asterisk/trunk/tests/feature_call_pickup/configs/ast2/sip.conf (with props)
asterisk/trunk/tests/feature_call_pickup/run-test (with props)
asterisk/trunk/tests/feature_call_pickup/test-config.yaml (with props)
Modified:
asterisk/trunk/tests/tests.yaml
Added: asterisk/trunk/tests/feature_call_pickup/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/feature_call_pickup/configs/ast1/extensions.conf?view=auto&rev=3877
==============================================================================
--- asterisk/trunk/tests/feature_call_pickup/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/feature_call_pickup/configs/ast1/extensions.conf Tue Jul 2 18:02:17 2013
@@ -1,0 +1,12 @@
+[general]
+
+[globals]
+
+[pickuptest]
+exten => dial_faker,1,NoOp()
+ same => n,Answer()
+ same => n,Dial(SIP/faker)
+
+exten => test_fuzz,1,NoOp
+ same => n,Answer()
+ same => n,Playback(tt-monkeys)
Propchange: asterisk/trunk/tests/feature_call_pickup/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/feature_call_pickup/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/feature_call_pickup/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/feature_call_pickup/configs/ast1/features.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/feature_call_pickup/configs/ast1/features.conf?view=auto&rev=3877
==============================================================================
--- asterisk/trunk/tests/feature_call_pickup/configs/ast1/features.conf (added)
+++ asterisk/trunk/tests/feature_call_pickup/configs/ast1/features.conf Tue Jul 2 18:02:17 2013
@@ -1,0 +1,4 @@
+[general]
+pickupexten = *8
+pickupsound = tt-allbusy
+pickupfailsound = beeperr
Propchange: asterisk/trunk/tests/feature_call_pickup/configs/ast1/features.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/feature_call_pickup/configs/ast1/features.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/feature_call_pickup/configs/ast1/features.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/feature_call_pickup/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/feature_call_pickup/configs/ast1/sip.conf?view=auto&rev=3877
==============================================================================
--- asterisk/trunk/tests/feature_call_pickup/configs/ast1/sip.conf (added)
+++ asterisk/trunk/tests/feature_call_pickup/configs/ast1/sip.conf Tue Jul 2 18:02:17 2013
@@ -1,0 +1,16 @@
+[general]
+bindaddr = 127.0.0.1
+disallow = all
+allow = ulaw
+
+[sip_receive]
+type = friend
+host = 127.0.0.2
+context = default
+pickupgroup = 5
+
+[faker]
+type=friend
+host = 127.0.0.3
+context = default
+callgroup = 5
Propchange: asterisk/trunk/tests/feature_call_pickup/configs/ast1/sip.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/feature_call_pickup/configs/ast1/sip.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/feature_call_pickup/configs/ast1/sip.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/feature_call_pickup/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/feature_call_pickup/configs/ast2/extensions.conf?view=auto&rev=3877
==============================================================================
--- asterisk/trunk/tests/feature_call_pickup/configs/ast2/extensions.conf (added)
+++ asterisk/trunk/tests/feature_call_pickup/configs/ast2/extensions.conf Tue Jul 2 18:02:17 2013
@@ -1,0 +1,7 @@
+[pickuptest]
+exten => test_out,1,NoOp
+ same => n, Dial(SIP/sip_send/*8)
+
+exten => pickup_exten,1,NoOp
+ same => n, Answer()
+ same => n, playback(tt-monkeys)
Propchange: asterisk/trunk/tests/feature_call_pickup/configs/ast2/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/feature_call_pickup/configs/ast2/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/feature_call_pickup/configs/ast2/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/feature_call_pickup/configs/ast2/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/feature_call_pickup/configs/ast2/sip.conf?view=auto&rev=3877
==============================================================================
--- asterisk/trunk/tests/feature_call_pickup/configs/ast2/sip.conf (added)
+++ asterisk/trunk/tests/feature_call_pickup/configs/ast2/sip.conf Tue Jul 2 18:02:17 2013
@@ -1,0 +1,9 @@
+[general]
+bindaddr = 127.0.0.2
+disallow = all
+allow = ulaw
+
+[sip_send]
+type = friend
+host = 127.0.0.1
+context = default
Propchange: asterisk/trunk/tests/feature_call_pickup/configs/ast2/sip.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/feature_call_pickup/configs/ast2/sip.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/feature_call_pickup/configs/ast2/sip.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/feature_call_pickup/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/feature_call_pickup/run-test?view=auto&rev=3877
==============================================================================
--- asterisk/trunk/tests/feature_call_pickup/run-test (added)
+++ asterisk/trunk/tests/feature_call_pickup/run-test Tue Jul 2 18:02:17 2013
@@ -1,0 +1,168 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2013, Digium, Inc.
+Jonathan Rose <jrose at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import os
+import logging
+import re
+
+from twisted.internet import reactor
+
+sys.path.append("lib/python")
+from asterisk.asterisk import Asterisk
+from asterisk.version import AsteriskVersion
+from asterisk.TestCase import TestCase
+
+LOGGER = logging.getLogger(__name__)
+
+class CallPickupTest(TestCase):
+
+ def __init__(self):
+ TestCase.__init__(self)
+
+ self.pickeeChannel = "Local/dial_faker at pickuptest-"
+ self.pickerChannel = "SIP/sip_receive-"
+ self.targetChannel = "SIP/faker-"
+
+ self.bridge = None
+ self.bridgingModel12 = False
+
+ self.bridgeComplete = False
+ self.pickupComplete = False
+
+ self.pickerJoined = False
+ self.pickeeJoined = False
+
+ self.connectionsEstablished = 0
+
+ self.create_asterisk(count=2)
+
+ def hangup(self, ami):
+ self.stop_reactor()
+
+ def check_bridge_enter(self, ami, event):
+ channel = event.get('channel')
+ bridge = event.get('bridgeuniqueid')
+
+ if not self.bridge:
+ self.bridge = bridge
+ elif self.bridge != bridge:
+ LOGGER.error("The bridge ID mismatch - got %s - expected %s - FAIL" % (bridge, self.bridge))
+ self.set_passed(False)
+ self.stop_reactor()
+
+ patternPicker = re.compile(self.pickerChannel)
+ patternPickee = re.compile(self.pickeeChannel)
+
+ if patternPicker.match(channel):
+ self.pickerJoined = True
+ elif patternPickee.match(channel):
+ self.pickeeJoined = True
+ else:
+ LOGGER.error("Unexpected Channel %s joined the bridge - FAIL" % channel)
+ self.set_passed(False)
+ self.stop_reactor()
+
+ if self.pickerJoined and self.pickeeJoined:
+ if self.pickupComplete:
+ self.set_passed(True)
+ self.ami[0].hangup(channel2).addCallback(self.hangup)
+ else:
+ self.bridgeComplete = True
+
+ def check_bridge(self, ami, event):
+ if event.get("bridgestate") != "Link":
+ return
+
+ channel1 = event.get("channel1")
+ channel2 = event.get("channel2")
+
+ pattern1 = re.compile(self.pickeeChannel)
+ pattern2 = re.compile(self.pickerChannel)
+
+ if pattern1.match(channel1) and pattern2.match(channel2):
+ if self.pickupComplete:
+ self.set_passed(True)
+ self.ami[0].hangup(channel2).addCallback(self.hangup)
+ else:
+ self.bridgeComplete = True
+
+ def check_pickup(self, ami, event):
+ picker = event.get("channel")
+ target = event.get("targetchannel")
+
+ pattern1 = re.compile(self.pickerChannel)
+ pattern2 = re.compile(self.targetChannel)
+
+ if pattern1.match(picker) and pattern2.match(target):
+ if self.bridgeComplete:
+ self.set_passed(True)
+ self.ami[0].hangup(picker).addCallback(self.hangup)
+ else:
+ self.pickupComplete = True
+
+ def check_dial(self, ami, event):
+ dialstring = event.get('dialstring')
+ if dialstring != 'faker':
+ return
+
+ self.ami[0].registerEvent('Pickup', self.check_pickup)
+
+ if self.bridgingModel12:
+ self.ami[0].registerEvent('BridgeEnter', self.check_bridge_enter)
+ else:
+ self.ami[0].registerEvent('Bridge', self.check_bridge)
+
+ LOGGER.info("Originating Pickup attempt")
+
+ self.ami[1].originate(
+ channel = "Local/test_out at pickuptest",
+ exten = "pickup_exten",
+ context = "pickuptest",
+ priority = "1"
+ ).addErrback(self.handleOriginateFailure)
+
+ def ami_connect(self, ami):
+ self.connectionsEstablished += 1
+
+ if self.connectionsEstablished != 2:
+ return
+
+ running_version = AsteriskVersion()
+ post_version = AsteriskVersion("12.0.0")
+ if running_version < post_version:
+ #Pre-Asterisk 12
+ self.ami[0].registerEvent("Dial", self.check_dial)
+ else:
+ self.bridgingModel12 = True
+ self.ami[0].registerEvent("DialBegin", self.check_dial)
+
+ LOGGER.info("Originating channel to be picked up")
+ self.ami[0].originate(
+ channel = "LOCAL/dial_faker at pickuptest",
+ exten = "test_fuzz",
+ context = "pickuptest",
+ priority = 1
+ ).addErrback(self.handleOriginateFailure)
+
+ def run(self):
+ TestCase.run(self)
+ self.create_ami_factory(2)
+
+def main():
+ test = CallPickupTest()
+ reactor.run()
+ if test.passed != True:
+ return 1
+ return 0
+
+if __name__ == "__main__":
+ sys.exit(main() or 0)
+
+# vim:sw=4:ts=4:expandtab:textwidth=79
Propchange: asterisk/trunk/tests/feature_call_pickup/run-test
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/feature_call_pickup/run-test
------------------------------------------------------------------------------
svn:executable = *
Propchange: asterisk/trunk/tests/feature_call_pickup/run-test
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/feature_call_pickup/run-test
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/feature_call_pickup/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/feature_call_pickup/test-config.yaml?view=auto&rev=3877
==============================================================================
--- asterisk/trunk/tests/feature_call_pickup/test-config.yaml (added)
+++ asterisk/trunk/tests/feature_call_pickup/test-config.yaml Tue Jul 2 18:02:17 2013
@@ -1,0 +1,13 @@
+testinfo:
+ summary: 'Test Call Pickup'
+ description: |
+ 'This test verifies that a channel can use the call pickup extension to
+ Answer a call to a channel that is assigned to its pickupgroup.'
+
+properties:
+ minversion: '11.0.0'
+ dependencies:
+ - python : 'twisted'
+ - python : 'starpy'
+ tags:
+ - pickup
Propchange: asterisk/trunk/tests/feature_call_pickup/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/feature_call_pickup/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/feature_call_pickup/test-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: asterisk/trunk/tests/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/tests.yaml?view=diff&rev=3877&r1=3876&r2=3877
==============================================================================
--- asterisk/trunk/tests/tests.yaml (original)
+++ asterisk/trunk/tests/tests.yaml Tue Jul 2 18:02:17 2013
@@ -8,6 +8,7 @@
- dir: 'channels'
- test: 'udptl'
- test: 'udptl_v6'
+ - test: 'feature_call_pickup'
- test: 'feature_blonde_transfer'
- test: 'feature_attended_transfer'
- test: 'blind-transfer-parkingtimeout'
More information about the asterisk-commits
mailing list