[svn-commits] mnicholson: testsuite/asterisk/trunk r323 - in /asterisk/trunk/tests: ./ cdr/...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Wed Jun 2 14:24:29 CDT 2010
Author: mnicholson
Date: Wed Jun 2 14:24:26 2010
New Revision: 323
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=323
Log:
Added test for CDR's produced after app_queue runs
Added:
asterisk/trunk/tests/cdr/app_queue/
asterisk/trunk/tests/cdr/app_queue/configs/
asterisk/trunk/tests/cdr/app_queue/configs/cdr.conf (with props)
asterisk/trunk/tests/cdr/app_queue/configs/extensions.conf (with props)
asterisk/trunk/tests/cdr/app_queue/configs/modules.conf (with props)
asterisk/trunk/tests/cdr/app_queue/configs/queues.conf (with props)
asterisk/trunk/tests/cdr/app_queue/configs/sip.conf (with props)
asterisk/trunk/tests/cdr/app_queue/run-test (with props)
asterisk/trunk/tests/cdr/app_queue/sipp/
asterisk/trunk/tests/cdr/app_queue/sipp/call-then-hangup.xml (with props)
asterisk/trunk/tests/cdr/app_queue/sipp/call.xml (with props)
asterisk/trunk/tests/cdr/app_queue/sipp/data.csv (with props)
asterisk/trunk/tests/cdr/app_queue/sipp/wait-for-call-hangup.xml (with props)
asterisk/trunk/tests/cdr/app_queue/test-config.yaml (with props)
asterisk/trunk/tests/cdr/app_queue/test.lua (with props)
Modified:
asterisk/trunk/tests/tests.yaml
Added: asterisk/trunk/tests/cdr/app_queue/configs/cdr.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/app_queue/configs/cdr.conf?view=auto&rev=323
==============================================================================
--- asterisk/trunk/tests/cdr/app_queue/configs/cdr.conf (added)
+++ asterisk/trunk/tests/cdr/app_queue/configs/cdr.conf Wed Jun 2 14:24:26 2010
@@ -1,0 +1,8 @@
+[general]
+unanswered = no
+
+[csv]
+usegmtime = yes
+loguniqueid = yes
+loguserfield = yes
+
Propchange: asterisk/trunk/tests/cdr/app_queue/configs/cdr.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/cdr/app_queue/configs/cdr.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/cdr/app_queue/configs/cdr.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/cdr/app_queue/configs/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/app_queue/configs/extensions.conf?view=auto&rev=323
==============================================================================
--- asterisk/trunk/tests/cdr/app_queue/configs/extensions.conf (added)
+++ asterisk/trunk/tests/cdr/app_queue/configs/extensions.conf Wed Jun 2 14:24:26 2010
@@ -1,0 +1,19 @@
+[general]
+
+[default]
+
+exten => abandon,1,Noop
+exten => abandon,n,Answer
+exten => abandon,n,Queue(zero-members)
+
+exten => completeagent,1,Noop
+exten => completeagent,n,Queue(one-member)
+
+exten => exitempty,1,Noop
+exten => exitempty,n,Answer
+exten => exitempty,n,Queue(zero-members-exit-empty)
+
+exten => timeout,1,Noop
+exten => timeout,n,Answer
+exten => timeout,n,Queue(zero-members,,,,1)
+
Propchange: asterisk/trunk/tests/cdr/app_queue/configs/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/cdr/app_queue/configs/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/cdr/app_queue/configs/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/cdr/app_queue/configs/modules.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/app_queue/configs/modules.conf?view=auto&rev=323
==============================================================================
--- asterisk/trunk/tests/cdr/app_queue/configs/modules.conf (added)
+++ asterisk/trunk/tests/cdr/app_queue/configs/modules.conf Wed Jun 2 14:24:26 2010
@@ -1,0 +1,12 @@
+
+[modules]
+autoload=yes
+load => res_musiconhold.so
+load => res_rtp_asterisk.so
+load => chan_sip.so
+load => app_queue.so
+
+noload => pbx_gtkconsole.so
+noload => chan_alsa.so
+noload => chan_oss.so
+noload => chan_console.so
Propchange: asterisk/trunk/tests/cdr/app_queue/configs/modules.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/cdr/app_queue/configs/modules.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/cdr/app_queue/configs/modules.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/cdr/app_queue/configs/queues.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/app_queue/configs/queues.conf?view=auto&rev=323
==============================================================================
--- asterisk/trunk/tests/cdr/app_queue/configs/queues.conf (added)
+++ asterisk/trunk/tests/cdr/app_queue/configs/queues.conf Wed Jun 2 14:24:26 2010
@@ -1,0 +1,11 @@
+[general]
+
+[zero-members]
+joinempty = yes
+
+[one-member]
+member = SIP/answered at 127.0.0.2
+
+[zero-members-exit-empty]
+joinempty = no
+
Propchange: asterisk/trunk/tests/cdr/app_queue/configs/queues.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/cdr/app_queue/configs/queues.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/cdr/app_queue/configs/queues.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/cdr/app_queue/configs/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/app_queue/configs/sip.conf?view=auto&rev=323
==============================================================================
--- asterisk/trunk/tests/cdr/app_queue/configs/sip.conf (added)
+++ asterisk/trunk/tests/cdr/app_queue/configs/sip.conf Wed Jun 2 14:24:26 2010
@@ -1,0 +1,5 @@
+[general]
+udpbindaddr = 127.0.0.1:5060
+bindaddr = 127.0.0.1
+canreinvite = no
+
Propchange: asterisk/trunk/tests/cdr/app_queue/configs/sip.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/cdr/app_queue/configs/sip.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/cdr/app_queue/configs/sip.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/cdr/app_queue/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/app_queue/run-test?view=auto&rev=323
==============================================================================
--- asterisk/trunk/tests/cdr/app_queue/run-test (added)
+++ asterisk/trunk/tests/cdr/app_queue/run-test Wed Jun 2 14:24:26 2010
@@ -1,0 +1,5 @@
+#!/bin/bash -e
+export LUA_PATH=../../lib/lua/?.lua\;\;
+export LUA_CPATH=../../lib/lua/?.so\;\;
+asttest -a / -s tests/cdr/app_queue
+
Propchange: asterisk/trunk/tests/cdr/app_queue/run-test
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/cdr/app_queue/run-test
------------------------------------------------------------------------------
svn:executable = *
Propchange: asterisk/trunk/tests/cdr/app_queue/run-test
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/cdr/app_queue/run-test
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/cdr/app_queue/sipp/call-then-hangup.xml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/app_queue/sipp/call-then-hangup.xml?view=auto&rev=323
==============================================================================
--- asterisk/trunk/tests/cdr/app_queue/sipp/call-then-hangup.xml (added)
+++ asterisk/trunk/tests/cdr/app_queue/sipp/call-then-hangup.xml Wed Jun 2 14:24:26 2010
@@ -1,0 +1,80 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="send a call then hanup">
+ <Global variables="file,user"/>
+ <nop>
+ <action>
+ <lookup assign_to="line" file="[$file]" key="[$user]"/>
+ </action>
+ </nop>
+ <Reference variables="file,user"/>
+
+ <send retrans="500">
+ <![CDATA[
+
+ INVITE sip:[field1 line="[$line]"]@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: [field0 line="[$line]"] <sip:[field0 line="[$line]"]@[local_ip]:[local_port]>;tag=[call_number]
+ To: [field1 line="[$line]"] <sip:[field1 line="[$line]"]@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: 1 INVITE
+ Contact: sip:[field0 line="[$line]"]@[local_ip]:[local_port]
+ Max-Forwards: 70
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+ s=-
+ c=IN IP[media_ip_type] [media_ip]
+ t=0 0
+ m=audio [media_port] RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+
+ ]]>
+ </send>
+
+ <recv response="100" optional="true"/>
+ <recv response="180" optional="true"/>
+ <recv response="183" optional="true"/>
+
+ <recv response="200" rtd="true" rrs="true"/>
+
+ <send>
+ <![CDATA[
+
+ ACK sip:[field1 line="[$line]"]@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: [field0 line="[$line]"] <sip:[field0 line="[$line]"]@[local_ip]:[local_port]>;tag=[call_number]
+ To: [field1 line="[$line]"] <sip:[field1 line="[$line]"]@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: 1 ACK
+ Contact: sip:[field0 line="[$line]"]@[local_ip]:[local_port]
+ Max-Forwards: 70
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <pause milliseconds="5000"/>
+
+ <send retrans="500">
+ <![CDATA[
+
+ BYE sip:[field1 line="[$line]"]@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: [field0 line="[$line]"] <sip:[field0 line="[$line]"]@[local_ip]:[local_port]>;tag=[call_number]
+ To: [field1 line="[$line]"] <sip:[field1 line="[$line]"]@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: 2 BYE
+ Contact: sip:[field0 line="[$line]"]@[local_ip]:[local_port]
+ Max-Forwards: 70
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv response="200" optional="false"/>
+
+</scenario>
+
Propchange: asterisk/trunk/tests/cdr/app_queue/sipp/call-then-hangup.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/cdr/app_queue/sipp/call-then-hangup.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/cdr/app_queue/sipp/call-then-hangup.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/cdr/app_queue/sipp/call.xml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/app_queue/sipp/call.xml?view=auto&rev=323
==============================================================================
--- asterisk/trunk/tests/cdr/app_queue/sipp/call.xml (added)
+++ asterisk/trunk/tests/cdr/app_queue/sipp/call.xml Wed Jun 2 14:24:26 2010
@@ -1,0 +1,77 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="send a call then wait for a hangup">
+ <Global variables="file,user"/>
+ <nop>
+ <action>
+ <lookup assign_to="line" file="[$file]" key="[$user]"/>
+ </action>
+ </nop>
+ <Reference variables="file,user"/>
+
+ <send retrans="500">
+ <![CDATA[
+
+ INVITE sip:[field1 line="[$line]"]@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: [field0 line="[$line]"] <sip:[field0 line="[$line]"]@[local_ip]:[local_port]>;tag=[call_number]
+ To: [field1 line="[$line]"] <sip:[field1 line="[$line]"]@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: 1 INVITE
+ Contact: sip:[field0 line="[$line]"]@[local_ip]:[local_port]
+ Max-Forwards: 70
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+ s=-
+ c=IN IP[media_ip_type] [media_ip]
+ t=0 0
+ m=audio [media_port] RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+
+ ]]>
+ </send>
+
+ <recv response="100" optional="true"/>
+ <recv response="180" optional="true"/>
+ <recv response="183" optional="true"/>
+
+ <recv response="200" rtd="true" rrs="true"/>
+
+ <send>
+ <![CDATA[
+
+ ACK sip:[field1 line="[$line]"]@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: [field0 line="[$line]"] <sip:[field0 line="[$line]"]@[local_ip]:[local_port]>;tag=[call_number]
+ To: [field1 line="[$line]"] <sip:[field1 line="[$line]"]@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: 1 ACK
+ Contact: sip:[field0 line="[$line]"]@[local_ip]:[local_port]
+ Max-Forwards: 70
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv request="BYE" optional="false" timeout="10000"/>
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: sip:[field0 line="[$line]"]@[local_ip]:[local_port]
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+</scenario>
+
Propchange: asterisk/trunk/tests/cdr/app_queue/sipp/call.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/cdr/app_queue/sipp/call.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/cdr/app_queue/sipp/call.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/cdr/app_queue/sipp/data.csv
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/app_queue/sipp/data.csv?view=auto&rev=323
==============================================================================
--- asterisk/trunk/tests/cdr/app_queue/sipp/data.csv (added)
+++ asterisk/trunk/tests/cdr/app_queue/sipp/data.csv Wed Jun 2 14:24:26 2010
@@ -1,0 +1,7 @@
+USER
+# from/contact;to
+abandon;abandon
+answered;completeagent
+completeagent;compelteagent
+exitempty;exitempty
+timeout;timeout
Propchange: asterisk/trunk/tests/cdr/app_queue/sipp/data.csv
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/cdr/app_queue/sipp/data.csv
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/cdr/app_queue/sipp/data.csv
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/cdr/app_queue/sipp/wait-for-call-hangup.xml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/app_queue/sipp/wait-for-call-hangup.xml?view=auto&rev=323
==============================================================================
--- asterisk/trunk/tests/cdr/app_queue/sipp/wait-for-call-hangup.xml (added)
+++ asterisk/trunk/tests/cdr/app_queue/sipp/wait-for-call-hangup.xml Wed Jun 2 14:24:26 2010
@@ -1,0 +1,68 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="wait for a call followed by a hangup">
+
+ <Global variables="file,user"/>
+ <nop>
+ <action>
+ <lookup assign_to="line" file="[$file]" key="[$user]"/>
+ </action>
+ </nop>
+ <Reference variables="file,user"/>
+
+ <recv request="INVITE" crlf="true" timeout="5000"/>
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 180 Ringing
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: sip:[field0 line="[$line]"]@[local_ip]:[local_port]
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: sip:[field0 line="[$line]"]@[local_ip]:[local_port]
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv request="ACK" optional="false"/>
+
+ <pause milliseconds="5000"/>
+
+ <send retrans="500">
+ <![CDATA[
+
+ BYE sip:[field1 line="[$line]"]@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ CSeq: 2 BYE
+ Contact: sip:[field0 line="[$line]"]@[local_ip]:[local_port]
+ Max-Forwards: 70
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv response="200" optional="false"/>
+
+</scenario>
+
Propchange: asterisk/trunk/tests/cdr/app_queue/sipp/wait-for-call-hangup.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/cdr/app_queue/sipp/wait-for-call-hangup.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/cdr/app_queue/sipp/wait-for-call-hangup.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/cdr/app_queue/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/app_queue/test-config.yaml?view=auto&rev=323
==============================================================================
--- asterisk/trunk/tests/cdr/app_queue/test-config.yaml (added)
+++ asterisk/trunk/tests/cdr/app_queue/test-config.yaml Wed Jun 2 14:24:26 2010
@@ -1,0 +1,15 @@
+testinfo:
+ summary: 'Test for proper CDR dispositions for queue calls.'
+ description: |
+ "This test verifies that the CDRs generated for calls involving
+ app_queue have the proper dispositions."
+ issues:
+ - mantis : '17334'
+
+properties:
+ minversion: '1.4'
+ dependencies:
+ - app : 'bash'
+ - app : 'sipp'
+ - app : 'asttest'
+
Propchange: asterisk/trunk/tests/cdr/app_queue/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/cdr/app_queue/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/cdr/app_queue/test-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/tests/cdr/app_queue/test.lua
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/app_queue/test.lua?view=auto&rev=323
==============================================================================
--- asterisk/trunk/tests/cdr/app_queue/test.lua (added)
+++ asterisk/trunk/tests/cdr/app_queue/test.lua Wed Jun 2 14:24:26 2010
@@ -1,0 +1,155 @@
+
+function check(msg, r, err)
+ if not r then
+ error(msg .. ": " .. err)
+ end
+ return r
+end
+
+function mcheck(msg, r, err)
+ check(msg, r, err)
+ if r["Response"] ~= "Success" then
+ error(msg .. ": " .. r["Message"])
+ end
+ return r
+end
+
+function sipp_exec(scenario, name, host, port)
+ host = host or "127.0.0.1"
+ port = port or "5060"
+ local inf = "data.csv"
+ local p = proc.exec_io("sipp",
+ "127.0.0.1",
+ "-m", "1",
+ "-sf", scenario,
+ "-inf", "sipp/" .. inf,
+ "-infindex", inf, "0",
+ "-i", host,
+ "-p", port,
+ "-timeout", "30",
+ "-timeout_error",
+ "-set", "user", name,
+ "-set", "file", inf
+ )
+
+ posix.sleep(1)
+ return p
+end
+
+function sipp_exec_and_wait(scenario, name, host, port)
+ return sipp_check_error(sipp_exec(scenario, name, host, port), scenario)
+end
+
+function sipp_check_error(p, scenario)
+ local res, err = p:wait()
+
+ if not res then error(err) end
+ if res ~= 0 then
+ error("error while executing " .. scenario .. " sipp scenario (sipp exited with status " .. res .. ")\n" .. p.stderr:read("*a"))
+ end
+
+ return res, err
+end
+
+function check_cdr_disposition(a, record, disposition)
+ print("checking CDR")
+ local cdr_path = a:path("/var/log/asterisk/cdr-csv/Master.csv")
+ local f, err = io.open(cdr_path, "r")
+ if not f then
+ error("error opening cdr file (" .. cdr_path .. "): " .. err)
+ end
+
+ local found = false
+ local lineno = 0
+ for line in f:lines() do
+ lineno = lineno + 1
+
+ if lineno == record then
+ fail_if(not line:find(string.format('"%s"', disposition)), string.format("did not find disposition '%s' on line %s of cdr:\n%s", disposition, lineno, line))
+ found = true
+ break
+ end
+ end
+ fail_if(not found, string.format("expected disposition '%s' on line %s of cdr, but line %s does not exist in the file", disposition, record, record))
+end
+
+function check_for_n_cdrs(a, records)
+ local cdr_path = a:path("/var/log/asterisk/cdr-csv/Master.csv")
+ local f, err = io.open(cdr_path, "r")
+ if not f then
+ error("error opening cdr file (" .. cdr_path .. "): " .. err)
+ end
+
+ local found = false
+ local lineno = 0
+ for line in f:lines() do
+ lineno = lineno + 1
+ end
+ fail_if(lineno ~= records, string.format("expected %s CDR(s) but found %s", records, lineno))
+end
+
+function do_call(scenario, key)
+ -- start sipp and wait for calls
+ print(string.format("starting sipp (%s)", scenario))
+ local s1 = check("error starting sipp", sipp_exec("sipp/" .. scenario, key, "127.0.0.2"))
+
+ -- wait for everything to finish
+ print("waiting for sipp to exit")
+ sipp_check_error(s1, "sipp/" .. scenario)
+
+ posix.sleep(1) -- give asterisk a second to write CDRs
+end
+
+function do_two_calls(scenario1, key1, scenario2, key2)
+ -- start sipp and wait for calls
+ print(string.format("starting first sipp (%s)", scenario1))
+ local s1 = check("error starting sipp", sipp_exec("sipp/" .. scenario1, key1, "127.0.0.2"))
+
+ print(string.format("starting second sipp (%s)", scenario2))
+ local s2 = check("error starting sipp", sipp_exec("sipp/" .. scenario2, key2, "127.0.0.3"))
+
+ -- wait for everything to finish
+ print("waiting for sipp to exit")
+ sipp_check_error(s2, "sipp/" .. scenario2)
+ sipp_check_error(s1, "sipp/" .. scenario1)
+
+ posix.sleep(1) -- give asterisk a second to write CDRs
+end
+
+-- start asterisk
+print("starting asterisk")
+a = ast.new()
+a:load_config("configs/sip.conf")
+a:load_config("configs/extensions.conf")
+a:load_config("configs/cdr.conf")
+a:load_config("configs/queues.conf")
+a:load_config("configs/modules.conf")
+
+a:generate_asterisk_conf()
+a["asterisk.conf"]["options"]["verbose"] = 10
+a["asterisk.conf"]["options"]["debug"] = 10
+
+a:spawn()
+
+-- make test calls
+
+print("testing abandoned call")
+do_call("call-then-hangup.xml", "abandon")
+check_cdr_disposition(a, 1, "ANSWERED")
+check_for_n_cdrs(a, 1)
+
+print("testing normal agent completed call")
+do_two_calls("wait-for-call-hangup.xml", "completeagent", "call.xml", "answered")
+check_cdr_disposition(a, 2, "ANSWERED")
+check_for_n_cdrs(a, 2)
+
+print("testing call with joinempty=no and an empty queue")
+do_call("call.xml", "exitempty")
+check_cdr_disposition(a, 3, "ANSWERED")
+check_for_n_cdrs(a, 3)
+
+print("testing a timeout")
+do_call("call.xml", "timeout")
+check_cdr_disposition(a, 4, "ANSWERED")
+check_for_n_cdrs(a, 4)
+
Propchange: asterisk/trunk/tests/cdr/app_queue/test.lua
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/tests/cdr/app_queue/test.lua
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/tests/cdr/app_queue/test.lua
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: asterisk/trunk/tests/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/tests.yaml?view=diff&rev=323&r1=322&r2=323
==============================================================================
--- asterisk/trunk/tests/tests.yaml (original)
+++ asterisk/trunk/tests/tests.yaml Wed Jun 2 14:24:26 2010
@@ -16,6 +16,7 @@
- test: 'cdr/cdr_unanswered_yes'
- test: 'cdr/cdr_userfield'
- test: 'cdr/nocdr'
+ - test: 'cdr/app_queue'
- test: 'originate-cdr-disposition'
- test: 'func_srv'
- test: 'sip_outbound_address'
More information about the svn-commits
mailing list