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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 15 10:41:06 CDT 2011


Author: mjordan
Date: Thu Sep 15 10:41:01 2011
New Revision: 2271

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=2271
Log:
Add SIP dialog pre- and post-test checks; allow for individual configuration of checks

This patch adds a SIP dialog pre- and post-test check.  It also changes the way in which
the test conditions are being configured by having the TestConditionConfig object be
injected into the constructor of the base class TestCondition.  This allows any implementation
to configure itself with its own configuration data.  The test-config.yaml files were
updated to use this mechanism to filter out known 'slightly off-nominal' results 
being exhibited on bamboo.  Some additional cleanup was done as well in existing tests.

(closes issue ASTERISK-18434)

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

Added:
    asterisk/trunk/lib/python/asterisk/SipDialogTestCondition.py
      - copied, changed from r2261, asterisk/team/mjordan/test_conditions/trunk/lib/python/asterisk/SipDialogTestCondition.py
Modified:
    asterisk/trunk/lib/python/asterisk/LockTestCondition.py
    asterisk/trunk/lib/python/asterisk/TestConditions.py
    asterisk/trunk/lib/python/asterisk/TestConfig.py
    asterisk/trunk/lib/python/asterisk/ThreadTestCondition.py
    asterisk/trunk/tests/apps/directory_attendant_exit/run-test
    asterisk/trunk/tests/apps/directory_context_operator_exit/run-test
    asterisk/trunk/tests/apps/directory_operator_exit/run-test
    asterisk/trunk/tests/apps/voicemail/authenticate_nominal/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/configs/ast2/extensions.conf
    asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/check_voicemail_nominal/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/func_vmcount/test-config.yaml
    asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/test-config.yaml

Modified: asterisk/trunk/lib/python/asterisk/LockTestCondition.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/LockTestCondition.py?view=diff&rev=2271&r1=2270&r2=2271
==============================================================================
--- asterisk/trunk/lib/python/asterisk/LockTestCondition.py (original)
+++ asterisk/trunk/lib/python/asterisk/LockTestCondition.py Thu Sep 15 10:41:01 2011
@@ -145,8 +145,8 @@
     is never a good thing.
     """
 
-    def __init__(self):
-        super(LockTestCondition, self).__init__("LockTestCondition")
+    def __init__(self, test_config):
+        super(LockTestCondition, self).__init__(test_config)
         self.locks = []
 
         """ core show locks is dependent on DEBUG_THREADS """
@@ -265,17 +265,26 @@
         lockLines += "=======================================================================\n"
         return lockLines
 
+class TestConfig(object):
+    def __init__(self):
+        """ Values here don't matter much - we just need to have something """
+        self.classTypeName = "asterisk.LockTestCondition.LockTestCondition"
+        self.passExpected = True
+        self.type = "Post"
+        self.relatedCondition = ""
+        self.config = {}
+
 class LockTestConditionUnitTest(unittest.TestCase):
     def test_evaluate_failed(self):
         ast = AstMockObjectFailure()
-        obj = LockTestCondition()
+        obj = LockTestCondition(TestConfig())
         obj.register_asterisk_instance(ast)
         obj.evaluate()
         self.assertEqual(obj.getStatus(), 'Failed')
 
     def test_evaluate_pass(self):
         ast = AstMockObjectPassed()
-        obj = LockTestCondition()
+        obj = LockTestCondition(TestConfig())
         obj.register_asterisk_instance(ast)
         obj.evaluate()
         self.assertEqual(obj.getStatus(), 'Passed')
@@ -283,7 +292,7 @@
     def test_evaluate_multiple(self):
         ast1 = AstMockObjectPassed()
         ast2 = AstMockObjectFailure()
-        obj = LockTestCondition()
+        obj = LockTestCondition(TestConfig())
         obj.register_asterisk_instance(ast1)
         obj.register_asterisk_instance(ast2)
         obj.evaluate()

Copied: asterisk/trunk/lib/python/asterisk/SipDialogTestCondition.py (from r2261, asterisk/team/mjordan/test_conditions/trunk/lib/python/asterisk/SipDialogTestCondition.py)
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/SipDialogTestCondition.py?view=diff&rev=2271&p1=asterisk/team/mjordan/test_conditions/trunk/lib/python/asterisk/SipDialogTestCondition.py&r1=2261&p2=asterisk/trunk/lib/python/asterisk/SipDialogTestCondition.py&r2=2271
==============================================================================
--- asterisk/team/mjordan/test_conditions/trunk/lib/python/asterisk/SipDialogTestCondition.py (original)
+++ asterisk/trunk/lib/python/asterisk/SipDialogTestCondition.py Thu Sep 15 10:41:01 2011
@@ -48,7 +48,9 @@
         for dn in dialogNames:
             logger.debug("Retrieving history for SIP dialog %s" % dn)
             rawHistory = ast.cli_exec("sip show history %s" % dn, True)
-            dialogsHistory[dn] = rawHistory.split('\n')
+            if 'No such SIP Call ID' not in rawHistory:
+                """ dialog got disposed before we could get its history; ignore """
+                dialogsHistory[dn] = rawHistory.split('\n')
 
         return dialogsHistory
 

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=2271&r1=2270&r2=2271
==============================================================================
--- asterisk/trunk/lib/python/asterisk/TestConditions.py (original)
+++ asterisk/trunk/lib/python/asterisk/TestConditions.py Thu Sep 15 10:41:01 2011
@@ -157,19 +157,19 @@
 
     __buildOptions = AsteriskBuildOptions()
 
-    def __init__(self, name):
+    def __init__(self, test_config):
         """
         Initialize a new test condition
 
         Keyword arguments:
-        name -- The name of the condition that is being checked
+        test_config - the test configuration object that defines this Test Condition
         """
         self.failureReasons = []
-        self.__name = name
+        self.__name = test_config.classTypeName
         self.__testStatus = TestStatuses.Inconclusive
         self.ast = []
         self.build_options = []
-        self.pass_expected = True
+        self.pass_expected = test_config.passExpected
 
     def __str__(self):
         """

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=2271&r1=2270&r2=2271
==============================================================================
--- asterisk/trunk/lib/python/asterisk/TestConfig.py (original)
+++ asterisk/trunk/lib/python/asterisk/TestConfig.py Thu Sep 15 10:41:01 2011
@@ -52,6 +52,8 @@
             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
 
     def get_type(self):
         """
@@ -75,9 +77,7 @@
             m = __import__(module)
             for comp in parts[1:]:
                 m = getattr(m, comp)
-            obj = m()
-            if not self.passExpected:
-                obj.pass_expected = False
+            obj = m(self)
             return obj
         return None
 

Modified: asterisk/trunk/lib/python/asterisk/ThreadTestCondition.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/ThreadTestCondition.py?view=diff&rev=2271&r1=2270&r2=2271
==============================================================================
--- asterisk/trunk/lib/python/asterisk/ThreadTestCondition.py (original)
+++ asterisk/trunk/lib/python/asterisk/ThreadTestCondition.py Thu Sep 15 10:41:01 2011
@@ -10,6 +10,7 @@
 import logging
 import logging.config
 from TestConditions import TestCondition
+from version import AsteriskVersion
 
 logger = logging.getLogger(__name__)
 
@@ -21,8 +22,11 @@
     command
     """
 
-    def __init__(self, name):
-        super(ThreadTestCondition, self).__init__(name)
+    __ast_version = AsteriskVersion()
+    __ast_version_10 = AsteriskVersion("10")
+
+    def __init__(self, test_config):
+        super(ThreadTestCondition, self).__init__(test_config)
 
         """
         astThreads is a list of tuples, where the first entry is the host IP of the
@@ -30,6 +34,10 @@
         thread name
         """
         self.astThreads = []
+
+        self.ignoredThreads = []
+        if 'ignoredThreads' in test_config.config:
+            self.ignoredThreads = test_config.config['ignoredThreads']
 
         """ Core show threads is not available if LOW_MEMORY is turned on """
         self.add_build_option("LOW_MEMORY", "0")
@@ -46,10 +54,15 @@
             if not 'threads listed' in line and not 'Asterisk ending' in line:
                 """ get the name and thread ID - strip off the cli_exec / pthread ID """
                 initialPartition = line.partition(' ')
-                initialPartition = initialPartition[2].partition(' ')
+                """
+                In v10 and greater, the result of core show threads introduces the Asterisk thread ID
+                immediately after the pthread ID.  Use that if its available.
+                """
+                if (ThreadTestCondition.__ast_version >= ThreadTestCondition.__ast_version_10):
+                    initialPartition = initialPartition[2].partition(' ')
                 threadId = initialPartition[0]
                 threadName = initialPartition[2].partition(' ')[0]
-                if threadId != "" and threadName != "":
+                if threadId != "" and threadName != "" and threadName not in self.ignoredThreads:
                     logger.debug("Tracking thread %s[%s]" % (threadName, threadId))
                     thread_list.append((threadId, threadName))
 
@@ -64,8 +77,8 @@
     in the system prior to test execution.
     """
 
-    def __init__(self):
-        super(ThreadPreTestCondition, self).__init__("ThreadPreTestCondition")
+    def __init__(self, test_config):
+        super(ThreadPreTestCondition, self).__init__(test_config)
 
     def evaluate(self, related_test_condition = None):
         for ast in self.ast:
@@ -88,8 +101,8 @@
     failure is flagged.
     """
 
-    def __init__(self):
-        super(ThreadPostTestCondition, self).__init__("ThreadPostTestCondition")
+    def __init__(self, test_config):
+        super(ThreadPostTestCondition, self).__init__(test_config)
 
     def evaluate(self, related_test_condition = None):
 

Modified: asterisk/trunk/tests/apps/directory_attendant_exit/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/directory_attendant_exit/run-test?view=diff&rev=2271&r1=2270&r2=2271
==============================================================================
--- asterisk/trunk/tests/apps/directory_attendant_exit/run-test (original)
+++ asterisk/trunk/tests/apps/directory_attendant_exit/run-test Thu Sep 15 10:41:01 2011
@@ -20,10 +20,10 @@
 from asterisk.TestCase import TestCase
 
 class DirectoryTest(TestCase):
-   reactor_timeout = 60
 
    def __init__(self):
       TestCase.__init__(self)
+      self.reactor_timeout = 60
       self.create_asterisk(2)
 
    def ami_connect(self, ami):

Modified: asterisk/trunk/tests/apps/directory_context_operator_exit/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/directory_context_operator_exit/run-test?view=diff&rev=2271&r1=2270&r2=2271
==============================================================================
--- asterisk/trunk/tests/apps/directory_context_operator_exit/run-test (original)
+++ asterisk/trunk/tests/apps/directory_context_operator_exit/run-test Thu Sep 15 10:41:01 2011
@@ -20,10 +20,10 @@
 from asterisk.TestCase import TestCase
 
 class DirectoryTest(TestCase):
-   reactor_timeout = 60
 
    def __init__(self):
       TestCase.__init__(self)
+      self.reactor_timeout = 60
       self.create_asterisk(2)
 
    def ami_connect(self, ami):

Modified: asterisk/trunk/tests/apps/directory_operator_exit/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/directory_operator_exit/run-test?view=diff&rev=2271&r1=2270&r2=2271
==============================================================================
--- asterisk/trunk/tests/apps/directory_operator_exit/run-test (original)
+++ asterisk/trunk/tests/apps/directory_operator_exit/run-test Thu Sep 15 10:41:01 2011
@@ -20,10 +20,10 @@
 from asterisk.TestCase import TestCase
 
 class DirectoryTest(TestCase):
-   reactor_timeout = 60
 
    def __init__(self):
       TestCase.__init__(self)
+      self.reactor_timeout = 60
       self.create_asterisk(2)
 
    def ami_connect(self, ami):

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=2271&r1=2270&r2=2271
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/authenticate_nominal/test-config.yaml (original)
+++ asterisk/trunk/tests/apps/voicemail/authenticate_nominal/test-config.yaml Thu Sep 15 10:41:01 2011
@@ -14,8 +14,19 @@
         -
             name: 'asterisk.ThreadTestCondition.ThreadPostTestCondition'
             type: 'Post'
-            relatedCondition: 'ThreadPreTestCondition'
-            expectedResult: 'FAIL'
+            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'

Modified: asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/configs/ast2/extensions.conf?view=diff&rev=2271&r1=2270&r2=2271
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/configs/ast2/extensions.conf (original)
+++ asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/configs/ast2/extensions.conf Thu Sep 15 10:41:01 2011
@@ -14,8 +14,8 @@
 
 exten => sendAudioWithDTMF,1,NoOp()
 	same => n,Verbose(1, Sending audio file ${TALK_AUDIO})
+	same => n,Verbose(1, Sending DTMF Signal ${DTMF_TO_SEND})
 	same => n,Playback(${TALK_AUDIO})
-	same => n,Verbose(1, Sending DTMF Signal ${DTMF_TO_SEND})
 	same => n,SendDTMF(${DTMF_TO_SEND})
 	same => n,Goto(voicemailCaller,wait,1)
 

Modified: asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/test-config.yaml?view=diff&rev=2271&r1=2270&r2=2271
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/test-config.yaml (original)
+++ asterisk/trunk/tests/apps/voicemail/check_voicemail_new_user/test-config.yaml Thu Sep 15 10:41:01 2011
@@ -15,8 +15,19 @@
         -
             name: 'asterisk.ThreadTestCondition.ThreadPostTestCondition'
             type: 'Post'
-            relatedCondition: 'ThreadPreTestCondition'
-            expectedResult: 'FAIL'
+            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'

Modified: asterisk/trunk/tests/apps/voicemail/check_voicemail_nominal/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/check_voicemail_nominal/test-config.yaml?view=diff&rev=2271&r1=2270&r2=2271
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/check_voicemail_nominal/test-config.yaml (original)
+++ asterisk/trunk/tests/apps/voicemail/check_voicemail_nominal/test-config.yaml Thu Sep 15 10:41:01 2011
@@ -14,8 +14,19 @@
         -
             name: 'asterisk.ThreadTestCondition.ThreadPostTestCondition'
             type: 'Post'
-            relatedCondition: 'ThreadPreTestCondition'
-            expectedResult: 'FAIL'
+            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'

Modified: asterisk/trunk/tests/apps/voicemail/func_vmcount/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/func_vmcount/test-config.yaml?view=diff&rev=2271&r1=2270&r2=2271
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/func_vmcount/test-config.yaml (original)
+++ asterisk/trunk/tests/apps/voicemail/func_vmcount/test-config.yaml Thu Sep 15 10:41:01 2011
@@ -14,8 +14,10 @@
         -
             name: 'asterisk.ThreadTestCondition.ThreadPostTestCondition'
             type: 'Post'
-            relatedCondition: 'ThreadPreTestCondition'
-            expectedResult: 'FAIL'
+            ignoredThreads:
+                - 'netconsole'
+                - 'pbx_thread'
+            relatedCondition: 'asterisk.ThreadTestCondition.ThreadPreTestCondition'
         -
             name: 'asterisk.LockTestCondition.LockTestCondition'
             type: 'Pre'

Modified: asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/test-config.yaml?view=diff&rev=2271&r1=2270&r2=2271
==============================================================================
--- asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/test-config.yaml (original)
+++ asterisk/trunk/tests/apps/voicemail/leave_voicemail_nominal/test-config.yaml Thu Sep 15 10:41:01 2011
@@ -15,8 +15,19 @@
         -
             name: 'asterisk.ThreadTestCondition.ThreadPostTestCondition'
             type: 'Post'
-            relatedCondition: 'ThreadPreTestCondition'
-            expectedResult: 'FAIL'
+            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'




More information about the asterisk-commits mailing list