[asterisk-commits] mjordan: testsuite/asterisk/trunk r3916 - in /asterisk/trunk/tests/cdr: ./ cd...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jul 13 18:32:04 CDT 2013


Author: mjordan
Date: Sat Jul 13 18:32:02 2013
New Revision: 3916

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3916
Log:
Fix blind-transfer-accountcode; convert originate-cdr-disposition

This patch does two things:
 * It converts the originate-cdr-disposition test from Lua to a pluggable
   module based test.
 * It fixes the blind-transfer-accountcode test such that it runs correctly
   with Asterisk 12.

(closes issue ASTERISK-21831)
Reported by: Matt Jordan

Removed:
    asterisk/trunk/tests/cdr/cdr_properties/blind-transfer-accountcode/run-test
    asterisk/trunk/tests/cdr/cdr_properties/blind-transfer-accountcode/test.lua
    asterisk/trunk/tests/cdr/originate-cdr-disposition/run-test
    asterisk/trunk/tests/cdr/originate-cdr-disposition/test.lua
Modified:
    asterisk/trunk/tests/cdr/cdr-tests.py
    asterisk/trunk/tests/cdr/cdr_properties/blind-transfer-accountcode/sipp/call-then-blind-transfer.xml
    asterisk/trunk/tests/cdr/cdr_properties/blind-transfer-accountcode/test-config.yaml
    asterisk/trunk/tests/cdr/cdr_properties/tests.yaml
    asterisk/trunk/tests/cdr/originate-cdr-disposition/test-config.yaml

Modified: asterisk/trunk/tests/cdr/cdr-tests.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/cdr-tests.py?view=diff&rev=3916&r1=3915&r2=3916
==============================================================================
--- asterisk/trunk/tests/cdr/cdr-tests.py (original)
+++ asterisk/trunk/tests/cdr/cdr-tests.py Sat Jul 13 18:32:02 2013
@@ -10,12 +10,61 @@
 
 import sys
 import logging
+import time
 
 sys.path.append("lib/python")
 from cdr import CDRModule
 from cdr import AsteriskCSVCDR
 
-logger = logging.getLogger(__name__)
+LOGGER = logging.getLogger(__name__)
+
+class SequenceOriginator(object):
+    ''' A class that performs an origination on each iteration of a SIPp
+    scenario.
+
+    Right now this is only used by the originate-cdr-disposition test; if it happens to
+    be more generically useful it can be relocated into another module.
+    '''
+
+    def __init__(self, module_config, test_object):
+        ''' Constructor '''
+
+        self.module_config = module_config
+        test_object.register_scenario_started_observer(self.scenario_started)
+        test_object.register_ami_observer(self.ami_connect)
+        self.ami = None
+        self.test_counter = 0
+
+    def ami_connect(self, ami):
+        ''' Callback for when AMI connects '''
+        self.ami = ami
+
+    def scenario_started(self, result):
+        ''' Handle origination on SIPp scenario start '''
+        LOGGER.info("Scenario started; originating new call")
+        self.originate_call()
+        self.test_counter += 1
+        return result
+
+    def originate_call(self):
+        ''' Originate a new call '''
+
+        def failure_absorber(reason):
+            ''' Absorb an exception thrown by an Originate failure '''
+            LOGGER.debug('Ignoring originate failure...')
+            return reason
+
+        if self.test_counter > (len(self.module_config) - 1):
+            LOGGER.debug('Ignoring scenario start; no more calls to originate')
+            return
+        originate_obj = self.module_config[self.test_counter]
+        defered = self.ami.originate(**originate_obj['parameters'])
+        ignore_failures = originate_obj.get('ignore-originate-failure') or False
+        if ignore_failures:
+            defered.addErrback(failure_absorber)
+
+
+
 
 class ForkCdrModuleBasic(CDRModule):
     ''' A class that adds some additional CDR checking on top of CDRModule
@@ -37,7 +86,7 @@
              self.test_object.ast[0].directories['astlogdir'], "cdrtest_local"))
 
         if int(cdr1[0].duration) < int(cdr1[1].duration):
-            logger.error("Fail: Original CDR duration shorter than forked")
+            LOGGER.error("Fail: Original CDR duration shorter than forked")
             self.test_object.set_passed(False)
         return
 
@@ -65,12 +114,12 @@
                  self.test_object.ast[0].directories['astlogdir'],
                  "cdrtest_local"))
 
-        logger.debug('Checking for missing fields')
+        LOGGER.debug('Checking for missing fields')
         for cdritem in cdr1:
             if (cdritem.duration is None or
                 cdritem.start is None or
                 cdritem.end is None):
-                logger.error("EPIC FAILURE: CDR record %s is missing one or " \
+                LOGGER.error("EPIC FAILURE: CDR record %s is missing one or " \
                              "more key fields. This should never be able to " \
                              "happen." % cdritem)
                 self.test_object.set_passed(False)
@@ -79,27 +128,29 @@
         # The dialplan is set up so that these two CDRs should each last at
         # least 4 seconds. Giving it wiggle room, we'll just say we want it to
         # be greater than 1 second.
-        logger.debug('Checking durations')
+        LOGGER.debug('Checking durations')
         for entry in self.entries_to_check:
             if (int(cdr1[entry].duration) <= 1):
-                logger.error("CDR at %d has duration less than one second" %
+                LOGGER.error("CDR at %d has duration less than one second" %
                              entry)
                 self.test_object.set_passed(False)
                 return
 
-        logger.debug('Checking start/end times for forked entries')
+        LOGGER.debug('Checking start/end times for forked entries')
         for i in range(len(self.entries_to_check) - 1):
-            end = time.strptime(cdr1[self.entries_to_check[i]].end, "%Y-%m-%d %H:%M:%S")
-            beg = time.strptime(cdr1[self.entries_to_check[i + 1]].start, "%Y-%m-%d %H:%M:%S")
+            end = time.strptime(cdr1[self.entries_to_check[i]].end,
+                "%Y-%m-%d %H:%M:%S")
+            beg = time.strptime(cdr1[self.entries_to_check[i + 1]].start,
+                "%Y-%m-%d %H:%M:%S")
 
             #check that the end of the first CDR occurred within 1 second of
             # the beginning of the second CDR
             if (abs(time.mktime(end) - time.mktime(beg)) > 1):
-                logger.error("Time discrepancy between end1 and start2: must " \
+                LOGGER.error("Time discrepancy between end1 and start2: must " \
                              "be one second or less.\n")
-                logger.error("Actual times: end cdr1 = %s   begin cdr2 = %s" %
+                LOGGER.error("Actual times: end cdr1 = %s   begin cdr2 = %s" %
                              (cdr1[self.entries_to_check[i]].end,
-                              cdr1[self_entries_to_check[i + 1]].start))
+                              cdr1[self.entries_to_check[i + 1]].start))
                 self.test_object.set_passed(False)
                 return
 

Modified: asterisk/trunk/tests/cdr/cdr_properties/blind-transfer-accountcode/sipp/call-then-blind-transfer.xml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/cdr_properties/blind-transfer-accountcode/sipp/call-then-blind-transfer.xml?view=diff&rev=3916&r1=3915&r2=3916
==============================================================================
--- asterisk/trunk/tests/cdr/cdr_properties/blind-transfer-accountcode/sipp/call-then-blind-transfer.xml (original)
+++ asterisk/trunk/tests/cdr/cdr_properties/blind-transfer-accountcode/sipp/call-then-blind-transfer.xml Sat Jul 13 18:32:02 2013
@@ -70,7 +70,7 @@
         Max-Forwards: 70
         Content-Length: 0
         Refer-To: <sip:[field3 line="[$line]"]@[remote_ip]:[remote_port]>
-        Reffered-By: <sip:[field0 line="[$line]"]@[local_ip]:[local_port]>
+        Referred-By: <sip:[field0 line="[$line]"]@[local_ip]:[local_port]>
 
         ]]>
     </send>
@@ -93,22 +93,4 @@
 
         ]]>
     </send>
-
-    <recv request="NOTIFY" optional="false" />
-
-    <send>
-        <![CDATA[
-
-        SIP/2.0 200 OK
-        [last_Via:]
-        [last_From:]
-        [last_To:]
-        [last_Call-ID:]
-        [last_CSeq:]
-        [last_Record-Route:]
-        Contact: sip:[field0 line="[$line]"]@[local_ip]:[local_port]
-        Content-Length: 0
-
-        ]]>
-    </send>
 </scenario>

Modified: asterisk/trunk/tests/cdr/cdr_properties/blind-transfer-accountcode/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/cdr_properties/blind-transfer-accountcode/test-config.yaml?view=diff&rev=3916&r1=3915&r2=3916
==============================================================================
--- asterisk/trunk/tests/cdr/cdr_properties/blind-transfer-accountcode/test-config.yaml (original)
+++ asterisk/trunk/tests/cdr/cdr_properties/blind-transfer-accountcode/test-config.yaml Sat Jul 13 18:32:02 2013
@@ -2,7 +2,7 @@
     summary:     'Test account code propagation for SIP blind transfers.'
     description: |
         "This test ensures that when a channel with an account code, dials a
-        channel without and account code, then transfers the dialed channel to
+        channel without an account code, then transfers the dialed channel to
         another channel, the calling (and transferring) channel's account code
         is copied to the called channel and stored in the CDR record for the
         transfer."
@@ -12,8 +12,6 @@
 properties:
     minversion: '1.8.0.0'
     dependencies:
-        - app : 'bash'
-        - app : 'asttest'
         - sipp :
             version : 'v3.0'
             feature : 'TLS'
@@ -22,3 +20,134 @@
         - CDR
         - SIP
         - transfer
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'sipp.SIPpTestCase'
+    modules:
+        -
+            config-section: 'cdr-config'
+            typename: 'cdr.CDRModule'
+
+test-object-config:
+    test-iterations:
+        -
+            # Register all 3 peers; names test1, -2, -3
+            scenarios:
+                - { 'key-args': {'scenario': 'register.xml', '-p': '5060',
+                    '-i': '127.0.0.2', '-inf': 'data.csv' },
+                    'ordered-args': [
+                        '-infindex', 'data.csv', '0',
+                        '-set', 'user', 'test1',
+                        '-set', 'file', 'data.csv'] }
+                - { 'key-args': {'scenario': 'register.xml', '-p': '5060',
+                    '-i': '127.0.0.3', '-inf': 'data.csv' },
+                    'ordered-args': [
+                        '-infindex', 'data.csv', '0',
+                        '-set', 'user', 'test2',
+                        '-set', 'file', 'data.csv'] }
+                - { 'key-args': {'scenario': 'register.xml', '-p': '5060',
+                    '-i': '127.0.0.4', '-inf': 'data.csv' },
+                    'ordered-args': [
+                        '-infindex', 'data.csv', '0',
+                        '-set', 'user', 'test3',
+                        '-set', 'file', 'data.csv'] }
+        -
+            scenarios:
+                - { 'key-args': {'scenario': 'wait-for-call.xml', '-p': '5060',
+                    '-i': '127.0.0.2', '-inf': 'data.csv' },
+                    'ordered-args': [
+                        '-infindex', 'data.csv', '0',
+                        '-set', 'user', 'test1',
+                        '-set', 'file', 'data.csv'] }
+                - { 'key-args': {'scenario': 'wait-for-call-do-hangup.xml', '-p': '5060',
+                    '-i': '127.0.0.3', '-inf': 'data.csv' },
+                    'ordered-args': [
+                        '-infindex', 'data.csv', '0',
+                        '-set', 'user', 'test2',
+                        '-set', 'file', 'data.csv'] }
+                - { 'key-args': {'scenario': 'call-then-blind-transfer.xml', '-p': '5060',
+                    '-i': '127.0.0.4', '-inf': 'data.csv' },
+                    'ordered-args': [
+                        '-infindex', 'data.csv', '0',
+                        '-set', 'user', 'test3',
+                        '-set', 'file', 'data.csv'] }
+            # Re-Register all 3 peers; names test3, -2, -1
+            scenarios:
+                - { 'key-args': {'scenario': 'register.xml', '-p': '5060',
+                    '-i': '127.0.0.2', '-inf': 'data.csv' },
+                    'ordered-args': [
+                        '-infindex', 'data.csv', '0',
+                        '-set', 'user', 'test3',
+                        '-set', 'file', 'data.csv'] }
+                - { 'key-args': {'scenario': 'register.xml', '-p': '5060',
+                    '-i': '127.0.0.3', '-inf': 'data.csv' },
+                    'ordered-args': [
+                        '-infindex', 'data.csv', '0',
+                        '-set', 'user', 'test2',
+                        '-set', 'file', 'data.csv'] }
+                - { 'key-args': {'scenario': 'register.xml', '-p': '5060',
+                    '-i': '127.0.0.4', '-inf': 'data.csv' },
+                    'ordered-args': [
+                        '-infindex', 'data.csv', '0',
+                        '-set', 'user', 'test1',
+                        '-set', 'file', 'data.csv'] }
+        -
+            scenarios:
+                - { 'key-args': {'scenario': 'wait-for-call.xml', '-p': '5060',
+                    '-i': '127.0.0.2', '-inf': 'data.csv' },
+                    'ordered-args': [
+                        '-infindex', 'data.csv', '0',
+                        '-set', 'user', 'test3',
+                        '-set', 'file', 'data.csv'] }
+                - { 'key-args': {'scenario': 'wait-for-call-do-hangup.xml', '-p': '5060',
+                    '-i': '127.0.0.3', '-inf': 'data.csv' },
+                    'ordered-args': [
+                        '-infindex', 'data.csv', '0',
+                        '-set', 'user', 'test2',
+                        '-set', 'file', 'data.csv'] }
+                - { 'key-args': {'scenario': 'call-then-blind-transfer.xml', '-p': '5060',
+                    '-i': '127.0.0.4', '-inf': 'data.csv' },
+                    'ordered-args': [
+                        '-infindex', 'data.csv', '0',
+                        '-set', 'user', 'test1',
+                        '-set', 'file', 'data.csv'] }
+
+cdr-config:
+    -
+        file: 'Master'
+        lines:
+            -
+                source: 'test1'
+                destination: 'test3'
+                accountcode: 'account1'
+                disposition: 'ANSWERED'
+                channel: 'SIP/test1-.*'
+                dchannel: 'SIP/test3-.*'
+            -
+                source: 'test3'
+                destination: 'test2'
+                accountcode: 'account1'
+                disposition: 'ANSWERED'
+                channel: 'SIP/test3-.*'
+                dchannel: 'SIP/test2-.*'
+    -
+        file: 'account1'
+        lines:
+            -
+                source: 'test1'
+                destination: 'test3'
+                accountcode: 'account1'
+                disposition: 'ANSWERED'
+                channel: 'SIP/test1-.*'
+                dchannel: 'SIP/test3-.*'
+            -
+                source: 'test3'
+                destination: 'test2'
+                accountcode: 'account1'
+                disposition: 'ANSWERED'
+                channel: 'SIP/test3-.*'
+                dchannel: 'SIP/test2-.*'
+
+

Modified: asterisk/trunk/tests/cdr/cdr_properties/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/cdr_properties/tests.yaml?view=diff&rev=3916&r1=3915&r2=3916
==============================================================================
--- asterisk/trunk/tests/cdr/cdr_properties/tests.yaml (original)
+++ asterisk/trunk/tests/cdr/cdr_properties/tests.yaml Sat Jul 13 18:32:02 2013
@@ -2,5 +2,5 @@
 tests:
     - test: 'cdr_accountcode'
     - test: 'cdr_userfield'
-#    - test: 'blind-transfer-accountcode'
+    - test: 'blind-transfer-accountcode'
 

Modified: asterisk/trunk/tests/cdr/originate-cdr-disposition/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/originate-cdr-disposition/test-config.yaml?view=diff&rev=3916&r1=3915&r2=3916
==============================================================================
--- asterisk/trunk/tests/cdr/originate-cdr-disposition/test-config.yaml (original)
+++ asterisk/trunk/tests/cdr/originate-cdr-disposition/test-config.yaml Sat Jul 13 18:32:02 2013
@@ -12,11 +12,117 @@
 properties:
     minversion: '1.8.0.0'
     dependencies:
-        - app : 'bash'
-        - app : 'asttest'
         - sipp :
             version : 'v3.0'
         - asterisk : 'cdr_csv'
     tags:
         - SIP
-        - CDR
+        - CDR
+
+test-modules:
+    add-to-search-path:
+        -
+            'tests/cdr'
+    test-object:
+        config-section: test-object-config
+        typename: 'sipp.SIPpTestCase'
+    modules:
+        -
+            config-section: 'sequence-originator'
+            typename: 'cdr-tests.SequenceOriginator'
+        -
+            config-section: 'cdr-config'
+            typename: 'cdr.CDRModule'
+
+cdr-config:
+    -
+        file: 'Master'
+        lines:
+            -
+                disposition: 'ANSWERED'
+                channel: 'SIP/test1-.*'
+                dchannel: ''
+            -
+                disposition: 'BUSY'
+                channel: 'SIP/test1-.*'
+                dchannel: ''
+            -
+                disposition: 'FAILED'
+                channel: 'SIP/test1-.*'
+                dchannel: ''
+            -
+                disposition: 'NO ANSWER'
+                channel: 'SIP/test1-.*'
+                dchannel: ''
+            -
+                disposition: 'NO ANSWER'
+                channel: 'SIP/test1-.*'
+                dchannel: 'SIP/test2-.*'
+
+sequence-originator:
+    -
+        parameters: { channel: 'sip/test1', context: 'default', exten: 'wait', priority: '1' }
+        ignore-originate-failure: 'no'
+    -
+        parameters: { channel: 'sip/test1', context: 'default', exten: 'wait', priority: '1' }
+        ignore-originate-failure: 'no'
+    -
+        parameters: { channel: 'sip/test1', context: 'default', exten: 'wait', priority: '1' }
+        ignore-originate-failure: 'no'
+    -
+        parameters: { channel: 'sip/test1', context: 'default', exten: 'wait', priority: '1', timeout: 1 }
+        ignore-originate-failure: 'yes'
+    -
+        parameters: { channel: 'sip/test1', context: 'default', exten: 'dial', priority: '1' }
+        ignore-originate-failure: 'yes'
+
+
+test-object-config:
+    test-iterations:
+        -
+            scenarios:
+                - { 'key-args': {'scenario': 'wait-for-call.xml', '-p': '5060',
+                    '-i': '127.0.0.2', '-inf': 'data.csv' },
+                    'ordered-args': [
+                        '-infindex', 'data.csv', '0',
+                        '-set', 'user', 'test1',
+                        '-set', 'file', 'data.csv'] }
+        -
+            scenarios:
+                - { 'key-args': {'scenario': 'wait-for-call-busy.xml', '-p': '5060',
+                    '-i': '127.0.0.2', '-inf': 'data.csv' },
+                    'ordered-args': [
+                        '-infindex', 'data.csv', '0',
+                        '-set', 'user', 'test1',
+                        '-set', 'file', 'data.csv'] }
+        -
+            scenarios:
+                - { 'key-args': {'scenario': 'wait-for-call-congestion.xml', '-p': '5060',
+                    '-i': '127.0.0.2', '-inf': 'data.csv' },
+                    'ordered-args': [
+                        '-infindex', 'data.csv', '0',
+                        '-set', 'user', 'test1',
+                        '-set', 'file', 'data.csv'] }
+        -
+            scenarios:
+                - { 'key-args': {'scenario': 'wait-for-call-timeout.xml', '-p': '5060',
+                    '-i': '127.0.0.2', '-inf': 'data.csv' },
+                    'ordered-args': [
+                        '-infindex', 'data.csv', '0',
+                        '-set', 'user', 'test1',
+                        '-set', 'file', 'data.csv'] }
+        -
+            scenarios:
+                - { 'key-args': {'scenario': 'wait-for-call.xml', '-p': '5060',
+                    '-i': '127.0.0.2', '-inf': 'data.csv' },
+                    'ordered-args': [
+                        '-infindex', 'data.csv', '0',
+                        '-set', 'user', 'test1',
+                        '-set', 'file', 'data.csv'] }
+                - { 'key-args': {'scenario': 'wait-for-call-timeout.xml', '-p': '5060',
+                    '-i': '127.0.0.3', '-inf': 'data.csv' },
+                    'ordered-args': [
+                        '-infindex', 'data.csv', '0',
+                        '-set', 'user', 'test2',
+                        '-set', 'file', 'data.csv'] }
+




More information about the asterisk-commits mailing list