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