[svn-commits] mjordan: testsuite/asterisk/trunk r2507 - in /asterisk/trunk: ./ lib/python/a...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Oct 11 12:04:21 CDT 2011


Author: mjordan
Date: Tue Oct 11 12:04:14 2011
New Revision: 2507

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=2507
Log:
Added test execution modes to the test suite

This change adds the ability for a test configuration to be defined
at a global level, enabling or disabling features for all tests that
are executed.  This global information is shared with all tests that
inherit from the python TestCase class.

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

Added:
    asterisk/trunk/lib/python/asterisk/ChannelTestCondition.py   (with props)
    asterisk/trunk/test-config.yaml   (with props)
Modified:
    asterisk/trunk/README.txt
    asterisk/trunk/lib/python/asterisk/FdTestCondition.py
    asterisk/trunk/lib/python/asterisk/TestCase.py
    asterisk/trunk/lib/python/asterisk/TestConditions.py
    asterisk/trunk/lib/python/asterisk/TestConfig.py
    asterisk/trunk/runtests.py
    asterisk/trunk/tests/apps/voicemail/authenticate_extensions/run-test
    asterisk/trunk/tests/apps/voicemail/authenticate_extensions/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/authenticate_invalid_mailbox/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/authenticate_invalid_password/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/authenticate_nominal/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_callback/configs/ast1/extensions.conf
    asterisk/trunk/tests/apps/voicemail/check_voicemail_callback/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_delete/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_dialout/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_envelope/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_forward/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_forward_hangup/configs/ast2/extensions.conf
    asterisk/trunk/tests/apps/voicemail/check_voicemail_forward_hangup/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_forward_with_prepend/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user_hangup/configs/ast2/extensions.conf
    asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user_hangup/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_nominal/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_options_change_password/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_options_record_busy/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_options_record_name/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_options_record_temp/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_options_record_unavail/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_reply/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_while_leaving_msg/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/func_vmcount/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_contexts/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_external_notification/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_forwarding/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_forwarding_auto_urgent/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_priority/test-config.yaml

Modified: asterisk/trunk/README.txt
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/README.txt?view=diff&rev=2507&r1=2506&r2=2507
==============================================================================
--- asterisk/trunk/README.txt (original)
+++ asterisk/trunk/README.txt Tue Oct 11 12:04:14 2011
@@ -279,13 +279,86 @@
 #
 # Example test configuration file - test-config.yaml
 #
-# All elements are required unless explicitly noted as OPTIONAL
+# All elements are required unless explicitly noted as OPTIONAL.  If marked
+# GLOBAL, those elements are only processed if they exist in the top level
+# test-config.yaml file, which applies global options across the test.
 #
 
-# The testinfo section contains information that describes the purpose of the
-# test.
+# The global settings section, which defines which test configuration to execute
+# and other non-test specific information
+global-settings: # GLOBAL
+    # The active test configuration.  The value must match a subsequent key
+    # in this file, which defines the global settings to apply to the test execution
+    # run.
+    test-configuration: config-pessimistic # GLOBAL
+
+    # The following sequence defines for any test configuration the available pre-
+    # and post-test conditions.  The 'name' field specifies how the test configurations
+    # refer to the pre- and post-test conditions in order to activate them.
+    condition-definitions: # GLOBAL
+            -
+                name: 'threads'
+                # A pre-test condition, which specifies that the object will be evaluated
+                # prior to test execution
+                pre:
+                    # The fully qualified Python typename of the object to create using
+                    # introspection
+                    typename: 'asterisk.ThreadTestCondition.ThreadPreTestCondition'
+                post:
+                    typename: 'asterisk.ThreadTestCondition.ThreadPostTestCondition'
+                    # The fully qualified Python typename of the object to pass to the evaluate
+                    # function of this object
+                    related-type: 'asterisk.ThreadTestCondition.ThreadPreTestCondition'
+            -
+                name: 'sip-dialogs'
+                pre:
+                    typename: 'asterisk.SipDialogTestCondition.SipDialogPreTestCondition'
+                post:
+                    typename: 'asterisk.SipDialogTestCondition.SipDialogPostTestCondition'
+            -
+                name: 'locks'
+                pre:
+                    typename: 'asterisk.LockTestCondition.LockTestCondition'
+                post:
+                    typename: 'asterisk.LockTestCondition.LockTestCondition'
+            -
+                name: 'file-descriptors'
+                pre:
+                    typename: 'asterisk.FdTestCondition.FdPreTestCondition'
+                post:
+                    typename: 'asterisk.FdTestCondition.FdPostTestCondition'
+                    related-type: 'asterisk.FdTestCondition.FdPreTestCondition'
+            -
+                name: 'channels'
+                pre:
+                    typename: 'asterisk.ChannelTestCondition.ChannelTestCondition'
+                post:
+                    typename: 'asterisk.ChannelTestCondition.ChannelTestCondition'
+
+# A global test definition.  This name can be anything, but must be referenced
+# by the global-settings.test-configuration key.
+config-pessimistic: # GLOBAL
+    # A list of tests to explicitly exclude from execution.  This overrides the
+    # test listsing in the tests.yaml files.
+    exclude-tests: # GLOBAL
+        # The name of a test to exclude.  Name matching is done using the Python
+        # in operator.
+        - 'authenticate_invalid_password'
+    properties:
+        # The test conditions to apply to all tests.  See specific configuration
+        # information for the test conditions in the individual test configuration
+        # section below.
+        testconditions:
+            - name: 'threads'
+            - name: 'sip-dialogs'
+            - name: 'locks'
+            - name: 'file-descriptors'
+            - name: 'channels'
+
+# The testinfo section contains information that describes the purpose of an
+# individual test
 testinfo:
-    skip : 'Breif reason for skipping test' # OPTIONAL
+    skip : 'Brief reason for skipping test' # OPTIONAL
     summary     : 'Put a short one liner summary of the test here'
     issues      : |
         # List of issue numbers associated with this test
@@ -300,6 +373,7 @@
 # dependencies for this test.
 properties:
     minversion : '1.4' # minimum Asterisk version compatible with this test
+    buildoption : 'TEST_FRAMEWORK' # OPTIONAL - Asterisk compilation flag
     maxversion : '1.8' # OPTIONAL
     dependencies : |   # OPTIONAL
         # List dependencies that must be met for this test to run
@@ -312,6 +386,11 @@
         # import a module by this name to determine whether the dependency is
         # met.
         - python : 'yaml'
+
+        # A 'module' dependency is an Asterisk module that must be loaded by
+        # Asterisk in order for this test to execute.  If the module is not loaded,
+        # the test will not execute.
+        - module : 'app_dial'
 
         # 'custom' dependency can be anything.  Checking for this dependency is
         # done by calling a corresponding method in the Dependency class in
@@ -319,7 +398,61 @@
         # depend_ipv6() method is called to determine if the dependency is met.
         - custom : 'ipv6'
         - custom : 'fax'
-
+    testconditions: # OPTIONAL
+        #
+        # List of overrides for pre-test and post-test conditions.  If a condition is
+        # defined for a test, the configuration of that condition in the test overrides
+        # the setting defined in the global test configuration file.
+        #
+        -   # Check for thread usage in Asterisk.  Any threads present in Asterisk after test
+            # execution - and any threads that were detected prior to test execution
+            # that are no longer present - will be flagged as a test error.
+            name: 'threads'
+            #
+            # Disable execution of this condition.  This setting applies to any defined condition.
+            # Any other value but 'False' will result in the condition being executed.
+            enabled: 'False'
+            #
+            # Execute the condition, but expect the condition to fail
+            expectedResult: 'Fail'
+            #
+            # The thread test condition allows for certain detected threads to be
+            # ignored.  This is a list of the thread names, as reported by the CLI
+            # command 'core show threads'
+            ignoredThreads:
+                - 'netconsole'
+                - 'pbx_thread'
+        #
+        -   # Check for SIP dialog usage.  This looks for any SIP dialogs present
+            # in the system before and after a run; if any are present and are not
+            # scheduled for destruction, an error is raised.
+            name: 'sip-dialogs'
+            #
+            # In addition to checking for scheduled destruction, a test can request that
+            # certain entries should appear in the SIP history.  If the entries do not
+            # appear, an error is raised.
+            sipHistoryRequirements:
+                - 'NewChan'
+                - 'Hangup'
+        #
+        -   # Check for held locks in Asterisk after test execution.  A lock is determined to
+            # be in potential error if threads are detected holding mutexes and waiting on
+            # other threads that are also holding mutexes.
+            name: 'locks'
+        #
+        -   # Check for active channels in Asterisk.  If active channels are detected, flag
+            # an error
+            name: 'channels'
+            #
+            # The number of allowed active channels that can exist when the condition is checked.
+            # If the number of channels detected is greater than this value, an error is raised.
+            # By default, this value is 0.
+            allowedchannels: 1
+        #
+        -   # Check for active file descriptors in Asterisk.  File descriptors detected before
+            # test execution are tracked throughout the test; if any additional file descriptors
+            # after test execution are detected, the test condition fails.
+            name: 'file-descriptors'
 
 
 --------------------------------------------------------------------------------

Added: asterisk/trunk/lib/python/asterisk/ChannelTestCondition.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/ChannelTestCondition.py?view=auto&rev=2507
==============================================================================
--- asterisk/trunk/lib/python/asterisk/ChannelTestCondition.py (added)
+++ asterisk/trunk/lib/python/asterisk/ChannelTestCondition.py Tue Oct 11 12:04:14 2011
@@ -1,0 +1,49 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2011, Digium, Inc.
+Matt Jordan <mjordan at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import logging
+import logging.config
+import unittest
+
+from TestConditions import TestCondition
+
+logger = logging.getLogger(__name__)
+
+class ChannelTestCondition(TestCondition):
+    """
+    Test condition that checks for the existance of channels.  If channels
+    are detected and the number of active channels is greater than the
+    configured amount, an error is raised.
+
+    By default, the number of allowed active channels is 0.
+    """
+
+    def __init__(self, test_config):
+        super(ChannelTestCondition, self).__init__(test_config)
+
+        self.allowed_channels = 0
+        if ('allowedchannels' in test_config.config):
+            self.allowed_channels = test_config.config['allowedchannels']
+
+    def evaluate(self, related_test_condition = None):
+        for ast in self.ast:
+            """ For logging / debug purposes, do a full core show channels """
+            channel_lines = ast.cli_exec('core show channels')
+            channel_tokens = channel_lines.strip().split('\n')
+            active_channels = 0
+            for token in channel_tokens:
+                if 'active channels' in token:
+                    active_channel_tokens = token.partition(' ')
+                    active_channels = int(active_channel_tokens[0].strip())
+            if active_channels > self.allowed_channels:
+                super(ChannelTestCondition, self).failCheck(
+                    'Detected number of active channels %d is greater than the allowed %d on Asterisk %s' % (active_channels, self.allowed_channels, ast.host))
+        """ Set to pass if we haven't detected any failures """
+        super(ChannelTestCondition, self).passCheck()
+

Propchange: asterisk/trunk/lib/python/asterisk/ChannelTestCondition.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/lib/python/asterisk/ChannelTestCondition.py
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/lib/python/asterisk/ChannelTestCondition.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/trunk/lib/python/asterisk/FdTestCondition.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/FdTestCondition.py?view=diff&rev=2507&r1=2506&r2=2507
==============================================================================
--- asterisk/trunk/lib/python/asterisk/FdTestCondition.py (original)
+++ asterisk/trunk/lib/python/asterisk/FdTestCondition.py Tue Oct 11 12:04:14 2011
@@ -51,12 +51,29 @@
             return
 
         lines = ast.cli_exec("core show fd")
+        if 'No such command' in lines:
+            return
+
         """ Trim off the first and last lines """
         lines = lines[lines.find('\n'):].strip()
         lines = lines[:lines.find("Asterisk ending")].strip()
         line_tokens = lines.split('\n')
         fds = []
         for line in line_tokens:
+            """
+            chan_sip is going to create sockets for the active channels and won't close them until
+            the dialog is reclaimed - 32 seconds after the test.  We ignore the UDP socket file
+            descriptors because of this.
+            """
+            if 'socket(PF_INET,SOCK_DGRAM,"udp")' in line:
+                logger.debug("Ignoring created UDP socket: " + line)
+                continue
+            """
+            If we have MALLOC_DEBUG on and are writing out to the mmlog, ignore
+            """
+            if '__ast_mm_init' in line:
+                logger.debug("Ignoring malloc debug: " + line)
+                continue
             fd = FileDescriptor(line)
             if fd.number != -1:
                 logger.debug("Tracking %d [%s]", fd.number, fd.info)

Modified: asterisk/trunk/lib/python/asterisk/TestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/TestCase.py?view=diff&rev=2507&r1=2506&r2=2507
==============================================================================
--- asterisk/trunk/lib/python/asterisk/TestCase.py (original)
+++ asterisk/trunk/lib/python/asterisk/TestCase.py Tue Oct 11 12:04:14 2011
@@ -46,7 +46,8 @@
         self.defaultLogLevel = "WARN"
         self.defaultLogFileName = "logger.conf"
         self.timeoutId = None
-        self.test_config = TestConfig(self.test_name)
+        self.global_config = TestConfig(os.getcwd())
+        self.test_config = TestConfig(self.test_name, self.global_config)
         self.testStateController = None
 
         """ Set up logging """
@@ -72,7 +73,19 @@
         Register pre and post-test conditions.  Note that we have to first register condition checks
         without related conditions, so that those that have dependencies can find them
         """
+        self.global_conditions = self.global_config.get_conditions()
         self.conditions = self.test_config.get_conditions()
+
+        """ If there are no global conditions return """
+        if (len(self.global_conditions) == 0):
+            return
+
+        """ Get those global conditions that are not in the self conditions """
+        for g in self.global_conditions:
+            disallowed = [i for i in self.conditions if i[0].getName() == g[0].getName() and i[1] == g[1]]
+            if (len(disallowed) == 0):
+                self.conditions.append(g)
+
         for c in self.conditions:
             """ c is a 3-tuple of object, pre-post type, and related name """
             if (c[2] == ""):

Modified: asterisk/trunk/lib/python/asterisk/TestConditions.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/TestConditions.py?view=diff&rev=2507&r1=2506&r2=2507
==============================================================================
--- asterisk/trunk/lib/python/asterisk/TestConditions.py (original)
+++ asterisk/trunk/lib/python/asterisk/TestConditions.py Tue Oct 11 12:04:14 2011
@@ -121,13 +121,13 @@
             if (check[0].check_build_options()):
                 for ast in self.__ast:
                     check[0].register_asterisk_instance(ast)
-
-                logger.debug("Evaluating %s" % check[0].getName())
-                if (check[1] != None):
-                    check[0].evaluate(check[1])
-                else:
-                    check[0].evaluate()
-                self.__check_observers(check[0])
+                if (check[0].getEnabled()):
+                    logger.debug("Evaluating %s" % check[0].getName())
+                    if (check[1] != None):
+                        check[0].evaluate(check[1])
+                    else:
+                        check[0].evaluate()
+                    self.__check_observers(check[0])
 
     def __check_observers(self, test_condition):
         for observerTuple in self.__observers:
@@ -141,6 +141,7 @@
         if (test_condition.getStatus() == 'Inconclusive'):
             logger.warning(test_condition)
         elif (test_condition.getStatus() == 'Failed'):
+            logger.info(str(test_condition.pass_expected))
             if test_condition.pass_expected:
                 logger.error(test_condition)
             else:
@@ -169,6 +170,7 @@
         self.__testStatus = TestStatuses.Inconclusive
         self.ast = []
         self.build_options = []
+        self.__enabled = test_config.enabled
         self.pass_expected = test_config.passExpected
 
     def __str__(self):
@@ -229,6 +231,12 @@
         """
         pass
 
+    def getEnabled(self):
+        """
+        True if the condition is enabled and should run, false otherwise
+        """
+        return self.__enabled
+
     def getName(self):
         """
         Return the name of the test condition

Modified: asterisk/trunk/lib/python/asterisk/TestConfig.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/TestConfig.py?view=diff&rev=2507&r1=2506&r2=2507
==============================================================================
--- asterisk/trunk/lib/python/asterisk/TestConfig.py (original)
+++ asterisk/trunk/lib/python/asterisk/TestConfig.py Tue Oct 11 12:04:14 2011
@@ -31,27 +31,30 @@
     object that derives from TestCondition based on that configuration
     """
 
-    def __init__(self, config):
-        """
-        Construct a new test condition from a config sequence constructed
-        from the test-config.yaml file
-        """
-        self.classTypeName = ""
+    def __init__(self, config, definition, pre_post_type):
+        """
+        Construct a new test condition
+
+        config - the test condition specific configuration, from a test-config.yaml file
+        definition - the global type information, obtained from the global test-config.yaml file
+        pre_post_type - 'pre' or 'post', depending on the type to build
+        """
         self.passExpected = True
-        self.type = ""
         self.relatedCondition = ""
-        if 'name' in config:
-            self.classTypeName = config['name']
+        self.type = pre_post_type.upper().strip()
+        self.classTypeName = definition[pre_post_type.lower()]['typename']
+        self.enabled = True
+        if 'related-type' in definition[pre_post_type.lower()]:
+            self.relatedCondition = definition[pre_post_type.lower()]['related-type'].strip()
+        if 'enabled' in config:
+            if config ['enabled'].upper().strip() == 'FALSE':
+                self.enabled = False
         if 'expectedResult' in config:
             try:
                 self.passExpected = not (config["expectedResult"].upper().strip() == "FAIL")
             except:
                 self.passExpected = False
                 print "ERROR: '%s' is not a valid value for expectedResult" % config["expectedResult"]
-        if 'type' in config:
-            self.type = config['type'].upper().strip()
-        if 'relatedCondition' in config:
-            self.relatedCondition = config['relatedCondition'].strip()
         """ Let non-standard configuration items be obtained from the config object """
         self.config = config
 
@@ -222,7 +225,7 @@
     by that tests test.yaml file.
     """
 
-    def __init__(self, test_name):
+    def __init__(self, test_name, global_test_config = None):
         """
         Create a new TestConfig
 
@@ -240,12 +243,40 @@
         self.minversion_check = False
         self.deps = []
         self.expectPass = True
-
+        self.excludedTests = []
+        self.test_configuration = "(none)"
+        self.condition_definitions = []
+        self.global_test_config = global_test_config
         self.__parse_config()
+
+    def __process_global_settings(self):
+        """
+        These settings only apply to the 'global' test-yaml config file.  If we were passed in
+        the global settings, grab what we need and return
+        """
+        if self.global_test_config != None:
+            self.condition_definitions = self.global_test_config.condition_definitions
+            return
+
+        if "global-settings" in self.config:
+            global_settings = self.config['global-settings']
+            if "condition-definitions" in global_settings:
+                self.condition_definitions = global_settings['condition-definitions']
+            if "test-configuration" in global_settings:
+                self.test_configuration = global_settings['test-configuration']
+                if self.test_configuration in self.config:
+                    self.config = self.config[self.test_configuration]
+
+                    if self.config != None and 'exclude-tests' in self.config:
+                        self.excludedTests = self.config['exclude-tests']
+                else:
+                    print "WARNING - test configuration [%s] not found in config file" % self.test_configuration
 
     def __process_testinfo(self):
         self.summary = "(none)"
         self.description = "(none)"
+        if self.config == None:
+            return
         if "testinfo" not in self.config:
             return
         testinfo = self.config["testinfo"]
@@ -259,6 +290,8 @@
 
     def __process_properties(self):
         self.minversion = AsteriskVersion("1.4")
+        if self.config == None:
+            return
         if "properties" not in self.config:
             return
         properties = self.config["properties"]
@@ -303,6 +336,7 @@
                     self.test_name
             return
 
+        self.__process_global_settings()
         self.__process_testinfo()
         self.__process_properties()
 
@@ -316,12 +350,21 @@
             2: The name of the related condition that this one depends on
         """
         conditions = []
-        if not self.config:
+        conditions_temp = []
+        if not self.config or 'properties' not in self.config or 'testconditions' not in self.config['properties']:
             return conditions
 
-        conditionsTemp = [TestConditionConfig(c) for c in self.config["properties"].get("testconditions") or [] ]
-
-        for cond in conditionsTemp:
+        for c in self.config['properties'].get('testconditions'):
+            matched_definition = [d for d in self.condition_definitions if d['name'] == c['name']]
+            if len(matched_definition) != 1:
+                print "Unknown or too many matches for condition: " + c['name']
+            else:
+                pre_cond = TestConditionConfig(c, matched_definition[0], "Pre")
+                post_cond = TestConditionConfig(c, matched_definition[0], "Post")
+                conditions_temp.append(pre_cond)
+                conditions_temp.append(post_cond)
+
+        for cond in conditions_temp:
             c = cond.make_condition(), cond.get_type(), cond.get_related_condition()
             conditions.append(c)
 

Modified: asterisk/trunk/runtests.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/runtests.py?view=diff&rev=2507&r1=2506&r2=2507
==============================================================================
--- asterisk/trunk/runtests.py (original)
+++ asterisk/trunk/runtests.py Tue Oct 11 12:04:14 2011
@@ -99,6 +99,15 @@
                         except shutil.Error, err:
                             for e in err:
                                 print "Exception occurred while archiving logs from %s to %s: %s" % (e[0], e[1], e[2])
+                    except IOError, io:
+                        """ Don't let an IOError blow out the whole test run """
+                        print "IOError Exception occured while archiving logs"
+                        try:
+                            (code, message) = io
+                        except:
+                            code = 0
+                            message = io
+                        print "ErrNo: %d - %s" % code, message
             else:
                 break
             i += 1
@@ -116,10 +125,13 @@
 
         self.tests = []
         self.tests = self._parse_test_yaml("tests", ast_version)
-
+        self.global_config = self._parse_global_config()
         self.total_time = 0.0
         self.total_count = 0
         self.total_failures = 0
+
+    def _parse_global_config(self):
+        return TestConfig(os.getcwd())
 
     def _parse_test_yaml(self, test_dir, ast_version):
         tests = []
@@ -189,6 +201,14 @@
                     print "--- --> Dependency: %s - %s" % (d.name, str(d.met))
                 print
                 continue
+            if self.global_config != None:
+                exclude = False
+                for excluded in self.global_config.excludedTests:
+                    if excluded in t.test_name:
+                        print "--- ---> Excluded test: %s" % excluded
+                        exclude = True
+                if exclude:
+                    continue
 
             print "--> Running test '%s' ...\n" % t.test_name
 

Added: asterisk/trunk/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/test-config.yaml?view=auto&rev=2507
==============================================================================
--- asterisk/trunk/test-config.yaml (added)
+++ asterisk/trunk/test-config.yaml Tue Oct 11 12:04:14 2011
@@ -1,0 +1,93 @@
+# This configuration file defines global settings for test execution.
+# The test suite will attempt to apply these settings to all tests that
+# support them.
+
+# Global settings
+global-settings:
+    # The active test configuration.  The value must match a subsequent key
+    # in this file, which defines the global settings to apply to the test execution
+    # run.
+    test-configuration: config-fast
+
+    # The following sequence defines for any test configuration the available pre-
+    # and post-test conditions.  The 'name' field specifies how the test configurations
+    # refer to the pre- and post-test conditions in order to activate them.
+    condition-definitions:
+            -
+                name: 'threads'
+                pre:
+                    typename: 'asterisk.ThreadTestCondition.ThreadPreTestCondition'
+                post:
+                    typename: 'asterisk.ThreadTestCondition.ThreadPostTestCondition'
+                    related-type: 'asterisk.ThreadTestCondition.ThreadPreTestCondition'
+            -
+                name: 'sip-dialogs'
+                pre:
+                    typename: 'asterisk.SipDialogTestCondition.SipDialogPreTestCondition'
+                post:
+                    typename: 'asterisk.SipDialogTestCondition.SipDialogPostTestCondition'
+            -
+                name: 'locks'
+                pre:
+                    typename: 'asterisk.LockTestCondition.LockTestCondition'
+                post:
+                    typename: 'asterisk.LockTestCondition.LockTestCondition'
+            -
+                name: 'file-descriptors'
+                pre:
+                    typename: 'asterisk.FdTestCondition.FdPreTestCondition'
+                post:
+                    typename: 'asterisk.FdTestCondition.FdPostTestCondition'
+                    related-type: 'asterisk.FdTestCondition.FdPreTestCondition'
+            -
+                name: 'channels'
+                pre:
+                    typename: 'asterisk.ChannelTestCondition.ChannelTestCondition'
+                post:
+                    typename: 'asterisk.ChannelTestCondition.ChannelTestCondition'
+
+# Exclude all long-running tests (greater than one minute)
+config-fast:
+    exclude-tests:
+        - 'authenticate_invalid_password'
+        - 'check_voicemail_callback'
+        - 'check_voicemail_delete'
+        - 'check_voicemail_dialout'
+        - 'check_voicemail_envelope'
+        - 'check_voicemail_new_user'
+        - 'check_voicemail_nominal'
+        - 'check_voicemail_reply'
+        - 'leave_voicemail_external_notification'
+        - 'leave_voicemail_nominal'
+        - 'gateway_g711_t38'
+        - 'gateway_mix1'
+        - 'gateway_mix2'
+        - 'gateway_mix3'
+        - 'gateway_mix4'
+        - 'gateway_native_t38'
+        - 'gateway_native_t38_ced'
+        - 'gateway_no_t38'
+        - 'gateway_t38_g711'
+        - 'gateway_timeout1'
+        - 'gateway_timeout2'
+        - 'gateway_timeout3'
+        - 'gateway_timeout4'
+        - 'gateway_timeout5'
+
+# Include all tests that can run under the installed version of Asterisk.
+# It is included merely for completeness.
+config-standard:
+
+# This test enables the pre- and post-test condition checking on all tests
+# that support it.  Individual tests can override the behavior of a pre-
+# and post-test in their test-config.yaml files.
+config-pessimistic:
+    properties:
+        testconditions:
+            - name: 'threads'
+            - name: 'sip-dialogs'
+            - name: 'locks'
+            - name: 'file-descriptors'
+            - name: 'channels'
+
+

Propchange: asterisk/trunk/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/trunk/tests/apps/voicemail/authenticate_extensions/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/authenticate_extensions/run-test?view=diff&rev=2507&r1=2506&r2=2507
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/authenticate_extensions/run-test (original)
+++ asterisk/trunk/tests/apps/voicemail/authenticate_extensions/run-test Tue Oct 11 12:04:14 2011
@@ -28,6 +28,7 @@
 
         self.reactor_timeout = 60
         self.create_asterisk(2)
+        self.pass_results = 0
 
     def ami_connect(self, ami):
         super(AuthenticateExtensions, self).ami_connect(ami)
@@ -55,15 +56,17 @@
             return
 
         if event['result'] == 'pass':
-            self.passed = self.passed and True
+            self.pass_results += 1
+            if self.pass_results == 2:
+                self.passed = True
+                self.stop_reactor()
             logger.info("Received pass result from VMAuthenticate test")
         else:
             logger.warn("VMAuthenticate Failure:")
             logger.warn("result: %s" % (event['result'],))
             logger.warn("error: %s" % (event['status'],))
             self.passed = False
-
-        self.stop_reactor()
+            self.stop_reactor()
 
     def run(self):
         super(AuthenticateExtensions, self).run()

Modified: asterisk/trunk/tests/apps/voicemail/authenticate_extensions/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/authenticate_extensions/test-config.yaml?view=diff&rev=2507&r1=2506&r2=2507
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/authenticate_extensions/test-config.yaml (original)
+++ asterisk/trunk/tests/apps/voicemail/authenticate_extensions/test-config.yaml Tue Oct 11 12:04:14 2011
@@ -6,6 +6,15 @@
 
 properties:
     minversion: '1.8'
+    testconditions:
+        - name: 'threads'
+          ignoredThreads:
+            - 'netconsole'
+            - 'pbx_thread'
+        - name: 'sip-dialogs'
+          sipHistoryRequirements:
+            - 'NewChan'
+            - 'Hangup'
     dependencies:
         - python : 'twisted'
         - python : 'starpy'

Modified: asterisk/trunk/tests/apps/voicemail/authenticate_invalid_mailbox/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/authenticate_invalid_mailbox/test-config.yaml?view=diff&rev=2507&r1=2506&r2=2507
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/authenticate_invalid_mailbox/test-config.yaml (original)
+++ asterisk/trunk/tests/apps/voicemail/authenticate_invalid_mailbox/test-config.yaml Tue Oct 11 12:04:14 2011
@@ -6,6 +6,15 @@
 
 properties:
     minversion: '1.8'
+    testconditions:
+        - name: 'threads'
+          ignoredThreads:
+            - 'netconsole'
+            - 'pbx_thread'
+        - name: 'sip-dialogs'
+          sipHistoryRequirements:
+            - 'NewChan'
+            - 'Hangup'
     dependencies:
         - python : 'twisted'
         - python : 'starpy'

Modified: asterisk/trunk/tests/apps/voicemail/authenticate_invalid_password/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/authenticate_invalid_password/test-config.yaml?view=diff&rev=2507&r1=2506&r2=2507
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/authenticate_invalid_password/test-config.yaml (original)
+++ asterisk/trunk/tests/apps/voicemail/authenticate_invalid_password/test-config.yaml Tue Oct 11 12:04:14 2011
@@ -6,6 +6,15 @@
 
 properties:
     minversion: '1.8'
+    testconditions:
+        - name: 'threads'
+          ignoredThreads:
+            - 'netconsole'
+            - 'pbx_thread'
+        - name: 'sip-dialogs'
+          sipHistoryRequirements:
+            - 'NewChan'
+            - 'Hangup'
     dependencies:
         - python : 'twisted'
         - python : 'starpy'

Modified: asterisk/trunk/tests/apps/voicemail/authenticate_nominal/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/authenticate_nominal/test-config.yaml?view=diff&rev=2507&r1=2506&r2=2507
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/authenticate_nominal/test-config.yaml (original)
+++ asterisk/trunk/tests/apps/voicemail/authenticate_nominal/test-config.yaml Tue Oct 11 12:04:14 2011
@@ -8,31 +8,14 @@
 properties:
     minversion: '1.8'
     testconditions:
-        -
-            name: 'asterisk.ThreadTestCondition.ThreadPreTestCondition'
-            type: 'Pre'
-        -
-            name: 'asterisk.ThreadTestCondition.ThreadPostTestCondition'
-            type: 'Post'
-            ignoredThreads:
-                - 'netconsole'
-                - 'pbx_thread'
-            relatedCondition: 'asterisk.ThreadTestCondition.ThreadPreTestCondition'
-        -
-            name: 'asterisk.SipDialogTestCondition.SipDialogPreTestCondition'
-            type: 'Pre'
-        -
-            name: 'asterisk.SipDialogTestCondition.SipDialogPostTestCondition'
-            type: 'Post'
-            sipHistoryRequirements:
-                - 'NewChan'
-                - 'Hangup'
-        -
-            name: 'asterisk.LockTestCondition.LockTestCondition'
-            type: 'Pre'
-        -
-            name: 'asterisk.LockTestCondition.LockTestCondition'
-            type: 'Post'
+        - name: 'threads'
+          ignoredThreads:
+            - 'netconsole'
+            - 'pbx_thread'
+        - name: 'sip-dialogs'
+          sipHistoryRequirements:
+            - 'NewChan'
+            - 'Hangup'
     dependencies:
         - python : 'twisted'
         - python : 'starpy'

Modified: asterisk/trunk/tests/apps/voicemail/check_voicemail_callback/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/check_voicemail_callback/configs/ast1/extensions.conf?view=diff&rev=2507&r1=2506&r2=2507
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/check_voicemail_callback/configs/ast1/extensions.conf (original)
+++ asterisk/trunk/tests/apps/voicemail/check_voicemail_callback/configs/ast1/extensions.conf Tue Oct 11 12:04:14 2011
@@ -7,7 +7,6 @@

[... 896 lines stripped ...]



More information about the svn-commits mailing list