[asterisk-commits] mnicholson: branch mnicholson/asttest r247384 - in /team/mnicholson/asttest/a...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 17 17:08:35 CST 2010


Author: mnicholson
Date: Wed Feb 17 17:08:32 2010
New Revision: 247384

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=247384
Log:
Added a (currently failing) test to test for empty account codes after sip blind transfers (bug 0016331)

Added:
    team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/
    team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/
    team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/extensions.conf   (with props)
    team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/sip.conf   (with props)
    team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/
    team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/call-then-blind-transfer.xml   (with props)
    team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/data.csv   (with props)
    team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/register.xml   (with props)
    team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/wait-for-call-do-hangup.xml   (with props)
    team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/wait-for-call.xml   (with props)
    team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/test.lua   (with props)

Added: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/extensions.conf
URL: http://svnview.digium.com/svn/asterisk/team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/extensions.conf?view=auto&rev=247384
==============================================================================
--- team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/extensions.conf (added)
+++ team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/extensions.conf Wed Feb 17 17:08:32 2010
@@ -1,0 +1,12 @@
+[general]
+
+[default]
+exten = test1,1,Noop
+exten = test1,n,Dial(SIP/test1)
+
+exten = test2,1,Noop
+exten = test2,n,Dial(SIP/test2)
+
+exten = test3,1,Noop
+exten = test3,n,Dial(SIP/test3)
+

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/sip.conf
URL: http://svnview.digium.com/svn/asterisk/team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/sip.conf?view=auto&rev=247384
==============================================================================
--- team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/sip.conf (added)
+++ team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/sip.conf Wed Feb 17 17:08:32 2010
@@ -1,0 +1,19 @@
+[general]
+udpbindaddr = 127.0.0.1:5060
+canreinvite = no
+
+[test1]
+type = friend
+host = dynamic
+;accountcode = account1
+
+[test2]
+type = friend
+host = dynamic
+;accountcode = account2
+
+[test3]
+type = friend
+host = dynamic
+accountcode = account3
+

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/sip.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/sip.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/sip.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/call-then-blind-transfer.xml
URL: http://svnview.digium.com/svn/asterisk/team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/call-then-blind-transfer.xml?view=auto&rev=247384
==============================================================================
--- team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/call-then-blind-transfer.xml (added)
+++ team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/call-then-blind-transfer.xml Wed Feb 17 17:08:32 2010
@@ -1,0 +1,99 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="Send Call then Blind Transfer">
+	<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:[field2 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: [field2 line="[$line]"] <sip:[field2 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:[field2 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: [field2 line="[$line]"] <sip:[field2 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="1000"/>
+
+	<send retrans="500">
+		<![CDATA[
+
+		REFER sip:[field2 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: [field2 line="[$line]"] <sip:[field2 line="[$line]"]@[remote_ip]:[remote_port]>
+		Call-ID: [call_id]
+		CSeq: 2 REFER
+		Contact: sip:[field0 line="[$line]"]@[local_ip]:[local_port]
+		Max-Forwards: 70
+		Content-Length: 0
+		Refer-To: <sip:[field3 line="[$line]"]@[remote_ip]:[remote_port]>
+		Reffered-By: <sip:[field0 line="[$line]"]@[local_ip]:[local_port]>
+
+		]]>
+	</send>
+
+	<recv response="202" optional="false"/>
+
+	<recv request="NOTIFY" optional="false"/>
+	<send retrans="500">
+		<![CDATA[
+
+		SIP/2.0 200 OK
+		[last_Via:]
+		[last_From:]
+		[last_To:]
+		[last_Call-ID:]
+		[last_CSeq:]
+		[last_Record-Route:]
+		Contact: sip:[field0 line="[$line]"]@[local_ip]:[local_port]
+		Content-Length: 0
+
+		]]>
+	</send>
+
+</scenario>
+

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/call-then-blind-transfer.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/call-then-blind-transfer.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/call-then-blind-transfer.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/data.csv
URL: http://svnview.digium.com/svn/asterisk/team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/data.csv?view=auto&rev=247384
==============================================================================
--- team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/data.csv (added)
+++ team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/data.csv Wed Feb 17 17:08:32 2010
@@ -1,0 +1,5 @@
+USER
+# from;expiry;to;refer-to
+test1;120;test3;test2
+test2;120;test1;test3
+test3;120;test2;test1

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/data.csv
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/data.csv
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/data.csv
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/register.xml
URL: http://svnview.digium.com/svn/asterisk/team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/register.xml?view=auto&rev=247384
==============================================================================
--- team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/register.xml (added)
+++ team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/register.xml Wed Feb 17 17:08:32 2010
@@ -1,0 +1,37 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<!--
+This scenario will execute a sip register with the given parameters.
+-->
+
+
+<scenario name="Register">
+
+	<Global variables="file,user"/>
+	<nop>
+		<action>
+			<lookup assign_to="line" file="[$file]" key="[$user]"/>
+		</action>
+	</nop>
+	<Reference variables="file,user"/>
+
+	<send retrans="500">
+		<![CDATA[
+
+		REGISTER sip:[field0 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: [field0 line="[$line]"] <sip:[field0 line="[$line]"]@[remote_ip]:[remote_port]>
+		Call-ID: [call_id]
+		CSeq: 1 REGISTER
+		Contact: sip:[field0 line="[$line]"]@[local_ip]:[local_port]
+		Content-Length: 0
+		Expires: [field1 line="[$line]"]
+
+		]]>
+	</send>
+
+	<recv response="200"/>
+
+</scenario>
+

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/register.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/register.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/register.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/wait-for-call-do-hangup.xml
URL: http://svnview.digium.com/svn/asterisk/team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/wait-for-call-do-hangup.xml?view=auto&rev=247384
==============================================================================
--- team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/wait-for-call-do-hangup.xml (added)
+++ team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/wait-for-call-do-hangup.xml Wed Feb 17 17:08:32 2010
@@ -1,0 +1,68 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<scenario name="wait for a call, then 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:];tag=[call_number]
+		[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
+		[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>
+
+	<recv request="ACK" optional="false"/>
+
+	<pause milliseconds="5000"/>
+
+	<send retrans="500">
+		<![CDATA[
+
+		BYE sip:[field2 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: [field2 line="[$line]"] <sip:[field2 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: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/wait-for-call-do-hangup.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/wait-for-call-do-hangup.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/wait-for-call-do-hangup.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/wait-for-call.xml
URL: http://svnview.digium.com/svn/asterisk/team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/wait-for-call.xml?view=auto&rev=247384
==============================================================================
--- team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/wait-for-call.xml (added)
+++ team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/wait-for-call.xml Wed Feb 17 17:08:32 2010
@@ -1,0 +1,65 @@
+<?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:];tag=[call_number]
+		[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
+		[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>
+	
+	<recv request="ACK" optional="false"/>
+	<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: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/wait-for-call.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/wait-for-call.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/sipp/wait-for-call.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/test.lua
URL: http://svnview.digium.com/svn/asterisk/team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/test.lua?view=auto&rev=247384
==============================================================================
--- team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/test.lua (added)
+++ team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/test.lua Wed Feb 17 17:08:32 2010
@@ -1,0 +1,74 @@
+xfail()
+
+a = ast.new()
+a:load_config("configs/sip.conf")
+a:load_config("configs/extensions.conf")
+
+a:generate_asterisk_conf()
+a["asterisk.conf"]["options"]["verbose"] = 10
+--a["asterisk.conf"]["options"]["debug"] = 10
+
+a:spawn()
+
+function sipp_exec(scenario, name, local_port)
+	local inf = "data.csv"
+	return proc.exec("sipp",
+	"127.0.0.1",
+	"-m", "1",
+	"-sf", scenario,
+	"-inf", "sipp/" .. inf,
+	"-infindex", inf, "0",
+	"-i", "127.0.0.1",
+	"-p", local_port,
+	"-timeout", "30",
+	"-timeout_error",
+	"-set", "user", name,
+	"-set", "file", inf 
+	)
+end
+
+function sipp_exec_and_wait(scenario, name, local_port)
+	return sipp_check_error(sipp_exec(scenario, name, local_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 .. ")") end
+	
+	return res, err
+end
+
+
+-- register our three peers
+sipp_exec_and_wait("sipp/register.xml", "test1", "5061")
+sipp_exec_and_wait("sipp/register.xml", "test2", "5062")
+sipp_exec_and_wait("sipp/register.xml", "test3", "5063")
+
+print("executing scripts")
+
+-- make the calls and transfers
+t1 = sipp_exec("sipp/wait-for-call.xml", "test1", "5061")
+t2 = sipp_exec("sipp/wait-for-call-do-hangup.xml", "test2", "5062")
+t3 = sipp_exec("sipp/call-then-blind-transfer.xml", "test3", "5063")
+
+sipp_check_error(t3, "sipp/call-then-blind-transfer.xml")
+sipp_check_error(t2, "sipp/wait-for-call-do-hangup.xml")
+sipp_check_error(t1, "sipp/wait-for-call.xml")
+
+-- examine the CDR records generated to make sure account code is present
+cdr_path = a:path("/var/log/asterisk/cdr-csv/Master.csv")
+f, err = io.open(cdr_path, "r")
+if not f then
+	error("error opening cdr file '" .. cdr_path .. "': " .. err)
+end
+
+f:read("*l")
+cdr = f:read("*l")
+if not cdr then
+	error("error reading lines from cdr file")
+end
+
+fail_if(not cdr:find("account3"), "'account3' not found in second line of cdr file '" .. cdr_path .. "': " .. cdr)
+

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/test.lua
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/test.lua
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/test.lua
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the asterisk-commits mailing list