[Tsung] Use of ts_file_server for input data stream
Nicolas Niclausse
nicolas at niclux.org
Thu Nov 16 23:21:23 CET 2006
Pentti Kavanagh wrote:
> Hi,
>
> I'm trying out Tsung for the first time and have a query regarding the
> use of ts_file_server. I have a csv file from which I'm reading user
> and account ids. I would like to use the data from a single row
> multiple times within a session.
> Within a session I use user(Pid) to get the login details, and then
> currentaccount(Pid) for subsequent substitutions in the same session
> where I need the account number. This seems to work fine, but could
> this be done a better way (ie. using dynamic variables for example)?
hmm, it's not currently possible to set a new dyn variable within a
function called in a substitution
> If my solution is ok, then maybe it would be worth including
> get_current_line() in ts_file_server as a standard feature.
I think your code doesn't work (you can get a wrong account) if you have
concurrent sessions.
A quick & dirty solution is to use the process dictionnary:
user(_) ->
{ok,Line} = ts_file_server:get_next_line(),
[Username, Passwd, Account] = string:tokens(Line,";"),
put(account,Account),
"tbxUser=" ++ Username ++ "&tbxPwd=" ++ Passwd.
account(_)->
get(account).
(warn: not tested !)
--
Nicolas
More information about the Tsung-users
mailing list