[asterisk-scf-commits] asterisk-scf/integration/testsuite.git branch "review" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Fri Jun 10 08:35:07 CDT 2011


branch "review" has been updated
       via  4e27683acc7c0bb38b0dcf5e4d3d7f2ae9ae69bd (commit)
       via  8b34c1d3091cc71cba6b5954a30ab572c92578ba (commit)
       via  c17ff01bea7135df2ae8f40b39cb0cd5e7e2d676 (commit)
      from  d21f6f873fba614f1319019c86bc4dccdbef1478 (commit)

Summary of changes:
 lib/python/TestSuite.py                            |   12 +++++
 plugins/asteriskscf_icebox.py                      |   10 +++-
 plugins/wireshark.py                               |   44 ++++++++++++++++---
 tests/sip/Functional_Basic_CallSetup/testcase.yaml |   10 ++---
 testsuite.py                                       |   17 ++++----
 5 files changed, 69 insertions(+), 24 deletions(-)


- Log -----------------------------------------------------------------
commit 4e27683acc7c0bb38b0dcf5e4d3d7f2ae9ae69bd
Author: Darren Sessions <dsessions at digium.com>
Date:   Fri Jun 10 08:35:01 2011 -0500

    updated the icebox configs to reflect some of the new settings discovered in the source tree config files.

diff --git a/plugins/asteriskscf_icebox.py b/plugins/asteriskscf_icebox.py
index 841c19d..beaa13d 100644
--- a/plugins/asteriskscf_icebox.py
+++ b/plugins/asteriskscf_icebox.py
@@ -82,12 +82,15 @@ class plugin(TestSuite.RemoteBaseClass):
         elif component == 'bridge':
             return [
                 'Ice.ThreadPool.Client.Size=10',
+                'IceBox.Service.BridgeManager=bridgeservice:create',
+                'BridgeManager.ManagerId=BridgeManager',
                 'BridgeManager.BridgeService.Endpoints=default',
+                'BridgeManager.Standby=no',
+                'BridgeManager.Standalone=yes',
                 'ServiceLocatorManagementProxy=LocatorServiceManagement:tcp -p 4422',
                 'LocatorService.Proxy=LocatorService:tcp -p 4411',
                 'TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:default -p 10000',
-                'IceBox.InheritProperties=1',
-                'IceBox.Service.BridgeManager=bridgeservice:create']
+                'IceBox.InheritProperties=1']
         elif component == 'routing_state_replicator':
             return [
                 'Ice.ThreadPool.Client.Size=4',
@@ -117,7 +120,8 @@ class plugin(TestSuite.RemoteBaseClass):
                 'LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -p 4422',
                 'LocatorService.Proxy=LocatorService:tcp -p 4411',
                 'TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:default -p 10000',
-                'BridgeManager.ServiceLocatorId=BridgeService']
+                'AsteriskSCF.BasicRoutingService.logger=Debug'
+                'BridgeManager.ServiceLocatorId=BridgeManager']
         elif component == 'sip_state_replicator':
             return [
                 'Ice.ThreadPool.Client.Size=4',

commit 8b34c1d3091cc71cba6b5954a30ab572c92578ba
Author: Darren Sessions <dsessions at digium.com>
Date:   Fri Jun 10 08:34:13 2011 -0500

    I have bested the pcap capture filter developers and have actually created something advanced that works!! I racked my brain on this one for a while and as it turns out, I needed a matrix of the hosts involved in the testing to isolate all the unwanted packets / hosts.

diff --git a/plugins/wireshark.py b/plugins/wireshark.py
index fac3c0a..89c0c5c 100644
--- a/plugins/wireshark.py
+++ b/plugins/wireshark.py
@@ -15,6 +15,7 @@ import TestSuite
 class plugin(TestSuite.RemoteBaseClass):
     def main(self, testData, testPath, globalVars, remote):
         rpc = {}
+        protos = []
         hostFilter = []
         ''' start and stop individual components. shutdown is implemented in the main testsuite code ''' 
         for cmd in testData['cmd']:
@@ -28,22 +29,39 @@ class plugin(TestSuite.RemoteBaseClass):
                         ipv6 = rpc[remoteHost]['ipv6']
                         ipv6 = ipv6.replace('[', '')
                         ipv6 = ipv6.replace(']', '')
-                        hostFilter.append('ip.addr == %s or ipv6.addr == %s' % (rpc[remoteHost]['ipv4'], ipv6))
-                    hostFilters = ' or '.join(hostFilter)
+                        hostFilter.append('%s' % rpc[remoteHost]['ipv4'])
+                        hostFilter.append('%s' % ipv6)
+                    hostFilters = self.captureFilterHostMatrix(hostFilter)
                 else:
                     return {'success':False,'msg':'The host_filter option is required.'}
 
                 if 'protocol_filter' in testData['cmd'][cmd]:
-                    protocolFilters = ' or '.join(testData['cmd'][cmd]['protocol_filter'])
+                    for proto in testData['cmd'][cmd]['protocol_filter']:
+                        if proto == 'sip':
+                            protos.append('port 5060')
+                        elif proto == 'rtp':
+                            protos.append('(udp[0:2] > 9999 and udp[0:2] < 20001)')
+                        elif proto == 'dns':
+                            protos.append('udp port 53')
+                        elif proto == 'icmp':
+                            protos.append('icmp[icmptype]==icmp-echo or icmp[icmptype]==icmp-echoreply')
+                        elif proto == 't38':
+                            protos.append('tcp port 6004')
+                        else:
+                            return {'success':False, 'msg':'Unrecognized protocol.'}
+                    protocolFilters = ' or '.join(protos)
+                    #protocolFilters = 'not arp and not broadcast and not multicast and not port 22 and not port 8000 and %s' % ' or '.join(protos)
                 else:
                     return {'success':False,'msg':'The protocol_filter command is required.'}
 
                 runCmd = [
-                    'tshark',
+                    'dumpcap',
+                    '-f',
+                    '%s and (%s)' % (hostFilters, protocolFilters),
                     '-w',
-                    '/tmp/capture.pcap',
-                    '-R', 
-                    '(%s) and (%s)' % (protocolFilters, hostFilters)]
+                    '/tmp/capture.pcap']
+
+                print ' '.join(runCmd)
 
                 results = remote['rpc']('run', remote['hostname'], globalVars, 'wireshark', 'start', runCmd)
                 if results['success'] == False:
@@ -75,3 +93,15 @@ class plugin(TestSuite.RemoteBaseClass):
                 return {'success':False, 'msg':'Unknown command: %s' % cmd}
 
         return {'success':True}   
+
+    def captureFilterHostMatrix(self, hosts):
+        capFilter = []
+        for n in range(0, len(hosts)):
+            src = ''
+            for host in hosts:
+                if host == hosts[n]:
+                    continue
+                src += 'src host ' + host + ' or '
+            capFilter.append('(dst host ' + hosts[n] + ' and ' + src.strip(' or ') + ')')
+        return '(' + ' or '.join(capFilter) + ')'
+

commit c17ff01bea7135df2ae8f40b39cb0cd5e7e2d676
Author: Darren Sessions <dsessions at digium.com>
Date:   Fri Jun 10 08:32:23 2011 -0500

    Added the ability for a failed test to continue iterating through the plugins, checking for a specific option flag being set (run_on_test_failure). If that flag is found, then that plugin is still executed. This feature was required so that if a wireshark trace was initially started, the stop command will still be ran and the capture file will end up where it needs to go.

diff --git a/lib/python/TestSuite.py b/lib/python/TestSuite.py
index 5dbd9e3..239a5c0 100644
--- a/lib/python/TestSuite.py
+++ b/lib/python/TestSuite.py
@@ -127,12 +127,24 @@ class utils():
 
 class BaseClass(utils):
     def run(self, testData, testPath, globalVars):
+        if globalVars['testSuccess'] == False:
+            if 'run_on_test_failure' in testData:
+                if testData['run_on_test_failure'] == False:
+                    return {'success':False,'msg':'Test has already failed.'}
+            else:
+                return {'success':False,'msg':'Test has already failed.'}
         if not 'cmd' in testData:
             return {'success':False,'msg':'No command specified.'}
         return self.main(testData, testPath, globalVars)
 
 class RemoteBaseClass(utils):
     def run(self, testData, testPath, globalVars):
+        if globalVars['testSuccess'] == False: 
+            if 'run_on_test_failure' in testData:
+                if testData['run_on_test_failure'] == False:
+                    return {'success':False,'msg':'Test has already failed.'}
+            else:
+                return {'success':False,'msg':'Test has already failed.'}
         if not 'cmd' in testData:
             return {'success':False,'msg':'No command specified.'}
         if not 'testsuite_remote_host' in testData:
diff --git a/tests/sip/Functional_Basic_CallSetup/testcase.yaml b/tests/sip/Functional_Basic_CallSetup/testcase.yaml
index 9d39bf1..a9ada89 100644
--- a/tests/sip/Functional_Basic_CallSetup/testcase.yaml
+++ b/tests/sip/Functional_Basic_CallSetup/testcase.yaml
@@ -1,7 +1,5 @@
 name : Functional_Basic_CallSetup
 options : 
-    network_captures: True
-    call_flow_diagrams: True
     restart_persistant_plugins_between_tests: True
 tests :
     - ipv4toipv4 :
@@ -18,7 +16,6 @@ tests :
                         protocol_filter :
                             - sip
                             - rtp
-                            - rtcp
                             - icmp
                             - t38
                             - dns
@@ -85,6 +82,7 @@ tests :
                         transport : udp
                         timeout : 10
             - wireshark :
+                run_on_test_failure : True
                 testsuite_remote_host : testsuite-remote-1.digium.internal
                 cmd :
                     stop :
@@ -102,7 +100,6 @@ tests :
                         protocol_filter :
                             - sip
                             - rtp
-                            - rtcp
                             - icmp
                             - t38
                             - dns
@@ -170,6 +167,7 @@ tests :
                         transport : udp
                         timeout : 10
             - wireshark :
+                run_on_test_failure : True
                 testsuite_remote_host : testsuite-remote-1.digium.internal
                 cmd :
                     stop :
@@ -187,7 +185,6 @@ tests :
                         protocol_filter :
                             - sip
                             - rtp
-                            - rtcp
                             - icmp
                             - t38
                             - dns
@@ -260,6 +257,7 @@ tests :
                         transport : udp
                         timeout : 10
             - wireshark :
+                run_on_test_failure : True
                 testsuite_remote_host : testsuite-remote-1.digium.internal
                 cmd :
                     stop :
@@ -277,7 +275,6 @@ tests :
                         protocol_filter :
                             - sip
                             - rtp
-                            - rtcp
                             - icmp
                             - t38
                             - dns
@@ -350,6 +347,7 @@ tests :
                         transport : udp
                         timeout : 10
             - wireshark :
+                run_on_test_failure : True
                 testsuite_remote_host : testsuite-remote-1.digium.internal
                 cmd :
                     stop :
diff --git a/testsuite.py b/testsuite.py
index 9dd3222..ab52418 100755
--- a/testsuite.py
+++ b/testsuite.py
@@ -79,6 +79,8 @@ class __main__:
                         if stopTests == True:
                             break
                         for testName in subTestCase:
+                            self.globalVars['testSuccess'] = True
+                            self.globalVars['testMsg'] = ''
                             self.globalVars['testInfo']['testCategory'] = testCategory
                             self.globalVars['testInfo']['testCase'] = testData['name']
                             self.globalVars['testInfo']['testName'] = testName
@@ -117,11 +119,10 @@ class __main__:
                                         else:
                                             for remote in runResults['shutdownList']:
                                                shutdownList.append({remote:plugin})
-                                        if not runResults['success'] == True:
+                                        if runResults['success'] == False and self.globalVars['testSuccess'] == True:
+                                            self.globalVars['testSuccess'] = False
+                                            self.globalVars['testMsg'] = runResults['msg'] = "'%s' plugin: %s" % (plugin, runResults['msg'])
                                             break
-                                    if runResults['success'] == False:
-                                        runResults['msg'] = "'%s' plugin: %s" % (plugin, runResults['msg'])
-                                        break
 
                                 ''' shutdown if 'restart_persistant_plugins_between_tests' is true or not specified '''
                                 for d in shutdownList:
@@ -132,11 +133,11 @@ class __main__:
                                         except:
                                             pass
 
-                                if runResults['success'] == False:
-                                    print >> sys.stderr, '   |- Test "' + testName + '" - FAILED!\n    \- ' + runResults['msg']
-                                    xmlFailureMsg = '%s' % runResults['msg']
+                                if self.globalVars['testSuccess'] == False:
+                                    print >> sys.stderr, '   |- Test "' + testName + '" - FAILED!\n    \- ' + self.globalVars['testMsg']
+                                    xmlFailureMsg = '%s' % self.globalVars['testMsg']
                                     if 'bambooBuildURL' in self.globalVars:
-                                        xmlFailureMsg = '%s\nIf artifacts specific to this test were generated,\n' % runResults['msg']
+                                        xmlFailureMsg = '%s\nIf artifacts specific to this test were generated,\n' % self.globalVars['testMsg']
                                         xmlFailureMsg = '%s they can be found pasting the link below in your browser or by clicking the Artifacts tab above.\n\n' % xmlFailureMsg
                                         xmlFailureMsg = '%s%s%s' % (xmlFailureMsg, self.globalVars['bambooBuildURL'], self.globalVars['testInfo']['testPath'])
                                     subTestElement, errorMsgs = xml().addFailure(subTestElement, [xmlFailureMsg])

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/testsuite.git



More information about the asterisk-scf-commits mailing list