[asterisk-commits] mmichelson: testsuite/asterisk/trunk r250 - in /asterisk/trunk/tests: ./ func...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 23 15:35:29 CDT 2010


Author: mmichelson
Date: Fri Apr 23 15:35:26 2010
New Revision: 250

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=250
Log:
Add tests for func_srv and explicit setting of remote SIP IP address or host.


Added:
    asterisk/trunk/tests/func_srv/
    asterisk/trunk/tests/func_srv/configs/
    asterisk/trunk/tests/func_srv/configs/extensions.conf   (with props)
    asterisk/trunk/tests/func_srv/run-test   (with props)
    asterisk/trunk/tests/func_srv/test-config.yaml   (with props)
    asterisk/trunk/tests/func_srv/test.lua   (with props)
    asterisk/trunk/tests/sip_outbound_address/
    asterisk/trunk/tests/sip_outbound_address/configs/
    asterisk/trunk/tests/sip_outbound_address/configs/extensions.conf   (with props)
    asterisk/trunk/tests/sip_outbound_address/configs/sip.conf   (with props)
    asterisk/trunk/tests/sip_outbound_address/run-test   (with props)
    asterisk/trunk/tests/sip_outbound_address/sipp/
    asterisk/trunk/tests/sip_outbound_address/sipp/dtmf_2833_1.pcap   (with props)
    asterisk/trunk/tests/sip_outbound_address/sipp/dtmf_2833_2.pcap   (with props)
    asterisk/trunk/tests/sip_outbound_address/sipp/dtmf_2833_pound.pcap   (with props)
    asterisk/trunk/tests/sip_outbound_address/sipp/uas1.xml   (with props)
    asterisk/trunk/tests/sip_outbound_address/sipp/uas2.xml   (with props)
    asterisk/trunk/tests/sip_outbound_address/test-config.yaml   (with props)
    asterisk/trunk/tests/sip_outbound_address/test.lua   (with props)
Modified:
    asterisk/trunk/tests/tests.yaml

Added: asterisk/trunk/tests/func_srv/configs/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/func_srv/configs/extensions.conf?view=auto&rev=250
==============================================================================
--- asterisk/trunk/tests/func_srv/configs/extensions.conf (added)
+++ asterisk/trunk/tests/func_srv/configs/extensions.conf Fri Apr 23 15:35:26 2010
@@ -1,0 +1,22 @@
+[test_context]
+
+exten => test,1,Answer
+exten => test,n,NoOp(SRV TEST)
+exten => test,n,SET(ID=${SRVQUERY(_sip._udp.asteriskcheck.com)})
+exten => test,n,NoOp(Got ${SRVRESULT(${ID},getnum)} results)
+exten => test,n,Set(i=1)
+exten => test,n,While($[${i} <= ${SRVRESULT(${ID},getnum)}])
+exten => test,n,UserEvent(SRV,RecordNum: ${i},Host: ${SRVRESULT(${ID},${i},host)},Port: ${SRVRESULT(${ID},${i},port)},Priority: ${SRVRESULT(${ID},${i},priority)},Weight: ${SRVRESULT(${ID},${i},weight)})
+exten => test,n,Set(i=$[${i} + 1])
+exten => test,n,EndWhile
+
+;Test 2 skips using SRVQUERY and instead passes the service directly to SRVRESULT
+exten => test2,1,Answer
+exten => test2,n,NoOp(SRV TEST)
+exten => test2,n,SET(ID=_sip._udp.asteriskcheck.com)
+exten => test2,n,NoOp(Got ${SRVRESULT(${ID},getnum)} results)
+exten => test2,n,Set(i=1)
+exten => test2,n,While($[${i} <= ${SRVRESULT(${ID},getnum)}])
+exten => test2,n,UserEvent(SRV,RecordNum: ${i},Host: ${SRVRESULT(${ID},${i},host)},Port: ${SRVRESULT(${ID},${i},port)},Priority: ${SRVRESULT(${ID},${i},priority)},Weight: ${SRVRESULT(${ID},${i},weight)})
+exten => test2,n,Set(i=$[${i} + 1])
+exten => test2,n,EndWhile

Propchange: asterisk/trunk/tests/func_srv/configs/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/func_srv/configs/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/func_srv/configs/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/func_srv/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/func_srv/run-test?view=auto&rev=250
==============================================================================
--- asterisk/trunk/tests/func_srv/run-test (added)
+++ asterisk/trunk/tests/func_srv/run-test Fri Apr 23 15:35:26 2010
@@ -1,0 +1,3 @@
+#!/bin/bash -e
+
+asttest -a / -s tests/func_srv

Propchange: asterisk/trunk/tests/func_srv/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/func_srv/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/func_srv/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/func_srv/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/func_srv/test-config.yaml?view=auto&rev=250
==============================================================================
--- asterisk/trunk/tests/func_srv/test-config.yaml (added)
+++ asterisk/trunk/tests/func_srv/test-config.yaml Fri Apr 23 15:35:26 2010
@@ -1,0 +1,10 @@
+testinfo:
+    summary:     'Test func_srv for correctness'
+    description: |
+        'This test exercises the SRVQUERY and SRVRESULT dialplan functions
+        to be certain that the results obtained are what are expected.'
+
+properties:
+    minversion: '1.8'
+    dependencies:
+        - app: 'asttest'

Propchange: asterisk/trunk/tests/func_srv/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/func_srv/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/func_srv/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/func_srv/test.lua
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/func_srv/test.lua?view=auto&rev=250
==============================================================================
--- asterisk/trunk/tests/func_srv/test.lua (added)
+++ asterisk/trunk/tests/func_srv/test.lua Fri Apr 23 15:35:26 2010
@@ -1,0 +1,94 @@
+srv_record = {}
+function srv_record:new(host, port, priority, weight)
+	local s = {
+		host = host or '',
+		port = port or 0,
+		priority = priority or 0,
+		weight = weight or 0
+	}
+	setmetatable(s, self)
+	self.__index = self
+	return s
+end
+
+function srv_record.__eq(rec1, rec2)
+	-- Helpful for debugging
+	print ("Going to compare the following:")
+	print ("Host 1: " .. rec1.host .. " Host 2: " .. rec2.host)
+	print ("Port 1: " .. rec1.port .. " Port 2: " .. rec2.port)
+	print ("priority 1: " .. rec1.priority .. " priority 2: " .. rec2.priority)
+	print ("weight 1: " .. rec1.weight .. " weight 2: " .. rec2.weight)
+	return rec1.host == rec2.host and rec1.port == rec2.port and rec1.priority == rec2.priority and rec1.weight == rec2.weight
+end
+
+srv_records = {
+	srv_record:new("udpserver1.asteriskcheck.com","5060","0","3"),
+	srv_record:new("udpserver2.asteriskcheck.com","5061","1","0"),
+	srv_record:new("udpserver3.asteriskcheck.com","5060","1","0"),
+	srv_record:new("udpserver4.asteriskcheck.com","5060","65535","65535")
+}
+
+function analyze_srv(event)
+	local record_num = tonumber(event["RecordNum"])
+	local record = srv_record:new(event["Host"], event["Port"], event["Priority"], event["Weight"])
+	--Helpful for debugging
+	print ("User event callback")
+	print ("Got record Host: " .. event["Host"] .. " Port: " .. event["Port"] .. " Priority: " .. event["Priority"] .. " Weight: " .. event["Weight"])
+	if record ~= srv_records[record_num] then
+		-- Since records 2 and 3 share the same priority, it is unpredictable
+		-- which order we'll see them arrive
+		if record_num == 2 then
+			record_num = 3
+		elseif record_num == 3 then
+			record_num = 2
+		else
+			fail("Records don't match!")
+		end
+		if record ~= srv_records[record_num] then
+			fail("Records don't match!")
+		end
+	end
+end
+
+function do_call(man, exten)
+	local orig = ast.manager.action:new("Originate")
+	orig["Channel"] = "Local/" .. exten .. "@test_context"
+	orig["Application"] = "Wait"
+	orig["Data"] = "3"
+	man:register_event("UserEvent", analyze_srv)
+	local res, err = man(orig)
+	if not res then
+		fail("Error originating call: " .. err)
+	end
+	if res["Response"] ~= "Success" then
+		fail("Response failure for Originate: " .. res["Message"])
+	end
+	posix.sleep(4)
+	res, err = man:pump_messages()
+	if not res then
+		fail("Error pumping messages: " .. err)
+	end
+	man:process_events()
+	man:unregister_event("UserEvent", analyze_srv)
+end
+
+instance = ast.new()
+instance:load_config("configs/extensions.conf")
+instance:generate_manager_conf()
+instance:spawn()
+
+man,err = instance:manager_connect()
+if not man then
+	fail("error connecting to asterisk: " .. err)
+end
+
+login = ast.manager.action.login()
+if not login then
+	fail("Couldn't create login?")
+end
+man(login)
+do_call(man, "test")
+do_call(man, "test2")
+logoff = ast.manager.action.logoff()
+man(logoff)
+instance:term_or_kill()

Propchange: asterisk/trunk/tests/func_srv/test.lua
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/func_srv/test.lua
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/func_srv/test.lua
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/sip_outbound_address/configs/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/sip_outbound_address/configs/extensions.conf?view=auto&rev=250
==============================================================================
--- asterisk/trunk/tests/sip_outbound_address/configs/extensions.conf (added)
+++ asterisk/trunk/tests/sip_outbound_address/configs/extensions.conf Fri Apr 23 15:35:26 2010
@@ -1,0 +1,35 @@
+[test_context]
+
+;Base line.
+;Result: Use sip.conf info
+exten => test1,1,Dial(SIP/peer,,M(readdtmf))
+exten => test1,n,Hangup
+
+;Basic change to outbound. Should dial to explicit host:port
+;Result: Use host in dialstring
+exten => test2,1,Dial(SIP/peer//127.0.0.1:5062,,M(readdtmf))
+exten => test2,n,Hangup
+
+;Adding user portion should not affect routing
+;Result: Use host in dialstring
+exten => test3,1,Dial(SIP/1000 at peer//127.0.0.1:5062,,M(readdtmf))
+exten => test3,n,Hangup
+
+;Neither should adding extension between peer and host
+;Result: Use host in dialstring
+exten => test4,1,Dial(SIP/peer/1000/127.0.0.1:5062,,M(readdtmf))
+exten => test4,n,Hangup
+
+;Neither should a conflict in which extension to use
+;Result: Use host in dialstring
+exten => test5,1,Dial(SIP/1000 at peer/1000/127.0.0.1:5062,,M(readdtmf))
+exten => test5,n,Hangup
+
+;This one has the wrong number of slashes before the host
+;Result: Use sip.conf info
+exten => test6,1,Dial(SIP/1000 at peer/127.0.0.1:5062,,M(readdtmf))
+exten => test6,n,Hangup
+
+[macro-readdtmf]
+exten => s,1,Read(READRESULT,,1,,1,5)
+exten => s,n,MacroExit

Propchange: asterisk/trunk/tests/sip_outbound_address/configs/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/sip_outbound_address/configs/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/sip_outbound_address/configs/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/sip_outbound_address/configs/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/sip_outbound_address/configs/sip.conf?view=auto&rev=250
==============================================================================
--- asterisk/trunk/tests/sip_outbound_address/configs/sip.conf (added)
+++ asterisk/trunk/tests/sip_outbound_address/configs/sip.conf Fri Apr 23 15:35:26 2010
@@ -1,0 +1,10 @@
+[general]
+canreinvite=no
+
+;This is the peer dialed for
+;all outbound calls
+[peer]
+type=friend
+dtmfmode=rfc2833
+host=127.0.0.1
+port=5061

Propchange: asterisk/trunk/tests/sip_outbound_address/configs/sip.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/sip_outbound_address/configs/sip.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/sip_outbound_address/configs/sip.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/sip_outbound_address/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/sip_outbound_address/run-test?view=auto&rev=250
==============================================================================
--- asterisk/trunk/tests/sip_outbound_address/run-test (added)
+++ asterisk/trunk/tests/sip_outbound_address/run-test Fri Apr 23 15:35:26 2010
@@ -1,0 +1,3 @@
+#!/bin/bash -e
+
+asttest -a / -s tests/sip_outbound_address

Propchange: asterisk/trunk/tests/sip_outbound_address/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/sip_outbound_address/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/sip_outbound_address/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/sip_outbound_address/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/sip_outbound_address/sipp/dtmf_2833_1.pcap
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/sip_outbound_address/sipp/dtmf_2833_1.pcap?view=auto&rev=250
==============================================================================
Binary file - no diff available.

Propchange: asterisk/trunk/tests/sip_outbound_address/sipp/dtmf_2833_1.pcap
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/sip_outbound_address/sipp/dtmf_2833_1.pcap
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: asterisk/trunk/tests/sip_outbound_address/sipp/dtmf_2833_2.pcap
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/sip_outbound_address/sipp/dtmf_2833_2.pcap?view=auto&rev=250
==============================================================================
Binary file - no diff available.

Propchange: asterisk/trunk/tests/sip_outbound_address/sipp/dtmf_2833_2.pcap
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/sip_outbound_address/sipp/dtmf_2833_2.pcap
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: asterisk/trunk/tests/sip_outbound_address/sipp/dtmf_2833_pound.pcap
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/sip_outbound_address/sipp/dtmf_2833_pound.pcap?view=auto&rev=250
==============================================================================
Binary file - no diff available.

Propchange: asterisk/trunk/tests/sip_outbound_address/sipp/dtmf_2833_pound.pcap
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/sip_outbound_address/sipp/dtmf_2833_pound.pcap
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: asterisk/trunk/tests/sip_outbound_address/sipp/uas1.xml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/sip_outbound_address/sipp/uas1.xml?view=auto&rev=250
==============================================================================
--- asterisk/trunk/tests/sip_outbound_address/sipp/uas1.xml (added)
+++ asterisk/trunk/tests/sip_outbound_address/sipp/uas1.xml Fri Apr 23 15:35:26 2010
@@ -1,0 +1,133 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<!-- This program is free software; you can redistribute it and/or      -->
+<!-- modify it under the terms of the GNU General Public License as     -->
+<!-- published by the Free Software Foundation; either version 2 of the -->
+<!-- License, or (at your option) any later version.                    -->
+<!--                                                                    -->
+<!-- This program is distributed in the hope that it will be useful,    -->
+<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of     -->
+<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      -->
+<!-- GNU General Public License for more details.                       -->
+<!--                                                                    -->
+<!-- You should have received a copy of the GNU General Public License  -->
+<!-- along with this program; if not, write to the                      -->
+<!-- Free Software Foundation, Inc.,                                    -->
+<!-- 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA             -->
+<!--                                                                    -->
+<!--                 Sipp default 'uas' scenario.                       -->
+<!--                                                                    -->
+
+<scenario name="Basic UAS responder">
+  <!-- By adding rrs="true" (Record Route Sets), the route sets         -->
+  <!-- are saved and used for following messages sent. Useful to test   -->
+  <!-- against stateful SIP proxies/B2BUAs.                             -->
+  <recv request="INVITE" crlf="true">
+  </recv>
+
+  <!-- The '[last_*]' keyword is replaced automatically by the          -->
+  <!-- specified header if it was present in the last message received  -->
+  <!-- (except if it was a retransmission). If the header was not       -->
+  <!-- present or if no message has been received, the '[last_*]'       -->
+  <!-- keyword is discarded, and all bytes until the end of the line    -->
+  <!-- are also discarded.                                              -->
+  <!--                                                                  -->
+  <!-- If the specified header was present several times in the         -->
+  <!-- message, all occurences are concatenated (CRLF seperated)        -->
+  <!-- to be used in place of the '[last_*]' keyword.                   -->
+
+  <send>
+    <![CDATA[
+
+      SIP/2.0 180 Ringing
+      [last_Via:]
+      [last_From:]
+      [last_To:];tag=[pid]SIPpTag01[call_number]
+      [last_Call-ID:]
+      [last_CSeq:]
+      Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <send retrans="500">
+    <![CDATA[
+
+      SIP/2.0 200 OK
+      [last_Via:]
+      [last_From:]
+      [last_To:];tag=[pid]SIPpTag01[call_number]
+      [last_Call-ID:]
+      [last_CSeq:]
+      Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+      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 101
+      a=rtpmap:0 PCMU/8000
+      a=rtpmap:101 telephone-event/8000
+      a=fmtp:101 0-16
+      a=sendrecv
+
+    ]]>
+  </send>
+
+  <recv request="ACK"
+        rtd="true"
+        crlf="true">
+  </recv>
+
+  <nop>
+  	<action>
+		<exec play_pcap_audio="sipp/dtmf_2833_1.pcap" />
+	</action>
+  </nop>
+
+  <pause milliseconds="200" />
+  
+  <nop>
+  	<action>
+		<exec play_pcap_audio="sipp/dtmf_2833_pound.pcap" />
+	</action>
+  </nop>
+
+  <pause milliseconds="200" />
+
+  <recv request="BYE">
+  </recv>
+
+  <send>
+    <![CDATA[
+
+      SIP/2.0 200 OK
+      [last_Via:]
+      [last_From:]
+      [last_To:]
+      [last_Call-ID:]
+      [last_CSeq:]
+      Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <!-- Keep the call open for a while in case the 200 is lost to be     -->
+  <!-- able to retransmit it if we receive the BYE again.               -->
+  <pause milliseconds="4000"/>
+
+
+  <!-- definition of the response time repartition table (unit is ms)   -->
+  <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
+
+  <!-- definition of the call length repartition table (unit is ms)     -->
+  <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
+
+</scenario>
+

Propchange: asterisk/trunk/tests/sip_outbound_address/sipp/uas1.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/sip_outbound_address/sipp/uas1.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/sip_outbound_address/sipp/uas1.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/sip_outbound_address/sipp/uas2.xml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/sip_outbound_address/sipp/uas2.xml?view=auto&rev=250
==============================================================================
--- asterisk/trunk/tests/sip_outbound_address/sipp/uas2.xml (added)
+++ asterisk/trunk/tests/sip_outbound_address/sipp/uas2.xml Fri Apr 23 15:35:26 2010
@@ -1,0 +1,133 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<!-- This program is free software; you can redistribute it and/or      -->
+<!-- modify it under the terms of the GNU General Public License as     -->
+<!-- published by the Free Software Foundation; either version 2 of the -->
+<!-- License, or (at your option) any later version.                    -->
+<!--                                                                    -->
+<!-- This program is distributed in the hope that it will be useful,    -->
+<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of     -->
+<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      -->
+<!-- GNU General Public License for more details.                       -->
+<!--                                                                    -->
+<!-- You should have received a copy of the GNU General Public License  -->
+<!-- along with this program; if not, write to the                      -->
+<!-- Free Software Foundation, Inc.,                                    -->
+<!-- 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA             -->
+<!--                                                                    -->
+<!--                 Sipp default 'uas' scenario.                       -->
+<!--                                                                    -->
+
+<scenario name="Basic UAS responder">
+  <!-- By adding rrs="true" (Record Route Sets), the route sets         -->
+  <!-- are saved and used for following messages sent. Useful to test   -->
+  <!-- against stateful SIP proxies/B2BUAs.                             -->
+  <recv request="INVITE" crlf="true">
+  </recv>
+
+  <!-- The '[last_*]' keyword is replaced automatically by the          -->
+  <!-- specified header if it was present in the last message received  -->
+  <!-- (except if it was a retransmission). If the header was not       -->
+  <!-- present or if no message has been received, the '[last_*]'       -->
+  <!-- keyword is discarded, and all bytes until the end of the line    -->
+  <!-- are also discarded.                                              -->
+  <!--                                                                  -->
+  <!-- If the specified header was present several times in the         -->
+  <!-- message, all occurences are concatenated (CRLF seperated)        -->
+  <!-- to be used in place of the '[last_*]' keyword.                   -->
+
+  <send>
+    <![CDATA[
+
+      SIP/2.0 180 Ringing
+      [last_Via:]
+      [last_From:]
+      [last_To:];tag=[pid]SIPpTag01[call_number]
+      [last_Call-ID:]
+      [last_CSeq:]
+      Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <send retrans="500">
+    <![CDATA[
+
+      SIP/2.0 200 OK
+      [last_Via:]
+      [last_From:]
+      [last_To:];tag=[pid]SIPpTag01[call_number]
+      [last_Call-ID:]
+      [last_CSeq:]
+      Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+      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 101
+      a=rtpmap:0 PCMU/8000
+      a=rtpmap:101 telephone-event/8000
+      a=fmtp:101 0-16
+      a=sendrecv
+
+    ]]>
+  </send>
+
+  <recv request="ACK"
+        rtd="true"
+        crlf="true">
+  </recv>
+
+  <nop>
+  	<action>
+		<exec play_pcap_audio="sipp/dtmf_2833_2.pcap" />
+	</action>
+  </nop>
+
+  <pause milliseconds="200" />
+
+  <nop>
+  	<action>
+		<exec play_pcap_audio="sipp/dtmf_2833_pound.pcap" />
+	</action>
+  </nop>
+
+  <pause milliseconds="200" />
+
+  <recv request="BYE">
+  </recv>
+
+  <send>
+    <![CDATA[
+
+      SIP/2.0 200 OK
+      [last_Via:]
+      [last_From:]
+      [last_To:]
+      [last_Call-ID:]
+      [last_CSeq:]
+      Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <!-- Keep the call open for a while in case the 200 is lost to be     -->
+  <!-- able to retransmit it if we receive the BYE again.               -->
+  <pause milliseconds="4000"/>
+
+
+  <!-- definition of the response time repartition table (unit is ms)   -->
+  <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
+
+  <!-- definition of the call length repartition table (unit is ms)     -->
+  <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
+
+</scenario>
+

Propchange: asterisk/trunk/tests/sip_outbound_address/sipp/uas2.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/sip_outbound_address/sipp/uas2.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/sip_outbound_address/sipp/uas2.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/sip_outbound_address/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/sip_outbound_address/test-config.yaml?view=auto&rev=250
==============================================================================
--- asterisk/trunk/tests/sip_outbound_address/test-config.yaml (added)
+++ asterisk/trunk/tests/sip_outbound_address/test-config.yaml Fri Apr 23 15:35:26 2010
@@ -1,0 +1,22 @@
+testinfo:
+    summary:     'Test explicit outbound host for SIP calls'
+    description: |
+        "This tests the ability to specify an explicit host to send
+        an outbound SIP INVITE to. The test works by having two SIPp
+        UASs waiting for INVITEs. Each is set to answer an inbound INVITE
+        and then send an RFC2833 DTMF digit. Asterisk will read this digit,
+        and determine who answered the call. Based on who answered the call,
+        we can determine which UAS answered and whether it was the one we
+        expected.
+
+        It is possible that this test could be done in a more straightforward
+        manner. Suggestions are certainly welcome."
+    issues:
+        - jira : 'ABE-2153'
+
+properties:
+    minversion: 'trunk'
+    dependencies:
+        - app : 'bash'
+        - app : 'sipp'
+        - app : 'asttest'

Propchange: asterisk/trunk/tests/sip_outbound_address/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/sip_outbound_address/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/sip_outbound_address/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/sip_outbound_address/test.lua
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/sip_outbound_address/test.lua?view=auto&rev=250
==============================================================================
--- asterisk/trunk/tests/sip_outbound_address/test.lua (added)
+++ asterisk/trunk/tests/sip_outbound_address/test.lua Fri Apr 23 15:35:26 2010
@@ -1,0 +1,123 @@
+function sipp_exec(scenario, local_port)
+	return proc.exec_io("sipp",
+	"127.0.0.1",
+	"-m", "1",
+	"-sf", scenario,
+	"-i", "127.0.0.1",
+	"-p", local_port,
+	"-timeout", "30",
+	"-trace_err"
+	)
+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 .. ")\n" .. p.stderr:read("*a"))
+	end
+
+	return res, err
+end
+
+function varset_event_one(event)
+	if (event["Variable"] == "READRESULT") then
+		if (event["Value"] ~= "1") then
+			fail("Wrong UAS answered. Expected DTMF '1' but received " .. event["Value"])
+		else
+			passed = true;
+		end
+	end
+end
+
+function varset_event_two(event)
+	if (event["Variable"] == "READRESULT") then
+		if (event["Value"] ~= "2") then
+			fail("Wrong UAS answered. Expected DTMF '2' but received " .. event["Value"])
+		else
+			passed = true;
+		end
+	end
+end
+
+function manager_setup(a)
+	m,err = a:manager_connect()
+	if not m then
+		fail("error connecting to asterisk: " .. err)
+	end
+
+	login = ast.manager.action:new("login")
+	login["Username"] = "asttest"
+	login["Secret"] = "asttest"
+
+	local r = m(login)
+	if not r then
+		fail("error logging in to the manager: " .. err)
+	end
+
+	if r["Response"] ~= "Success" then
+		fail("error authenticating: " .. r["Message"])
+	end
+end
+
+function setup_uas()
+	local t1 = sipp_exec("sipp/uas1.xml", "5061")
+	local t2 = sipp_exec("sipp/uas2.xml", "5062")
+	return t1, t2
+end
+
+function kill_uas(t1, t2)
+	t1:term_or_kill()
+	t2:term_or_kill()
+end
+
+function test_call(exten, handler)
+	passed = false;
+	m:register_event("VarSet", handler)
+	local uas1, uas2 = setup_uas()
+	local orig = ast.manager.action:new("Originate")
+	orig["Channel"] = "Local/" .. exten .. "@test_context"
+	orig["Context"] = "test_context"
+	orig["Application"] = "Wait"
+	orig["Data"] = "1"
+	local res, err = m(orig)
+	if not res then
+		fail("Error originating call: " .. err)
+	end
+	if res["Response"] ~= "Success" then
+		fail("Response failure for Originate: " .. res["Message"])
+	end
+	posix.sleep(2)
+	local res, err = m:pump_messages()
+	if not res then
+		fail("error pumping manager messages: " .. err)
+	end
+	m:process_events()
+	m:unregister_event("VarSet", handler)
+	kill_uas(uas1, uas2)
+	if not passed then
+		fail("Failure has occurred")
+	end
+end
+
+a = ast.new()
+a:load_config("configs/sip.conf")
+a:load_config("configs/extensions.conf")
+a:generate_manager_conf()
+a:spawn()
+
+manager_setup(a)
+
+test_call("test1", varset_event_one)
+test_call("test2", varset_event_two)
+test_call("test3", varset_event_two)
+test_call("test4", varset_event_two)
+test_call("test5", varset_event_two)
+test_call("test6", varset_event_one)
+
+a:term_or_kill()

Propchange: asterisk/trunk/tests/sip_outbound_address/test.lua
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/sip_outbound_address/test.lua
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/sip_outbound_address/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=250&r1=249&r2=250
==============================================================================
--- asterisk/trunk/tests/tests.yaml (original)
+++ asterisk/trunk/tests/tests.yaml Fri Apr 23 15:35:26 2010
@@ -8,3 +8,5 @@
     - test: 'iax-call-basic'
     - test: 'manager-action-events-response'
     - test: 'originate-cdr-disposition'
+    - test: 'func_srv'
+    - test: 'sip_outbound_address'




More information about the asterisk-commits mailing list