tsung压测实际项目的请求例子2

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tsung SYSTEM "/usr/local/tsung1.7/share/tsung/tsung-1.0.dtd">
<!-- 日志级别 emergency critical error warning notice (default) info debug-->
<tsung loglevel="error" dumptraffic="false" version="1.0">
<!--客服端配置 16GB内存 每天机器可生成20万左右的用户-->
<clients>
<client host="slavea" weight="1" cpu="8" maxusers="1000000">
<ip value="192.168.4.73"></ip>
</client>

<client host="slaveb" weight="1" cpu="8" maxusers="1000000">
<ip value="192.168.4.75"></ip>
</client>

<client host="slavec" weight="1" cpu="8" maxusers="1000000">
<ip value="192.168.4.76"></ip>
</client>

<client host="slaved" weight="1" cpu="8" maxusers="1000000">
<ip value="192.168.4.77"></ip>
</client>

<client host="slavee" weight="1" cpu="8" maxusers="1000000">
<ip value="192.168.4.78"></ip>
</client>

<client host="slavef" weight="1" cpu="8" maxusers="1000000">
<ip value="192.168.4.79"></ip>
</client>

<client host="slaveg" weight="1" cpu="8" maxusers="1000000">
<ip value="192.168.4.80"></ip>
</client>

<client host="slaveh" weight="1" cpu="8" maxusers="1000000">
<ip value="192.168.4.81"></ip>
</client>

<client host="slavei" weight="1" cpu="8" maxusers="1000000">
<ip value="192.168.4.82"></ip>
</client>

<client host="slavej" weight="1" cpu="8" maxusers="1000000">
<ip value="192.168.4.83"></ip>
</client>
</clients>

<!--被压测服务器配置-->
<servers>
<server host="www.xxx.com" port="80" type="tcp" weight="10"/>
<server host="ip" port="80" type="tcp" weight="1" />
<!--<server host="ip" port="8090" type="tcp"/>-->
</servers>

<!--监控方式配置-->
<monitoring>
<monitor host="slavea" type="erlang"></monitor>
<monitor host="slaveb" type="erlang"></monitor>
<monitor host="slavec" type="erlang"></monitor>
<monitor host="slaved" type="erlang"></monitor>
<monitor host="slavee" type="erlang"></monitor>
<monitor host="slavef" type="erlang"></monitor>
<monitor host="slaveg" type="erlang"></monitor>
<monitor host="slaveh" type="erlang"></monitor>
<monitor host="slavei" type="erlang"></monitor>
<monitor host="slavej" type="erlang"></monitor>
</monitoring>

<!--加载方式配置-->
<!--<load duration="300" unit="secnod" >-->
<load>
<arrivalphase phase="1" duration="120" unit="second">
<users arrivalrate="10" unit="second"></users>
</arrivalphase>
<!--
<arrivalphase phase="2" duration="1" unit="minute">
<users maxnumber="1000" interarrival="1" unit="second"></users>
</arrivalphase>
-->
</load>

<!-- options选项配置 通用设置 override=true 会覆盖 session 同名称的项的值-->
<options>
<option name="tcp_rcv_buffer" value="24576"/>
<option name="tcp_snd_buffer" value="24576"/>

<option name="ssl_reuse_sessions" value="false"/>
<option name="connect_timeout" value="5000" />
<option name="tcp_reuseaddr" value="true" />

<option name="ip_transparent" value="true" />
<option name="max_retries" value="3" />
<option name="ports_range" min="1025" max="65535"/>

<option name="idle_timeout" value="5000"/>
<option name="global_ack_timeout" value="5000"/>

<option type="ts_http" name="user_agent">
<user_agent probability="40">Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36</user_agent>
<user_agent probability="30">Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0</user_agent>
<user_agent probability="30">User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko</user_agent>
</option>
</options>

<!-- 用户会话配置 一个用户只会按一个场景执行 可以有多个 session -->
<sessions>
<session name="help" probability="100" type="ts_http">
<!--<transaction name="test_web_help_query">
<request>
<http url="http://www.xxx.com/index/help" content_type="application/x-www-form-urlencoded;charset=utf-8" method="GET" version="1.1"></http>
</request>

<thinktime min="1" max="2" random="true"></thinktime>

<for from="1" to="10" incr="1" var="counter">
<request subst="true">
<http url="http://www.xxx.com/index/helpFaq?search=%e4%b8%8d%e7%94%a8%e7%a9%bf%e5%a4%aa%e5%8e%9a" content_type="application/x-www-form-urlencoded;charset=utf-8" method="GET" version="1.1"></http>
</request>

<thinktime min="1" max="2" random="true"></thinktime>
</for>
</transaction>
</session>

<session name="center" probability="20" type="ts_http">-->
<setdynvars sourcetype="random_number" start="0" end="2">
<var name="status" />
</setdynvars>
<setdynvars sourcetype="random_number" start="0" end="1">
<var name="isShow" />
</setdynvars>
<setdynvars sourcetype="random_number" start="1" end="4">
<var name="languageId" />
</setdynvars>

<transaction name="test_web_help_precedure">
<request subst="true">
<http url="http://192.168.4.229:80/help/pageRetrievalArticle" content_type='application/json;charset=utf-8' method="POST" version="1.1"
contents='{&quot;content&quot;: &quot;%e4%b8%8d%e7%94%a8%e7%a9%bf%e5%a4%aa%e5%8e%9a&quot;,&quot;status&quot;: %%_status%%,&quot;isShow&quot;: %%_isShow%%,&quot;languageId&quot;: %%_languageId%%,&quot;page&quot;: {&quot;currPage&quot;: &quot;10&quot;,&quot;pageSize&quot;: &quot;1&quot;}}'>
<http_header name="token" value="test20171114COM$PS"/>
<http_header name="Content-Type" value="application/json"/>
</http>
</request>

<thinktime min="1" max="2" random="true"></thinktime>

<for from="1" to="10" incr="1" var="counter">
<request subst="true">
<http url="http://192.168.4.229:80/help/queryCateMenu" content_type='application/json;charset=utf-8' method="POST" version="1.1"
contents='{&quot;code&quot;:&quot;commonProblem&quot;,&quot;isShow&quot;: %%_isShow%%,&quot;languageId&quot;:%%_languageId%%}'>
<http_header name="token" value="test20171114COM$PS"/>
<http_header name="Content-Type" value="application/json"/>
</http>
</request>

<thinktime min="1" max="2" random="true"></thinktime>
</for>
</transaction>

</session>
</sessions>
</tsung>

原文地址:https://www.cnblogs.com/NiceTime/p/9192635.html