[asterisk-commits] mjordan: testsuite/asterisk/trunk r5993 - /asterisk/trunk/lib/python/asterisk/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Nov 22 21:37:22 CST 2014


Author: mjordan
Date: Sat Nov 22 21:37:11 2014
New Revision: 5993

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=5993
Log:
asterisk: Fix timeout issues introduced by r5942

When the valgrind patch was merged for r5942, it unilaterally increased the
timeouts for the callback sequence during an Asterisk shutdown. When we
shutdown Asterisk, we:
* Call stop gracefully
* Wait a bit, then call stop now
* Wait a bit, then kill Asterisk

The wait times for killing Asterisk was increased from 5 seconds to 200
seconds. For tests that currently KILL Asterisk, this made them run
inordinately long. It also increased unilaterally the 'core wait fullybooted'
timeout.

This patch restores the regular timeouts when VALGRIND_ENABLED is not detected.

Modified:
    asterisk/trunk/lib/python/asterisk/asterisk.py

Modified: asterisk/trunk/lib/python/asterisk/asterisk.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/asterisk.py?view=diff&rev=5993&r1=5992&r2=5993
==============================================================================
--- asterisk/trunk/lib/python/asterisk/asterisk.py (original)
+++ asterisk/trunk/lib/python/asterisk/asterisk.py Sat Nov 22 21:37:11 2014
@@ -231,6 +231,9 @@
         self.astetcdir = ""
         self.original_astmoddir = ""
 
+        valgrind_env = os.getenv("VALGRIND_ENABLE") or ""
+        self.valgrind_enabled = True if "true" in valgrind_env else False
+
         if base is not None:
             self.base = base
         else:
@@ -332,8 +335,9 @@
         def __wait_fully_booted_error(cli_command):
             """Errback for CLI command waitfullybooted"""
 
-            if time.time() - self.__start_asterisk_time > 90:
-                msg = "Asterisk core waitfullybooted for %s failed" % self.host 
+            timeout = 90 if self.valgrind_enabled else 5
+            if time.time() - self.__start_asterisk_time > timeout:
+                msg = "Asterisk core waitfullybooted for %s failed" % self.host
                 LOGGER.error(msg)
                 self._start_deferred.errback(Exception(msg))
             else:
@@ -357,7 +361,6 @@
                 cmd = [valgrind_path] + cmd
             else:
                 LOGGER.error('Valgrind not found')
-
 
         # Make the start/stop deferreds - this method will return
         # the start deferred, and pass the stop deferred to the AsteriskProtocol
@@ -459,11 +462,13 @@
                         "Asterisk %s stopped prematurely" % self.host)
             except defer.AlreadyCalledError:
                 LOGGER.warning("Asterisk %s stop deferred already called" %
-                    self.host)
+                               self.host)
         else:
             # Schedule a kill. If we don't gracefully shut down Asterisk, this
             # will ensure that the test is stopped.
-            self._stop_cancel_tokens.append(reactor.callLater(200, __send_kill))
+            sched_time = 200 if self.valgrind_enabled else 5
+            self._stop_cancel_tokens.append(reactor.callLater(sched_time,
+                                            __send_kill))
 
             # Start by asking to stop gracefully.
             __send_stop_gracefully()




More information about the asterisk-commits mailing list