[svn-commits] jrose: testsuite/asterisk/trunk r2960 - in /asterisk/trunk: ./ lib/python/ast...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Dec 22 16:17:22 CST 2011


Author: jrose
Date: Thu Dec 22 16:17:15 2011
New Revision: 2960

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=2960
Log:
Adding tests from Congestion logging branch and also converting all old python CDR tests to use the new test suite.

Also hoping this commit doesn't destroy the world. Merging this was painful.
Review: https://reviewboard.asterisk.org/r/1637/
(issue ASTERISK-14842)


Added:
    asterisk/trunk/lib/python/asterisk/CDRTestCase.py
      - copied unchanged from r2951, asterisk/team/group/cdr_test_log_congestion/lib/python/asterisk/CDRTestCase.py
    asterisk/trunk/tests/cdr/cdr_originate_sip_congestion_log/
      - copied from r2951, asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_originate_sip_congestion_log/
    asterisk/trunk/tests/cdr/cdr_originate_sip_congestion_log/configs/
      - copied from r2951, asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_originate_sip_congestion_log/configs/
    asterisk/trunk/tests/cdr/cdr_originate_sip_congestion_log/configs/ast1/
      - copied from r2951, asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_originate_sip_congestion_log/configs/ast1/
    asterisk/trunk/tests/cdr/cdr_originate_sip_congestion_log/configs/ast1/cdr.conf
      - copied unchanged from r2951, asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_originate_sip_congestion_log/configs/ast1/cdr.conf
    asterisk/trunk/tests/cdr/cdr_originate_sip_congestion_log/configs/ast1/extensions.conf
      - copied unchanged from r2951, asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_originate_sip_congestion_log/configs/ast1/extensions.conf
    asterisk/trunk/tests/cdr/cdr_originate_sip_congestion_log/configs/ast1/manager.general.conf.inc
      - copied unchanged from r2951, asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_originate_sip_congestion_log/configs/ast1/manager.general.conf.inc
    asterisk/trunk/tests/cdr/cdr_originate_sip_congestion_log/configs/ast1/sip.conf
      - copied unchanged from r2951, asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_originate_sip_congestion_log/configs/ast1/sip.conf
    asterisk/trunk/tests/cdr/cdr_originate_sip_congestion_log/run-test
      - copied unchanged from r2951, asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_originate_sip_congestion_log/run-test
    asterisk/trunk/tests/cdr/cdr_originate_sip_congestion_log/test-config.yaml
      - copied unchanged from r2951, asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_originate_sip_congestion_log/test-config.yaml
Removed:
    asterisk/trunk/tests/cdr/cdr_unanswered_yes/configs/ast1/manager.conf
    asterisk/trunk/tests/cdr/cdr_userfield/configs/ast1/manager.conf
    asterisk/trunk/tests/cdr/console_dial_sip_answer/configs/ast2/
    asterisk/trunk/tests/cdr/console_dial_sip_busy/configs/ast1/manager.conf
    asterisk/trunk/tests/cdr/console_dial_sip_busy/configs/ast2/
    asterisk/trunk/tests/cdr/console_dial_sip_congestion/configs/ast1/manager.conf
    asterisk/trunk/tests/cdr/console_dial_sip_congestion/configs/ast2/
    asterisk/trunk/tests/cdr/console_dial_sip_transfer/configs/ast1/manager.conf
    asterisk/trunk/tests/cdr/console_dial_sip_transfer/configs/ast2/
    asterisk/trunk/tests/cdr/console_fork_after_busy_forward/configs/ast1/manager.conf
    asterisk/trunk/tests/cdr/console_fork_after_busy_forward/configs/ast2/
    asterisk/trunk/tests/cdr/console_fork_before_dial/configs/ast1/manager.conf
    asterisk/trunk/tests/cdr/console_fork_before_dial/configs/ast2/
    asterisk/trunk/tests/cdr/nocdr/configs/ast1/manager.conf
Modified:
    asterisk/trunk/   (props changed)
    asterisk/trunk/tests/cdr/cdr_unanswered_yes/configs/ast1/extensions.conf
    asterisk/trunk/tests/cdr/cdr_unanswered_yes/run-test
    asterisk/trunk/tests/cdr/cdr_userfield/configs/ast1/extensions.conf
    asterisk/trunk/tests/cdr/cdr_userfield/run-test
    asterisk/trunk/tests/cdr/console_dial_sip_answer/configs/ast1/branch-1.4/sip.conf
    asterisk/trunk/tests/cdr/console_dial_sip_answer/configs/ast1/extensions.conf
    asterisk/trunk/tests/cdr/console_dial_sip_answer/configs/ast1/sip.conf
    asterisk/trunk/tests/cdr/console_dial_sip_answer/run-test
    asterisk/trunk/tests/cdr/console_dial_sip_answer/test-config.yaml
    asterisk/trunk/tests/cdr/console_dial_sip_busy/configs/ast1/branch-1.4/sip.conf
    asterisk/trunk/tests/cdr/console_dial_sip_busy/configs/ast1/extensions.conf
    asterisk/trunk/tests/cdr/console_dial_sip_busy/configs/ast1/sip.conf
    asterisk/trunk/tests/cdr/console_dial_sip_busy/run-test
    asterisk/trunk/tests/cdr/console_dial_sip_busy/test-config.yaml
    asterisk/trunk/tests/cdr/console_dial_sip_congestion/configs/ast1/branch-1.4/sip.conf
    asterisk/trunk/tests/cdr/console_dial_sip_congestion/configs/ast1/extensions.conf
    asterisk/trunk/tests/cdr/console_dial_sip_congestion/configs/ast1/sip.conf
    asterisk/trunk/tests/cdr/console_dial_sip_congestion/run-test
    asterisk/trunk/tests/cdr/console_dial_sip_congestion/test-config.yaml
    asterisk/trunk/tests/cdr/console_dial_sip_transfer/configs/ast1/branch-1.4/sip.conf
    asterisk/trunk/tests/cdr/console_dial_sip_transfer/configs/ast1/extensions.conf
    asterisk/trunk/tests/cdr/console_dial_sip_transfer/configs/ast1/sip.conf
    asterisk/trunk/tests/cdr/console_dial_sip_transfer/run-test
    asterisk/trunk/tests/cdr/console_fork_after_busy_forward/configs/ast1/extensions.conf
    asterisk/trunk/tests/cdr/console_fork_after_busy_forward/configs/ast1/sip.conf
    asterisk/trunk/tests/cdr/console_fork_after_busy_forward/run-test
    asterisk/trunk/tests/cdr/console_fork_after_busy_forward/test-config.yaml
    asterisk/trunk/tests/cdr/console_fork_before_dial/configs/ast1/branch-1.4/sip.conf
    asterisk/trunk/tests/cdr/console_fork_before_dial/configs/ast1/extensions.conf
    asterisk/trunk/tests/cdr/console_fork_before_dial/configs/ast1/sip.conf
    asterisk/trunk/tests/cdr/console_fork_before_dial/run-test
    asterisk/trunk/tests/cdr/console_fork_before_dial/test-config.yaml
    asterisk/trunk/tests/cdr/nocdr/run-test
    asterisk/trunk/tests/cdr/tests.yaml

Propchange: asterisk/trunk/
------------------------------------------------------------------------------
    automerge = *

Propchange: asterisk/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 22 16:17:15 2011
@@ -1,1 +1,2 @@
+/asterisk/team/group/cdr_test_log_congestion:1823-2951
 /asterisk/trunk:1112

Propchange: asterisk/trunk/
------------------------------------------------------------------------------
    svnmerge-integrated = /asterisk/trunk:1-2945

Modified: asterisk/trunk/tests/cdr/cdr_unanswered_yes/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/cdr_unanswered_yes/configs/ast1/extensions.conf?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/cdr_unanswered_yes/configs/ast1/extensions.conf (original)
+++ asterisk/trunk/tests/cdr/cdr_unanswered_yes/configs/ast1/extensions.conf Thu Dec 22 16:17:15 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/trunk/tests/cdr/cdr_unanswered_yes/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/cdr_unanswered_yes/run-test?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/cdr_unanswered_yes/run-test (original)
+++ asterisk/trunk/tests/cdr/cdr_unanswered_yes/run-test Thu Dec 22 16:17:15 2011
@@ -8,79 +8,29 @@
 '''
 
 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):
+        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.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"
+        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/trunk/tests/cdr/cdr_userfield/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/cdr_userfield/configs/ast1/extensions.conf?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/cdr_userfield/configs/ast1/extensions.conf (original)
+++ asterisk/trunk/tests/cdr/cdr_userfield/configs/ast1/extensions.conf Thu Dec 22 16:17:15 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/trunk/tests/cdr/cdr_userfield/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/cdr_userfield/run-test?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/cdr_userfield/run-test (original)
+++ asterisk/trunk/tests/cdr/cdr_userfield/run-test Thu Dec 22 16:17:15 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 CDRUserFieldTest(CDRTestCase):
+    def __init__(self):
 
-class Test:
-    def __init__(self):
-        self.passed = False
+        CDRTestCase.__init__(self)
 
-        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"
+        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 = CDRUserFieldTest()
+    test.start_asterisk()
     reactor.run()
-    return not test.passed
+    test.stop_asterisk()
+    return test.results()
 
 if __name__ == '__main__':
     sys.exit(main())

Modified: asterisk/trunk/tests/cdr/console_dial_sip_answer/configs/ast1/branch-1.4/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_answer/configs/ast1/branch-1.4/sip.conf?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_answer/configs/ast1/branch-1.4/sip.conf (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_answer/configs/ast1/branch-1.4/sip.conf Thu Dec 22 16:17:15 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/trunk/tests/cdr/console_dial_sip_answer/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_answer/configs/ast1/extensions.conf?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_answer/configs/ast1/extensions.conf (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_answer/configs/ast1/extensions.conf Thu Dec 22 16:17:15 2011
@@ -5,4 +5,10 @@
 [globals]
 
 [default]
-exten => 1,1,Dial(SIP/1 at test)
+exten => 1,1,NoOp()
+exten => 1,n,Set(CDR(accountcode)=cdrtest_local)
+exten => 1,n,Dial(SIP/2 at test)
+
+exten => 2,1,NoOp()
+exten => 2,n,Answer()
+exten => 2,n,HangUp()

Modified: asterisk/trunk/tests/cdr/console_dial_sip_answer/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_answer/configs/ast1/sip.conf?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_answer/configs/ast1/sip.conf (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_answer/configs/ast1/sip.conf Thu Dec 22 16:17:15 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/trunk/tests/cdr/console_dial_sip_answer/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_answer/run-test?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_answer/run-test (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_answer/run-test Thu Dec 22 16:17:15 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/trunk/tests/cdr/console_dial_sip_answer/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_answer/test-config.yaml?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_answer/test-config.yaml (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_answer/test-config.yaml Thu Dec 22 16:17:15 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/trunk/tests/cdr/console_dial_sip_busy/configs/ast1/branch-1.4/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_busy/configs/ast1/branch-1.4/sip.conf?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_busy/configs/ast1/branch-1.4/sip.conf (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_busy/configs/ast1/branch-1.4/sip.conf Thu Dec 22 16:17:15 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/trunk/tests/cdr/console_dial_sip_busy/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_busy/configs/ast1/extensions.conf?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_busy/configs/ast1/extensions.conf (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_busy/configs/ast1/extensions.conf Thu Dec 22 16:17:15 2011
@@ -5,4 +5,9 @@
 [globals]
 
 [default]
-exten => 1,1,Dial(SIP/1 at test)
+exten => 1,1,NoOp()
+exten => 1,n,Set(CDR(accountcode)=cdrtest_local)
+exten => 1,n,Dial(SIP/2 at test)
+
+exten => 2,1,Busy()
+exten => 2,n,Hangup()

Modified: asterisk/trunk/tests/cdr/console_dial_sip_busy/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_busy/configs/ast1/sip.conf?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_busy/configs/ast1/sip.conf (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_busy/configs/ast1/sip.conf Thu Dec 22 16:17:15 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/trunk/tests/cdr/console_dial_sip_busy/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_busy/run-test?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_busy/run-test (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_busy/run-test Thu Dec 22 16:17:15 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())
+    sys.exit(main())

Modified: asterisk/trunk/tests/cdr/console_dial_sip_busy/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_busy/test-config.yaml?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_busy/test-config.yaml (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_busy/test-config.yaml Thu Dec 22 16:17:15 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/trunk/tests/cdr/console_dial_sip_congestion/configs/ast1/branch-1.4/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_congestion/configs/ast1/branch-1.4/sip.conf?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_congestion/configs/ast1/branch-1.4/sip.conf (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_congestion/configs/ast1/branch-1.4/sip.conf Thu Dec 22 16:17:15 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/trunk/tests/cdr/console_dial_sip_congestion/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_congestion/configs/ast1/extensions.conf?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_congestion/configs/ast1/extensions.conf (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_congestion/configs/ast1/extensions.conf Thu Dec 22 16:17:15 2011
@@ -5,4 +5,10 @@
 [globals]
 
 [default]
-exten => 1,1,Dial(SIP/1 at test)
+exten => 1,1,NoOp()
+exten => 1,n,Set(CDR(accountcode)=cdrtest_local)
+exten => 1,n,Dial(SIP/test/2)
+
+exten => 2,1,NoOp()
+exten => 2,n,Congestion()
+

Modified: asterisk/trunk/tests/cdr/console_dial_sip_congestion/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_congestion/configs/ast1/sip.conf?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_congestion/configs/ast1/sip.conf (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_congestion/configs/ast1/sip.conf Thu Dec 22 16:17:15 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/trunk/tests/cdr/console_dial_sip_congestion/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_congestion/run-test?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_congestion/run-test (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_congestion/run-test Thu Dec 22 16:17:15 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())
+    sys.exit(main())

Modified: asterisk/trunk/tests/cdr/console_dial_sip_congestion/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_congestion/test-config.yaml?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_congestion/test-config.yaml (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_congestion/test-config.yaml Thu Dec 22 16:17:15 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/trunk/tests/cdr/console_dial_sip_transfer/configs/ast1/branch-1.4/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_transfer/configs/ast1/branch-1.4/sip.conf?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_transfer/configs/ast1/branch-1.4/sip.conf (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_transfer/configs/ast1/branch-1.4/sip.conf Thu Dec 22 16:17:15 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/trunk/tests/cdr/console_dial_sip_transfer/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_transfer/configs/ast1/extensions.conf?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_transfer/configs/ast1/extensions.conf (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_transfer/configs/ast1/extensions.conf Thu Dec 22 16:17:15 2011
@@ -5,4 +5,15 @@
 [globals]
 
 [default]
-exten => _X,1,Dial(SIP/${EXTEN}@test)
+exten => 1,1,NoOp()
+exten => 1,n,Set(CDR(accountcode)=cdrtest_local)
+exten => 1,n,Dial(SIP/2 at test)
+
+exten => 2,1,NoOp()
+exten => 2,n,Set(CDR(accountcode)=cdrtest_local2)
+exten => 2,n,Transfer(3)
+
+exten => 3,1,NoOp()
+exten => 3,n,Set(CDR(accountcode)=cdrtest_local3)
+exten => 3,n,Answer()
+exten => 3,n,Hangup()

Modified: asterisk/trunk/tests/cdr/console_dial_sip_transfer/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_transfer/configs/ast1/sip.conf?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_transfer/configs/ast1/sip.conf (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_transfer/configs/ast1/sip.conf Thu Dec 22 16:17:15 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/trunk/tests/cdr/console_dial_sip_transfer/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_transfer/run-test?view=diff&rev=2960&r1=2959&r2=2960
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_transfer/run-test (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_transfer/run-test Thu Dec 22 16:17:15 2011
@@ -15,79 +15,31 @@
 from asterisk.cdr import AsteriskCSVCDR, AsteriskCSVCDRLine
 from asterisk.ami import AMI
 from twisted.internet import reactor
+from asterisk.CDRTestCase import CDRTestCase
 import logging
 
-workingdir = "cdr/console_dial_sip_transfer"
-testdir = "tests/%s" % workingdir
-
-class Test:
+class SIP_Dial_Transfer_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))
-        cdr2 = AsteriskCSVCDR(fn="%s/var/log/asterisk/cdr-csv/Master.csv" % (self.ast2.base))
-
-        cdr1_records=[]
-        cdr1_records.append(AsteriskCSVCDRLine(
-            disposition="ANSWERED", dchannel="SIP/test-.*", dcontext="default",
-            amaflags="DOCUMENTATION", callerid="", userfield="", source="",
-            destination="2", lastapp="Dial", lastarg="SIP/2 at test"))
-        cdr1_records.append(AsteriskCSVCDRLine(
-            disposition="ANSWERED", dcontext="default", amaflags="DOCUMENTATION",
-            accountcode="", callerid="", userfield="", destination="1", lastapp="Dial",
-            lastarg="SIP/1 at test", channel="Console/dsp"))
-
-        cdr1_expect = AsteriskCSVCDR(records=cdr1_records)
-
-        cdr2_expect=AsteriskCSVCDR(records=[AsteriskCSVCDRLine(
-            disposition="ANSWERED", dchannel="", dcontext="default", amaflags="DOCUMENTATION",
-            accountcode="", callerid='"asterisk" <asterisk>', userfield="", source="asterisk",
-            destination="2", lastapp="Hangup", lastarg="", channel="SIP/.*5065-.*")])
-        if cdr1_expect.match(cdr1) and cdr2_expect.match(cdr2):
-            print "Success"
-            self.passed = True
-        else:
-            print "Failure"
+        CDRTestCase.__init__(self)
+        self.add_expectation('cdrtest_local', AsteriskCSVCDRLine(
+            destination="1",

[... 574 lines stripped ...]



More information about the svn-commits mailing list