4

我对 ERLANG 和 TSung 很陌生,我从未在这方面工作过,但我非常热衷于了解基础知识并为我的 Web 应用程序进行分布式负载测试。我已经完成了一半,但是我遇到了很大的障碍,无法继续前进,请阅读以下tsung.xml文件并告诉我我在哪里以及我缺少什么?

**===> tsung.xml  (this file perfectly working without any errors)**

*<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM  "/usr/share/tsung/tsung-1.0.dtd">
<tsung loglevel = "debug" dumptraffic="true" version="1.0">
<clients>
        <client host="localhost" weight ="1" maxusers="40000" cpu = "1" >
        <ip value = '127.000.000.111'/>
</client>
</clients>
<servers>
        <server host="127.000.000.112" port="80" type="tcp"></server>
</servers>
<load duration="1" unit="minute">
        <arrivalphase phase="1" duration="1" unit="minute">
        <users arrivalrate="10" unit="second"></users>
    </arrivalphase>
</load>

<sessions>
<session name="mySession" probability="100" type="ts_http">
<transaction name="trx">
        <request>
            <dyn_variable name="myId" re="&lt;myId&gt;(\.*)\&lt;/myId&gt;"/> <-- Trying with RegExp option, not getting the value myId
            <!--dyn_variable name="myId" xpath="//response/myId" /-->  <-- Trying with xpath option, not getting the value myId
            <!--dyn_variable name="myId" jsonpath="response.myId" /-->  <-- Trying with jsonpath option, not getting the value myId
            <http  url='http://127.000.000.112/Create_Rec' method='POST' version='1.1' content_type='text/xml'/>
        </request>
        <request subst="true">
        <http  url='http://999.000.000.999/Get_Rec/myId=%%_myId%%' method='GET' version='1.1' content_type='application/xml'/>
</request>
</transaction>
</session>
</sessions>
</tsung>*

当我在 Web 浏览器中运行此 url(它是 Web 服务调用)“ http://_127.000.000.112/Create_Rec ”时,我从服务器得到以下类似的响应(在后台它在数据库中创建记录并生成新的 id 即 myId)。当我在 tsung.xml 上运行时,第一个请求按我的预期工作得非常好。

===> 响应(浏览器响应)

<response id="SomeWebService">
    <status>
        <statusCode>1</statusCode>
        <statusMsg>SomeMessage</statusMsg>
        <statusTime>2013-06-20 02:52:25</statusTime>
    </status>
    <myId>298346728934734987</myId>
</response>

我在这里看到的是,我需要从第一个请求中获取 myId 并将其传递给第二个请求 myId=%%_myId%%,但它永远无法正常工作,并且 myId 始终为空字符串。两天以来,我已经超出了 dyn_variable 的范围,没有任何线索和适当的示例/文档。请建议我,我错过了什么。

4

1 回答 1

1

您必须在您的替换请求中设置 subst="true" 才能工作。因此,您的请求应更改为..

<request subst="true">

如果它仍然不起作用,那么我建议您查看 tsung.dump 文件并检查您从服务器获得的响应

于 2013-06-21T16:09:11.487 回答