tsung.xml request 部分 subst要设置为true ,%%lxwregister:getmessage%%为module:function
<request subst="true"> <http url="https://localhost:80/user/register?%%lxwregister:getmessage%%" method="GET" version="1.1" ></http> </request>
<request subst="true"> <http url="http://localhost:80/hello/%%lxwregister:getmessage%%" method="GET" version="1.1"></http> </request>
<request subst="true"> <http url="http://localhost:5280/hello/testpost" method="POST" version="1.1" contents="%%lxwregister:getmessage%%"><!--post body data 数据 --> <http_header name="Accept-Language" value="zh_cn"/> <http_header name="Accept-Encoding" value="deflate"/> <http_header name="Accept" value="text/html"/> </http> </request>
编写好module放入 ..//tsung-XXX/ebin/目录下
1 -module(lxwregister). 2 -export([getmessage/1]). 3 getmessage({Pid, DynData})-> 4 Key = "langxianwu", 6 [{tsung_userid,UserId}] = DynData, 7 io:format("langxw------------------~p---- UserId=~p----~n",[DynData,UserId]), 9 Token =langxw_md5:md5(lists:concat([UserId,Key])), 10 lists:concat(["version=1&token=",Token,"&userid=",UserId,"&password=",UserId]). ~
{Pid, DynData}中的DynData 是[{tsung_userid,"53"}]格式数据 ”53“ 部分是递增的
补充一点 当xml 里面配置两个sesion时{Pid,DynData}中的数字生成是轮流使用 “1”“2”“3”“4”,一个session时生成的 数字是相互独立的“1“”1“”2“”2”。
如:register_user UserId="1" sf register_device UserId="1" sf register_user UserId="2" sf register_device UserId="2" sf register_user UserId="3" sf register_device UserId="3" sf register_user UserId="4" sf register_device UserId="4" sf register_user UserId="5" sf register_device UserId="5" sf register_user UserId="6" sf register_device UserId="6" sf register_user UserId="7" sf register_user UserId="1" sf register_device UserId="2" sf register_device UserId="3" sf register_device UserId="4" sf register_user UserId="5" sf register_user UserId="6" sf register_device UserId="7" sf register_device UserId="8" sf register_user UserId="9" sf register_device UserId="10" sf register_user UserId="11" sf register_user UserId="12" sf register_user UserId="13" sf register_user UserId="14" sf
随即生成字符串和数字 <setdynvars sourcetype="random_string" start="1" end="100" > <var name="nick2"/> </setdynvars> <setdynvars sourcetype="random_number" length="10"> <var name="nickstr"/> </setdynvars> <request subst="true"> <http url="http://localhost:5280/hello/testpost" method="POST" version="1.1" contents="nick2%%_nick2%%read%%_nickstr%%end"> </http> </request>