[asterisk-commits] pabelanger: testsuite/asterisk/trunk r1121 - in /asterisk/trunk/tests: ./ sip...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Dec 9 16:13:16 CST 2010


Author: pabelanger
Date: Thu Dec  9 16:13:12 2010
New Revision: 1121

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1121
Log:
Optimized test and re-enable.

Modified:
    asterisk/trunk/tests/sip_register/run-test
    asterisk/trunk/tests/tests.yaml

Modified: asterisk/trunk/tests/sip_register/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/sip_register/run-test?view=diff&rev=1121&r1=1120&r2=1121
==============================================================================
--- asterisk/trunk/tests/sip_register/run-test (original)
+++ asterisk/trunk/tests/sip_register/run-test Thu Dec  9 16:13:12 2010
@@ -25,6 +25,7 @@
 
 class RegisterTest:
     def __init__(self, argv):
+        self.passed = False
         self.last_step = ""
         self.sipps = {}
 
@@ -44,6 +45,10 @@
         self.log_last_step("Starting Asterisk")
         self.ast1.start()
 
+    def stop_asterisk(self):
+        self.log_last_step("Stopping Asterisk")
+        self.ast1.stop()
+
     def ami_on_connect(self, ami):
         self.log_last_step("Connected to the AMI")
         self.ami = ami
@@ -53,7 +58,7 @@
 
     def ami_login_error(self, ami):
         self.log_last_step("AMI login failed")
-        reactor.callLater(1, self.shutDown)
+        self.stop_reactor()
 
     def ami_login(self):
         self.log_last_step("Logging in to the AMI")
@@ -63,17 +68,21 @@
     def check_register_result(self, ami, event):
         peer = event.get("peer")
         status = event.get("peerstatus")
-
         self.log_last_step("Checking registration result")
-        record = self.sipps[peer]
-        if not record:
+        if not self.sipps[peer]:
             return
 
         if status == "Registered":
-            record['pass'] = True
-            print ("Successful registration for peer %s" % (peer))
+            print "Successful registration for peer %s" % (peer)
+            self.sipps[peer]['pass'] = True
         else:
             print ("Registration for peer %s in state %s" % (peer, status))
+
+        if (self.sipps['SIP/v4-in']['pass'] is True and
+                self.sipps['SIP/v6-in']['pass'] is True):
+            self.stop_reactor()
+            self.passed = True
+            print "SIP registration test passed!"
 
     def start_sipp(self, peer, host, scenario, port):
         self.log_last_step("Starting SIPp scenario %s" % (scenario))
@@ -84,49 +93,29 @@
         print step
         self.lastStep = step
 
-    def shut_down(self):
-        if not self.sipps:
-            self.ast1.stop()
-            return
-
-        passing = True
-
-        for peer, i in self.sipps.iteritems():
-            if i['pass'] == True:
-                continue;
-            else:
-                passing = False
-                print ("Registration failure for peer %s" % (peer))
-            i['process'].terminate()
-
-        self.ast1.stop()
-
-        self.passed = passing
-
-        if self.passed == True:
-            print "SIP registration test passed!"
-        else:
-            print "SIP registration test failed"
-
+    def stop_reactor(self):
+        print "Stopping reactor"
         if reactor.running:
-            print "Stopping reactor"
             reactor.stop()
 
     def run(self):
-        self.start_asterisk()
         self.ami_login()
-        reactor.callLater(5, self.shut_down)
+        reactor.callLater(30, self.stop_reactor)
 
 def main(argv=None):
     if argv is None:
         argv = sys.argv
 
     # Run Register Test
-    register_test = RegisterTest(argv)
+    test = RegisterTest(argv)
+    test.start_asterisk()
     reactor.run()
-    if not register_test.passed:
+    test.stop_asterisk()
+    if not test.passed:
         return 1
     return 0
 
 if __name__ == "__main__":
     sys.exit(main() or 0)
+
+# vim:sw=4:ts=4:expandtab:textwidth=79

Modified: asterisk/trunk/tests/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/tests.yaml?view=diff&rev=1121&r1=1120&r2=1121
==============================================================================
--- asterisk/trunk/tests/tests.yaml (original)
+++ asterisk/trunk/tests/tests.yaml Thu Dec  9 16:13:12 2010
@@ -18,8 +18,7 @@
     - test: 'sip_one_legged_transfer'
     # Temporarily disabled while failures are debugged
     #- test: 'sip_one_legged_transfer_v6'
-    # Temporarily disabled while failures are debugged
-    #- test: 'sip_register'
+    - test: 'sip_register'
     # Temporarily disabled while failures are debugged
     - dir: 'sip'
     - test: 'udptl'




More information about the asterisk-commits mailing list