[asterisk-commits] mnicholson: testsuite/asterisk/trunk r1911 - /asterisk/trunk/tests/queues/que...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Aug 24 15:00:21 CDT 2011


Author: mnicholson
Date: Wed Aug 24 15:00:18 2011
New Revision: 1911

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1911
Log:
made queue_baseline more reliable and simpler

Modified:
    asterisk/trunk/tests/queues/queue_baseline/run-test
    asterisk/trunk/tests/queues/queue_baseline/test.lua

Modified: asterisk/trunk/tests/queues/queue_baseline/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/queues/queue_baseline/run-test?view=diff&rev=1911&r1=1910&r2=1911
==============================================================================
--- asterisk/trunk/tests/queues/queue_baseline/run-test (original)
+++ asterisk/trunk/tests/queues/queue_baseline/run-test Wed Aug 24 15:00:18 2011
@@ -1,4 +1,3 @@
 #!/usr/bin/env bash
-set -e
-
-asttest -a / -s tests/queues/queue_baseline
+. lib/sh/lua.sh
+asttest -a / -s `dirname $0` $@

Modified: asterisk/trunk/tests/queues/queue_baseline/test.lua
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/queues/queue_baseline/test.lua?view=diff&rev=1911&r1=1910&r2=1911
==============================================================================
--- asterisk/trunk/tests/queues/queue_baseline/test.lua (original)
+++ asterisk/trunk/tests/queues/queue_baseline/test.lua Wed Aug 24 15:00:18 2011
@@ -1,3 +1,5 @@
+require "watcher"
+
 function manager_setup(a)
 	local m,err = a:manager_connect()
 	if not m then
@@ -20,42 +22,22 @@
 	return m
 end
 
-join = nil
-function join_event(event)
-	join = 1
-end
-
-called = nil
-function called_event(event)
-	called = 1
-end
-
-connect = nil
-function connect_event(event)
-	connect = 1
-end
-
-leave = nil
-function leave_event(event)
-	leave = 1
-end
-
-complete = nil
-function complete_event(event)
-	complete = 1
-end
-
 function do_call(man)
 	local orig = ast.manager.action:new("Originate")
 	orig["Channel"] = "Local/test at test_context"
 	orig["Exten"] = "queue"
 	orig["Context"] = "test_context"
 	orig["Priority"] = "1"
-	man:register_event("Join", join_event)
-	man:register_event("AgentCalled", called_event)
-	man:register_event("AgentConnect", connect_event)
-	man:register_event("Leave", leave_event)
-	man:register_event("AgentComplete", complete_event)
+
+	local e = watcher.event.new;
+	local events = watcher.etree:new{
+		e("Join"),
+		e("AgentCalled"),
+		e("AgentConnect"),
+		e("Leave"),
+		e("AgentComplete"),
+	}
+
 	local res, err = man(orig)
 	if not res then
 		fail("Error originating call: " .. err)
@@ -63,17 +45,26 @@
 	if res["Response"] ~= "Success" then
 		fail("Response failure for Originate: " .. res["Message"])
 	end
-	posix.sleep(3)
-	res, err = man:pump_messages()
+	
+	res, err = watcher.watch(man, events, 10000)
 	if not res then
-		fail("Error pumping messages: " .. err)
+		print("Error matching events (" .. err .. ")")
+		print "Expected (not ordered):"
+		print "   Join"
+		print "   AgentCalled"
+		print "   AgentConnect"
+		print "   Leave"
+		print "   AgentComplete"
+		print "\nReceived:"
+
+		for _, e in pairs(events.multi) do
+			print("   " .. e["Event"])
+		end
+
+		print ""
+
+		fail()
 	end
-	man:process_events()
-	man:unregister_event("Join", join_event)
-	man:unregister_event("AgentCalled", called_event)
-	man:unregister_event("AgentConnect", connect_event)
-	man:unregister_event("Leave", leave_event)
-	man:unregister_event("AgentComplete", complete_event)
 end
 
 instance = ast.new()
@@ -86,26 +77,6 @@
 man = manager_setup(instance)
 
 do_call(man)
-logoff = ast.manager.action.logoff()
-man(logoff)
+man(ast.manager.action.logoff())
 instance:term_or_kill()
 
-if not join then
-	print "Failed to capture Join event"
-end
-if not called then
-	print "Failed to capture AgentCalled event"
-end
-if not connect then
-	print "Failed to capture AgentConnect event"
-end
-if not leave then
-	print "Failed to capture Leave event"
-end
-if not complete then
-	print "Failed to capture AgentComplete event"
-end
-
-if not join or not called or not connect or not leave or not complete then
-	fail("Failed to capture one of our expected events")
-end




More information about the asterisk-commits mailing list