[Tsung] setdynvars problem

Pablo Polvorin ppolv at yahoo.com.ar
Tue May 27 20:27:01 CEST 2008


Hi, 
your plugin must implement its own add_dynparams/4, a signature like this:
add_dynparams(SubstFlag,DynData, Param, HostData) ->
    [
    here you define what the substitution rules are for the different 
    messages types of your plugin
    ]


If SubstFlag is false, (subst=false in the request) you probably want to return
the original message whitout any further processing:

add_dynparams(false, _DynData, Param, _HostData) ->
    Param;


if not, you must implement substitution depending on the message type, like: 
add_dynparams(true, 
              DynData, 
              #plcdtester_request{type=send, user=User, password=Password},
             _HostData) ->
 #plcdtester_request{type=send, 
                     user=*USER_FIELD_AFTER_SUBSTITUTION*, 
                     password=*PASSWORD_FIELD_AFTER_SUBSTITUTION*};

you can use ts_search:subst/2 for performing string substitutions on those
fields you want, just look how the others plugins behave.

cheers!








--- Matteo <mcanato at gmail.com> escribió:

> Hi list,
> 
> i'm working on my own plugin with the setdynvars variables with the snv
> tsung trunk rev 851. I want to read from a .csv file a set of user/passwd
> and create a request with these parameters. In the trunk i see that this is
> possible (http_setdynvars.xml) and i write tried to "copy" the code in my
> own plugin. But i think i'm wrong somewhere in the code, because in the
> request, tsung doesn't substitute the dynvar value...
> 
> Example:
> 
> %%%% mytest.xml
>     <options>
>         <option name="file_server" id='userdb'
> value="/home/matteo/Desktop/BACKUP/23-maggio/mwg.csv"/>
>     </options>
> <-cut->
>             <setdynvars sourcetype="file" fileid="userdb" delimiter=";"
> order="iter">
>                 <var name="user" />
>                 <var name="passwd" />
>             </setdynvars>
> <-cut->
>             <request subst="true">
>                 <mytest type="send" user="%%_user%%"
> password="%%_passwd%%"></mytest>
>             </request>
> 
> %%%%%% ts_config_mytest.erl
> <-cut->
>     Request = case ts_config:getAttr(atom, Element#xmlElement.attributes,
> type) of
>                   login ->
>             #ts_request{ack = no_ack, endpage = true, dynvar_specs = DynVar,
> subst = SubstFlag, match = MatchRegExp,
>                     param = #mytest_request{type=login}};
>                   send ->
>             User = ts_config:getAttr( Element#xmlElement.attributes, user),
>             Password = ts_config:getAttr( Element#xmlElement.attributes,
> password),
>             #ts_request{ack = parse, endpage = true, dynvar_specs = DynVar,
> subst = SubstFlag, match = MatchRegExp,
>                     param = #plcdtester_request{type=send, user=User,
> password=Password}};
> 
> 
> %%%%%%%% Results in the log
> =INFO REPORT==== 26-May-2008::22:09:31 ===
>        ts_mytest:(5:<0.76.0>) ts_mytest:parse(<<"OK 01 3bf94f8a\r\n">>,
> #state_rcv{acc=[], dyndata={dyndata,
> 
> [{user,
> 
> "00000001"},
> 
> {passwd,
> 
> "12345678"}],
> 
> {mytest_dyndata,
> 
> undefined}}})
> 
> =INFO REPORT==== 26-May-2008::22:09:31 ===
>     "SERIAL VALUE: %%_user%%" - [ts_mytest,
>                                                            5,
>                                                            <0.76.0>|
>                                                            ts_mytest]
> 
> 
> In fact, the my client send the string "%%_user%%" to the server instead of
> the string "00000001". The field {mytest_dyndata, undefined} is used for
> other use in my app and it run perfectly.
> 
> Where i'm wrong?
> 
> Best regards,
> M.Canato
> > _______________________________________________
> Tsung-users mailing list
> Tsung-users at lists.process-one.net
> https://lists.process-one.net/mailman/listinfo/tsung-users
> 



      Tarjeta de crédito Yahoo! de Banco Supervielle.
Solicitá tu nueva Tarjeta de crédito. De tu PC directo a tu casa. www.tuprimeratarjeta.com.ar 


More information about the Tsung-users mailing list