[asterisk-commits] pabelanger: branch pabelanger/SWP-2718 r1304 - in /asterisk/team/pabelanger/S...

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


Author: pabelanger
Date: Tue Dec 28 13:17:41 2010
New Revision: 1304

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1304
Log:
First round of updates

Added:
    asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast2/
      - copied from r1302, asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast1/
Modified:
    asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast1/extensions.conf
    asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast1/manager.conf
    asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast1/sip.conf
    asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast2/extensions.conf
    asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast2/manager.conf
    asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast2/sip.conf
    asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/run-test
    asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/test-config.yaml

Modified: asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast1/extensions.conf?view=diff&rev=1304&r1=1303&r2=1304
==============================================================================
--- asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast1/extensions.conf (original)
+++ asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast1/extensions.conf Tue Dec 28 13:17:41 2010
@@ -12,13 +12,10 @@
 exten => chanspytest,1,ChanSpy(SIP,qB)
 
 exten => detect_audio,1,Answer()
-exten => detect_audio,n,Set(TALK_DETECTED=0) ; initialize TALK_DETECT var
 exten => detect_audio,n,BackgroundDetect(${TALK_AUDIO},1,20,,20000)
-exten => detect_audio,n,GoToIf($[${TALK_DETECTED}=0]?talkdetectfail:talkdetectpass)
-exten => detect_audio,n(talkdetectfail),Hangup()
+exten => detect_audio,n,Hangup()
 
-;PASSED!
-exten => detect_audio,n(talkdetectpass),AGI(agi://127.0.0.1:4573)
+exten => talk,1,AGI(agi://127.0.0.1:4573)
 
 exten => play_recording,1,Answer()
 exten => play_recording,n,PlayBack(${TESTAUDIO1})

Modified: asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast1/manager.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast1/manager.conf?view=diff&rev=1304&r1=1303&r2=1304
==============================================================================
--- asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast1/manager.conf (original)
+++ asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast1/manager.conf Tue Dec 28 13:17:41 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-2718/tests/chanspy/chanspy_barge/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast1/sip.conf?view=diff&rev=1304&r1=1303&r2=1304
==============================================================================
--- asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast1/sip.conf (original)
+++ asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast1/sip.conf Tue Dec 28 13:17:41 2010
@@ -1,29 +1,24 @@
 [general]
+bindaddr=127.0.0.1
 directmedia=no
 
 [end_a]
 context=test
 type=friend
-host=127.0.0.1
-port=5065
-insecure=invite
+host=127.0.0.2
 disallow=all
 allow=ulaw
 
 [end_b]
 context=test
 type=friend
-host=127.0.0.1
-port=5066
-insecure=invite
+host=127.0.0.3
 disallow=all
 allow=ulaw
 
 [end_c]
 context=test
 type=friend
-host=127.0.0.1
-port=5067
-insecure=invite
+host=127.0.0.4
 disallow=all
 allow=ulaw

Modified: asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast2/extensions.conf?view=diff&rev=1304&r1=1302&r2=1304
==============================================================================
--- asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast2/extensions.conf (original)
+++ asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast2/extensions.conf Tue Dec 28 13:17:41 2010
@@ -12,13 +12,10 @@
 exten => chanspytest,1,ChanSpy(SIP,qB)
 
 exten => detect_audio,1,Answer()
-exten => detect_audio,n,Set(TALK_DETECTED=0) ; initialize TALK_DETECT var
 exten => detect_audio,n,BackgroundDetect(${TALK_AUDIO},1,20,,20000)
-exten => detect_audio,n,GoToIf($[${TALK_DETECTED}=0]?talkdetectfail:talkdetectpass)
-exten => detect_audio,n(talkdetectfail),Hangup()
+exten => detect_audio,n,Hangup()
 
-;PASSED!
-exten => detect_audio,n(talkdetectpass),AGI(agi://127.0.0.1:4573)
+exten => talk,1,AGI(agi://127.0.0.1:4573)
 
 exten => play_recording,1,Answer()
 exten => play_recording,n,PlayBack(${TESTAUDIO1})

Modified: asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast2/manager.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast2/manager.conf?view=diff&rev=1304&r1=1302&r2=1304
==============================================================================
--- asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast2/manager.conf (original)
+++ asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast2/manager.conf Tue Dec 28 13:17:41 2010
@@ -1,10 +1,9 @@
 [general]
 enabled = yes
 port = 5038
-bindaddr = 127.0.0.1
+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-2718/tests/chanspy/chanspy_barge/configs/ast2/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast2/sip.conf?view=diff&rev=1304&r1=1302&r2=1304
==============================================================================
--- asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast2/sip.conf (original)
+++ asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/configs/ast2/sip.conf Tue Dec 28 13:17:41 2010
@@ -1,29 +1,24 @@
 [general]
+bindaddr=127.0.0.2
 directmedia=no
 
 [end_a]
 context=test
 type=friend
-host=127.0.0.1
-port=5065
-insecure=invite
+host=127.0.0.2
 disallow=all
 allow=ulaw
 
 [end_b]
 context=test
 type=friend
-host=127.0.0.1
-port=5066
-insecure=invite
+host=127.0.0.3
 disallow=all
 allow=ulaw
 
 [end_c]
 context=test
 type=friend
-host=127.0.0.1
-port=5067
-insecure=invite
+host=127.0.0.4
 disallow=all
 allow=ulaw

Modified: asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/run-test?view=diff&rev=1304&r1=1303&r2=1304
==============================================================================
--- asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/run-test (original)
+++ asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/run-test Tue Dec 28 13:17:41 2010
@@ -15,7 +15,6 @@
 from twisted.application import service, internet
 from twisted.internet import reactor, defer
 from starpy import manager
-from starpy import fastagi
 
 sys.path.append("lib/python")
 from asterisk.asterisk import Asterisk
@@ -41,8 +40,6 @@
         self.ast_version = AsteriskVersion(options.ast_version)
 
         reactor.callWhenRunning(self.run)
-        self.agi = fastagi.FastAGIFactory(self.reportPassed)
-        reactor.listenTCP(4573, self.agi, self.test_to, '127.0.0.1')
 
         print self.ast_version
 
@@ -52,37 +49,24 @@
 
         self.ast1 = Asterisk(base=workingdir, ast_conf_options=ast_conf_options)
         self.ast1.install_configs("%s/configs/ast1" % (testdir))
+        self.ast2 = Asterisk(base=workingdir)
+        self.ast2.install_configs("%s/configs/ast2" % (testdir))
+
         self.talkingaudio = os.path.join(os.getcwd(), "%s/sounds/talking" % (testdir))
         self.audiofile1 = os.path.join(os.getcwd(), "%s/testaudio1" % (testdir))
 
-    def reportPassed(self, agi):
-        print "GOT PASS RESULTS!!!\n"
-        sequence = fastagi.InSequence()
-        sequence.append(agi.execute, "HangUp")
-        sequence.append(agi.finish)
-        self.passed = True
-        reactor.callLater(1, self.readResult)
-        return sequence()
-
     def readResult(self):
+        self.stop_reactor()
         self.logLastStep("Reading results")
-        self.ast1.cli_exec("core show locks")   # get lock output in case of deadlock before tearing down.
-        self.ast1.cli_exec("core show channels")# if channels are still up for some reason, we want to know that as well
-
-        if self.ast_version < AsteriskVersion("1.6.1"):
-            self.ast1.cli_exec("core show globals") # The global variables here hold failure conditions
-        else:
-            self.ast1.cli_exec("dialplan show globals") # The global variables here hold failure conditions
 
         if self.passed == True:
             print 'SIP ChanSpy test PASSED!'
         else:
             print 'SIP ChanSpy Test FAILED'
 
-        self.stopProcesses()
-
+    def stop_reactor(self):
+        print "Stopping Reactor ..."
         if reactor.running:
-            print "Stopping Reactor ..."
             reactor.stop()
 
     def chanspyEvent(self, ami, event):
@@ -91,37 +75,27 @@
             reactor.callLater(3, self.aHangup)
             reactor.callLater(4, self.bHangup)
         print event
-    def amiOnConnect(self, ami):
+
+    def ami_connect1(self, ami):
         self.logLastStep("Connected to the AMI")
         self.ami = ami
         self.ami.registerEvent('ChanSpyStart', self.chanspyEvent)
+
     def amiLoginError(self, ami):
         self.logLastStep("AMI login failed")
         reactor.callLater(1, self.readResult)
+
     def amiLogin(self):
         self.logLastStep("Logging in to the AMI")
-        self.ami_factory = manager.AMIFactory("user", "mysecret")
-        self.ami_factory.login('127.0.0.1', 5038).addCallbacks(self.amiOnConnect, self.amiLoginError)
-    def aCall(self):
-        self.logLastStep("A Calling into Wait")
-        self.pja.stdin.write("m\n")
-        self.pja.stdin.write("sip:play_exten at 127.0.0.1:5060\n")
-    def bCall(self):
-        self.logLastStep("B Calling into Playback")
-        self.pjb.stdin.write("m\n")
-        self.pjb.stdin.write("sip:play_exten at 127.0.0.1:5060\n")
-    def aHangup(self):
-        self.pja.stdin.write("h\n")
-    def bHangup(self): #calls into chanspy extension and plays audio to A using Barge
-        self.pjb.stdin.write("h\n")
-        reactor.callLater(2, self.verifyAudio)
+        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_connect1 self.amiLoginError)
+#        self.ami_factory2.login('127.0.0.2', 5038).addCallbacks(self.ami_connect2 self.amiLoginError)
 
-    def startProcesses(self):
+    def start_asterisk(self):
         self.logLastStep("Starting Processes")
         self.ast1.start()
-        playfilearg = "--play-file=%s.wav" % (self.talkingaudio)
-        self.pja = subprocess.Popen(['pjsua', '--local-port=5065', '--auto-answer=200', '--null-audio', '--auto-loop'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
-        self.pjb = subprocess.Popen(['pjsua', '--local-port=5066', '--auto-answer=200', playfilearg, '--auto-play'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+        self.ast2.start()
 
         if self.ast_version < AsteriskVersion("1.6.1"):
             self.ast1.cli_exec("core set global TESTAUDIO1 " + self.audiofile1)
@@ -130,11 +104,10 @@
             self.ast1.cli_exec("dialplan set global TESTAUDIO1 " + self.audiofile1)
             self.ast1.cli_exec("dialplan set global TALK_AUDIO " + self.talkingaudio)
 
-    def stopProcesses(self):
+    def stop_asterisk(self):
         self.logLastStep("Stopping Processes")
         self.ast1.stop()
-        os.kill(self.pja.pid, signal.SIGKILL)
-        os.kill(self.pjb.pid, signal.SIGKILL)
+        self.ast2.stop()
 
     def logLastStep(self, step):
         print step
@@ -142,29 +115,18 @@
 
     def callChanSpy(self):
         self.logLastStep("Placing call to ChanSpy extension.")
-        if self.ast_version < AsteriskVersion("1.6.2"):
-            self.ast1.cli_exec("originate SIP/end_b extension chanspytest at test")
-        else:
-            self.ast1.cli_exec("channel originate SIP/end_b extension chanspytest at test")
+        self.ast1.cli_originate("SIP/end_b extension chanspytest at test")
 
     def verifyAudio(self):
-        if self.ast_version < AsteriskVersion("1.6.2"):
-            self.ast1.cli_exec("originate Local/play_recording at test extension detect_audio at test")
-        else:
-            self.ast1.cli_exec("channel originate Local/play_recording at test extension detect_audio at test")
+        self.ast1.cli_originate("Local/play_recording at test extension detect_audio at test")
 
     def run(self):
-
-        # start up the processes
-        self.startProcesses()
-
         # call extensions
         self.amiLogin()
-        reactor.callLater(1, self.callChanSpy)
-        reactor.callLater(2, self.aCall)
+        self.callChanSpy()
 
         # stop and read results after timeout
-        reactor.callLater(self.test_to, self.readResult)
+        reactor.callLater(self.test_to, self.stop_reactor)
 
 def main(argv=None):
     if argv is None:
@@ -172,8 +134,9 @@
 
     # Run Test
     test = ChanSpyBarge(argv)
+    test.start_asterisk()
     reactor.run()
-    test.stopProcesses()
+    test.stop_asterisk()
     if test.passed != True:
         return 1
     return 0
@@ -181,3 +144,5 @@
 if __name__ == "__main__":
     sys.exit(main() or 0)
 
+
+# vim:sw=4:ts=4:expandtab:textwidth=79

Modified: asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/test-config.yaml?view=diff&rev=1304&r1=1303&r2=1304
==============================================================================
--- asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/test-config.yaml (original)
+++ asterisk/team/pabelanger/SWP-2718/tests/chanspy/chanspy_barge/test-config.yaml Tue Dec 28 13:17:41 2010
@@ -1,5 +1,4 @@
 testinfo:
-    skip: 'Skip while failures are debugged'
     summary:     'Test Chanspy with the \"B\" option for barging in on both channels.'
     description: |
         'This test verifies basic functionality of using ChanSpy with the 
@@ -16,4 +15,3 @@
     dependencies:
         - python : 'twisted'
         - python : 'starpy'
-        - app : 'pjsua'




More information about the asterisk-commits mailing list