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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 30 12:21:51 CST 2011


Author: jrose
Date: Wed Nov 30 12:21:47 2011
New Revision: 2818

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=2818
Log:
Adds current change set to Group branch for CDR Test Overhaul

Removed:
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_unanswered_yes/configs/ast1/manager.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_userfield/configs/ast1/manager.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/configs/ast1/manager.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/configs/ast1/manager.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_transfer/configs/ast1/manager.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_before_dial/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/cdr_unanswered_yes/configs/ast1/extensions.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_unanswered_yes/run-test
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_userfield/configs/ast1/extensions.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_userfield/run-test
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/configs/ast1/branch-1.4/sip.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/configs/ast1/extensions.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/configs/ast1/sip.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/run-test
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/test-config.yaml
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/configs/ast1/branch-1.4/sip.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/configs/ast1/extensions.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/configs/ast1/sip.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/run-test
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/test-config.yaml
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/configs/ast1/branch-1.4/sip.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/configs/ast1/extensions.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/configs/ast1/sip.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/run-test
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/test-config.yaml
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_transfer/configs/ast1/branch-1.4/sip.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_transfer/configs/ast1/extensions.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_transfer/configs/ast1/sip.conf
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_transfer/run-test
    asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_fork_before_dial/configs/ast1/branch-1.4/sip.conf
    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/configs/ast1/sip.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

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=2818&r1=2817&r2=2818
==============================================================================
--- 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 Nov 30 12:21:47 2011
@@ -15,6 +15,7 @@
 from asterisk import Asterisk
 from TestCase import TestCase
 from cdr import AsteriskCSVCDR, AsteriskCSVCDRLine
+from collections import defaultdict
 
 logger = logging.getLogger(__name__)
 
@@ -26,7 +27,7 @@
     class TestFoo(CDRTestCase):
         def __init__(self):
             TestCase.__init__(self):
-            self.add_expectation(AsteriskCSVCDRLine(
+            self.add_expectation("Master", AsteriskCSVCDRLine(
                 accountcode='testsuite',
                 source='',
                 destination='1',
@@ -46,57 +47,50 @@
     """
 
     def __init__(self):
-        """"
+        """
         Create a single Asterisk instance.
         """
         TestCase.__init__(self)
-        self.CDRFileExpectations = []
+        self.CDRFileExpectations = defaultdict(list)
         self.create_asterisk()
 
 
-    def add_expectation(self, filename, cdrline):
+    def add_expectation(self, recordname, cdrline):
         """
         Add an expectation to the expectation list
 
         Keyword Arguments:
+        recordname -- name of the record in which the cdr line is expected to appear
         cdrline -- AsteriskCSVCDRLine for an expected element of the cdr
 
         Example Usage:
-        self.add_expectation(AsteriskCSVCDRLine(accountcode="",
+        self.add_expectation("Master", AsteriskCSVCDRLine(accountcode="",
             source="", destination="s", dcontext="default", callerid="",
             channel="SIP/test-00000000", disposition="CONGESTION",
             amaflags="DOCUMENTATION"))
         """
-        for i in self.CDRFileExpectations:
-            if i and i[0] == filename:
-                i.append(cdrline)
-                return
-
-        self.CDRFileExpectations.append([])
-        self.CDRFileExpectations[len(self.CDRFileExpectations) - 1].append(filename)
-        self.CDRFileExpectations[len(self.CDRFileExpectations) - 1].append(cdrline)
+        self.CDRFileExpectations[recordname].append(cdrline)
 
     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
 
-        self.passed = True
-        for i in self.CDRFileExpectations:
-            # We'll store the cdrlines for an individual instance of Asterisk in here
+        for key in self.CDRFileExpectations:
+            # We'll store the cdrlines for an individual cdr log file in here
             records = []
 
-            # Build records with just the cdrlines that belong to this instance of Asterisk
-            for j in range(1,len(i)):
-                records.append(i[j])
+            # Build records with just the cdrlines that belong to this record
+            for i in self.CDRFileExpectations.get(key):
+                records.append(i)
 
             cdr_expect = AsteriskCSVCDR(records=records)
-            cdr_file = AsteriskCSVCDR(fn="%s/%s/cdr-csv/%s.csv" % (self.ast[0].base, self.ast[0].directories['astlogdir'], i[0]))
+            cdr_file = AsteriskCSVCDR(fn="%s/%s/cdr-csv/%s.csv" % (self.ast[0].base, self.ast[0].directories['astlogdir'], key))
 
             if cdr_expect.match(cdr_file):
-                logger.debug("%s.csv - CDR results met expectations" % i[0])
+                logger.debug("%s.csv - CDR results met expectations" % key)
             else:
-                logger.debug("%s.csv - CDR results did not meet expectations.  Test Failed." % i[0])
+                logger.error("%s.csv - CDR results did not meet expectations.  Test Failed." % key)
                 self.passed = False
-
 
     def results(self):
         """

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_unanswered_yes/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_unanswered_yes/configs/ast1/extensions.conf?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_unanswered_yes/configs/ast1/extensions.conf (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_unanswered_yes/configs/ast1/extensions.conf Wed Nov 30 12:21:47 2011
@@ -5,4 +5,5 @@
 [globals]
 
 [default]
-exten => 1,1,Hangup()
+exten => 1,1,Set(CDR(accountcode)=cdrtest_local)
+exten => 1,n,Hangup()

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_unanswered_yes/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_unanswered_yes/run-test?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_unanswered_yes/run-test (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_unanswered_yes/run-test Wed Nov 30 12:21:47 2011
@@ -8,79 +8,30 @@
 '''
 
 import sys
-from time import sleep
-import os
 sys.path.append("lib/python")
+from asterisk.CDRTestCase import CDRTestCase
 from asterisk.asterisk import Asterisk
 from asterisk.cdr import AsteriskCSVCDR, AsteriskCSVCDRLine
-from asterisk.ami import AMI
 from twisted.internet import reactor
-import logging
-import re
 
-workingdir = "cdr/cdr_unanswered_yes"
-testdir = "tests/%s" % workingdir
+class CDRUnansweredYesTest(CDRTestCase):
+    def __init__(self):
 
-class Test:
-    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", async = True)
-
-    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):
-        if not re.match(".*;2$", event['channel']):
-                return
-        self.stop_reactor()
-
-        cdr1 = AsteriskCSVCDR(fn="%s/var/log/asterisk/cdr-csv/Master.csv" % (self.ast1.base))
-
-        cdr1_expect = AsteriskCSVCDR(records=[AsteriskCSVCDRLine(accountcode="",
-            source="", destination="1", dcontext="default", callerid="",
-            channel="Local/1 at default;2", dchannel="", lastapp="Hangup", lastarg="",
-            disposition="NO ANSWER", amaflags="DOCUMENTATION")])
-
-        cdr1_match = None
-
-        # Find the CDR we want to match, since ordering is random.
-        for c in cdr1:
-                if re.match("Local/1 at default-....;2", c.channel):
-                        cdr1_match = c
-                        # Small hack to force channels to match.  No problem, since we just checked them ourselves.
-                        cdr1_match.channel = cdr1_expect[0].channel
-                        break
-
-        if cdr1_expect[0].match(cdr1_match):
-            print "Success"
-            self.passed = True
-        else:
-            print "Failure"
+        CDRTestCase.__init__(self)
+        
+        self.add_expectation('cdrtest_local', AsteriskCSVCDRLine(source="", destination="1",
+            dcontext="default", callerid="", channel="Local/1 at default-.*", dchannel="",
+            lastapp="Hangup", lastarg="", disposition="NO ANSWER",
+            amaflags="DOCUMENTATION"
+        ))
 
 def main():
-    logging.basicConfig()
-    test = Test()
+    test = CDRUnansweredYesTest()
+    test.start_asterisk()
     reactor.run()
-    return not test.passed
+    test.stop_asterisk()
+
+    return test.results()
 
 if __name__ == '__main__':
-    sys.exit(main())
+    sys.exit(main())

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_userfield/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_userfield/configs/ast1/extensions.conf?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_userfield/configs/ast1/extensions.conf (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_userfield/configs/ast1/extensions.conf Wed Nov 30 12:21:47 2011
@@ -6,5 +6,6 @@
 
 [default]
 exten => 1,1,Answer
+exten => 1,n,Set(CDR(accountcode)=cdrtest_local)
 exten => 1,n,Set(CDR(userfield)=bazinga)
 exten => 1,n,Hangup

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_userfield/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_userfield/run-test?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_userfield/run-test (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_userfield/run-test Wed Nov 30 12:21:47 2011
@@ -8,73 +8,30 @@
 '''
 
 import sys
-from time import sleep
-import os
 sys.path.append("lib/python")
+from asterisk.CDRTestCase import CDRTestCase
 from asterisk.asterisk import Asterisk
 from asterisk.cdr import AsteriskCSVCDR, AsteriskCSVCDRLine
-from asterisk.ami import AMI
 from twisted.internet import reactor
-import logging
-import re
 
-workingdir = "cdr/cdr_userfield"
-testdir = "tests/%s" % workingdir
+class CDRUnansweredYesTest(CDRTestCase):
+    def __init__(self):
 
-class Test:
-    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):
-        if not re.match(".*;2$", event['channel']):
-                return
-        self.stop_reactor()
-
-        cdr1 = AsteriskCSVCDR(fn="%s/var/log/asterisk/cdr-csv/Master.csv" % (self.ast1.base))
-
-        cdr1_expect = AsteriskCSVCDR(records=[AsteriskCSVCDRLine(accountcode="",
-            source="", destination="1", dcontext="default", callerid="",
-            channel="Local/1 at default;2", dchannel="", lastapp="Hangup", lastarg="",
-            disposition="ANSWERED", amaflags="DOCUMENTATION", userfield="bazinga")])
-
-        if re.match("Local/1 at default-....;2", cdr1[0].channel):
-                # Small hack to force channels to match.  No problem, since we just checked them ourselves.
-                cdr1[0].channel = cdr1_expect[0].channel
-
-        if cdr1_expect[0].match(cdr1[0]):
-            print "Success"
-            self.passed = True
-        else:
-            print "Failure"
+        CDRTestCase.__init__(self)
+        
+        self.add_expectation('cdrtest_local',AsteriskCSVCDRLine(source="", 
+            destination="1", dcontext="default", callerid="",
+            channel="Local/1 at default-.*", dchannel="", lastapp="Hangup", lastarg="",
+            disposition="ANSWERED", amaflags="DOCUMENTATION", userfield="bazinga"
+        ))
 
 def main():
-    logging.basicConfig()
-    test = Test()
+    test = CDRUnansweredYesTest()
+    test.start_asterisk()
     reactor.run()
-    return not test.passed
+    test.stop_asterisk()
+
+    return test.results()
 
 if __name__ == '__main__':
     sys.exit(main())

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/configs/ast1/branch-1.4/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/configs/ast1/branch-1.4/sip.conf?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/configs/ast1/branch-1.4/sip.conf (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/configs/ast1/branch-1.4/sip.conf Wed Nov 30 12:21:47 2011
@@ -1,12 +1,9 @@
 [general]
 context=default
-bindaddr=0.0.0.0
-bindport=5065
+udpbindaddr=127.0.0.1
 canreinvite=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_dial_sip_answer/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/configs/ast1/extensions.conf?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/configs/ast1/extensions.conf (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/configs/ast1/extensions.conf Wed Nov 30 12:21:47 2011
@@ -5,4 +5,10 @@
 [globals]
 
 [default]
-exten => 1,1,Dial(SIP/1 at test)
+exten => 1,1,NoOp()
+	same => n,Set(CDR(accountcode)=cdrtest_local)
+	same => n,Dial(SIP/2 at test)
+
+exten => 2,1,NoOp()
+	same => n, Answer()
+	same => n, HangUp()

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/configs/ast1/sip.conf?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/configs/ast1/sip.conf (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/configs/ast1/sip.conf Wed Nov 30 12:21:47 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_dial_sip_answer/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/run-test?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/run-test (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/run-test Wed Nov 30 12:21:47 2011
@@ -15,58 +15,33 @@
 from asterisk.asterisk import Asterisk
 from asterisk.cdr import AsteriskCSVCDR, AsteriskCSVCDRLine
 from asterisk.TestCase import TestCase
+from asterisk.CDRTestCase import CDRTestCase
 from twisted.internet import reactor
 
 
-class Test(TestCase):
+class SIP_Dial_Answer_Test(CDRTestCase):
     def __init__(self):
-        TestCase.__init__(self)
-        self.create_asterisk(2)
+        CDRTestCase.__init__(self)
 
-    def ami_connect(self, ami):
-        if ami.id == 0:
-            self.ami[0].registerEvent('Hangup', self.end)
-            self.ami[0].originate(channel = "Local/1 at default", application = "Echo")
-
-    def end(self, ami, event):
-        if not re.match(".*;1$", event['channel']):
-            return
-        self.stop_reactor()
-
-    def results(self):
-        cdr1 = AsteriskCSVCDR(fn="%s/var/log/asterisk/cdr-csv/Master.csv" %
-                (self.ast[0].base))
-        cdr2 = AsteriskCSVCDR(fn="%s/var/log/asterisk/cdr-csv/Master.csv" %
-                (self.ast[1].base))
-
-        cdr1_expect = AsteriskCSVCDR(records=[AsteriskCSVCDRLine(accountcode="",
-            source="", destination="1", dcontext="default", callerid="",
-            channel="Local/1 at default-.*", dchannel="SIP/test-00000000", lastapp="Dial",
-            lastarg="SIP/1 at test", disposition="ANSWERED",
-            amaflags="DOCUMENTATION")])
-        cdr2_expect = AsteriskCSVCDR(records=[AsteriskCSVCDRLine(accountcode="",
-            source="Anonymous", destination="1", dcontext="default",
-            callerid='"Anonymous" <Anonymous>', channel="SIP/anonymous.invalid-.*",
-            dchannel="", lastapp="Hangup", lastarg="", disposition="ANSWERED",
-            amaflags="DOCUMENTATION")])
-
-        if cdr1_expect[0].match(cdr1[0]) and cdr2_expect.match(cdr2):
-            print "Success"
-            self.passed = True
-        else:
-            print "Failure"
-
-    def run(self):
-        TestCase.run(self)
-        self.create_ami_factory()
+        self.add_expectation('cdrtest_local', AsteriskCSVCDRLine(
+            destination="1",
+            dcontext="default",
+            channel="Local/1 at default-.*",
+            disposition="ANSWERED",
+            amaflags="DOCUMENTATION"))
+        self.add_expectation('cdrtest_sip', AsteriskCSVCDRLine(
+            destination="2",
+            dcontext="default",
+            channel="SIP/test-.*",
+            disposition="ANSWERED",
+            amaflags="DOCUMENTATION"))
 
 def main():
-    test = Test()
+    test = SIP_Dial_Answer_Test()
     test.start_asterisk()
     reactor.run()
     test.stop_asterisk()
-    test.results()
-    return not test.passed
+    return test.results()
 
 if __name__ == '__main__':
     sys.exit(main())

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/test-config.yaml?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/test-config.yaml (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_answer/test-config.yaml Wed Nov 30 12:21:47 2011
@@ -1,8 +1,8 @@
 testinfo:
     summary: CLI exec console dial which dials via SIP which answers
     description: |
-        'One Asterisk instance with console dial calls another instance via SIP.
-        the other instance answers and the CDRs are tested for expected behavior.'
+        'An Asterisk instance originates a local channel to dial an internal extension
+        with a SIP peer. Asterisk then answers this call and shortly after hangs up.'
 
 properties:
     minversion: '1.4'

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/configs/ast1/branch-1.4/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/configs/ast1/branch-1.4/sip.conf?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/configs/ast1/branch-1.4/sip.conf (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/configs/ast1/branch-1.4/sip.conf Wed Nov 30 12:21:47 2011
@@ -1,12 +1,9 @@
 [general]
 context=default
-bindaddr=0.0.0.0
-bindport=5065
+udpbindaddr=127.0.0.1
 canreinvite=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_dial_sip_busy/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/configs/ast1/extensions.conf?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/configs/ast1/extensions.conf (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/configs/ast1/extensions.conf Wed Nov 30 12:21:47 2011
@@ -5,4 +5,9 @@
 [globals]
 
 [default]
-exten => 1,1,Dial(SIP/1 at test)
+exten => 1,1,NoOp()
+	same => n,Set(CDR(accountcode)=cdrtest_local)
+	same => n,Dial(SIP/2 at test)
+
+exten => 2,1,Busy()
+	same => n,Hangup()

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/configs/ast1/sip.conf?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/configs/ast1/sip.conf (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/configs/ast1/sip.conf Wed Nov 30 12:21:47 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_dial_sip_busy/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/run-test?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/run-test (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/run-test Wed Nov 30 12:21:47 2011
@@ -14,72 +14,26 @@
 from asterisk.asterisk import Asterisk
 from asterisk.cdr import AsteriskCSVCDR, AsteriskCSVCDRLine
 from asterisk.ami import AMI
+from asterisk.CDRTestCase import CDRTestCase
 from twisted.internet import reactor
 import logging
 
-workingdir = "cdr/console_dial_sip_busy"
-testdir = "tests/%s" workingdir
-
-class Test:
+class SIP_Dial_Busy_Test(CDRTestCase):
     def __init__(self):
-        self.passed = False
-
-        self.ast1 = Asterisk(base=workingdir)
-        self.ast1.install_configs("%s/configs/ast1" % (testdir))
-
-        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))
-
-        print "The failure to open the next CDR is expected"
-        cdr2 = AsteriskCSVCDR(fn="%s/var/log/asterisk/cdr-csv/Master.csv" % (self.ast2.base))
-
-        cdr1_expect = AsteriskCSVCDR(records=[AsteriskCSVCDRLine(accountcode="",
-            source="", destination="1", dcontext="default", callerid="",
-            channel="Console/dsp", dchannel="SIP/test-00000000", lastapp="Dial",
-            lastarg="SIP/1 at test", disposition="BUSY",
-            amaflags="DOCUMENTATION")])
-
-        if cdr1_expect.match(cdr1) and len(cdr2) == 0:
-            print "Success"
-            self.passed = True
-        else:
-            print "Failure"
+        CDRTestCase.__init__(self)
+        self.add_expectation('cdrtest_local', AsteriskCSVCDRLine(
+            destination="1",
+            dcontext="default",
+            channel="Local/1 at default-.*",
+            disposition="BUSY",
+            amaflags="DOCUMENTATION"))
 
 def main():
-    logging.basicConfig()
-    test = Test()
+    test = SIP_Dial_Busy_Test()
+    test.start_asterisk()
     reactor.run()
-    return not test.passed
+    test.stop_asterisk()
+    return test.results()
 
 if __name__ == '__main__':
     sys.exit(main())

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/test-config.yaml?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/test-config.yaml (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_busy/test-config.yaml Wed Nov 30 12:21:47 2011
@@ -1,14 +1,12 @@
 testinfo:
     summary: CLI exec console dial which dials via SIP which returns busy
     description: |
-        'One Asterisk instance with console dial calls another instance via SIP.
-        the other instance returns busy and the CDRs are tested for expected
-        behavior.'
+        'An Asterisk instance dials itself from a local channel via SIP.
+        The extension sends a busy indication.'
 
 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_dial_sip_congestion/configs/ast1/branch-1.4/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/configs/ast1/branch-1.4/sip.conf?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/configs/ast1/branch-1.4/sip.conf (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/configs/ast1/branch-1.4/sip.conf Wed Nov 30 12:21:47 2011
@@ -1,12 +1,10 @@
 [general]
 context=default
-bindaddr=0.0.0.0
-bindport=5065
+udpbindaddr=127.0.0.1
 canreinvite=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_dial_sip_congestion/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/configs/ast1/extensions.conf?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/configs/ast1/extensions.conf (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/configs/ast1/extensions.conf Wed Nov 30 12:21:47 2011
@@ -5,4 +5,10 @@
 [globals]
 
 [default]
-exten => 1,1,Dial(SIP/1 at test)
+exten => 1,1,NoOp()
+	same => n,Set(CDR(accountcode)=cdrtest_local)
+    same => n,Dial(SIP/test/2)
+
+exten => 2,1,NoOp()
+    same => n,Congestion()
+

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/configs/ast1/sip.conf?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/configs/ast1/sip.conf (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/configs/ast1/sip.conf Wed Nov 30 12:21:47 2011
@@ -1,11 +1,10 @@
 [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_dial_sip_congestion/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/run-test?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/run-test (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/run-test Wed Nov 30 12:21:47 2011
@@ -8,78 +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/console_dial_sip_congestion"
-testdir = "tests/%s" workingdir
+class SIP_Dial_Congestion_Test(CDRTestCase):
+    def __init__(self):
+        CDRTestCase.__init__(self)
 
-class Test:
-    def __init__(self):
-        self.passed = False
-
-        self.ast1 = Asterisk(base=workingdir)
-        self.ast1.install_configs("%s/configs/ast1" % (testdir))
-
-        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))
-
-        print "The failure to open the next CDR is expected"
-        cdr2 = AsteriskCSVCDR(fn="%s/var/log/asterisk/cdr-csv/Master.csv" % (self.ast2.base))
-
-        cdr1_expect = AsteriskCSVCDR(records=[AsteriskCSVCDRLine(accountcode="",
-            source="", destination="1", dcontext="default", callerid="",
-            channel="Console/dsp", dchannel="SIP/test-00000000", lastapp="Dial",
-            lastarg="SIP/1 at test", disposition="FAILED",
-            amaflags="DOCUMENTATION")])
-
-        if cdr1_expect.match(cdr1) and len(cdr2) == 0:
-            print "Success"
-            self.passed = True
-        else:
-            print "Failure"
+        self.add_expectation('cdrtest_local', AsteriskCSVCDRLine(
+            destination="1",
+            dcontext="default",
+            channel="Local/1 at default-.*",
+            dchannel="SIP/test-.*",
+            disposition="FAILED",
+            amaflags="DOCUMENTATION"
+        ))
 
 def main():
-    logging.basicConfig()
-    test = Test()
+    test = SIP_Dial_Congestion_Test()
+    test.start_asterisk()
     reactor.run()
-    return not test.passed
+    test.stop_asterisk()
+    return test.results()
 
 if __name__ == '__main__':
     sys.exit(main())

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/test-config.yaml?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/test-config.yaml (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_congestion/test-config.yaml Wed Nov 30 12:21:47 2011
@@ -1,14 +1,12 @@
 testinfo:
     summary: CLI exec console dial which dials via SIP which returns congestion
     description: |
-        'One Asterisk instance with console dial calls another instance via SIP.
-        the other instance returns congestion and the CDRs are tested for expected
-        behavior.'
+        'An Asterisk instance originates a local channel to dial itself via SIP.
+        Upon reaching the extension the SIP channel dials, Asterisk will return congestion.'
 
 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_dial_sip_transfer/configs/ast1/branch-1.4/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_transfer/configs/ast1/branch-1.4/sip.conf?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_transfer/configs/ast1/branch-1.4/sip.conf (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_transfer/configs/ast1/branch-1.4/sip.conf Wed Nov 30 12:21:47 2011
@@ -1,12 +1,10 @@
 [general]
 context=default
-bindaddr=0.0.0.0
-bindport=5065
+udpbindaddr=127.0.0.1
 canreinvite=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_dial_sip_transfer/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_transfer/configs/ast1/extensions.conf?view=diff&rev=2818&r1=2817&r2=2818
==============================================================================
--- asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_transfer/configs/ast1/extensions.conf (original)
+++ asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_transfer/configs/ast1/extensions.conf Wed Nov 30 12:21:47 2011
@@ -5,4 +5,15 @@
 [globals]
 
 [default]
-exten => _X,1,Dial(SIP/${EXTEN}@test)
+exten => 1,1,NoOp()
+	same => n,Set(CDR(accountcode)=cdrtest_local)
+	same => n,Dial(SIP/2 at test)
+
+exten => 2,1,NoOp()
+	same => n,Set(CDR(accountcode)=cdrtest_local2)
+	same => n,Transfer(3)
+
+exten => 3,1,NoOp()
+	same => n,Set(CDR(accountcode)=cdrtest_local3)
+	same => n,Answer()
+	same => n,Hangup()

Modified: asterisk/team/group/cdr_test_log_congestion/tests/cdr/console_dial_sip_transfer/configs/ast1/sip.conf

[... 299 lines stripped ...]



More information about the asterisk-commits mailing list