[asterisk-commits] pabelanger: branch pabelanger/SWP-2712 r1158 - in /asterisk/team/pabelanger/S...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 13 17:09:06 CST 2010


Author: pabelanger
Date: Mon Dec 13 17:09:01 2010
New Revision: 1158

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1158
Log:
Rework mixmonitor logic, test now passes.

Added:
    asterisk/team/pabelanger/SWP-2712/tests/mixmonitor/configs/ast1/manager.conf
      - copied unchanged from r1156, asterisk/team/pabelanger/SWP-2712/tests/udptl/configs/ast1/manager.conf
Modified:
    asterisk/team/pabelanger/SWP-2712/tests/mixmonitor/configs/ast1/extensions.conf
    asterisk/team/pabelanger/SWP-2712/tests/mixmonitor/run-test
    asterisk/team/pabelanger/SWP-2712/tests/mixmonitor/test-config.yaml

Modified: asterisk/team/pabelanger/SWP-2712/tests/mixmonitor/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2712/tests/mixmonitor/configs/ast1/extensions.conf?view=diff&rev=1158&r1=1157&r2=1158
==============================================================================
--- asterisk/team/pabelanger/SWP-2712/tests/mixmonitor/configs/ast1/extensions.conf (original)
+++ asterisk/team/pabelanger/SWP-2712/tests/mixmonitor/configs/ast1/extensions.conf Mon Dec 13 17:09:01 2010
@@ -2,33 +2,30 @@
 
 [globals]
 
-[mixmonitortest]
-exten => test1,1,Answer()
-exten => test1,n,MixMonitor(${TESTAUDIO1})
-exten => test1,n,Playback(${TALK_AUDIO})
-exten => test1,n,StopMixMonitor()
+[test1]
+exten => s,1,Answer()
+exten => s,n,MixMonitor(${TESTAUDIO1})
+exten => s,n,Playback(${TALK_AUDIO})
+exten => s,n,StopMixMonitor()
+;If PlayBack fails, then StopMixMonitor has not yet let go of the file
+exten => s,n,PlayBack(${TESTAUDIO1})
+exten => s,n,GoToIf($[${PLAYBACKSTATUS} = SUCCESS]?domore:stopnow)
+; StopMixMonitor failed to let go of the file as we could not play it back
+exten => s,n(stopnow),HangUp()
+; StopMixMonitor worked, now test stopping on hangup
+exten => s,n(domore), MixMonitor(${TESTAUDIO2})
+exten => s,n,Playback(${TALK_AUDIO})
+exten => s,n,HangUp()
 
-;If PlayBack fails, then StopMixMonitor has not yet let go of the file
-exten => test1,n,PlayBack(${TESTAUDIO1})
-exten => test1,n,GoToIf($[${PLAYBACKSTATUS} = SUCCESS]?domore:stopnow)
+exten => h,1,UserEvent(test1, status: ${PLAYBACKSTATUS})
 
-; StopMixMonitor failed to let go of the file as we could not play it back
-exten => test1,n(stopnow),HangUp()
+[test2]
+; Test 2 verifies the TESTAUDIO2 file was released during hangup of the previous test
+exten => s,1,PlayBack(${TESTAUDIO2})
+exten => s,n,GoToIf($[${PLAYBACKSTATUS} = SUCCESS]?domore2:stopnow2)
+exten => s,n(stopnow2),HangUp()
+exten => s,n(domore2), MixMonitor(${TESTAUDIO3})
+exten => s,n,Playback(${TALK_AUDIO})
+exten => s,n,HangUp()
 
-; StopMixMonitor worked, now test stopping on hangup
-exten => test1,n(domore), MixMonitor(${TESTAUDIO2})
-exten => test1,n,Playback(${TALK_AUDIO})
-exten => test1,n,HangUp()
-
-; Test 2 verifies the TESTAUDIO2 file was released during hangup of the previous test
-exten => test2,1,PlayBack(${TESTAUDIO2})
-exten => test2,n,GoToIf($[${PLAYBACKSTATUS} = SUCCESS]?domore2:stopnow2)
-
-exten => test2,n(stopnow2),HangUp()
-
-exten => test2,n(domore2), MixMonitor(${TESTAUDIO3})
-exten => test2,n,Playback(${TALK_AUDIO})
-exten => test2,n,HangUp()
-
-
-
+exten => h,1,UserEvent(test2, status: ${PLAYBACKSTATUS})

Modified: asterisk/team/pabelanger/SWP-2712/tests/mixmonitor/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2712/tests/mixmonitor/run-test?view=diff&rev=1158&r1=1157&r2=1158
==============================================================================
--- asterisk/team/pabelanger/SWP-2712/tests/mixmonitor/run-test (original)
+++ asterisk/team/pabelanger/SWP-2712/tests/mixmonitor/run-test Mon Dec 13 17:09:01 2010
@@ -12,6 +12,7 @@
 import math
 from optparse import OptionParser
 from twisted.internet import reactor
+from starpy import manager
 
 sys.path.append("lib/python")
 from asterisk.asterisk import Asterisk
@@ -40,7 +41,6 @@
 
         reactor.callWhenRunning(self.run)
 
-        print self.ast_version
         self.ast1 = Asterisk(base=workingdir)
         self.ast1.install_configs("%s/configs/ast1" % (testdir))
         self.audiofile1 = os.path.join(os.getcwd(), "%s/testaudio1" % (testdir))
@@ -50,6 +50,8 @@
         self.talkingaudio = os.path.join(os.getcwd(), "%s/sounds/talking" % (testdir))
 
     def read_result(self):
+        self.passed = True
+        self.stop_reactor()
         self.log_last_step("Reading result file from MixMonitor")
         if os.path.exists(self.audiofile1 + ".raw"):
             self.audiofile1size = os.path.getsize(self.audiofile1 + ".raw")
@@ -57,13 +59,6 @@
             self.audiofile2size = os.path.getsize(self.audiofile2 + ".raw")
         if os.path.exists(self.audiofile3 + ".raw"):
             self.audiofile3size = os.path.getsize(self.audiofile3 + ".raw")
-
-        self.stop_asterisk()
-        print "Stopping Reactor ..."
-        if reactor.running:
-            reactor.stop()
-
-        self.passed = True
 
         self.log_last_step("audiofile1 size is %d, a negative size indicates the file was not present." % (self.audiofile1size, ))
         if math.fabs(self.audiofile1size - self.expectedfilesize) > self.filesizetolerance:
@@ -86,13 +81,18 @@
         if self.passed == True:
             self.log_last_step("Test Passed... All audio files are the correct.")
 
+    def stop_reactor(self):
+        print "Stopping Reactor ..."
+        if reactor.running:
+            reactor.stop()
+
     def launch_test1(self):
         self.log_last_step("Placing call to test1 exten")
-        self.ast1.cli_exec("console dial test1 at mixmonitortest")
+        self.ast1.cli_exec("console dial s at test1")
 
     def launch_test2(self):
         self.log_last_step("Placing call to test2 exten")
-        self.ast1.cli_exec("console dial test2 at mixmonitortest")
+        self.ast1.cli_exec("console dial s at test2")
 
     def start_asterisk(self):
         self.log_last_step("Starting Asterisk")
@@ -116,22 +116,54 @@
         print step
         self.last_step = step
 
+    def check_test1(self, ami, event):
+        self.log_last_step("Checking Userevent")
+        if event.get("userevent").lower() != "test1":
+            return
+        status = event.get("status")
+        print ("Status of test1 is %s" % (status))
+        if status != "SUCCESS":
+            self.stop_reactor()
+
+        self.ami.registerEvent("UserEvent", self.check_test2)
+        self.launch_test2()
+
+    def check_test2(self, ami, event):
+        self.log_last_step("Checking Userevent")
+        if event.get("userevent").lower() != "test2":
+            return
+        status = event.get("status")
+        print ("Status of test2 is %s" % (status))
+        if status != "SUCCESS":
+            self.stop_reactor()
+
+        self.read_result()
+
+    def ami_on_connect1(self, ami):
+        self.log_last_step("Connected to AMI 2")
+        self.ami = ami
+        self.ami.registerEvent("UserEvent", self.check_test1)
+
+    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)
+
     def run(self):
-        self.start_asterisk()
-
-        # call test1 extension now
+        self.ami_login()
         self.launch_test1()
 
-        # call test2 extension in 15 seconds
-        reactor.callLater(15, self.launch_test2)
-
-        # read test results in 25 seconds
-        reactor.callLater(25, self.read_result)
+        reactor.callLater(30, self.stop_reactor)
 
 def main(argv=None):
     if argv is None:
         argv = sys.argv
     test = MixMonitorTest(argv)
+    test.start_asterisk()
     reactor.run()
     test.stop_asterisk()
     if test.passed:
@@ -142,3 +174,5 @@
 if __name__ == "__main__":
     sys.exit(main() or 0)
 
+
+# vim:sw=4:ts=4:expandtab:textwidth=79

Modified: asterisk/team/pabelanger/SWP-2712/tests/mixmonitor/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2712/tests/mixmonitor/test-config.yaml?view=diff&rev=1158&r1=1157&r2=1158
==============================================================================
--- asterisk/team/pabelanger/SWP-2712/tests/mixmonitor/test-config.yaml (original)
+++ asterisk/team/pabelanger/SWP-2712/tests/mixmonitor/test-config.yaml Mon Dec 13 17:09:01 2010
@@ -1,5 +1,4 @@
 testinfo:
-    skip: 'Skip while failures are debugged'
     summary:     'Test MixMonitor and StopMixMonitor applications'
     description: |
         'This test verifies basic functionality of both the MixMonitor




More information about the asterisk-commits mailing list