[asterisk-commits] jrose: testsuite/asterisk/trunk r3183 - in /asterisk/trunk/tests/cdr: ./ cdr_...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Apr 13 11:21:00 CDT 2012
Author: jrose
Date: Fri Apr 13 11:20:55 2012
New Revision: 3183
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3183
Log:
Add a test for confirming that ForkCDR's e option has apppropriate start/end times.
(issue ASTERISK-19164)
Reported by: Steve Davies
Added:
asterisk/trunk/tests/cdr/cdr_fork_end_time/
asterisk/trunk/tests/cdr/cdr_fork_end_time/configs/
asterisk/trunk/tests/cdr/cdr_fork_end_time/configs/ast1/
asterisk/trunk/tests/cdr/cdr_fork_end_time/configs/ast1/extensions.conf (with props)
asterisk/trunk/tests/cdr/cdr_fork_end_time/configs/ast1/sip.conf (with props)
asterisk/trunk/tests/cdr/cdr_fork_end_time/run-test (with props)
asterisk/trunk/tests/cdr/cdr_fork_end_time/test-config.yaml (with props)
Modified:
asterisk/trunk/tests/cdr/tests.yaml
Added: asterisk/trunk/tests/cdr/cdr_fork_end_time/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/cdr_fork_end_time/configs/ast1/extensions.conf?view=auto&rev=3183
==============================================================================
--- asterisk/trunk/tests/cdr/cdr_fork_end_time/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/cdr/cdr_fork_end_time/configs/ast1/extensions.conf Fri Apr 13 11:20:55 2012
@@ -1,0 +1,14 @@
+[general]
+writeprotect=no
+clearglobalvars=no
+
+[globals]
+
+[default]
+exten => 1,1,NoOp(Dial something that should fail)
+exten => 1,n,Set(CDR(accountcode)=cdrtest_local)
+exten => 1,n,Dial(SIP/test/2)
+exten => 1,n,Playback(silence/3)
+exten => 1,n,ForkCDR(e)
+exten => 1,n,Playback(silence/4)
+exten => 1,n,Hangup
Propchange: asterisk/trunk/tests/cdr/cdr_fork_end_time/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/cdr/cdr_fork_end_time/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/cdr/cdr_fork_end_time/configs/ast1/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/cdr/cdr_fork_end_time/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/cdr_fork_end_time/configs/ast1/sip.conf?view=auto&rev=3183
==============================================================================
--- asterisk/trunk/tests/cdr/cdr_fork_end_time/configs/ast1/sip.conf (added)
+++ asterisk/trunk/tests/cdr/cdr_fork_end_time/configs/ast1/sip.conf Fri Apr 13 11:20:55 2012
@@ -1,0 +1,9 @@
+[general]
+context=default
+udpbindaddr=127.0.0.1
+directmedia=no
+
+[test]
+type=peer
+host=127.0.0.1
+accountcode=cdrtest_sip
Propchange: asterisk/trunk/tests/cdr/cdr_fork_end_time/configs/ast1/sip.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/cdr/cdr_fork_end_time/configs/ast1/sip.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/cdr/cdr_fork_end_time/configs/ast1/sip.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/cdr/cdr_fork_end_time/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/cdr_fork_end_time/run-test?view=auto&rev=3183
==============================================================================
--- asterisk/trunk/tests/cdr/cdr_fork_end_time/run-test (added)
+++ asterisk/trunk/tests/cdr/cdr_fork_end_time/run-test Fri Apr 13 11:20:55 2012
@@ -1,0 +1,83 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2012, Digium, Inc.
+Jonathan Rose <jrose at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import os
+import logging
+import re
+import time
+sys.path.append("lib/python")
+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
+
+logger = logging.getLogger(__name__)
+
+class ForkEndTimingTest(CDRTestCase):
+ def __init__(self):
+ CDRTestCase.__init__(self)
+
+ self.add_expectation('cdrtest_local', AsteriskCSVCDRLine(
+ destination = "1",
+ lastapp = "ForkCDR",
+ dcontext = "default",
+ dchannel = "SIP/test-.*",
+ channel = "Local/1 at default-.*",
+ disposition = "ANSWERED",
+ amaflags = "DOCUMENTATION"))
+
+ self.add_expectation('cdrtest_local', AsteriskCSVCDRLine(
+ destination = "1",
+ lastapp = "Hangup",
+ dcontext = "default",
+ dchannel = "SIP/test-.*",
+ channel = "Local/1 at default-.*",
+ disposition = "NO ANSWER",
+ amaflags = "DOCUMENTATION"))
+
+ def match_cdrs(self):
+ CDRTestCase.match_cdrs(self)
+ if not self.passed:
+ return
+
+ cdr1 = AsteriskCSVCDR(fn = "%s/%s/cdr-csv/%s.csv" % (self.ast[0].base, self.ast[0].directories['astlogdir'], "cdrtest_local"))
+
+ #check for missing fields
+ for cdritem in cdr1:
+ if cdritem.duration is None or cdritem.start is None or cdritem.end is None:
+ logger.Error("EPIC FAILURE: CDR record %s is missing one or more key fields. This should never be able to happen." % cdritem)
+ self.passed = False
+ return
+
+ # The dialplan is set up so that these two CDRs should each last at least 4 seconds. Giving it wiggle room,
+ # we'll just say we want it to be greater than 1 second.
+ if ((int(cdr1[0].duration) <= 1) or (int(cdr1[1].duration) <= 1)):
+ logger.error("FAILURE: One or both CDRs only lasted a second or less (expected more)")
+ self.passed = False
+ return
+
+ end = time.strptime(cdr1[0].end, "%Y-%m-%d %H:%M:%S")
+ beg = time.strptime(cdr1[1].start, "%Y-%m-%d %H:%M:%S")
+
+ #check that the end of the first CDR occured within a 1 second split of the beginning of the second CDR
+ if (abs(time.mktime(end) - time.mktime(beg)) > 1):
+ logger.error("Time discrepency between end1 and start2 must be one second or less.\n")
+ logger.error("Actual times: end cdr1 = %s begin cdr2 = %s" % (cdr1[0].end, cdr1[1].start))
+ self.passed = False
+ return
+
+def main():
+ test = ForkEndTimingTest()
+ reactor.run()
+ return test.results()
+
+if __name__ == '__main__':
+ sys.exit(main())
Propchange: asterisk/trunk/tests/cdr/cdr_fork_end_time/run-test
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/cdr/cdr_fork_end_time/run-test
------------------------------------------------------------------------------
svn:executable = *
Propchange: asterisk/trunk/tests/cdr/cdr_fork_end_time/run-test
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/cdr/cdr_fork_end_time/run-test
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/cdr/cdr_fork_end_time/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/cdr_fork_end_time/test-config.yaml?view=auto&rev=3183
==============================================================================
--- asterisk/trunk/tests/cdr/cdr_fork_end_time/test-config.yaml (added)
+++ asterisk/trunk/tests/cdr/cdr_fork_end_time/test-config.yaml Fri Apr 13 11:20:55 2012
@@ -1,0 +1,20 @@
+testinfo:
+ summary: Test ForkCDR option for ending the original CDR log before starting new one
+ description: |
+ 'This is a normal CDRTestCase test which originates a call to an extension which
+ plays some silence, calls ForkCDR with the e option, and then plays more silence
+ before hanging up. Afterwards, both CDR records are checked to see that they
+ match expected fields and that the duration of both call records is above a
+ minimum threshold (both should have noticeable durations). Then the end time of
+ the first record is checked to see if it came reasonably close to the beginning
+ time of the second (<=1 second to accomodate potential timing differences).'
+
+properties:
+ minversion: '1.8'
+ dependencies:
+ - python : 'twisted'
+ - python : 'starpy'
+ - asterisk : 'cdr_csv'
+ tags:
+ - CDR
+ - chan_local
Propchange: asterisk/trunk/tests/cdr/cdr_fork_end_time/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/cdr/cdr_fork_end_time/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/cdr/cdr_fork_end_time/test-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: asterisk/trunk/tests/cdr/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/tests.yaml?view=diff&rev=3183&r1=3182&r2=3183
==============================================================================
--- asterisk/trunk/tests/cdr/tests.yaml (original)
+++ asterisk/trunk/tests/cdr/tests.yaml Fri Apr 13 11:20:55 2012
@@ -7,6 +7,7 @@
- test: 'console_dial_sip_transfer'
- test: 'console_fork_after_busy_forward'
- test: 'console_fork_before_dial'
+ - test: 'cdr_fork_end_time'
- test: 'cdr_unanswered_yes'
- test: 'cdr_userfield'
- test: 'nocdr'
More information about the asterisk-commits
mailing list