[asterisk-commits] mnick: testsuite/asterisk/trunk r761 - in /asterisk/trunk/tests: ./ callparki...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Aug 18 11:25:14 CDT 2010


Author: mnick
Date: Wed Aug 18 11:25:11 2010
New Revision: 761

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=761
Log:
added test "callparking"

Added:
    asterisk/trunk/tests/callparking/
    asterisk/trunk/tests/callparking/configs/
    asterisk/trunk/tests/callparking/configs/extensions.conf   (with props)
    asterisk/trunk/tests/callparking/configs/iax.conf   (with props)
    asterisk/trunk/tests/callparking/configs2/
    asterisk/trunk/tests/callparking/configs2/extensions.conf   (with props)
    asterisk/trunk/tests/callparking/configs2/iax.conf   (with props)
    asterisk/trunk/tests/callparking/configs3/
    asterisk/trunk/tests/callparking/configs3/extensions.conf   (with props)
    asterisk/trunk/tests/callparking/configs3/iax.conf   (with props)
    asterisk/trunk/tests/callparking/run-test   (with props)
    asterisk/trunk/tests/callparking/test-config.yaml   (with props)
Modified:
    asterisk/trunk/tests/tests.yaml

Added: asterisk/trunk/tests/callparking/configs/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking/configs/extensions.conf?view=auto&rev=761
==============================================================================
--- asterisk/trunk/tests/callparking/configs/extensions.conf (added)
+++ asterisk/trunk/tests/callparking/configs/extensions.conf Wed Aug 18 11:25:11 2010
@@ -1,0 +1,37 @@
+[general]
+static=yes
+writeprotect=no
+lastaction=""
+
+[parking]
+exten => bridge_to_A,1,Answer()
+exten => bridge_to_A,n,NOOP(Bridge call to userA)
+exten => bridge_to_A,n,Dial(IAX2/userA at 127.0.0.1:4570/a_exten,120,rtT)
+exten => bridge_to_A,n,NOOP(END - Bridge call to userA)
+exten => bridge_to_A,n,Hangup()
+
+exten => bridge_to_B,1,Answer()
+exten => bridge_to_B,n,NOOP(Bridge call to userB)
+exten => bridge_to_B,n,Dial(IAX2/userB at 127.0.0.1:4571/b_exten,120,rtT)
+exten => bridge_to_B,n,NOOP(END - Bridge call to userB)
+exten => bridge_to_B,n,Hangup()
+
+exten => a_exten,1,Answer()
+exten => a_exten,n,NOOP(userA answerd the call!)
+exten => a_exten,n,Wait(1)
+exten => a_exten,n,NOOP(waiting for DTMF '110' from userB)
+exten => a_exten,n,Read(sync,,3,,,10) ;read 3 digits
+exten => a_exten,n,GotoIF($["${sync}"="110"]?DTMFpass:DTMFfail)
+exten => a_exten,n(DTMFpass),NOOP(read '${sync}' and expected '110' --> OK)
+exten => a_exten,n,NOOP(somewhere in the future I get parked!)
+exten => a_exten,n,NOOP(I will send DTMF '999' every 5 seconds in order to sync when I get reconnected)
+exten => a_exten,n,Set(count=1)
+exten => a_exten,n(sync),Wait(5)
+exten => a_exten,n,NOOP(Attempt ${count} to sync)
+exten => a_exten,n,Set(count=$[${count}+1])
+exten => a_exten,n,SendDTMF(999)
+exten => a_exten,n,Goto(sync)
+exten => a_exten,n(DTMFfail),NOOP(read '${sync}' and expected '110' --> FAILURE)
+exten => a_exten,n,Hangup()
+
+include => parkedcalls

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

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

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

Added: asterisk/trunk/tests/callparking/configs/iax.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking/configs/iax.conf?view=auto&rev=761
==============================================================================
--- asterisk/trunk/tests/callparking/configs/iax.conf (added)
+++ asterisk/trunk/tests/callparking/configs/iax.conf Wed Aug 18 11:25:11 2010
@@ -1,0 +1,14 @@
+[general]
+bindport=4570
+bindaddr=127.0.0.1
+transfer=yes
+disallow=all
+allow=ulaw
+jitterbuffer=no
+forcejitterbuffer=no
+
+[userA]
+type=friend
+host=127.0.0.1
+port=4570
+context=parking

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

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

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

Added: asterisk/trunk/tests/callparking/configs2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking/configs2/extensions.conf?view=auto&rev=761
==============================================================================
--- asterisk/trunk/tests/callparking/configs2/extensions.conf (added)
+++ asterisk/trunk/tests/callparking/configs2/extensions.conf Wed Aug 18 11:25:11 2010
@@ -1,0 +1,40 @@
+[general]
+static=yes
+writeprotect=no
+
+[parkingAB]
+exten => b_exten,1,Answer()
+exten => b_exten,n,NOOP(userB answered the call)
+exten => b_exten,n,Wait(1)
+exten => b_exten,n,NOOP(sync to userA -> send  DTMF '110')
+exten => b_exten,n,SendDTMF(1w1w0)
+exten => b_exten,n,Wait(1)
+exten => b_exten,n,NOOP(trying to Park userA)
+exten => b_exten,n,Set(GLOBAL(lastaction)=parkedA)
+exten => b_exten,n,SendDTMF(#)
+exten => b_exten,n,Wait(1)
+exten => b_exten,n,SendDTMF(7w0w0)
+exten => b_exten,n,Hangup()
+
+exten => h,1,NOOP(got hangup due to successful parking of userA)
+exten => h,n,AGI(agi://127.0.0.1:4574)
+exten => h,n,Hangup()
+
+[parkingBC]
+exten => b_exten,1,Answer()
+exten => b_exten,n,NOOP(userB answered the call)
+exten => b_exten,n,Wait(1)
+exten => b_exten,n,NOOP(waiting for DTMF '110' from userB)
+exten => b_exten,n,Read(sync,,3,,,10) ;read 3 digits, 5sek timeout
+exten => b_exten,n,GotoIF($["${sync}"="110"]?DTMFpass:DTMFfail)
+exten => b_exten,n(DTMFpass),NOOP(read '${sync}' and expected '110' --> OK)
+exten => b_exten,n,NOOP(somewhere in the future I get parked!)
+exten => b_exten,n,NOOP(I will send DTMF '888' every 5 seconds in order to sync when I get reconnected)
+exten => b_exten,n,Set(count=1)
+exten => b_exten,n(sync),Wait(5)
+exten => b_exten,n,NOOP(Attempt ${count} to sync)
+exten => b_exten,n,Set(count=$[${count}+1])
+exten => b_exten,n,SendDTMF(888)
+exten => b_exten,n,Goto(sync)
+exten => b_exten,n(DTMFfail),NOOP(read '${sync}' and expected '110' --> FAILURE)
+exten => b_exten,n,Hangup()

Propchange: asterisk/trunk/tests/callparking/configs2/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/callparking/configs2/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/callparking/configs2/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/callparking/configs2/iax.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking/configs2/iax.conf?view=auto&rev=761
==============================================================================
--- asterisk/trunk/tests/callparking/configs2/iax.conf (added)
+++ asterisk/trunk/tests/callparking/configs2/iax.conf Wed Aug 18 11:25:11 2010
@@ -1,0 +1,20 @@
+[general]
+bindport=4571
+bindaddr=127.0.0.1
+transfer=yes
+disallow=all
+allow=ulaw
+jitterbuffer=no
+forcejitterbuffer=no
+
+[userA]
+type=friend
+host=127.0.0.1
+port=4570
+context=parkingAB
+
+[userB]
+type=friend
+host=127.0.0.1
+port=4571
+context=parkingBC

Propchange: asterisk/trunk/tests/callparking/configs2/iax.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/callparking/configs2/iax.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/callparking/configs2/iax.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/callparking/configs3/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking/configs3/extensions.conf?view=auto&rev=761
==============================================================================
--- asterisk/trunk/tests/callparking/configs3/extensions.conf (added)
+++ asterisk/trunk/tests/callparking/configs3/extensions.conf Wed Aug 18 11:25:11 2010
@@ -1,0 +1,49 @@
+[general]
+static=yes
+writeprotect=no
+lastaction=""
+
+[parking]
+exten => c_exten,1,Answer()
+exten => c_exten,n,NOOP(userC answered the call)
+exten => c_exten,n,Wait(1)
+exten => c_exten,n,SendDTMF(1w1w0)
+exten => c_exten,n,Wait(1)
+exten => c_exten,n,NOOP(trying to park the call)
+exten => c_exten,n,SET(GLOBAL(lastaction)=parkedB)
+exten => c_exten,n,SendDTMF(#)
+exten => c_exten,n,Wait(1)
+exten => c_exten,n,SendDTMF(700)
+exten => c_exten,n,Hangup()
+
+exten => h,1,GotoIF($["${GLOBAL(lastaction)}"="parkedB"]?retrieveA)
+exten => h,n,Hangup()
+exten => h,n(retrieveA),NOOP(Got Hangup due to successfull parking of userB -> call 701 in order to retrieve userA)
+exten => h,n,AGI(agi://127.0.0.1:4575)
+exten => h,n,Hangup()
+
+exten => retrieve_A,1,NOOP(okay, I should now be connected to userA -> trying to sync)
+exten => retrieve_A,n(sync),Wait(1)
+exten => retrieve_A,n,Read(sync,,3,,,8) ;wait more than 5 but less than 10 seconds
+exten => retrieve_A,n,GotoIf($["${sync}"="999"]?DTMFpass:DTMFfail)
+exten => retrieve_A,n(DTMFpass),NOOP(read '${sync}' and expected '999' - OK)
+exten => retrieve_A,n,NOOP(synchronized to userA successfully - now retrieve userB!)
+exten => retrieve_A,n,Set(GLOBAL(lastaction)=successA)
+exten => retrieve_A,n,AGI(agi://127.0.0.1:4576)
+exten => retrieve_A,n,Hangup()
+exten => retrieve_A,n(DTMFfail),NOOP(read '${sync}' and exptected '999' - FAILURE)
+exten => retrieve_A,n,NOOP(trying to sync again!)
+exten => retrieve_A,n,Goto(sync)
+
+exten => retrieve_B,1,NOOP(okay, I should now be connected to userB -> trying to sync)
+exten => retrieve_B,n(sync),Wait(1)
+exten => retrieve_B,n,Read(sync,,3,,,8) ;wait more than 5 but less than 10 seconds
+exten => retrieve_B,n,GotoIf($["${sync}"="888"]?DTMFpass:DTMFfail)
+exten => retrieve_B,n(DTMFpass),NOOP(read '${sync}' and expected '888' - OK)
+exten => retrieve_B,n,NOOP(TEST PASSED!)
+exten => retrieve_B,n,Set(GLOBAL(lastaction)=success)
+exten => retrieve_B,n,AGI(agi://127.0.0.1:4577)
+exten => retrieve_B,n,Hangup()
+exten => retrieve_B,n(DTMFfail),NOOP(read '${sync}' and exptected '888' - FAILURE)
+exten => retrieve_B,n,NOOP(trying to sync again!)
+exten => retrieve_B,n,Goto(sync)

Propchange: asterisk/trunk/tests/callparking/configs3/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/callparking/configs3/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/callparking/configs3/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/callparking/configs3/iax.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking/configs3/iax.conf?view=auto&rev=761
==============================================================================
--- asterisk/trunk/tests/callparking/configs3/iax.conf (added)
+++ asterisk/trunk/tests/callparking/configs3/iax.conf Wed Aug 18 11:25:11 2010
@@ -1,0 +1,14 @@
+[general]
+bindport=4572
+bindaddr=127.0.0.1
+transfer=yes
+disallow=all
+allow=ulaw
+jitterbuffer=no
+forcejitterbuffer=no
+
+[userB]
+type=friend
+host=127.0.0.1
+port=4571
+context=parking

Propchange: asterisk/trunk/tests/callparking/configs3/iax.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/callparking/configs3/iax.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/callparking/configs3/iax.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/callparking/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking/run-test?view=auto&rev=761
==============================================================================
--- asterisk/trunk/tests/callparking/run-test (added)
+++ asterisk/trunk/tests/callparking/run-test Wed Aug 18 11:25:11 2010
@@ -1,0 +1,189 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2010, Digium, Inc.
+Matthias Nick <mnick86 at gmail.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import os
+import math
+from optparse import OptionParser
+from twisted.application import service, internet
+from twisted.internet import reactor
+from starpy import fastagi
+
+sys.path.append("lib/python")
+from asterisk.asterisk import Asterisk
+from asterisk.version import AsteriskVersion
+
+
+class CallParkingTest:
+    def __init__(self, argv):
+        self.passed = False
+        self.done = False
+
+        # Test timeout in seconds
+        self.timeout = 60
+        self.last_step = ""
+
+        # get version info
+        parser = OptionParser()
+        parser.add_option("-v", "--version", dest="ast_version",
+         help="Asterisk version string")
+        (options, args) = parser.parse_args(argv)
+        self.ast_version = AsteriskVersion(options.ast_version)
+        print self.ast_version
+
+        # FastAGI, listen for results from dialplan
+        self.agi_b = fastagi.FastAGIFactory(self.get_result_b)
+        reactor.listenTCP(4574, self.agi_b, self.timeout, '127.0.0.1')
+
+        self.agi_c = fastagi.FastAGIFactory(self.get_result_c)
+        reactor.listenTCP(4575, self.agi_c, self.timeout, '127.0.0.1')
+
+        self.agi_retrieve_A = fastagi.FastAGIFactory(
+          self.get_result_retrieve_A)
+        reactor.listenTCP(4576, self.agi_retrieve_A, self.timeout, '127.0.0.1')
+
+        self.agi_retrieve_B = fastagi.FastAGIFactory(
+         self.get_result_retrieve_B)
+        reactor.listenTCP(4577, self.agi_retrieve_B, self.timeout, '127.0.0.1')
+
+        reactor.callWhenRunning(self.run)
+
+        self.asterisk1 = Asterisk(
+         base="/tmp/asterisk-testsuite/callparking/asterisk1")
+        self.asterisk1.install_configs("tests/callparking/configs")
+
+        self.asterisk2 = Asterisk(
+         base="/tmp/asterisk-testsuite/callparking/asterisk2")
+        self.asterisk2.install_configs("tests/callparking/configs2")
+
+        self.asterisk3 = Asterisk(
+         base="/tmp/asterisk-testsuite/callparking/asterisk3")
+        self.asterisk3.install_configs("tests/callparking/configs3")
+
+    # This gets invoked by the dialplan when userB has parked userA to 701.
+    # Initiate new call userB <--> userC now.
+    def get_result_b(self, agi):
+        self.log_last_step("got AGI connection from userB. "
+         "Initiate new call between userB and userC now")
+        self.asterisk1.cli_originate(
+         "IAX2/userB at 127.0.0.1:4572/c_exten extension bridge_to_B at parking")
+        return agi.finish()
+
+    # This gets invoked by the dialplan when userC has parked userB to 702.
+    # Initiate new call between userC and parked userA (@701) now.
+    def get_result_c(self, agi):
+        self.log_last_step("got AGI connection from userC. "
+         "Now retrieve userA -> call 701")
+        self.asterisk3.cli_originate(
+         "IAX2/userA at 127.0.0.1:4570/701 extension retrieve_A at parking")
+        return agi.finish()
+
+    # This gets invoked by the dialplan when userC has retrieved userA.
+    # Initiate new call between userC and parked userB (@702) now.
+    def get_result_retrieve_A(self, agi):
+        self.log_last_step("got AGI connection from userC. "
+         "userA retrieved successfully, now retrieve userB")
+        self.asterisk3.cli_originate(
+         "IAX2/userA at 127.0.0.1:4570/702 extension retrieve_B at parking")
+        return agi.finish()
+
+    # This gets invoked by the dialplan when userC has retrieved userB.
+    # Test successful!
+    def get_result_retrieve_B(self, agi):
+        self.log_last_step("got AGI connection from userC. "
+         "userB retrieved successfully -> Test successful")
+        self.passed = True
+        reactor.callLater(2, self.read_result)
+        return agi.finish()
+
+    def read_result(self):
+        if self.done:
+            return
+        self.done = True
+
+        self.log_last_step("Reading results")
+
+        # get lock output in case of deadlock before tearing down.
+        self.asterisk1.cli_exec("core show locks")
+        self.asterisk2.cli_exec("core show locks")
+        self.asterisk3.cli_exec("core show locks")
+
+        # if channels are still up for some reason, we want to know that
+        self.asterisk1.cli_exec("core show channels")
+        self.asterisk2.cli_exec("core show channels")
+        self.asterisk3.cli_exec("core show channels")
+
+        if (self.passed):
+            self.log_last_step("Test Passed...")
+        else:
+            self.log_last_step("Test Failed... view result of "
+             "'core show globals' in log for more detailed failure results.")
+
+        if reactor.running:
+            print "Stopping Reactor ..."
+            reactor.stop()
+
+    # This is a callparking test.
+    # 1.  userA calls userB
+    # 2.  userB dials # -> 700, to park userA (701).
+    # 3.  userB calls userC
+    # 4.  userC dials # -> 700, to park userB (702).
+    # 5.  userC dials 701 and retrieves userA
+    # 6.  userC dials 702 and retrieves userB
+
+    def launch_test(self):
+        self.asterisk1.cli_exec("core set verbose 10")
+        self.asterisk2.cli_exec("core set verbose 10")
+        self.asterisk3.cli_exec("core set verbose 10")
+
+        self.log_last_step("Originating call to begin test")
+        self.asterisk1.cli_originate(
+         "IAX2/userA at 127.0.0.1:4571/b_exten extension bridge_to_A at parking")
+
+    def start_asterisk(self):
+        self.log_last_step("Starting Asterisk")
+        self.asterisk1.start()
+        self.asterisk2.start()
+        self.asterisk3.start()
+
+    def stop_asterisk(self):
+        self.asterisk1.stop()
+        self.asterisk2.stop()
+        self.asterisk3.stop()
+
+    def log_last_step(self, step):
+        print step
+        self.last_step = step
+
+    def run(self):
+        self.start_asterisk()
+
+        # start test in 5 seconds
+        reactor.callLater(5, self.launch_test)
+
+        # stop and read results after timeout
+        reactor.callLater(self.timeout, self.read_result)
+
+
+def main(argv=None):
+    if argv is None:
+        argv = sys.argv
+
+    # Run CallParking Test
+    call_parking_test = CallParkingTest(argv)
+    reactor.run()
+    call_parking_test.stop_asterisk()
+    if call_parking_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/callparking/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/callparking/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/callparking/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/callparking/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/callparking/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/callparking/test-config.yaml?view=auto&rev=761
==============================================================================
--- asterisk/trunk/tests/callparking/test-config.yaml (added)
+++ asterisk/trunk/tests/callparking/test-config.yaml Wed Aug 18 11:25:11 2010
@@ -1,0 +1,10 @@
+testinfo:
+    summary:     'Test Call Parking'
+    description: |
+        'This test verifies the Call Parking routine used in the feature code.'
+
+properties:
+    minversion: '1.4'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'

Propchange: asterisk/trunk/tests/callparking/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: asterisk/trunk/tests/callparking/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=761&r1=760&r2=761
==============================================================================
--- asterisk/trunk/tests/tests.yaml (original)
+++ asterisk/trunk/tests/tests.yaml Wed Aug 18 11:25:11 2010
@@ -34,7 +34,7 @@
     - test: 'feature_attended_transfer'
     - test: 'blind-transfer-parkingtimeout'
     - test: 'one-step-parking'
-    #- test: 'callparking'
+    - test: 'callparking'
     - test: 'mixmonitor'
     - test: 'chanspy/chanspy_w_mixmonitor'
     - test: 'chanspy/chanspy_barge'




More information about the asterisk-commits mailing list