Tsung 替换动态变量中的字符

Tsung replace characters in a dynamic variable

使用

 <dyn_variable name="OK_Button" jsonpath="test.items[0].links[0].href"/>

我可以从 json 中提取下面的 url http://localhost:8081/mycode/1.5.0/extended/call/action

但是,在下一个请求中,我想通过更改 IP 和端口

来利用上述 url

例如:

<dyn_variable name="ok_button" jsonpath = "test.items[0].links[0].href"/>
<setdynvars sourcetype="eval"
        code='fun({Pid,DynVars})->
                  {ok,Val}=ts_dynvars:lookup(ok_button,DynVars),
                  L1 = re:replace(Val,"localhost","192.169.1.100",[{return,list}]),
                  L2 = re:replace(L1,"8801","8800",[{return,list}]),
                  L2 end.'>
    <var name="new_address" />
</setdynvars>

%% ok_button tolower
%% L2 = "http://192.169.1.100:8800/mycode/1.5.0/extended/call/action"

<request subst="true">
     <http url="%%_new_address%%" method="POST" contents="......."
</request>