tsung <if>声明或如何获取tsung中的当前页面?</if>

时间:2014-11-03 10:51:54

标签: erlang load-testing tsung

我的网站有多个重定向,导致登录页面。重定向的数量可能会有所不同,我用以下方法解决了这个问题:

<transaction name="get_login_page">
<request>
    <dyn_variable name="redirect" re="Location: ((http|https)://.*)\r"/>
    <http url='/' version='1.1' method='GET'>
    </http>
</request>
<repeat name="redirect_loop" max_repeat="5">
  <request subst="true">
    <dyn_variable name="redirect" re="Location: ((http|https)://.*)\r"/>
    <http url="%%_redirect%%" method="GET"></http>
  </request>
  <until var="redirect" eq=""/>
</repeat>
</transaction>

从这一点开始我遇到了问题,因为在登录页面上我必须将数据提交到当前URL,但在最后一次迭代后,变量“redirect”变为空。我试图在周期中创建带条件的附加变量以保存最后的非空值:

<transaction name="get_login_page">
<request>
    <dyn_variable name="redirect" re="Location: ((http|https)://.*)\r"/>
    <http url='/' version='1.1' method='GET'>
    </http>
</request>
<repeat name="redirect_loop" max_repeat="5">
  <request subst="true">
    <dyn_variable name="redirect" re="Location: ((http|https)://.*)\r"/>
    <if var="redirect" eq=''>
        <dyn_variable name="login_url" re="Location: ((http|https)://.*)\r"/>
    </if>
    <http url="%%_redirect%%" method="GET"></http>
  </request>
  <until var="redirect" eq=""/>
</repeat>
</transaction>

但是现在我在tsung上遇到了一个错误:

Starting Tsung
"Log directory is: /home/***/login_portal/logs/20141103-0945"
594- fatal: {failed_validation,element_unauthorize_in_choice}
Config Error, aborting ! {{badmatch,
                              {<<"<arrivalphase phase=\"1\" duration=\"5\" unit=\"second\">\n    <users maxnumber=\"1\" arrivalrate=\"1\" unit=\"second\"></users>\n</arrivalphase>\n">>,
                               {xmerl_sax_parser_state,undefined,
                                   #Fun<xmerl_sax_parser.1.53952608>,
                                   {file_descriptor,prim_file,
                                       {#Port<0.1047>,13}},
                                   #Fun<xmerl_sax_parser.default_continuation_cb.1>,
                                   utf8,1,
                                   [{"xml",
                                     "http://www.w3.org/XML/1998/namespace"}],
                                   [],[],true,69656,no,normal,
                                   "/home/***/login_portal/.",
                                   "tsung_config_load.xml",false}}},
                          [{xmerl_sax_parser_utf8,handle_external_entity,2,
                               [{file,"xmerl_sax_parser_utf8.erl"},
                                {line,1692}]},
                           {xmerl_sax_parser_utf8,parse_external_entity,3,
                               [{file,"xmerl_sax_parser_utf8.erl"},
                                {line,1670}]},
                           {xmerl_sax_parser_utf8,parse_content,4,
                               [{file,"xmerl_sax_parser_utf8.erl"},
                                {line,1157}]},
                           {xmerl_sax_parser_utf8,parse_document,2,
                               [{file,"xmerl_sax_parser_utf8.erl"},
                                {line,179}]},
                           {xmerl_sax_parser_utf8,parse,2,
                               [{file,"xmerl_sax_parser_utf8.erl"},
                                {line,115}]},
                           {xmerl_sax_parser,file,2,
                               [{file,"xmerl_sax_parser.erl"},{line,77}]},
                           {ts_config,read,2,
                               [{file,"src/tsung_controller/ts_config.erl"},
                                {line,77}]},
                           {ts_config_server,handle_call,3,
                               [{file,
                                    "src/tsung_controller/ts_config_server.erl"},
                                {line,206}]}]}

是否有办法获取上次访问的URL或使用内置函数从DOM模型获取它?或者我应该如何让条件让它正常工作?

0 个答案:

没有答案