[asterisk-commits] mnicholson: branch mnicholson/asttest r247634 - in /team/mnicholson/asttest/a...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Feb 18 13:22:51 CST 2010
Author: mnicholson
Date: Thu Feb 18 13:22:47 2010
New Revision: 247634
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=247634
Log:
Removed xfail from test, and modularized test somewhat. Also added some
documentation to the test and added a test for an additional transfer scenario.
Modified:
team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/sip.conf
team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/test.lua
Modified: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/sip.conf
URL: http://svnview.digium.com/svn/asterisk/team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/sip.conf?view=diff&rev=247634&r1=247633&r2=247634
==============================================================================
--- team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/sip.conf (original)
+++ team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/configs/sip.conf Thu Feb 18 13:22:47 2010
@@ -5,7 +5,7 @@
[test1]
type = friend
host = dynamic
-;accountcode = account1
+accountcode = account1
[test2]
type = friend
Modified: team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/test.lua
URL: http://svnview.digium.com/svn/asterisk/team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/test.lua?view=diff&rev=247634&r1=247633&r2=247634
==============================================================================
--- team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/test.lua (original)
+++ team/mnicholson/asttest/asttest/tests/blind-transfer-accountcode/test.lua Thu Feb 18 13:22:47 2010
@@ -1,16 +1,15 @@
-xfail()
+--[[
+Test account code propagation for SIP blind transfers.
-a = ast.new()
-a:load_config("configs/sip.conf")
-a:load_config("configs/extensions.conf")
+This test ensures that when a channel with an account code, dials a channel
+without and account code, then transfers the dialed channel to another channel,
+the calling (and transferring) channel's account code is copied to the called
+channel and stored in the CDR record for the transfer.
---[[
-a:generate_asterisk_conf()
-a["asterisk.conf"]["options"]["verbose"] = 10
-a["asterisk.conf"]["options"]["debug"] = 10
+This test also ensures that if the called channel has an account code, the
+calling channel's account code is not copied and instead the called channel's
+account code is used.
]]
-
-a:spawn()
function sipp_exec(scenario, name, local_port)
local inf = "data.csv"
@@ -42,35 +41,60 @@
return res, err
end
+function check_cdr(a, end_line, value)
+ local cdr_path = a:path("/var/log/asterisk/cdr-csv/Master.csv")
+ local f, err = io.open(cdr_path, "r")
+ if not f then
+ error("error opening cdr file (" .. cdr_path .. "): " .. err)
+ end
--- register our three peers
-sipp_exec_and_wait("sipp/register.xml", "test1", "5061")
-sipp_exec_and_wait("sipp/register.xml", "test2", "5062")
-sipp_exec_and_wait("sipp/register.xml", "test3", "5063")
-
-print("executing scripts")
-
--- make the calls and transfers
-t1 = sipp_exec("sipp/wait-for-call.xml", "test1", "5061")
-t2 = sipp_exec("sipp/wait-for-call-do-hangup.xml", "test2", "5062")
-t3 = sipp_exec("sipp/call-then-blind-transfer.xml", "test3", "5063")
-
-sipp_check_error(t3, "sipp/call-then-blind-transfer.xml")
-sipp_check_error(t2, "sipp/wait-for-call-do-hangup.xml")
-sipp_check_error(t1, "sipp/wait-for-call.xml")
-
--- examine the CDR records generated to make sure account code is present
-cdr_path = a:path("/var/log/asterisk/cdr-csv/Master.csv")
-f, err = io.open(cdr_path, "r")
-if not f then
- error("error opening cdr file '" .. cdr_path .. "': " .. err)
+ local line
+ for i = 1, end_line do
+ line = f:read("*l")
+ if not line then
+ error("error reading lines from cdr file (" .. cdr_path .. ")")
+ end
+ end
+ fail_if(not line:find(value), "'" .. value .. "' not found in line " .. end_line .. " of cdr file (" .. cdr_path .. "):\n" .. line)
end
-f:read("*l")
-cdr = f:read("*l")
-if not cdr then
- error("error reading lines from cdr file")
+-- This function will execute the three sipp scenarios using the inf file
+-- provided. This will cause index[3] to dial either index[2] or index[1] and
+-- then transfer the called party to which ever index was not called
+-- originally. Whether index[2] or index[1] is called depends on the index[3],
+-- see the sipp/data.csv file to determine who is called in which situations.
+function do_transfer_and_check_results(accountcode, index)
+ local a = ast.new()
+ a:load_config("configs/sip.conf")
+ a:load_config("configs/extensions.conf")
+ a:spawn()
+
+ -- register our three peers
+ sipp_exec_and_wait("sipp/register.xml", index[1], "5061")
+ sipp_exec_and_wait("sipp/register.xml", index[2], "5062")
+ sipp_exec_and_wait("sipp/register.xml", index[3], "5063")
+
+ -- make the calls and transfers
+ local t1 = sipp_exec("sipp/wait-for-call.xml", index[1], "5061")
+ local t2 = sipp_exec("sipp/wait-for-call-do-hangup.xml", index[2], "5062")
+ local t3 = sipp_exec("sipp/call-then-blind-transfer.xml", index[3], "5063")
+
+ -- wait for everything to finish
+ sipp_check_error(t3, "sipp/call-then-blind-transfer.xml")
+ sipp_check_error(t2, "sipp/wait-for-call-do-hangup.xml")
+ sipp_check_error(t1, "sipp/wait-for-call.xml")
+
+ a:term()
+
+ -- examine the CDR records generated to make sure account code is present
+ check_cdr(a, 2, accountcode)
end
-fail_if(not cdr:find("account3"), "'account3' not found in second line of cdr file '" .. cdr_path .. "': " .. cdr)
+-- test dialing a peer without an account code set. The resulting account code
+-- should be that of the dialing peer
+do_transfer_and_check_results("account3", {"test1", "test2", "test3"})
+-- now test dialing a peer with an account code set. The resulting account
+-- code should be that of the dialed peer
+do_transfer_and_check_results("account3", {"test3", "test2", "test1"})
+
More information about the asterisk-commits
mailing list