[asterisk-commits] pabelanger: branch pabelanger/SWP-2715 r1194 - in /asterisk/team/pabelanger/S...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Dec 16 02:54:09 UTC 2010


Author: pabelanger
Date: Wed Dec 15 20:54:05 2010
New Revision: 1194

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1194
Log:
First round of new logic for test

Modified:
    asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast1/extensions.conf
    asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast1/manager.conf
    asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast2/extensions.conf
    asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast2/manager.conf
    asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/run-test

Modified: asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast1/extensions.conf?view=diff&rev=1194&r1=1193&r2=1194
==============================================================================
--- asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast1/extensions.conf (original)
+++ asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast1/extensions.conf Wed Dec 15 20:54:05 2010
@@ -1,95 +1,26 @@
 [general]
 
 [globals]
-; these global variables can be used during debugging to view what step went wrong
-BLONDE_TEST_A_LEG=FAIL-never even got to read the results
-BLONDE_TEST_C_LEG=FAIL-never even got to read the results
 
 [alpha]
-; __________________ A ______________________
-exten => a_exten,1,Answer()
-exten => a_exten,n,Set(GLOBAL(BLONDE_TEST_A_LEG)=FAIL-answered call from B)
+exten => 1000,1,Answer()
+exten => 1000,n,SendDTMF(1w0w5w0w)
+exten => 1000,n,Background(demo-congrats)
+exten => 1000,n,UserEvent(alpha, status: FAILURE)
+exten => 1000,n,Hangup()
 
-;Play back audio while B leg begins to start transfer. This
-;involves some timing.  Playback is done 4 times to guarantee
-;that B has begun the transfer before we start listening for DTMF.
-exten => a_exten,n,Playback(${TALK_AUDIO})
-exten => a_exten,n,Playback(${TALK_AUDIO})
-exten => a_exten,n,Playback(${TALK_AUDIO})
-exten => a_exten,n,Playback(${TALK_AUDIO})
-
-;WAIT FOR DTMF FROM C TO KNOW IT IS UP AND SYNCED
-exten => a_exten,n,Set(GLOBAL(BLONDE_TEST_A_LEG)=FAIL-after reading DTMF from C)
-exten => a_exten,n,Read(A_READ,,3,,,25)
-exten => a_exten,n,NoOp(A READ IS ${A_READ})
-
-;CHECK DTMF FROM C
-exten => a_exten,n,Set(GLOBAL(BLONDE_TEST_A_LEG)=FAIL-while checking dtmf from C results)
-exten => a_exten,n,GoToIf($[${A_READ}=100]?dtmfpass:dtmffail)
-exten => a_exten,n(dtmffail),Set(GLOBAL(BLONDE_TEST_A_LEG)=FAIL-DTMF_FROM_C_FAILED ${A_READ})
-exten => a_exten,n,Hangup()
-exten => a_exten,n(dtmfpass),Set(GLOBAL(BLONDE_TEST_A_LEG)=FAIL-Got DTMF from C A_READ is ${A_READ} now performing audio detect)
-
-;DETECT AUDIO
-exten => a_exten,n,Set(TALK_DETECTED=0) ; initialize TALK_DETECT var
-exten => a_exten,n,BackgroundDetect(${TALK_AUDIO},1,20,,20000) ; lets see if we have 2 way audio
-
-;CHECK AUDIO RESULTS
-exten => a_exten,n,Set(GLOBAL(BLONDE_TEST_A_LEG)=FAIL-checking talk detect results)
-exten => a_exten,n,GoToIf($[${TALK_DETECTED}=0]?talkdetectfail:talkdetectpass)
-exten => a_exten,n(talkdetectfail),Set(GLOBAL(BLONDE_TEST_A_LEG)=FAIL-talk detect failed TALK_DETECTED is ${TALK_DETECTED})
-exten => a_exten,n,Hangup()
-
-;PASSED ! we make it to this point in the dial plan, A has passed.
-exten => a_exten,n(talkdetectpass),Set(GLOBAL(BLONDE_TEST_A_LEG)=PASS)
-
-;REPORT SUCCESS, at this point in the dialplay this call leg passed.
-exten => a_exten,n,AGI(agi://127.0.0.1:4573) ;Tell the test script A passed
-
-; since both channels are attempted to detect audio, we must play this file twice because
-; we can not guarantee who broke out of BackgroundDetect first
-exten => a_exten,n,Playback(${TALK_AUDIO})
+exten => 2345,1,UserEvent(alpha, status: SUCCESS)
+exten => 2345,n,Background(demo-congrats)
+exten => 2345,n,Hangup()
 
 [charlie]
-; __________________ C  ______________________
-exten => c_exten,1,Set(GLOBAL(BLONDE_TEST_C_LEG)=FAIL-extension was called)
+exten => 1010,1,Answer()
+exten => 1010,n,Set(${TALK_DETECT}=0)
+exten => 1010,n,BackgroundDetect(demo-congrats,1,20,,20000)
+exten => 1010,n,UserEvent(charlie, status: FAILURE)
+exten => 1010,n,Hangup()
 
-;Wait after entering dialplan for B to hangup.
-exten => c_exten,n,Ringing()
-exten => c_exten,n,Wait(1)
-exten => c_exten,n,Set(GLOBAL(BLONDE_TEST_C_LEG)=FAIL-after waiting before answer)
-exten => c_exten,n,Answer()
-
-exten => c_exten,n,Set(GLOBAL(BLONDE_TEST_C_LEG)=FAIL-extension was answered)
-
-; Play the same amount of audio A does in while waiting to guarantee
-; A is ready to receive DTMF before we send it.
-exten => c_exten,n,Playback(${TALK_AUDIO})
-exten => c_exten,n,Playback(${TALK_AUDIO})
-exten => c_exten,n,Playback(${TALK_AUDIO})
-exten => c_exten,n,Playback(${TALK_AUDIO})
-
-;SEND DTMF TO A SIGNALLING WE ARE HERE, b hung up, now we should be talking to A
-exten => c_exten,n,SendDTMF(1w0w0w#) ; send some dtmf to A
-exten => c_exten,n,Set(GLOBAL(BLONDE_TEST_C_LEG)=FAIL-sent dtmf to A now performing audio detect)
-
-;DETECT AUDIO
-exten => c_exten,n,Set(TALK_DETECTED=0) ; initialize TALK_DETECTED var
-exten => c_exten,n,BackgroundDetect(${TALK_AUDIO},1,20,,20000) ; lets see if we have some 2 way audio
-
-;CHECK AUDIO RESULTS
-exten => c_exten,n,Set(GLOBAL(BLONDE_TEST_C_LEG)=FAIL-checking talk detect results)
-exten => c_exten,n,GoToIf($[${TALK_DETECTED}=0]?talkdetectfail:talkdetectpass)
-exten => c_exten,n(talkdetectfail),Set(GLOBAL(BLONDE_TEST_C_LEG)=FAIL-talk detect failed TALK_DETECT is ${TALK_DETECTED})
-exten => c_exten,n,Hangup()
-
-;PASSED ! we make it to this point in the dial plan, C has passed.
-exten => c_exten,n(talkdetectpass),Set(GLOBAL(BLONDE_TEST_C_LEG)=PASS)
-
-;REPORT SUCCESS, at this point in the dialplay this call leg passed.
-exten => c_exten,n,AGI(agi://127.0.0.1:4575) ;Tell the test script C passed
-
-; Since both channels are attempted to detect audio, we must continue to play
-; this file because we can not guarantee who broke out of BackgroundDetect first.
-exten => c_exten,n,Playback(${TALK_AUDIO})
-
+exten => talk,1,UserEvent(charlie, status: SUCCESS)
+exten => talk,n,SendDTMF(2w3w4w5w)
+exten => talk,n,Background(demo-congrats)
+exten => talk,n,Hangup()

Modified: asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast1/manager.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast1/manager.conf?view=diff&rev=1194&r1=1193&r2=1194
==============================================================================
--- asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast1/manager.conf (original)
+++ asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast1/manager.conf Wed Dec 15 20:54:05 2010
@@ -7,4 +7,3 @@
 secret = mysecret
 read = system,call,log,verbose,agent,user,config,dtmf,reporting,cdr,dialplan
 write = system,call,agent,user,config,command,reporting,originate
-

Modified: asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast2/extensions.conf?view=diff&rev=1194&r1=1193&r2=1194
==============================================================================
--- asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast2/extensions.conf (original)
+++ asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast2/extensions.conf Wed Dec 15 20:54:05 2010
@@ -6,24 +6,18 @@
 
 [transfertest]
 ;Call A leg
-exten => a_dial,1,Dial(IAX2/iax_a/a_exten,,T)
+exten => a_dial,1,Dial(IAX2/iax_a/1000,,T)
 ;Call C leg
-exten => 7002,1,Dial(IAX2/iax_c/c_exten)
+exten => 7002,1,Dial(IAX2/iax_c/1010)
 
-; __________________ B ______________________
-exten => b_exten,1,Set(GLOBAL(BLONDE_TEST_B_LEG)=FAIL-made it to b_exten though)
-exten => b_exten,n,Answer()
-exten => b_exten,n,Playback(${TALK_AUDIO})
+exten => 1000,1,Answer()
+exten => 1000,n,Background(demo-congrats)
+exten => 1000,n,UserEvent(bravo, status: SUCCESS)
+exten => 1000,n,Hangup()
 
-;SIGNAL FOR TRANSFER, then wait with audio
-exten => b_exten,n,SendDTMF(*w2)
-exten => b_exten,n,Playback(${TALK_AUDIO})
-exten => b_exten,n,Set(GLOBAL(BLONDE_TEST_B_LEG)=FAIL-began transfer)
+exten => 1050,1,SendDTMF(*w2)
+exten => 1050,n,SendDTMF(7w0w0w2w)
+exten => 1050,n,UserEvent(bravo, status: SUCCESS)
+exten => 1050,n,Hangup()
 
-;ENTER TRANSFER EXTEN
-exten => b_exten,n,SendDTMF(7w0w0w2w)
 
-exten => b_exten,n,Set(GLOBAL(BLONDE_TEST_B_LEG)=PASS)
-
-;HANGUP before C answers
-;exten => b_exten,n,HangUp()

Modified: asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast2/manager.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast2/manager.conf?view=diff&rev=1194&r1=1193&r2=1194
==============================================================================
--- asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast2/manager.conf (original)
+++ asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/configs/ast2/manager.conf Wed Dec 15 20:54:05 2010
@@ -1,10 +1,9 @@
 [general]
 enabled = yes
-port = 5039
-bindaddr = 127.0.0.1
+port = 5038
+bindaddr = 127.0.0.2
 
 [user]
 secret = mysecret
 read = system,call,log,verbose,agent,user,config,dtmf,reporting,cdr,dialplan
 write = system,call,agent,user,config,command,reporting,originate
-

Modified: asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/run-test?view=diff&rev=1194&r1=1193&r2=1194
==============================================================================
--- asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/run-test (original)
+++ asterisk/team/pabelanger/SWP-2715/tests/feature_blonde_transfer/run-test Wed Dec 15 20:54:05 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
@@ -24,13 +24,13 @@
 
 class BlondeTransferTest:
     def __init__(self, argv):
-        self.a_res = 0
-        self.c_res = 0
         self.passed = False
+        self.alpha = False
+        self.bravo = False
+        self.charlie = False
 
         # Test timeout in seconds
         self.test_to = 45
-        self.last_step = ""
 
         # get version info
         parser = OptionParser()
@@ -38,12 +38,6 @@
                           help="Asterisk version string")
         (options, args) = parser.parse_args(argv)
         self.ast_version = AsteriskVersion(options.ast_version)
-
-        # FastAGI, listen for results from dialplan
-        self.agi_a = fastagi.FastAGIFactory(self.get_result_a)
-        self.agi_c = fastagi.FastAGIFactory(self.get_result_c)
-        reactor.listenTCP(4573, self.agi_a, self.test_to, '127.0.0.1')
-        reactor.listenTCP(4575, self.agi_c, self.test_to, '127.0.0.1')
 
         reactor.callWhenRunning(self.run)
 
@@ -53,40 +47,12 @@
         self.ast2 = Asterisk(base=workingdir)
         self.ast2.install_configs("%s/configs/ast2" % (testdir))
 
-        self.talkingaudio = os.path.join(os.getcwd(), "%s/sounds/talking" % (testdir))
 
-    # Close out the agi
-    def handle_agi_result(self, agi):
-        sequence = fastagi.InSequence()
-        sequence.append(agi.finish)
-        self.result_changed()
-        return sequence()
-
-    # This gets invoked by the dialplan when call leg A passes
-    def get_result_a(self, agi):
-        self.log_last_step("Blonde Call Leg A PASSED")
-        self.a_res = 1
-        return self.handle_agi_result(agi)
-
-    # This gets invoked by the dialplan when call leg C passes
-    def get_result_c(self, agi):
-        self.log_last_step("Blonde Call Leg C PASSED")
-        self.c_res = 1
-        return self.handle_agi_result(agi)
-
-    def read_result(self):
-        self.stop_reactor()
-        self.log_last_step("Reading results")
-
-        if (self.a_res and self.c_res):
+    def check_result(self):
+        self.log_last_step("Checking results...")
+        if self.alpha is True and self.bravo is True and self.charlie is True:
+            self.stop_reactor()
             self.passed = True
-            self.log_last_step("Blonde Transfer Test Passed...")
-        else:
-            if self.a_res == 0:
-                self.log_last_step("Blonde Call Leg A failed.")
-            if self.c_res == 0:
-                self.log_last_step("Blonde Call Leg C failed.")
-            self.log_last_step("Blonde Transfer Test Failed... view result of 'core show globals' in log for more detailed failure results.")
 
     def stop_reactor(self):
         print "Stopping Reactor ..."
@@ -101,14 +67,7 @@
     # 5.  Audio and DTMF is passed and detected on each side of the call verifying the connection.
     # 6.  A and C report results to FastAGI and hangup.
     def launch_test(self):
-        if self.ast_version < AsteriskVersion("1.6.1"):
-            self.ast1.cli_exec("core set global TALK_AUDIO " + self.talkingaudio)
-            self.ast2.cli_exec("core set global TALK_AUDIO " + self.talkingaudio)
-        else:
-            self.ast1.cli_exec("dialplan set global TALK_AUDIO " + self.talkingaudio)
-            self.ast2.cli_exec("dialplan set global TALK_AUDIO " + self.talkingaudio)
-
-        self.ast2.cli_originate("Local/b_exten at transfertest extension a_dial at transfertest")
+        self.ast2.cli_originate("Local/1000 at transfertest extension a_dial at transfertest")
 
     def start_asterisk(self):
         self.log_last_step("Starting Asterisk")
@@ -123,17 +82,69 @@
         print step
         self.last_step = step
 
-    # This is called every time a result comes in, once all results are in
-    # we can quit early instead of waiting for the time out.
-    def result_changed(self):
-        if (self.a_res and self.c_res):
-            self.log_last_step("All the results are in, now read them.")
-            # This attempts to schedule a read result earlier than our default timeout.
-            # If the default timeout one gets called first, that is fine.  Either way
-            # this function shuts down the reactor so no other callbacks are processed.
-            self.read_result()
+    def check_alpha(self, ami, event):
+        self.log_last_step("Checking Userevent")
+        if event.get("userevent").lower() != "alpha":
+            return
+        status = event.get("status")
+        print ("Status of alpha is %s" % (status))
+        if status != "SUCCESS":
+            self.stop_reactor()
+            return
+
+        self.alpha = True
+        self.check_result()
+
+    def check_bravo(self, ami, event):
+        self.log_last_step("Checking Userevent")
+        if event.get("userevent").lower() != "bravo":
+            return
+        status = event.get("status")
+        print ("Status of bravo is %s" % (status))
+        if status != "SUCCESS":
+            self.stop_reactor()
+            return
+
+        self.bravo = True
+        self.check_result()
+
+    def check_charlie(self, ami, event):
+        self.log_last_step("Checking Userevent")
+        if event.get("userevent").lower() != "charlie":
+            return
+        status = event.get("status")
+        print ("Status of charlie is %s" % (status))
+        if status != "SUCCESS":
+            self.stop_reactor()
+            return
+
+        self.charlie = 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.check_bravo)
+
+    def ami_on_connect1(self, ami):
+        self.log_last_step("Connected to AMI 1")
+        self.ami1 = ami
+        self.ami1.registerEvent("UserEvent", self.check_alpha)
+        self.ami1.registerEvent("UserEvent", self.check_charlie)
+
+    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_factory1.login('127.0.0.1', 5038).addCallbacks(self.ami_on_connect1, self.ami_login_error)
+        self.ami_factory2 = manager.AMIFactory("user", "mysecret")
+        self.ami_factory2.login('127.0.0.2', 5038).addCallbacks(self.ami_on_connect2, self.ami_login_error)
 
     def run(self):
+        self.ami_login()
         self.launch_test()
 
         # stop and read results after timeout




More information about the asterisk-commits mailing list