[svn-commits] jrose: branch group/cdr_test_log_congestion r2945 - in /asterisk/team/group/c...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Dec 21 15:14:00 CST 2011


Author: jrose
Date: Wed Dec 21 15:13:58 2011
New Revision: 2945

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=2945
Log:
Converts the remaining non-lua cdr tests to use CDRTestCase and deletes some configs.

Removed:
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/configs/ast2/
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/configs/ast2/
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/configs/ast2/
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_transfer/configs/ast2/
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/configs/ast1/manager.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/configs/ast2/
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_before_dial/configs/ast2/
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/nocdr/configs/ast1/manager.conf
Modified:
    asterisk/team/group/cdr_test_log_congestion/lib/python/asterisk/CDRTestCase.py
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/configs/ast1/extensions.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/configs/ast1/sip.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/run-test
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/test-config.yaml
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_before_dial/configs/ast1/extensions.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_before_dial/run-test
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_before_dial/test-config.yaml
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/nocdr/run-test

Modified: asterisk/team/group/cdr_test_log_congestion/lib/python/asterisk/CDRTestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/lib/python/asterisk/CDRTestCase.py?view=diff&rev=2945&r1=2944&r2=2945
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/lib/python/asterisk/CDRTestCase.py (original)
+++ asterisk/team/group/cdr_test_log_congestion/lib/python/asterisk/CDRTestCase.py Wed Dec 21 15:13:58 2011
@@ -71,7 +71,7 @@
         """
         self.CDRFileExpectations[recordname].append(cdrline)
 
-    def __match_cdrs(self):
+    def match_cdrs(self):
         #Automatically invoked at the end of the test, this will test the CDR files against the listed expectations.
         self.passed = True
 
@@ -105,7 +105,7 @@
             return test.results()
         """
 
-        self.__match_cdrs()
+        self.match_cdrs()
         if self.passed == True:
             return 0
         return 1

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/configs/ast1/extensions.conf?view=diff&rev=2945&r1=2944&r2=2945
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/configs/ast1/extensions.conf (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/configs/ast1/extensions.conf Wed Dec 21 15:13:58 2011
@@ -5,9 +5,19 @@
 [globals]
 
 [default]
-exten => 1,1,Dial(SIP/1 at test)
-exten => 1,n,Goto(${DIALSTATUS})
-exten => 1,n,Hangup
-exten => 1,n(BUSY),ForkCDR
-exten => 1,n,Dial(SIP/2 at test)
-exten = >1,n,Hangup
+exten => 1,1,NoOp(Dial something that should fail)
+	same => n,Set(CDR(accountcode)=cdrtest_local)
+	same => n,Dial(SIP/test/2)
+	same => n,Goto(${DIALSTATUS})
+	same => n,Hangup
+	same => n(BUSY),ForkCDR
+	same => n,Dial(SIP/test/3)
+	same => n,Hangup
+
+exten => 2,1,NoOp()
+	same => n,Busy()
+	same => n,Hangup()
+
+exten => 3,1,NoOp()
+	same => n,Answer()
+	same => n,Hangup()

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/configs/ast1/sip.conf?view=diff&rev=2945&r1=2944&r2=2945
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/configs/ast1/sip.conf (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/configs/ast1/sip.conf Wed Dec 21 15:13:58 2011
@@ -1,11 +1,9 @@
 [general]
 context=default
-udpbindaddr=0.0.0.0:5065
+udpbindaddr=127.0.0.1
 directmedia=no
-disallow=all
-allow=ulaw
 
 [test]
 type=peer
 host=127.0.0.1
-port=5070
+accountcode=cdrtest_sip

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/run-test?view=diff&rev=2945&r1=2944&r2=2945
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/run-test (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/run-test Wed Dec 21 15:13:58 2011
@@ -8,100 +8,60 @@
 '''
 
 import sys
-from time import sleep
 import os
+import logging
+import re
 sys.path.append("lib/python")
 from asterisk.asterisk import Asterisk
 from asterisk.cdr import AsteriskCSVCDR, AsteriskCSVCDRLine
-from asterisk.ami import AMI
+from asterisk.TestCase import TestCase
+from asterisk.CDRTestCase import CDRTestCase
 from twisted.internet import reactor
-import logging
 
-workingdir = "cdr/console_fork_after_busy_forward"
-testdir = "tests/%s" % workingdir
+logger = logging.getLogger(__name__)
 
-class Test:
+class Fork_After_Busy_Test(CDRTestCase):
     def __init__(self):
-        self.passed = False
+        CDRTestCase.__init__(self)
 
-        self.ast1 = Asterisk(base=workingdir)
-        self.ast1.install_configs("%s/configs/ast1" % (testdir))
+        self.add_expectation('cdrtest_local', AsteriskCSVCDRLine(
+            destination="1",
+            lastapp="Dial",
+            lastarg="SIP/test/3",
+            dcontext="default",
+            dchannel="SIP/test-.*",
+            channel="Local/1 at default-.*",
+            disposition="ANSWERED",
+            amaflags="DOCUMENTATION"
+        ))
+        self.add_expectation('cdrtest_local', AsteriskCSVCDRLine(
+            destination="1",
+            lastapp="Dial",
+            lastarg="SIP/test/3",
+            dcontext="default",
+            dchannel="SIP/test-.*",
+            channel="Local/1 at default-.*",
+            disposition="ANSWERED",
+            amaflags="DOCUMENTATION"
+        ))
 
-        self.ast2 = Asterisk(base=workingdir)
-        self.ast2.install_configs("%s/configs/ast2" % (testdir))
-
-        self.ast1.start()
-        self.ast2.start()
-
-        reactor.callLater(30, self.stop_reactor)
-
-        self.ami = AMI(self.start, self.stop_reactor, timeout=20)
-        self.ami.login()
-
-    def start(self, ami):
-        ami.registerEvent('Hangup', self.end)
-        self.ast1.cli_exec("console dial 1 at default")
-
-    def stop_asterisk(self):
-        self.ast1.stop()
-        self.ast2.stop()
-
-    def stop_reactor(self):
-        print "Stopping Reactor ..."
-        if reactor.running:
-            reactor.stop()
-        self.stop_asterisk()
-
-    def end(self, ami, event):
-        if event.get('channel').lower() != "console/dsp":
-            return
-        self.stop_reactor()
-
-        cdr1 = AsteriskCSVCDR(fn="%s/var/log/asterisk/cdr-csv/Master.csv" % (self.ast1.base))
-        cdr2 = AsteriskCSVCDR(fn="%s/var/log/asterisk/cdr-csv/Master.csv" % (self.ast2.base))
-
-        records = []
-
-        records.append(AsteriskCSVCDRLine(disposition='ANSWERED', dchannel='SIP/test-.*',
-            dcontext='default', amaflags='DOCUMENTATION', uniqueid=cdr1[0].uniqueid,
-            accountcode='', callerid='', userfield='', source='', destination='1',
-            lastapp='Dial', lastarg='SIP/2 at test', channel='Console/dsp', billsec=cdr1[0].billsec))
-
-        records.append(AsteriskCSVCDRLine(disposition='ANSWERED', dchannel='SIP/test-.*',
-            dcontext='default', amaflags='DOCUMENTATION', uniqueid=cdr1[0].uniqueid,
-            accountcode='', callerid='', userfield='', source='', destination='1',
-            lastapp='Dial', lastarg='SIP/2 at test', channel='Console/dsp', billsec=cdr1[0].billsec))
-
-        cdr1_expect = AsteriskCSVCDR(records=records)
-
-        cdr2_expect = AsteriskCSVCDR(records=[AsteriskCSVCDRLine(accountcode="",
-            source="asterisk", destination="2", dcontext="default",
-            callerid='"asterisk" <asterisk>', channel="SIP/.*5065-.*",
-            dchannel="", lastapp="Hangup", lastarg="", disposition="ANSWERED",
-            amaflags="DOCUMENTATION")])
-
-        if len(cdr1) < 2:
-            print "Fewer cdr records than expected! (%d)" % len(cdr1)
-            reactor.stop()
+    def match_cdrs(self):
+        CDRTestCase.match_cdrs(self)
+        if (self.passed == False):
             return
 
+        cdr1 = AsteriskCSVCDR(fn="%s/%s/cdr-csv/%s.csv" % (self.ast[0].base, self.ast[0].directories['astlogdir'], "cdrtest_local"))
+
         if int(cdr1[0].duration) < int(cdr1[1].duration):
-            print "Fail: Original CDR duration shorter than forked"
-            sys.exit(-1)
-
-        if cdr1_expect.match(cdr1) and cdr2_expect.match(cdr2):
-            print "Success"
-            self.passed = True
-        else:
-            print "Failure"
+            logger.error("Fail: Original CDR duration shorter than forked")
+            self.passed = False
 
 def main():
-    logging.basicConfig()
-    test = Test()
+    test = Fork_After_Busy_Test()
+    test.start_asterisk()
     reactor.run()
-    return not test.passed
+    test.stop_asterisk()
+    return test.results()
 
 if __name__ == '__main__':
     sys.exit(main())
-
-# vim:sw=4:ts=4:expandtab:textwidth=79

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/test-config.yaml?view=diff&rev=2945&r1=2944&r2=2945
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/test-config.yaml (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_after_busy_forward/test-config.yaml Wed Dec 21 15:13:58 2011
@@ -1,15 +1,14 @@
 testinfo:
     summary: CLI exec console dial busy forward with ForkCDR
     description: |
-        'One Asterisk instance with console dial excutes another instance via SIP.
-        It responds with busy, then we call ForkCDR and dial another number which
-        answers.  The other instance answers and the CDRs are tested for expected
-        behavior.'
+        'An Asterisk instance originates a local channel on an extension. This
+        extension dials another which responds with busy, then we call ForkCDR and
+        dial another number which answers. Afterwards, the CDRs are tested for
+        expected behavior.'
 
 properties:
     minversion: '1.4'
     dependencies:
         - python : 'twisted'
         - python : 'starpy'
-        - custom : 'soundcard'
         - asterisk : 'cdr_csv'

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_before_dial/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_before_dial/configs/ast1/extensions.conf?view=diff&rev=2945&r1=2944&r2=2945
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_before_dial/configs/ast1/extensions.conf (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_before_dial/configs/ast1/extensions.conf Wed Dec 21 15:13:58 2011
@@ -7,7 +7,7 @@
 [default]
 exten => 1,1,NoOp(Wait a bit so that we can see different times)
 	same => n,Set(CDR(accountcode)=cdrtest_local)
-	same => n,Wait(3)
+	same => n,Playback(silence/3)
 	same => n,ForkCDR
 	same => n,Dial(SIP/test/2)
 

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_before_dial/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_before_dial/run-test?view=diff&rev=2945&r1=2944&r2=2945
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_before_dial/run-test (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_before_dial/run-test Wed Dec 21 15:13:58 2011
@@ -18,7 +18,9 @@
 from asterisk.CDRTestCase import CDRTestCase
 from twisted.internet import reactor
 
-class SIP_Dial_Congestion_Test(CDRTestCase):
+logger = logging.getLogger(__name__)
+
+class Fork_Before_Dial_Test(CDRTestCase):
     def __init__(self):
         CDRTestCase.__init__(self)
 
@@ -36,46 +38,28 @@
             disposition="ANSWERED",
             amaflags="DOCUMENTATION"
         ))
-    '''
-    def end(self, ami, event):
-        if event.get('channel').lower() != "console/dsp":
+        self.add_expectation('cdrtest_sip', AsteriskCSVCDRLine(
+            destination="2",
+            dcontext="default",
+            channel="SIP/test-.*",
+            disposition="ANSWERED",
+            amaflags="DOCUMENTATION"
+        ))
+
+    def match_cdrs(self):
+        CDRTestCase.match_cdrs(self)
+
+        if (self.passed == False):
             return
-        self.stop_reactor()
 
-        cdr1 = AsteriskCSVCDR(fn="%s/var/log/asterisk/cdr-csv/Master.csv" % (self.ast1.base))
-        cdr2 = AsteriskCSVCDR(fn="%s/var/log/asterisk/cdr-csv/Master.csv" % (self.ast2.base))
-
-        records = []
-
-        records.append(AsteriskCSVCDRLine(disposition='ANSWERED', dchannel='',
-            dcontext='default', amaflags='DOCUMENTATION', uniqueid=cdr1[0].uniqueid,
-            accountcode='', callerid='', userfield='', source='', destination='1',
-            lastapp='Dial', lastarg='SIP/1 at test', channel='Console/dsp', billsec=cdr1[0].billsec))
-
-        records.append(AsteriskCSVCDRLine(disposition='ANSWERED', dchannel='SIP/test-.*',
-            dcontext='default', amaflags='DOCUMENTATION', uniqueid=cdr1[0].uniqueid,
-            accountcode='', callerid='', userfield='', source='', destination='1',
-            lastapp='Dial', lastarg='SIP/1 at test', channel='Console/dsp', billsec=cdr1[0].billsec))
-
-        cdr1_expect = AsteriskCSVCDR(records=records)
-
-        cdr2_expect = AsteriskCSVCDR(records=[AsteriskCSVCDRLine(accountcode="",
-            source="asterisk", destination="1", dcontext="default",
-            callerid='"asterisk" <asterisk>', channel="SIP/.*5065-.*",
-            dchannel="", lastapp="Hangup", lastarg="", disposition="ANSWERED",
-            amaflags="DOCUMENTATION")])
+        cdr1 = AsteriskCSVCDR(fn="%s/%s/cdr-csv/%s.csv" % (self.ast[0].base, self.ast[0].directories['astlogdir'], "cdrtest_local"))
 
         if int(cdr1[0].duration) < int(cdr1[1].duration):
-            print "Fail: Original CDR duration shorter than forked"
+            logger.error("Fail: Original CDR duration shorter than forked")
+            self.passed = False
 
-        if cdr1_expect.match(cdr1) and cdr2_expect.match(cdr2):
-            print "Success"
-            self.passed = True
-        else:
-            print "Failure"
-    '''
 def main():
-    test = SIP_Dial_Congestion_Test()
+    test = Fork_Before_Dial_Test()
     test.start_asterisk()
     reactor.run()
     test.stop_asterisk()

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_before_dial/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_before_dial/test-config.yaml?view=diff&rev=2945&r1=2944&r2=2945
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_before_dial/test-config.yaml (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_before_dial/test-config.yaml Wed Dec 21 15:13:58 2011
@@ -1,9 +1,9 @@
 testinfo:
     summary: CLI exec console dial which calls ForkCDR before dialing via SIP which answers
     description: |
-        'One Asterisk instance with console dial excutes ForkCDR and calls another
-        instance via SIP. The other instance answers and the CDRs are tested for
-        expected behavior.'
+        'An Asterisk instance originates a Local channel which will play silence for about
+        3 seconds before using ForkCDR and then dial itself via SIP. The receiving channel
+        answers and then immediately hangs up. CDRs are tested for expected behavior.'
 
 properties:
     minversion: '1.4'

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/nocdr/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/nocdr/run-test?view=diff&rev=2945&r1=2944&r2=2945
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/nocdr/run-test (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/nocdr/run-test Wed Dec 21 15:13:58 2011
@@ -8,63 +8,35 @@
 '''
 
 import sys
-from time import sleep
 import os
+import logging
+import re
 sys.path.append("lib/python")
 from asterisk.asterisk import Asterisk
 from asterisk.cdr import AsteriskCSVCDR, AsteriskCSVCDRLine
-from asterisk.ami import AMI
+from asterisk.TestCase import TestCase
+from asterisk.CDRTestCase import CDRTestCase
 from twisted.internet import reactor
-import logging
 
-workingdir = "cdr/nocdr"
-testdir = "tests/%s" % workingdir
+logger = logging.getLogger(__name__)
 
-class Test:
+class NoCDRTest(CDRTestCase):
     def __init__(self):
-        self.passed = False
-
-        self.ast1 = Asterisk(base=workingdir)
-        self.ast1.install_configs("%s/configs/ast1" % (testdir))
-
-        self.ast1.start()
-
-        reactor.callLater(30, self.stop_reactor)
-
-        self.ami = AMI(self.start, self.stop_reactor, timeout=20)
-        self.ami.login()
-
-    def start(self, ami):
-        ami.registerEvent('Hangup', self.end)
-        ami.originate(channel = "Local/1 at default", application = "Echo")
-
-    def stop_asterisk(self):
-        self.ast1.stop()
-
-    def stop_reactor(self):
-        print "Stopping Reactor ..."
-        if reactor.running:
-            reactor.stop()
-        self.stop_asterisk()
-
-    def end(self, ami, event):
-        self.stop_reactor()
-
-        print "The failure to open the next CDR is expected"
-        cdr1 = AsteriskCSVCDR(fn="%s/var/log/asterisk/cdr-csv/Master.csv" % (self.ast1.base))
-
-        if len(cdr1) == 1 and cdr1[0].lastapp == "Echo":
-            # There will be 1 CDR record for the second end of the originated channel.
-            print "Success"
-            self.passed = True
-        else:
-            print "Failure"
+        CDRTestCase.__init__(self)
+        self.add_expectation('Master', AsteriskCSVCDRLine(
+            destination="1",
+            dcontext="default",
+            channel="Local/1 at default-.*",
+            disposition="ANSWERED",
+            amaflags="DOCUMENTATION"
+        ))
 
 def main():
-    logging.basicConfig()
-    test = Test()
+    test = NoCDRTest()
+    test.start_asterisk()
     reactor.run()
-    return not test.passed
+    test.stop_asterisk()
+    return test.results()
 
 if __name__ == '__main__':
     sys.exit(main())




More information about the svn-commits mailing list