[asterisk-commits] rmudgett: testsuite/asterisk/trunk r4936 - in /asterisk/trunk/tests/masquerad...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 4 18:09:25 CDT 2014


Author: rmudgett
Date: Fri Apr  4 18:09:15 2014
New Revision: 4936

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4936
Log:
testsuite: Add call setup tracking to masquerade supertest.

* Changed originated calls to use AMI originate instead of CLI originate
so a custom call timeout could be specified.  The number of calls in the
chain could take awhile to setup which the CLI originate might timeout
before all calls in the chain were dialed.

* Call setup is now tracked to so the test can better distinguish when
calls hangup if they were optimizations or timeout hangups.

* Added some helpful test failure diagnosis messages when the reactor is
stopped.

* Added needed debug routines to get "core show locks" output into the
test log.

ASTERISK-22846
Reported by: Matt Jordan

Review: https://reviewboard.asterisk.org/r/3370/

Modified:
    asterisk/trunk/tests/masquerade/configs/ast1/extensions.conf
    asterisk/trunk/tests/masquerade/run-test

Modified: asterisk/trunk/tests/masquerade/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/masquerade/configs/ast1/extensions.conf?view=diff&rev=4936&r1=4935&r2=4936
==============================================================================
--- asterisk/trunk/tests/masquerade/configs/ast1/extensions.conf (original)
+++ asterisk/trunk/tests/masquerade/configs/ast1/extensions.conf Fri Apr  4 18:09:15 2014
@@ -5,6 +5,7 @@
 
 [outgoing]
 exten => _XXXX,1,NoOp(Local channel chain to park call)
+exten => _XXXX,n,UserEvent(dialing,status: EXECUTING ${CHANNEL(name)})
 exten => _XXXX,n,Set(NEXT=$[${EXTEN} - 1])
 exten => _XXXX,n,GotoIf($[${NEXT:1} = 000]?last)
 exten => _XXXX,n,Dial(Local/${NEXT}@outgoing)
@@ -20,11 +21,13 @@
 
 [last_call]
 exten => 8000,1,NoOp(Last call in chain)
+exten => 8000,n,UserEvent(last_call,status: EXECUTING ${CHANNEL(name)})
 exten => 8000,n,Dial(SIP/ast2/last_in_chain,30)
 exten => 8000,n,UserEvent(ast1,status: FAILURE Last call continued in dialplan DIALSTATUS=${DIALSTATUS})
 exten => 8000,n,Hangup()
 
 exten => 9000,1,NoOp(Last call in chain)
+exten => 9000,n,UserEvent(last_call,status: EXECUTING ${CHANNEL(name)})
 exten => 9000,n,Dial(IAX2/ast2/last_in_chain,30)
 exten => 9000,n,UserEvent(ast1,status: FAILURE Last call continued in dialplan DIALSTATUS=${DIALSTATUS})
 exten => 9000,n,Hangup()

Modified: asterisk/trunk/tests/masquerade/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/masquerade/run-test?view=diff&rev=4936&r1=4935&r2=4936
==============================================================================
--- asterisk/trunk/tests/masquerade/run-test (original)
+++ asterisk/trunk/tests/masquerade/run-test Fri Apr  4 18:09:15 2014
@@ -31,8 +31,8 @@
 
         # Set longer timeout than default.
         #
-        # Optimizing out long chains of local channels can
-        # take awhile and they can come in bursts.
+        # Dialing and optimizing out long chains of local channels
+        # can take awhile and they can come in bursts.
         self.reactor_timeout = 60
 
         # Initial call chain parameters.
@@ -49,6 +49,7 @@
             self.base_exten = 9000
 
         # Clear test completion stage flags.
+        self.dialed_count = 0
         self.removed_count = 0
         self.park_retrieved = False
         self.got_AMI_ParkedCall = False
@@ -86,9 +87,15 @@
         logger.info("Initiating test call for a chain length of " + str(self.chain_length))
         exten = self.base_exten + self.chain_length
         if AsteriskVersion() < AsteriskVersion('12'):
-            self.ast[0].cli_originate("Local/" + str(exten) + "@outgoing extension parkme at parked")
-            return
-        self.ast[0].cli_originate("Local/" + str(exten) + "@outgoing extension parkme12 at parked")
+            self.ami[0].originate(channel="Local/" + str(exten) + "@outgoing",
+                context="parked", exten="parkme", priority=1,
+                timeout=900,
+                async=True).addErrback(TestCase.handle_originate_failure)
+            return
+        self.ami[0].originate(channel="Local/" + str(exten) + "@outgoing",
+            context="parked", exten="parkme12", priority=1,
+            timeout=900,
+            async=True).addErrback(TestCase.handle_originate_failure)
 
     # Initiate a call to retrieve the parked call.
     def get_parkedcall(self):
@@ -96,7 +103,10 @@
         tech_prefix = "IAX2/ast1/"
         if self.use_sip_calls:
             tech_prefix = "SIP/ast1/"
-        self.ast[1].cli_originate(tech_prefix + str(self.expected_space) + " extension retrieve at getit")
+        self.ami[1].originate(channel=tech_prefix + str(self.expected_space),
+            context="getit", exten="retrieve", priority=1,
+            timeout=30,
+            async=True).addErrback(TestCase.handle_originate_failure)
 
     # Called when got ParkedCall AMI event
     def evt_parkedcall(self, ami, event):
@@ -143,17 +153,25 @@
         status = event.get("status")
         logger.info("UserEvent: " + str(evt) + " status: " + str(status))
 
-        if evt == "optout":
+        if evt == "dialing":
+            self.dialed_count += 1
+            logger.info("Calls dialed: " + str(self.dialed_count))
+            # Prod reactor timeout
+            self.reset_timeout()
+            return
+        elif evt == "optout":
             self.removed_count += 1
-            logger.info("Calls optimized out: " + str(self.removed_count))
-            # Restart the timeout timer after so many local channels optimize out.
-            #if 0 == self.removed_count % 50:
-            #    self.reset_timeout()
+            logger.info("Calls hungup or optimized out: " + str(self.removed_count))
+            # Prod reactor timeout
             self.reset_timeout()
             self.check_result()
             return
         elif evt == "last_call":
-            if status == "HANGUP":
+            if "EXECUTING" in status:
+                # Prod reactor timeout
+                self.reset_timeout()
+                return
+            elif status == "HANGUP":
                 if self.park_retrieved:
                     return
                 logger.warning("The last call in the chain disconnected too early.")
@@ -198,19 +216,44 @@
         TestCase.run(self)
         self.create_ami_factory(2)
 
+    def send_core_show_locks(self):
+        """Send a core show locks CLI command"""
+        logger.debug('sending core show locks')
+        cli_deferred = self.ast[0].cli_exec("core show locks")
+        cli_deferred.addCallbacks(self.send_core_show_locks_callback)
+
+    def send_core_show_locks_callback(self, cli_command):
+        """Callback handler for the core show locks CLI command output"""
+        logger.info("Output for core show locks:")
+        logger.info(cli_command.output)
+        TestCase.stop_reactor(self)
+        return cli_command
+
     # This is called when we stop the reactor.
     def stop_reactor(self):
         self.test_complete = True
 
+        # Try to interpret results to reduce stupid assumptions
+        # when trying to figure out what went wrong.
+        if self.passed:
+            # Nothing to say about the test passing.
+            pass
+        elif not self.got_AMI_ParkedCall and self.chain_length != self.dialed_count:
+            logger.warning("Only dialed " + str(self.dialed_count) + " calls in chain.")
+        elif not self.got_AMI_ParkedCall:
+            logger.warning("Call did not get parked.")
+        elif self.chain_length != self.removed_count:
+            logger.warning("Only optimized " + str(self.removed_count) + " calls in chain.")
+        elif not self.got_AMI_UnParkedCall:
+            logger.warning("Call did not get retrieved from parking lot.")
+        elif not self.ast1_event or not self.ast2_event:
+            logger.warning("DTMF handshake failed.")
+
         # Get some useful output from the Asterisk instance
         # under test before tearing down in case of problems.
-        self.ast[0].cli_exec("core show locks")
-        # Must do "core show channels" after "core show locks" because
-        # the show channels command is likely to fail if a deadlock
-        # has happened.
-        #self.ast[0].cli_exec("core show channels concise")
-        self.ast[0].cli_exec("core show channels")
-
+        #self.send_core_show_locks()
+
+        # Comment this out when enabling "core show locks"
         TestCase.stop_reactor(self)
 
 




More information about the asterisk-commits mailing list