<p>Rodrigo Ramirez Norambuena has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/testsuite/+/11326">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">testsuite: Add test for the behaviour wrapuptime per member in queue<br><br>ASTERISK-27483<br><br>Change-Id: I4cad65aab2957d754596058ea3a39d244e89d7cd<br>---<br>M tests/apps/queues/tests.yaml<br>A tests/apps/queues/wrapup_time_per_member/configs/ast1/queues.conf<br>A tests/apps/queues/wrapup_time_per_member/configs/extensions.conf<br>A tests/apps/queues/wrapup_time_per_member/run-test<br>A tests/apps/queues/wrapup_time_per_member/test-config.yaml<br>A tests/apps/queues/wrapup_time_per_member/test.lua<br>6 files changed, 179 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/26/11326/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/apps/queues/tests.yaml b/tests/apps/queues/tests.yaml</span><br><span>index f618ee2..be78da0 100644</span><br><span>--- a/tests/apps/queues/tests.yaml</span><br><span>+++ b/tests/apps/queues/tests.yaml</span><br><span>@@ -13,5 +13,6 @@</span><br><span> - test: 'macro_gosub_test'</span><br><span> - test: 'ringinuse_and_pause'</span><br><span> - test: 'wrapup_time'</span><br><span style="color: hsl(120, 100%, 40%);">+ - test: 'wrapup_time_per_member'</span><br><span> - test: 'reason_pause_ami'</span><br><span> - test: 'queue_member_forward'</span><br><span>diff --git a/tests/apps/queues/wrapup_time_per_member/configs/ast1/queues.conf b/tests/apps/queues/wrapup_time_per_member/configs/ast1/queues.conf</span><br><span>new file mode 100644</span><br><span>index 0000000..270be03</span><br><span>--- /dev/null</span><br><span>+++ b/tests/apps/queues/wrapup_time_per_member/configs/ast1/queues.conf</span><br><span>@@ -0,0 +1,10 @@</span><br><span style="color: hsl(120, 100%, 40%);">+[general]</span><br><span style="color: hsl(120, 100%, 40%);">+shared_lastcall = yes</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[test_queue]</span><br><span style="color: hsl(120, 100%, 40%);">+strategy=linear</span><br><span style="color: hsl(120, 100%, 40%);">+timeout=1</span><br><span style="color: hsl(120, 100%, 40%);">+retry=1</span><br><span style="color: hsl(120, 100%, 40%);">+wrapuptime=10</span><br><span style="color: hsl(120, 100%, 40%);">+member => Local/member1@test_context/n,,member1,,,20</span><br><span style="color: hsl(120, 100%, 40%);">+member => Local/member2@test_context/n,,member2</span><br><span>diff --git a/tests/apps/queues/wrapup_time_per_member/configs/extensions.conf b/tests/apps/queues/wrapup_time_per_member/configs/extensions.conf</span><br><span>new file mode 100644</span><br><span>index 0000000..feccaa4</span><br><span>--- /dev/null</span><br><span>+++ b/tests/apps/queues/wrapup_time_per_member/configs/extensions.conf</span><br><span>@@ -0,0 +1,12 @@</span><br><span style="color: hsl(120, 100%, 40%);">+[test_context]</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+exten => member1,1,Answer</span><br><span style="color: hsl(120, 100%, 40%);">+exten => member1,n,Wait(1)</span><br><span style="color: hsl(120, 100%, 40%);">+exten => member1,n,Hangup</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+exten => member2,1,Answer</span><br><span style="color: hsl(120, 100%, 40%);">+exten => member2,n,Wait(1)</span><br><span style="color: hsl(120, 100%, 40%);">+exten => member2,n,Hangup</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+exten => test1,1,Queue(test_queue,n,,,5)</span><br><span style="color: hsl(120, 100%, 40%);">+exten => test1,n,Hangup</span><br><span>diff --git a/tests/apps/queues/wrapup_time_per_member/run-test b/tests/apps/queues/wrapup_time_per_member/run-test</span><br><span>new file mode 100755</span><br><span>index 0000000..3634ecc</span><br><span>--- /dev/null</span><br><span>+++ b/tests/apps/queues/wrapup_time_per_member/run-test</span><br><span>@@ -0,0 +1,3 @@</span><br><span style="color: hsl(120, 100%, 40%);">+#!/usr/bin/env bash</span><br><span style="color: hsl(120, 100%, 40%);">+set -e</span><br><span style="color: hsl(120, 100%, 40%);">+asttest -a /$AST_TEST_ROOT -s `dirname $0` $@</span><br><span>diff --git a/tests/apps/queues/wrapup_time_per_member/test-config.yaml b/tests/apps/queues/wrapup_time_per_member/test-config.yaml</span><br><span>new file mode 100644</span><br><span>index 0000000..3902b19</span><br><span>--- /dev/null</span><br><span>+++ b/tests/apps/queues/wrapup_time_per_member/test-config.yaml</span><br><span>@@ -0,0 +1,13 @@</span><br><span style="color: hsl(120, 100%, 40%);">+testinfo:</span><br><span style="color: hsl(120, 100%, 40%);">+ summary: 'Test wrapuptime for queue and member'</span><br><span style="color: hsl(120, 100%, 40%);">+ description: |</span><br><span style="color: hsl(120, 100%, 40%);">+ 'This test runs in one instance of Asterisk. We set a one queue with two members.</span><br><span style="color: hsl(120, 100%, 40%);">+ One member has set the wrapuptime and other no. We place calls to the queue</span><br><span style="color: hsl(120, 100%, 40%);">+ in a way such that we can properly see if wrapuptime is honored per the member</span><br><span style="color: hsl(120, 100%, 40%);">+ and queue setting.'</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+properties:</span><br><span style="color: hsl(120, 100%, 40%);">+ dependencies:</span><br><span style="color: hsl(120, 100%, 40%);">+ - app: 'asttest'</span><br><span style="color: hsl(120, 100%, 40%);">+ tags:</span><br><span style="color: hsl(120, 100%, 40%);">+ - queues</span><br><span>diff --git a/tests/apps/queues/wrapup_time_per_member/test.lua b/tests/apps/queues/wrapup_time_per_member/test.lua</span><br><span>new file mode 100644</span><br><span>index 0000000..3b02fc3</span><br><span>--- /dev/null</span><br><span>+++ b/tests/apps/queues/wrapup_time_per_member/test.lua</span><br><span>@@ -0,0 +1,140 @@</span><br><span style="color: hsl(120, 100%, 40%);">+function manager_setup(a)</span><br><span style="color: hsl(120, 100%, 40%);">+ local m,err = a:manager_connect()</span><br><span style="color: hsl(120, 100%, 40%);">+ if not m then</span><br><span style="color: hsl(120, 100%, 40%);">+ fail("error connecting to asterisk: " .. err)</span><br><span style="color: hsl(120, 100%, 40%);">+ end</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ login = ast.manager.action.login()</span><br><span style="color: hsl(120, 100%, 40%);">+ if not login then</span><br><span style="color: hsl(120, 100%, 40%);">+ fail("Couldn't create login?")</span><br><span style="color: hsl(120, 100%, 40%);">+ end</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ local r = m(login)</span><br><span style="color: hsl(120, 100%, 40%);">+ if not r then</span><br><span style="color: hsl(120, 100%, 40%);">+ fail("error logging in to the manager: " .. err)</span><br><span style="color: hsl(120, 100%, 40%);">+ end</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if r["Response"] ~= "Success" then</span><br><span style="color: hsl(120, 100%, 40%);">+ fail("error authenticating: " .. r["Message"])</span><br><span style="color: hsl(120, 100%, 40%);">+ end</span><br><span style="color: hsl(120, 100%, 40%);">+ return m</span><br><span style="color: hsl(120, 100%, 40%);">+end</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+function member1(event)</span><br><span style="color: hsl(120, 100%, 40%);">+ match_event_member(event, "member1")</span><br><span style="color: hsl(120, 100%, 40%);">+end</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+function member2(event)</span><br><span style="color: hsl(120, 100%, 40%);">+ match_event_member(event, "member2")</span><br><span style="color: hsl(120, 100%, 40%);">+end</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+function match_event_member(event, member)</span><br><span style="color: hsl(120, 100%, 40%);">+ --print("Got member")</span><br><span style="color: hsl(120, 100%, 40%);">+ --print("Queue: " .. tostring(event["Queue"]))</span><br><span style="color: hsl(120, 100%, 40%);">+ --print("Uniqueid: " .. tostring(event["Uniqueid"]))</span><br><span style="color: hsl(120, 100%, 40%);">+ --print("Channel: " .. tostring(event["Channel"]))</span><br><span style="color: hsl(120, 100%, 40%);">+ --print("Member: " .. tostring(event["Member"]))</span><br><span style="color: hsl(120, 100%, 40%);">+ --print("MemberName: " .. tostring(event["MemberName"]))</span><br><span style="color: hsl(120, 100%, 40%);">+ --print("Holdtime: " .. tostring(event["Holdtime"]))</span><br><span style="color: hsl(120, 100%, 40%);">+ --print("BridgedChannel: " .. tostring(event["BridgedChannel"]))</span><br><span style="color: hsl(120, 100%, 40%);">+ --print("Ringtime: " .. tostring(event["Ringtime"]))</span><br><span style="color: hsl(120, 100%, 40%);">+ if event["MemberName"] == member then</span><br><span style="color: hsl(120, 100%, 40%);">+ connectpass = true</span><br><span style="color: hsl(120, 100%, 40%);">+ else</span><br><span style="color: hsl(120, 100%, 40%);">+ print(event["Membername"])</span><br><span style="color: hsl(120, 100%, 40%);">+ end</span><br><span style="color: hsl(120, 100%, 40%);">+end</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+function setup_ast_instance(which)</span><br><span style="color: hsl(120, 100%, 40%);">+ local instance = ast.new()</span><br><span style="color: hsl(120, 100%, 40%);">+ instance:load_config("configs/extensions.conf")</span><br><span style="color: hsl(120, 100%, 40%);">+ instance:load_config("configs/" .. which .. "/queues.conf")</span><br><span style="color: hsl(120, 100%, 40%);">+ instance:generate_manager_conf()</span><br><span style="color: hsl(120, 100%, 40%);">+ instance:spawn()</span><br><span style="color: hsl(120, 100%, 40%);">+ return instance</span><br><span style="color: hsl(120, 100%, 40%);">+end</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+function complete_handler(event)</span><br><span style="color: hsl(120, 100%, 40%);">+ completepass = true</span><br><span style="color: hsl(120, 100%, 40%);">+end</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+function test_call(ast_instance, man, handler, exten)</span><br><span style="color: hsl(120, 100%, 40%);">+ if handler then</span><br><span style="color: hsl(120, 100%, 40%);">+ man:register_event("AgentConnect", handler)</span><br><span style="color: hsl(120, 100%, 40%);">+ man:register_event("AgentComplete", complete_handler)</span><br><span style="color: hsl(120, 100%, 40%);">+ connectpass = false</span><br><span style="color: hsl(120, 100%, 40%);">+ completepass = false</span><br><span style="color: hsl(120, 100%, 40%);">+ end</span><br><span style="color: hsl(120, 100%, 40%);">+ local orig = ast.manager.action:new("Originate")</span><br><span style="color: hsl(120, 100%, 40%);">+ orig["Channel"] = "Local/" .. exten .. "@test_context/n"</span><br><span style="color: hsl(120, 100%, 40%);">+ orig["Application"] = "Wait"</span><br><span style="color: hsl(120, 100%, 40%);">+ orig["Data"] = "1"</span><br><span style="color: hsl(120, 100%, 40%);">+ local res, err = man(orig)</span><br><span style="color: hsl(120, 100%, 40%);">+ if not res then</span><br><span style="color: hsl(120, 100%, 40%);">+ fail("Error originating call: " .. err)</span><br><span style="color: hsl(120, 100%, 40%);">+ end</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if res["Response"] ~= "Success" then</span><br><span style="color: hsl(120, 100%, 40%);">+ if not handler then</span><br><span style="color: hsl(120, 100%, 40%);">+ --When the handler is nil, this means we expect that no</span><br><span style="color: hsl(120, 100%, 40%);">+ --queue members will be available to answer the call. Since</span><br><span style="color: hsl(120, 100%, 40%);">+ --no one can answer the originated call, the originate will</span><br><span style="color: hsl(120, 100%, 40%);">+ --fail. If it doesn't, then something went wrong.</span><br><span style="color: hsl(120, 100%, 40%);">+ return</span><br><span style="color: hsl(120, 100%, 40%);">+ else</span><br><span style="color: hsl(120, 100%, 40%);">+ fail("Response failure for Originate: " .. res["Message"])</span><br><span style="color: hsl(120, 100%, 40%);">+ end</span><br><span style="color: hsl(120, 100%, 40%);">+ elseif not handler then</span><br><span style="color: hsl(120, 100%, 40%);">+ fail("Originate successful when there should have been no available queue members")</span><br><span style="color: hsl(120, 100%, 40%);">+ end</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ --This loop is constructed so that we will wait for the call to</span><br><span style="color: hsl(120, 100%, 40%);">+ --finish before moving on. We'll only wait a maximum of 30 iterations</span><br><span style="color: hsl(120, 100%, 40%);">+ --though. And since there is a n second sleep on each iteration, that</span><br><span style="color: hsl(120, 100%, 40%);">+ --comes out to about 30 seconds.</span><br><span style="color: hsl(120, 100%, 40%);">+ i = 0</span><br><span style="color: hsl(120, 100%, 40%);">+ while not completepass or not connectpass and i < 30 do</span><br><span style="color: hsl(120, 100%, 40%);">+ res, err = man:pump_messages()</span><br><span style="color: hsl(120, 100%, 40%);">+ if not res then</span><br><span style="color: hsl(120, 100%, 40%);">+ fail("Failure while waiting for event" .. err)</span><br><span style="color: hsl(120, 100%, 40%);">+ end</span><br><span style="color: hsl(120, 100%, 40%);">+ man:process_events()</span><br><span style="color: hsl(120, 100%, 40%);">+ i = i + 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ posix.sleep(1)</span><br><span style="color: hsl(120, 100%, 40%);">+ end</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if not connectpass then</span><br><span style="color: hsl(120, 100%, 40%);">+ fail("Failed to receive an AgentConnect event within 30 seconds")</span><br><span style="color: hsl(120, 100%, 40%);">+ end</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if not completepass then</span><br><span style="color: hsl(120, 100%, 40%);">+ fail("Failed to receive an AgentComplete event within 30 seconds")</span><br><span style="color: hsl(120, 100%, 40%);">+ end</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ man:unregister_event("AgentConnect", handler)</span><br><span style="color: hsl(120, 100%, 40%);">+ man:unregister_event("AgentComplete", complete_handler)</span><br><span style="color: hsl(120, 100%, 40%);">+end</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+instance = setup_ast_instance("ast1")</span><br><span style="color: hsl(120, 100%, 40%);">+man = manager_setup(instance)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+-- Wrapuptimes</span><br><span style="color: hsl(120, 100%, 40%);">+-- member1 = 20</span><br><span style="color: hsl(120, 100%, 40%);">+-- member2 = 10 (by queue setting)</span><br><span style="color: hsl(120, 100%, 40%);">+test_call(instance, man, member1, "test1")</span><br><span style="color: hsl(120, 100%, 40%);">+posix.sleep(1)</span><br><span style="color: hsl(120, 100%, 40%);">+test_call(instance, man, member2, "test1")</span><br><span style="color: hsl(120, 100%, 40%);">+posix.sleep(10)</span><br><span style="color: hsl(120, 100%, 40%);">+test_call(instance, man, member2, "test1")</span><br><span style="color: hsl(120, 100%, 40%);">+posix.sleep(1)</span><br><span style="color: hsl(120, 100%, 40%);">+test_call(instance, man, member1, "test1")</span><br><span style="color: hsl(120, 100%, 40%);">+posix.sleep(1)</span><br><span style="color: hsl(120, 100%, 40%);">+test_call(instance, man, member2, "test1")</span><br><span style="color: hsl(120, 100%, 40%);">+posix.sleep(1)</span><br><span style="color: hsl(120, 100%, 40%);">+test_call(instance, man, nil, "test1")</span><br><span style="color: hsl(120, 100%, 40%);">+logoff = ast.manager.action.logoff()</span><br><span style="color: hsl(120, 100%, 40%);">+man(logoff)</span><br><span style="color: hsl(120, 100%, 40%);">+instance:term_or_kill()</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/testsuite/+/11326">change 11326</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/testsuite/+/11326"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: testsuite </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I4cad65aab2957d754596058ea3a39d244e89d7cd </div>
<div style="display:none"> Gerrit-Change-Number: 11326 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Rodrigo Ramirez Norambuena <a@rodrigoramirez.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>