[asterisk-commits] mjordan: testsuite/asterisk/trunk r5839 - in /asterisk/trunk: lib/python/aste...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Nov 1 13:59:58 CDT 2014


Author: mjordan
Date: Sat Nov  1 13:59:46 2014
New Revision: 5839

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=5839
Log:
tests/rest_api/channels/originate_then_continue: Fix stability problems

In r5818, the ARI test object was modified to close the WebSocket on test
completion. This helps with reference leak detection, as it causes Asterisk
to clean up resources prior to exiting. Unfortunately, a number of tests were
written in a fashion that assumed events would continue to be received even
after the test was told to stop. This test - originate_then_continue - was
one of them.

A large part of the problem is that the ARITestObject (and its derivatives)
will stop the test when all test iterations have completed. That's fine when
the test iterations - and the events that occur within them - comprise the
entire test. If a test has events outside of that, the test is highly likely
to fail, as stopping the test now closes the WebSocket.

This updates the test object with a new parameter, stop-on-end, that allows
a test to not end the test when all iterations are done. The test - using
pluggable modules - can then stop the test when it wants.

Modified:
    asterisk/trunk/lib/python/asterisk/ari.py
    asterisk/trunk/sample-yaml/ari-config.yaml.sample
    asterisk/trunk/tests/rest_api/channels/originate_then_continue/channel_originate.py
    asterisk/trunk/tests/rest_api/channels/originate_then_continue/test-config.yaml

Modified: asterisk/trunk/lib/python/asterisk/ari.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/ari.py?view=diff&rev=5839&r1=5838&r2=5839
==============================================================================
--- asterisk/trunk/lib/python/asterisk/ari.py (original)
+++ asterisk/trunk/lib/python/asterisk/ari.py Sat Nov  1 13:59:46 2014
@@ -154,7 +154,7 @@
             test_config = {}
 
         self.iterations = test_config.get('test-iterations')
-
+        self.stop_on_end = test_config.get('stop-on-end', True)
         self.test_iteration = 0
         self.channels = []
 
@@ -211,8 +211,10 @@
             return
 
         if self.test_iteration == len(self.iterations):
-            LOGGER.info("All iterations executed; stopping")
-            self.stop_reactor()
+            LOGGER.info("All iterations executed")
+            if self.stop_on_end:
+                LOGGER.info("Stopping test")
+                self.stop_reactor()
             return
 
         iteration = self.iterations[self.test_iteration]

Modified: asterisk/trunk/sample-yaml/ari-config.yaml.sample
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/sample-yaml/ari-config.yaml.sample?view=diff&rev=5839&r1=5838&r2=5839
==============================================================================
--- asterisk/trunk/sample-yaml/ari-config.yaml.sample (original)
+++ asterisk/trunk/sample-yaml/ari-config.yaml.sample Sat Nov  1 13:59:46 2014
@@ -23,6 +23,11 @@
     # This is a comma seperated list of applications to connect for.
     # If not provided, default is 'testsuite'
     apps: foo-test
+
+    # If True, the test will be automatically stopped when all test iterations
+    # specified by test-iterations have completed. If set to False, the test will
+    # continue to run and must be stopped by another mechanism. Default is True.
+    stop-on-end: False
 
     # Define the channels to create for the test. If not specified, a single Local
     # channel will be created to s at default, tied to the Echo application. Channels

Modified: asterisk/trunk/tests/rest_api/channels/originate_then_continue/channel_originate.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/channels/originate_then_continue/channel_originate.py?view=diff&rev=5839&r1=5838&r2=5839
==============================================================================
--- asterisk/trunk/tests/rest_api/channels/originate_then_continue/channel_originate.py (original)
+++ asterisk/trunk/tests/rest_api/channels/originate_then_continue/channel_originate.py Sat Nov  1 13:59:46 2014
@@ -10,6 +10,9 @@
 
 LOGGER = logging.getLogger(__name__)
 
+DESTROYED_EVENTS = 0
+
+
 def on_kickoff_start(ari, event, test_object):
     LOGGER.debug("on_kickoff_start(%r)" % event)
     ari.post('channels', endpoint='Local/1000 at default', app='testsuite',
@@ -17,8 +20,12 @@
     ari.delete('channels', event['channel']['id'])
     return True
 
+
 def on_channel_destroyed(ari, event, test_object):
+    global DESTROYED_EVENTS
+
     LOGGER.debug("on_channel_destroyed(%r)" % event)
-    if event['channel']['id'] == 'continue_guy':
+    DESTROYED_EVENTS += 1
+    if DESTROYED_EVENTS == 2:
         test_object.stop_reactor()
     return True

Modified: asterisk/trunk/tests/rest_api/channels/originate_then_continue/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/rest_api/channels/originate_then_continue/test-config.yaml?view=diff&rev=5839&r1=5838&r2=5839
==============================================================================
--- asterisk/trunk/tests/rest_api/channels/originate_then_continue/test-config.yaml (original)
+++ asterisk/trunk/tests/rest_api/channels/originate_then_continue/test-config.yaml Sat Nov  1 13:59:46 2014
@@ -9,12 +9,16 @@
     add-test-to-search-path: True
     test-object:
         typename: ari.AriTestObject
+        config-section: test-config
     modules:
         -   config-section: ari-config
             typename: ari.WebSocketEventModule
 
         -   config-section: ami-config
             typename: ami.AMIEventModule
+
+test-config:
+    stop-on-end: False
 
 ari-config:
     apps: testsuite




More information about the asterisk-commits mailing list