[asterisk-commits] pabelanger: branch pabelanger/SWP-2716 r1245 - in /asterisk/team/pabelanger/S...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Dec 17 19:37:43 UTC 2010


Author: pabelanger
Date: Fri Dec 17 13:37:39 2010
New Revision: 1245

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1245
Log:
Rewrite callparking test

Added:
    asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/features.conf   (with props)
    asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/manager.conf
      - copied unchanged from r1236, asterisk/team/pabelanger/SWP-2716/tests/udptl/configs/ast1/manager.conf
    asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast2/manager.conf
      - copied, changed from r1236, asterisk/team/pabelanger/SWP-2716/tests/udptl/configs/ast1/manager.conf
Removed:
    asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast3/
Modified:
    asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/extensions.conf
    asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/iax.conf
    asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast2/extensions.conf
    asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast2/iax.conf
    asterisk/team/pabelanger/SWP-2716/tests/callparking/run-test
    asterisk/team/pabelanger/SWP-2716/tests/callparking/test-config.yaml

Modified: asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/extensions.conf?view=diff&rev=1245&r1=1244&r2=1245
==============================================================================
--- asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/extensions.conf (original)
+++ asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/extensions.conf Fri Dec 17 13:37:39 2010
@@ -3,35 +3,19 @@
 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()
+[ast2]
+exten => 9876,1,Dial(IAX2/ast2/${EXTEN},120,rtT)
+exten => 9876,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 => 101,1,Answer()
+exten => 101,n,SendDTMF(1w2w3w4w)
+exten => 101,n(restart),Background(demo-congrats)
+exten => 101,n,Goto(restart)
 
-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()
+exten => 5432,1,Verbose(Yay!)
+exten => 5432,n,SendDTMF(3w4w5w6w)
+exten => 5432,n,UserEvent(ast1, status: SUCCESS)
+exten => 5432,n,Playback(demo-congrats)
+exten => 5432,n,Hangup()
 
 include => parkedcalls

Added: asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/features.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/features.conf?view=auto&rev=1245
==============================================================================
--- asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/features.conf (added)
+++ asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/features.conf Fri Dec 17 13:37:39 2010
@@ -1,0 +1,5 @@
+[general]
+parkext => 700
+parkpos => 701-720
+context => parkedcalls
+parkingtime => 60

Propchange: asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/features.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/features.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/features.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/iax.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/iax.conf?view=diff&rev=1245&r1=1244&r2=1245
==============================================================================
--- asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/iax.conf (original)
+++ asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast1/iax.conf Fri Dec 17 13:37:39 2010
@@ -1,14 +1,25 @@
 [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
+[ast1]
+type=user
+host=127.0.0.2
+secret=p at ssw0rd
+context=parkedcalls
+deny=0.0.0.0/0.0.0.0
+permit=127.0.0.2/255.255.255.255
+disallow=all
+allow=gsm
+transfer=yes
+
+[ast2]
+type=peer
+host=127.0.0.2
+context=ast2
+username=ast2
+secret=pa$$word
+disallow=all
+allow=gsm
+transfers=yes

Modified: asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast2/extensions.conf?view=diff&rev=1245&r1=1244&r2=1245
==============================================================================
--- asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast2/extensions.conf (original)
+++ asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast2/extensions.conf Fri Dec 17 13:37:39 2010
@@ -3,38 +3,22 @@
 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 => 9876,1,Answer()
+exten => 9876,n,Background(demo-congrats)
+exten => 9876,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()
+exten => 1234,1,Verbose(Yay)
+exten => 1234,n,SendDTMF(#)
+exten => 1234,n,SendDTMF(7w0w0)
+exten => 1234,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()
+[ast1]
+exten => s,1,Answer()
+exten => s,n,SendDTMF(5w4w3w2)
+exten => s,n,Background(demo-congrats)
+exten => s,n,UserEvent(ast2, status: FAILURE)
+exten => s,n,Hangup()
+
+exten => 3456,1,UserEvent(ast2, status: SUCCESS)
+exten => 3456,n,Playback(demo-congrats)
+exten => 3456,n,Hangup()

Modified: asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast2/iax.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast2/iax.conf?view=diff&rev=1245&r1=1244&r2=1245
==============================================================================
--- asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast2/iax.conf (original)
+++ asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast2/iax.conf Fri Dec 17 13:37:39 2010
@@ -1,20 +1,25 @@
 [general]
-bindport=4571
-bindaddr=127.0.0.1
-transfer=yes
-disallow=all
-allow=ulaw
+bindaddr=127.0.0.2
 jitterbuffer=no
 forcejitterbuffer=no
 
-[userA]
-type=friend
+[ast1]
+type=peer
 host=127.0.0.1
-port=4570
+context=ast1
+username=ast1
+secret=p at ssw0rd
+disallow=all
+allow=gsm
+transfers=yes
+
+[ast2]
+type=user
+host=127.0.0.1
+secret=pa$$word
 context=parkingAB
-
-[userB]
-type=friend
-host=127.0.0.1
-port=4571
-context=parkingBC
+deny=0.0.0.0/0.0.0.0
+permit=127.0.0.1/255.255.255.255
+disallow=all
+allow=gsm
+transfer=yes

Copied: asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast2/manager.conf (from r1236, asterisk/team/pabelanger/SWP-2716/tests/udptl/configs/ast1/manager.conf)
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast2/manager.conf?view=diff&rev=1245&p1=asterisk/team/pabelanger/SWP-2716/tests/udptl/configs/ast1/manager.conf&r1=1236&p2=asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast2/manager.conf&r2=1245
==============================================================================
--- asterisk/team/pabelanger/SWP-2716/tests/udptl/configs/ast1/manager.conf (original)
+++ asterisk/team/pabelanger/SWP-2716/tests/callparking/configs/ast2/manager.conf Fri Dec 17 13:37:39 2010
@@ -1,7 +1,7 @@
 [general]
 enabled = yes
 port = 5038
-bindaddr = 127.0.0.1
+bindaddr = 127.0.0.2
 
 [user]
 secret = mysecret

Modified: asterisk/team/pabelanger/SWP-2716/tests/callparking/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2716/tests/callparking/run-test?view=diff&rev=1245&r1=1244&r2=1245
==============================================================================
--- asterisk/team/pabelanger/SWP-2716/tests/callparking/run-test (original)
+++ asterisk/team/pabelanger/SWP-2716/tests/callparking/run-test Fri Dec 17 13:37:39 2010
@@ -13,7 +13,7 @@
 from optparse import OptionParser
 from twisted.application import service, internet
 from twisted.internet import reactor
-from starpy import fastagi
+from starpy import manager
 
 sys.path.append("lib/python")
 from asterisk.asterisk import Asterisk
@@ -26,10 +26,11 @@
 class CallParkingTest:
     def __init__(self, argv):
         self.passed = False
-        self.done = False
+        self.ast1_event = False
+        self.ast2_event = False
 
         # Test timeout in seconds
-        self.timeout = 60
+        self.timeout = 30
         self.last_step = ""
 
         # get version info
@@ -39,21 +40,6 @@
         (options, args) = parser.parse_args(argv)
         self.ast_version = AsteriskVersion(options.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.ast1 = Asterisk(base=workingdir)
@@ -62,108 +48,100 @@
         self.ast2 = Asterisk(base=workingdir)
         self.ast2.install_configs("%s/configs/ast2" % (testdir))
 
-        self.ast3 = Asterisk(base=workingdir)
-        self.ast3.install_configs("%s/configs/ast3" % (testdir))
-
-    # 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.ast1.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.ast3.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.ast3.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.ast1.cli_exec("core show locks")
-        self.ast2.cli_exec("core show locks")
-        self.ast3.cli_exec("core show locks")
-
-        # if channels are still up for some reason, we want to know that
-        self.ast1.cli_exec("core show channels")
-        self.ast2.cli_exec("core show channels")
-        self.ast3.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.")
-
+    def stop_reactor(self):
+        print "Stopping Reactor ..."
         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 check_result(self):
+        self.log_last_step("Checking results...")
+        if self.ast1_event is True and self.ast2_event is True:
+            self.stop_reactor()
+            self.passed = True
+
+    def get_parkedcall(self):
+        self.ast2.cli_originate("IAX2/ast1/701 extension s at ast1")
 
     def launch_test(self):
-        self.log_last_step("Originating call to begin test")
-        self.ast1.cli_originate(
-         "IAX2/userA at 127.0.0.1:4571/b_exten extension bridge_to_A at parking")
+        self.ast1.cli_originate("Local/9876 at ast2 extension 101 at ast2")
+
+    def ast1_unparkedcall(self, ami, event):
+        self.log_last_step("UnParkedCall event on ast1 ...")
+        if event.get("exten").lower() != "701":
+            return
+        self.log_last_step("... Success")
+
+    def ast1_parkedcall(self, ami, event):
+        self.log_last_step("ParkedCall event on ast1 ...")
+        if event.get("exten").lower() != "701":
+            return
+        self.log_last_step("... Success")
+        self.get_parkedcall()
+
+    def ast2_userevent(self, ami, event):
+        self.log_last_step("UserEvent on ast2 ... ")
+        status = event.get("status")
+        print ("... %s" % (status))
+        if status != "SUCCESS":
+            self.stop_reactor()
+            return
+
+        self.ast2_event = True
+        self.check_result()
+
+    def ast1_userevent(self, ami, event):
+        self.log_last_step("UserEvent on ast1 ... ")
+        status = event.get("status")
+        print ("... %s" % (status))
+        if status != "SUCCESS":
+            self.stop_reactor()
+            return
+
+        self.ast1_event = True
+        self.check_result()
+
+    def ami_on_connect2(self, ami):
+        self.log_last_step("Connected to AMI 2")
+        self.ami2 = ami
+        self.ami2.registerEvent("UserEvent", self.ast2_userevent)
+
+    def ami_on_connect1(self, ami):
+        self.log_last_step("Connected to AMI 1")
+        self.ami1 = ami
+        self.ami1.registerEvent("ParkedCall", self.ast1_parkedcall)
+        self.ami1.registerEvent("UnParkedCall", self.ast1_unparkedcall)
+        self.ami1.registerEvent("UserEvent", self.ast1_userevent)
+
+    def ami_login_error(self, ami):
+        self.log_last_step("AMI login failed")
+        self.stop_reactor()
+
+    def ami_login(self):
+        self.log_last_step("Logging in to the AMI")
+        self.ami_factory1 = manager.AMIFactory("user", "mysecret")
+        self.ami_factory2 = manager.AMIFactory("user", "mysecret")
+        self.ami_factory1.login('127.0.0.1', 5038).addCallbacks(self.ami_on_connect1, self.ami_login_error)
+        self.ami_factory2.login('127.0.0.2', 5038).addCallbacks(self.ami_on_connect2, self.ami_login_error)
 
     def start_asterisk(self):
         self.log_last_step("Starting Asterisk")
         self.ast1.start()
         self.ast2.start()
-        self.ast3.start()
 
     def stop_asterisk(self):
         self.ast1.stop()
         self.ast2.stop()
-        self.ast3.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)
+        self.ami_login()
+        self.launch_test()
 
         # stop and read results after timeout
-        reactor.callLater(self.timeout, self.read_result)
+        reactor.callLater(self.timeout, self.stop_reactor)
 
 
 def main(argv=None):
@@ -171,10 +149,11 @@
         argv = sys.argv
 
     # Run CallParking Test
-    call_parking_test = CallParkingTest(argv)
+    test = CallParkingTest(argv)
+    test.start_asterisk()
     reactor.run()
-    call_parking_test.stop_asterisk()
-    if call_parking_test.passed != True:
+    test.stop_asterisk()
+    if test.passed != True:
         return 1
     return 0
 

Modified: asterisk/team/pabelanger/SWP-2716/tests/callparking/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2716/tests/callparking/test-config.yaml?view=diff&rev=1245&r1=1244&r2=1245
==============================================================================
--- asterisk/team/pabelanger/SWP-2716/tests/callparking/test-config.yaml (original)
+++ asterisk/team/pabelanger/SWP-2716/tests/callparking/test-config.yaml Fri Dec 17 13:37:39 2010
@@ -1,5 +1,4 @@
 testinfo:
-    skip: 'Skip while failures are debugged'
     summary:     'Test Call Parking'
     description: |
         'This test verifies the Call Parking routine used in the feature code.'




More information about the asterisk-commits mailing list