[asterisk-commits] mmichelson: branch mmichelson/queue_tests r264 - in /asterisk/team/mmichelson...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Apr 29 11:51:22 CDT 2010
Author: mmichelson
Date: Thu Apr 29 11:51:19 2010
New Revision: 264
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=264
Log:
Add a new queue test.
This took WAAAY longer than I expected, and mostly because
of careless scripting. A hint to all you would-be test writers,
remember to examine your test for errors before trying to debug
Asterisk, running tcpdumps, etc.
Added:
asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/
asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/
asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/extensions.conf (with props)
asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/queues.conf (with props)
asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/sip.conf (with props)
asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/run-test (with props)
asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/sipp/
asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/sipp/uas.xml (with props)
asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/test-config.yaml (with props)
asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/test.lua (with props)
Added: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/extensions.conf?view=auto&rev=264
==============================================================================
--- asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/extensions.conf (added)
+++ asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/extensions.conf Thu Apr 29 11:51:19 2010
@@ -1,0 +1,7 @@
+[test_context]
+
+exten => queue1,1,Queue(test_queue1,n,,,3)
+exten => queue1,n,Hangup
+
+exten => queue2,1,Queue(test_queue2,n,,,3)
+exten => queue2,n,Hangup
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/extensions.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/extensions.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/extensions.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/queues.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/queues.conf?view=auto&rev=264
==============================================================================
--- asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/queues.conf (added)
+++ asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/queues.conf Thu Apr 29 11:51:19 2010
@@ -1,0 +1,15 @@
+[test_queue1]
+eventwhencalled=yes
+ringinuse=no
+autopause=yes
+timeout=1
+retry=1
+member=SIP/member
+
+[test_queue2]
+eventwhencalled=yes
+ringinuse=yes
+autopause=yes
+timeout=1
+retry=1
+member=SIP/member
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/queues.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/queues.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/queues.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/sip.conf?view=auto&rev=264
==============================================================================
--- asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/sip.conf (added)
+++ asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/sip.conf Thu Apr 29 11:51:19 2010
@@ -1,0 +1,11 @@
+[general]
+udpbindaddr=127.0.0.1:5060
+canreinvite=no
+videosupport=yes
+
+[member]
+type = friend
+host = 127.0.0.1
+port = 5061
+context = test_context
+call-limit=3
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/sip.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/sip.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/configs/sip.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/run-test?view=auto&rev=264
==============================================================================
--- asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/run-test (added)
+++ asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/run-test Thu Apr 29 11:51:19 2010
@@ -1,0 +1,3 @@
+#!/bin/bash -e
+
+asttest -a / -s tests/queues/ringinuse_and_pause
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/run-test
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/run-test
------------------------------------------------------------------------------
svn:executable = *
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/run-test
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/run-test
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/sipp/uas.xml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/sipp/uas.xml?view=auto&rev=264
==============================================================================
--- asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/sipp/uas.xml (added)
+++ asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/sipp/uas.xml Thu Apr 29 11:51:19 2010
@@ -1,0 +1,115 @@
+<?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
+ a=rtpmap:0 ulaw/8000
+ a=sendrecv
+
+ ]]>
+ </send>
+
+ <recv request="ACK"
+ rtd="true"
+ crlf="true">
+ </recv>
+
+ <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/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/sipp/uas.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/sipp/uas.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/sipp/uas.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/test-config.yaml?view=auto&rev=264
==============================================================================
--- asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/test-config.yaml (added)
+++ asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/test-config.yaml Thu Apr 29 11:51:19 2010
@@ -1,0 +1,21 @@
+testinfo:
+ summary: 'Test ringinuse and autopause'
+ description: |
+ "This test accomplishes several tasks. First, it ensures that queue
+ members in queues with ringinuse=no are not called. Second, it ensures
+ that autopause takes effect properly after a called member does not answer.
+ Third, it makes sure that a paused member is not called, even if ringinuse
+ is not set to 'no.'
+
+ The test also tests some subtle behavior aspects. For instance, we do not
+ autopause a member UNLESS he gets called. So in the first test call run, we
+ call a busy member who has ringinuse=no. This means that since we didn't even
+ attempt to call the member, we will not autopause him."
+
+properties:
+ minversion: '1.4'
+ dependencies:
+ - app : 'bash'
+ - app : 'sipp'
+ - app : 'asttest'
+
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/test-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/test-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/test-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/test.lua
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/test.lua?view=auto&rev=264
==============================================================================
--- asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/test.lua (added)
+++ asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/test.lua Thu Apr 29 11:51:19 2010
@@ -1,0 +1,176 @@
+function sipp_exec(scenario, local_port)
+ return proc.exec_io("sipp",
+ "127.0.0.1",
+ "-sf", scenario,
+ "-i", "127.0.0.1",
+ "-m", "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 manager_setup(a)
+ local m, err = a:manager_connect()
+ if not m then
+ fail("error connecting to asterisk: " .. err)
+ end
+
+ login = ast.manager.action.login()
+ if not login then
+ fail("Couldn't create login?")
+ end
+
+ 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
+ return m
+end
+
+function setup_ast_instance()
+ local instance = ast.new()
+ instance:load_config("configs/extensions.conf")
+ instance:load_config("configs/queues.conf")
+ instance:load_config("configs/sip.conf")
+ instance:generate_manager_conf()
+ instance:spawn()
+ return instance
+end
+
+function get_chan_name(event)
+ chan_name = event["Channel"]
+ print("Set the chan_name to " .. chan_name)
+end
+
+function busy_the_member(man)
+ man:register_event("Newchannel", get_chan_name)
+ local orig = ast.manager.action:new("Originate")
+ orig["Channel"] = "SIP/member"
+ orig["Application"] = "Wait"
+ orig["Data"] = "15"
+ orig["Async"] = "yes"
+ local res, err = man(orig)
+ if not res then
+ fail("Error originating call: " .. err)
+ end
+ if res["Response"] ~= "Success" then
+ fail("Originate response failure when trying to busy the member")
+ end
+ man:pump_messages()
+ man:process_events()
+ if not chan_name then
+ fail("Failed to get channel name")
+ end
+ man:unregister_event("Newchannel", get_chan_name)
+end
+
+function unbusy_the_member(man)
+ local hangup = ast.manager.action:new("Hangup")
+ hangup["Channel"] = chan_name
+ local res, err = man(hangup)
+ if not res then
+ fail("Error trying to hang up call: " .. err)
+ end
+ if res["Response"] ~= "Success" then
+ fail("Response failure from hangup: " .. res["Message"])
+ end
+end
+
+function agent_called_handler(event)
+ print (event["ChannelCalling"])
+ actual_call_result = true
+end
+
+function agent_paused_handler(event)
+ actual_pause_result = true
+end
+
+function test_call(queue, originate_result, expected_call_result, pause_expectation)
+ local orig = ast.manager.action:new("Originate")
+ actual_call_result = false
+ actual_pause_result = false
+ man:register_event("AgentCalled", agent_called_handler)
+ man:register_event("QueueMemberPaused", agent_paused_handler)
+ orig["Channel"] = "Local/" .. queue .. "@test_context/n"
+ orig["Application"] = "Wait"
+ orig["Data"] = "3"
+ local res, err = man(orig)
+ if not res then
+ fail("Error originating call: " .. err)
+ end
+ --For calls to the queue where no member is
+ --available to answer, we expect the originate
+ --to fail.
+ if res["Response"] ~= originate_result then
+ fail("Unexpected originate result. Expected " .. originate_result .. " but got " .. res["Response"])
+ else
+ print("Good originate response")
+ end
+ man:pump_messages()
+ man:process_events()
+ if actual_call_result ~= expected_call_result then
+ fail("Unexpected AgentCalled result. Got " .. tostring(actual_call_result) .." but expected " .. tostring(expected_call_result))
+ else
+ print("Good AgentCalled result")
+ end
+ if actual_pause_result ~= pause_expectation then
+ fail("Unexpected QueueMemberPaused result")
+ else
+ print("Good QueueMemberPaused result")
+ end
+ man:unregister_event("AgentCalled", agent_called_handler)
+ man:unregister_event("QueueMemberPaused", agent_paused_handler)
+end
+
+ugugug = sipp_exec("sipp/uas.xml", "5061")
+a = setup_ast_instance()
+man = manager_setup(a)
+chan_name = nil
+
+busy_the_member(man)
+--Since the member is busy, we won't actually ever
+--call, and therefore we won't autopause the guy
+--either.
+test_call("queue1", "Error", false, false)
+--This queue allows ringinuse, but the member
+--is in use when we call. The result is that
+--we will actually attempt to call the member up, so
+--we will get an AgentCalled event. Since we
+--did try calling, we will also autopause the
+--jerk.
+test_call("queue2", "Error", true, true)
+unbusy_the_member(man)
+sipp_check_error(ugugug, "sipp/uas.xml")
+ugugug = sipp_exec("sipp/uas.xml", "5061")
+--Now the member is available. A call from
+--the first queue will work perfectly.
+test_call("queue1", "Success", true, false)
+--Have to restart the scenario since
+--it ends after a hangup
+sipp_check_error(ugugug, "sipp/uas.xml")
+ugugug = sipp_exec("sipp/uas.xml", "5061")
+--However, the member is paused in this queue,
+--so we should see no call attempt get made
+--at all.
+test_call("queue2", "Error", false, false)
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/test.lua
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/test.lua
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/mmichelson/queue_tests/tests/queues/ringinuse_and_pause/test.lua
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the asterisk-commits
mailing list