[Tsung] Calling a %%module:function%% multiple times with same Pid
Stein, Martin
martin.stein at sap.com
Tue May 20 20:50:04 CEST 2008
I am using the %%module:function%% feature to generate one random
number, that is subsequently reused.
Basically I have one call to generate a new ID that is returned and
stored in an ETS table with the Pid. (putCID)
Another call retrieves the ID for the given PID, and the last call
deletes the item in the ETS table.
This is done, so that a generated random ID can be used a couple of
times in one session.
<session>
<request><http>...%%ran500:putCID%%...
< request><http>...%%ran500:getCar%%...
<request><http>...%%ran500:getCar%%...
<request><http>...%%ran500:deleteCID%%...
</session>
The code for the functions is straightforward and at the end of the
message.
When I run with 10 users/sec things work fine, but with more users this
fails.
ts_client:(5:<0.65.0>) Stop in state wait_ack, reason= {badarg,
[{ets,
delete,
[tsungtest,
<0.65.0>]},
{ran500,
deleteCID,
1},
{ts_search,
extract_function,
5},
{ts_search,
subst,2},
{ts_http,
subst,2},
{ts_http,
add_dynparams,
4},
{ts_client,
handle_next_request,
2},
{gen_fsm,
handle_msg,
7}]}
I assume that in one session the Pid would be the same throughout the
session. So the 4 calls to my ran500 module should all be made with the
same Pid in the argument, even at higher loads.
A workaround would be to allow putting the result of a
%%module:function%% call into a dynamic variable, that could then be
used to refer to the same data later. Maybe the <dyn_variable> could be
extended to a <dyn_function> that calls a function and stores the
result?
Thanks!
------------------------------------- code
%%% File : ran500.erl
-module(ran500).
-export([putCID/1, getCar/1, deleteCID/1]).
randomCar() ->
io_lib:format("~p.VCar", [random:uniform(500)]).
% put generated ID into ETS
putCID({Pid, _DynData}) ->
case ets:info(tsungtest) of
undefined ->
ets:new(tsungtest, [named_table, public]);
_Otherwise -> ok
end,
Car = randomCar(),
true = ets:insert(tsungtest, {Pid, Car}),
Car.
% get car for cid in Dyndata
getCar({Pid, _DynData}) ->
[{_PidKey, Carname}] = ets:lookup(tsungtest, Pid),
Carname.
%delete car for cid
deleteCID({Pid, _DynData}) ->
true = ets:delete(tsungtest, Pid),
"".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.process-one.net/pipermail/tsung-users/attachments/20080520/5a4db962/attachment.html
More information about the Tsung-users
mailing list