[asterisk-commits] jrose: testsuite/asterisk/trunk r4114 - in /asterisk/trunk/tests/callparking_...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 5 11:23:44 CDT 2013


Author: jrose
Date: Thu Sep  5 11:23:38 2013
New Revision: 4114

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4114
Log:
testsuite: Rewrite callparking_retrieval test in Python

This test had been failing for some time and should be made
working again with this patch.

(issue ASTERISK-22328)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2779/

Added:
    asterisk/trunk/tests/callparking_retrieval/configs/
    asterisk/trunk/tests/callparking_retrieval/configs/ast1/
    asterisk/trunk/tests/callparking_retrieval/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/callparking_retrieval/configs/ast1/features.conf   (with props)
    asterisk/trunk/tests/callparking_retrieval/configs/ast1/iax.conf   (with props)
    asterisk/trunk/tests/callparking_retrieval/configs/ast1/res_parking.conf   (with props)
    asterisk/trunk/tests/callparking_retrieval/configs/ast2/
    asterisk/trunk/tests/callparking_retrieval/configs/ast2/extensions.conf   (with props)
    asterisk/trunk/tests/callparking_retrieval/configs/ast2/iax.conf   (with props)
    asterisk/trunk/tests/callparking_retrieval/configs/ast3/
    asterisk/trunk/tests/callparking_retrieval/configs/ast3/extensions.conf   (with props)
    asterisk/trunk/tests/callparking_retrieval/configs/ast3/features.conf   (with props)
    asterisk/trunk/tests/callparking_retrieval/configs/ast3/iax.conf   (with props)
    asterisk/trunk/tests/callparking_retrieval/configs/ast3/res_parking.conf   (with props)
Removed:
    asterisk/trunk/tests/callparking_retrieval/userA/
    asterisk/trunk/tests/callparking_retrieval/userB/
    asterisk/trunk/tests/callparking_retrieval/userC/
Modified:
    asterisk/trunk/tests/callparking_retrieval/run-test
    asterisk/trunk/tests/callparking_retrieval/test-config.yaml

Added: asterisk/trunk/tests/callparking_retrieval/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking_retrieval/configs/ast1/extensions.conf?view=auto&rev=4114
==============================================================================
--- asterisk/trunk/tests/callparking_retrieval/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/callparking_retrieval/configs/ast1/extensions.conf Thu Sep  5 11:23:38 2013
@@ -1,0 +1,14 @@
+[general]
+static=yes
+writeprotect=no
+lastaction=""
+
+[parking]
+; User A starts out by calling user B, with inband DTMF activated for transfer
+exten => callb,1,Dial(IAX2/userc/userb at parking)
+exten => callb,n,Hangup
+
+; What channel A will be doing
+exten => wait,1,Answer()
+exten => wait,n,Wait(100)
+

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

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

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

Added: asterisk/trunk/tests/callparking_retrieval/configs/ast1/features.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking_retrieval/configs/ast1/features.conf?view=auto&rev=4114
==============================================================================
--- asterisk/trunk/tests/callparking_retrieval/configs/ast1/features.conf (added)
+++ asterisk/trunk/tests/callparking_retrieval/configs/ast1/features.conf Thu Sep  5 11:23:38 2013
@@ -1,0 +1,3 @@
+[general]
+[featuremap]
+parkcall => 1

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast1/features.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast1/features.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast1/features.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/callparking_retrieval/configs/ast1/iax.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking_retrieval/configs/ast1/iax.conf?view=auto&rev=4114
==============================================================================
--- asterisk/trunk/tests/callparking_retrieval/configs/ast1/iax.conf (added)
+++ asterisk/trunk/tests/callparking_retrieval/configs/ast1/iax.conf Thu Sep  5 11:23:38 2013
@@ -1,0 +1,17 @@
+[general]
+bindport=4571
+bindaddr=127.0.0.1
+transfer=no
+disallow=all
+allow=ulaw
+jitterbuffer=no
+forcejitterbuffer=no
+
+[userc]
+type=friend
+username=usera
+host=127.0.0.1
+port=4573
+context=parking
+transfer=no
+

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast1/iax.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast1/iax.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast1/iax.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/callparking_retrieval/configs/ast1/res_parking.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking_retrieval/configs/ast1/res_parking.conf?view=auto&rev=4114
==============================================================================
--- asterisk/trunk/tests/callparking_retrieval/configs/ast1/res_parking.conf (added)
+++ asterisk/trunk/tests/callparking_retrieval/configs/ast1/res_parking.conf Thu Sep  5 11:23:38 2013
@@ -1,0 +1,4 @@
+[default]
+parkpos => 701-720
+parkedcalltransfers = caller
+parkedcallreparking = caller

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast1/res_parking.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast1/res_parking.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast1/res_parking.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/callparking_retrieval/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking_retrieval/configs/ast2/extensions.conf?view=auto&rev=4114
==============================================================================
--- asterisk/trunk/tests/callparking_retrieval/configs/ast2/extensions.conf (added)
+++ asterisk/trunk/tests/callparking_retrieval/configs/ast2/extensions.conf Thu Sep  5 11:23:38 2013
@@ -1,0 +1,15 @@
+[parking]
+
+; When user A calls user B, user B will attempt to callpark user A.
+exten => userb,1,Answer
+exten => userb,n,Playback(tt-weasels)
+exten => userb,n,SendDTMF(#)
+exten => userb,n,SendDTMF(700)
+exten => userb,n,Playback(tt-weasels)
+exten => userb,n,Hangup
+
+; After retrieving the parked call, try parking it again
+exten => parka,1,Goto(userb,1)
+
+exten => hangup,1,Hangup
+

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/callparking_retrieval/configs/ast2/iax.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking_retrieval/configs/ast2/iax.conf?view=auto&rev=4114
==============================================================================
--- asterisk/trunk/tests/callparking_retrieval/configs/ast2/iax.conf (added)
+++ asterisk/trunk/tests/callparking_retrieval/configs/ast2/iax.conf Thu Sep  5 11:23:38 2013
@@ -1,0 +1,17 @@
+[general]
+bindport=4572
+bindaddr=127.0.0.1
+transfer=no
+disallow=all
+allow=ulaw
+jitterbuffer=no
+forcejitterbuffer=no
+
+[userc]
+type=friend
+username=userb
+host=127.0.0.1
+port=4573
+context=parking
+transfer=no
+

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast2/iax.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast2/iax.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast2/iax.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/callparking_retrieval/configs/ast3/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking_retrieval/configs/ast3/extensions.conf?view=auto&rev=4114
==============================================================================
--- asterisk/trunk/tests/callparking_retrieval/configs/ast3/extensions.conf (added)
+++ asterisk/trunk/tests/callparking_retrieval/configs/ast3/extensions.conf Thu Sep  5 11:23:38 2013
@@ -1,0 +1,15 @@
+[general]
+static=yes
+writeprotect=no
+lastaction=""
+
+[parking]
+include => parkedcalls
+
+; User A starts out by calling user B, with inband DTMF activated for transfer
+exten => userb,1,Dial(IAX2/userb/userb at parking,,t)
+exten => userb,n,Hangup
+
+exten => 701,1,Answer
+exten => 701,n,Goto(parkedcalls,701,1)
+

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast3/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast3/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast3/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/callparking_retrieval/configs/ast3/features.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking_retrieval/configs/ast3/features.conf?view=auto&rev=4114
==============================================================================
--- asterisk/trunk/tests/callparking_retrieval/configs/ast3/features.conf (added)
+++ asterisk/trunk/tests/callparking_retrieval/configs/ast3/features.conf Thu Sep  5 11:23:38 2013
@@ -1,0 +1,14 @@
+[general]
+parkext => 700
+parkpos => 701-720
+context => parkedcalls
+
+parkedcalltransfers = caller   ; Enables or disables DTMF based transfers when picking up a parked call.
+                                ; one of: callee, caller, both, no (default is no)
+parkedcallreparking = caller   ; Enables or disables DTMF based parking when picking up a parked call.
+                                ; one of: callee, caller, both, no (default is no)
+
+[featuremap]
+
+[applicationmap]
+

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast3/features.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast3/features.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast3/features.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/callparking_retrieval/configs/ast3/iax.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking_retrieval/configs/ast3/iax.conf?view=auto&rev=4114
==============================================================================
--- asterisk/trunk/tests/callparking_retrieval/configs/ast3/iax.conf (added)
+++ asterisk/trunk/tests/callparking_retrieval/configs/ast3/iax.conf Thu Sep  5 11:23:38 2013
@@ -1,0 +1,25 @@
+[general]
+bindport=4573
+bindaddr=127.0.0.1
+transfer=no
+disallow=all
+allow=ulaw
+jitterbuffer=no
+forcejitterbuffer=no
+
+[usera]
+type=friend
+username=userc
+host=127.0.0.1
+port=4571
+context=parking
+transfer=no
+
+[userb]
+type=friend
+username=userc
+host=127.0.0.1
+port=4572
+context=parking
+transfer=no
+

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast3/iax.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast3/iax.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast3/iax.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/callparking_retrieval/configs/ast3/res_parking.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking_retrieval/configs/ast3/res_parking.conf?view=auto&rev=4114
==============================================================================
--- asterisk/trunk/tests/callparking_retrieval/configs/ast3/res_parking.conf (added)
+++ asterisk/trunk/tests/callparking_retrieval/configs/ast3/res_parking.conf Thu Sep  5 11:23:38 2013
@@ -1,0 +1,6 @@
+[default]
+parkedcallreparking = caller
+parkedcalltransfers = caller
+parkpos => 701-720
+parkext => 700
+context => parkedcalls

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast3/res_parking.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast3/res_parking.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/callparking_retrieval/configs/ast3/res_parking.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/trunk/tests/callparking_retrieval/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking_retrieval/run-test?view=diff&rev=4114&r1=4113&r2=4114
==============================================================================
--- asterisk/trunk/tests/callparking_retrieval/run-test (original)
+++ asterisk/trunk/tests/callparking_retrieval/run-test Thu Sep  5 11:23:38 2013
@@ -1,42 +1,138 @@
-#!/usr/bin/env bash
+#!/usr/bin/env python
+'''
+Copyright (C) 2013, Digium, Inc.
+Jonathan Rose <jrose at digium.com>
 
-. lib/sh/library.sh
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
 
-#debug=1
+import sys
+import logging
+from twisted.internet import reactor
 
-echo " >>> Starting callparking_retrieval test"
+sys.path.append("lib/python")
+from asterisk.TestCase import TestCase
+from asterisk.version import AsteriskVersion
 
-initialize userA userB userC
+LOGGER = logging.getLogger(__name__)
 
-echo " >>> User A is calling user B, who will park the call."
-$ASTERISK -C $userA_tmpdir/asterisk.conf -rx "$ORIGINATE Local/wait at parking extension callb at parking" &
-sleep 2
 
-# Verify that the call is up
-verify_call userA 3
+class ParkRetrieveTest(TestCase):
+    """This test checks event flow for a call being parked, then retrieved,
+    then finally parked once again without a hangup in between."""
+    def __init__(self):
+        """Prepare the test object"""
+        TestCase.__init__(self)
 
-sleep 5
+        self.mode_12 = False
 
-# Verify that the call is up on our bridge server
-verify_call userC 1
+        if AsteriskVersion() >= AsteriskVersion('12'):
+            self.mode_12 = True
 
-echo " >>> User B is retrieving user A from parking, then will attempt to repark it."
-$ASTERISK -C $userB_tmpdir/asterisk.conf -rx "$ORIGINATE IAX2/userc/701 at parking extension parka at parking" &
-sleep 2
+        self.channel_parked = None
+        self.times_parked = 0
+        self.times_unparked = 0
+        self.connections_established = 0
 
-# Verify that the call is up
-verify_call userC 2
+        # Create three Asterisk instances ...
+        self.create_asterisk(count=3)
 
-# Have to wait for the announcement to complete
-sleep 5
+    def validate_event_counts(self):
+        """Verify that the number of events received was the expected number"""
+        if self.times_parked != 2:
+            return False
+        if self.times_unparked != 1:
+            return False
+        return True
 
-verify_call userC 1
+    def check_parkedcall(self, ami, event):
+        """Check the values of a ParkedCall event against expectations"""
+        self.times_parked += 1
+        if self.mode_12:
+            parkee = event.get('parkeechannel')
+        else:
+            parkee = event.get('channel')
+        LOGGER.info("Parkee: %s" % parkee)
 
-echo " *** Success!"
+        if not "IAX2/usera-" in parkee:
+            LOGGER.error("Parkee doesn't match expected user IAX2/usera-*, "
+                         "got %s instead. Test failed." % parkee)
+            self.set_passed(False)
+            self.stop_reactor()
 
-$ASTERISK -C $userB_tmpdir/asterisk.conf -rx "$ORIGINATE IAX2/userc/701 at parking extension hangup at parking" &
+        if self.times_parked == 1:
+            LOGGER.info("Originating B to retrieve A and then repark A")
 
-cleanup
+            self.ami[1].originate(
+                channel="IAX2/userc/701 at parking",
+                exten="parka",
+                context="parking",
+                priority=1
+            ).addErrback(self.handleOriginateFailure)
 
-exit 0
+        if self.times_parked == 2:
+            if not self.validate_event_counts:
+                LOGGER.error("Received second parking event, but the event "
+                             "counts don't match expectations. Test Failed.")
+                self.set_passed(False)
+                self.stop_reactor()
+                return
 
+            LOGGER.info("All events matched expectations. Test Passed.")
+            self.set_passed(True)
+            self.stop_reactor()
+
+    def check_unparkedcall(self, ami, event):
+        """Check the values of an UnParkedCall event against expectations"""
+        self.times_unparked += 1
+        if self.mode_12:
+            retriever = event.get('retrieverchannel')
+        else:
+            retriever = event.get('from')
+
+        LOGGER.info("Retriever: %s" % retriever)
+
+        #verify the retriever is user b with regular expressions
+        if not "IAX2/userb-" in retriever:
+            LOGGER.error("Retriever doesn't match expected user IAX2/userb-*, "
+                         "got %s instead. Test failed." % retriever)
+            self.set_passed(False)
+            self.stop_reactor()
+
+    def run(self):
+        """Run the test and create AMI for each instance of Asterisk"""
+        TestCase.run(self)
+        self.create_ami_factory(3)
+
+    def ami_connect(self, ami):
+        """Respond to a new AMI connection. Register events and start calls."""
+        self.connections_established += 1
+
+        if self.connections_established != 3:
+            return
+
+        self.ami[2].registerEvent("ParkedCall", self.check_parkedcall)
+        self.ami[2].registerEvent("UnParkedCall", self.check_unparkedcall)
+
+        LOGGER.info("Originating call from A to B")
+        self.ami[0].originate(
+            channel="Local/wait at parking",
+            exten="callb",
+            context="parking",
+            priority=1
+        ).addErrback(self.handleOriginateFailure)
+
+
+def main():
+    """Entry function"""
+    # Run ParkRetrieve Test
+    test = ParkRetrieveTest()
+    reactor.run()
+    if test.passed:
+        LOGGER.info("Test Passed")
+        return 0
+    return 1
+
+if __name__ == "__main__":
+    sys.exit(main() or 0)

Modified: asterisk/trunk/tests/callparking_retrieval/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking_retrieval/test-config.yaml?view=diff&rev=4114&r1=4113&r2=4114
==============================================================================
--- asterisk/trunk/tests/callparking_retrieval/test-config.yaml (original)
+++ asterisk/trunk/tests/callparking_retrieval/test-config.yaml Thu Sep  5 11:23:38 2013
@@ -1,5 +1,4 @@
 testinfo:
-    skip: 'Skip while failures are debugged'
     summary:     'Test Call Parking'
     description: |
         'This test verifies that retrieving a parked call does not hamper the ability to park it once again.'




More information about the asterisk-commits mailing list