Tsung测试之配置文件

Jabber配置:

<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/local/tsung/share/tsung/tsung-1.0.dtd">
<tsung loglevel="notice" version="1.0"> <clients>
<client host="kaoqin3" use_controller_vm="true" maxusers="100000"></client>
</clients> <!-- Server side setup -->
<servers>
<server host="127.0.0.1" port="5222" type="tcp"></server>
</servers> <!-- 监控(cpu, network, memory). 使用erlang或SNMP,erlang是默认值,但是要保证监控的机器和server可以互相访问,装有erlang,否则用snmp -->
<monitoring>
<!-- host: 填别名,需要先去host文件配置 -->
<monitor host="127.0.0.1" type="erlang"></monitor>
</monitoring> <load>
<arrivalphase phase="1" duration="20" unit="minute">
<users maxnumber="100000" interarrival="0.0025" unit="second"></users>
</arrivalphase>
</load> <!-- JABBER parameters -->
<!-- to synchronise users, use a global acknoledgement -->
<options>
<option type="ts_jabber" name="global_number" value="10"></option>
<option type="ts_jabber" name="userid_max" value="100000"></option>
<option type="ts_jabber" name="domain" value="anjubao.openfire.cn"></option>
<option type="ts_jabber" name="username" value="tsung"></option>
<option type="ts_jabber" name="passwd" value="tsung"></option>
</options> <sessions>
<session probability="50" name="jabber-example" type="ts_jabber"> <request> <jabber type="connect" ack="no_ack"></jabber> </request>
<thinktime value="2"></thinktime>
<transaction name="authenticate">
<request> <jabber type="auth_get" ack="local"></jabber> </request>
<request> <jabber type="auth_set_plain" ack="local"></jabber> </request>
</transaction> <request> <jabber type="presence:initial" ack="no_ack"/> </request>
<thinktime value="2"></thinktime> <transaction name="roster">
<request> <jabber type="iq:roster:get" ack="local"></jabber></request>
</transaction> <thinktime value="30"></thinktime> <transaction name="online">
<!-- 模拟用户上线操作 -->
<request> <jabber type="chat" ack="no_ack" size="16" destination="online"></jabber> </request> <!-- 模拟发送消息 -->
<!-- <for from="1" to="10" incr="1" var="counter">
<request><jabber type="raw" ack="no_ack" data="&lt;message to='tsung10001@anjubao.openfire.cn'&gt;&lt;body&gt; zhouhui &lt;/body&gt; &lt;/message&gt;"></jabber></request>
</for>
<request><jabber type="raw" ack="no_ack" data="&lt;message to='tsung150527@anjubao.openfire.cn'&gt;&lt;body&gt;zhouhui&lt;/body&gt; &lt;/message&gt;"></jabber></request> -->
</transaction> <thinktime value="30"></thinktime> <!-- 模拟用户下线操作 -->
<transaction name="offline">
<request> <jabber type="chat" ack="no_ack" size="56" destination="offline"></jabber> </request>
</transaction> <thinktime value="30"></thinktime> <transaction name="close">
<request> <jabber type="close" ack="no_ack"></jabber> </request>
</transaction> </session> <session probability="20" name="jabber-plain" type="ts_jabber"> <request> <jabber type="connect" ack="no_ack"></jabber> </request> <thinktime value="2"></thinktime> <transaction name="auth_plain">
<request> <jabber type="auth_get" ack="local"></jabber> </request>
<request> <jabber type="auth_set_plain" ack="local"></jabber> </request>
</transaction> <thinktime value="30"></thinktime> <transaction name="close">
<request> <jabber type="close" ack="no_ack"></jabber> </request>
</transaction> </session> <session probability="20" name="jabber-digest" type="ts_jabber"> <!-- regexp captures stream ID returned by server -->
<request>
<dyn_variable name="sid" re="&lt;stream:stream id=&quot;(.*)&quot; xmlns:stream"/>
<jabber type="connect" ack="local"></jabber>
</request> <thinktime value="2"></thinktime> <transaction name="auth_digest">
<request> <jabber type="auth_get" ack="local"></jabber> </request>
<request subst='true'> <jabber type="auth_set_digest" ack="local"></jabber> </request>
</transaction>
<thinktime value="30"></thinktime> <transaction name="close">
<request> <jabber type="close" ack="no_ack"></jabber> </request>
</transaction>
</session> <session probability="10" name="jabber-sipdigest" type="ts_jabber"> <request> <jabber type="connect" ack="no_ack"></jabber> </request> <thinktime value="2"></thinktime> <transaction name="auth_sipdigest">
<!-- regexp captures nonce value returned by server -->
<request>
<dyn_variable name="nonce" re="&lt;Nonce encoding=&quot;hex&quot;&gt;(.*)&lt;\/Nonce&gt;"/>
<jabber type="auth_get" ack="local"></jabber>
</request>
<request subst='true'> <jabber type="auth_set_sip" ack="local"></jabber> </request>
</transaction>
<thinktime value="30"></thinktime> <transaction name="close">
<request> <jabber type="close" ack="no_ack"></jabber> </request>
</transaction>
</session> </sessions>
</tsung> <!-- 模拟空闲,可聊天状态脚本
<transaction name="chat">
<request>
<jabber type="presence:broadcast" show="chat" status="Avaliable to chat!" ack="no_ack"/>
</request>
</transaction> 模拟离开状态脚本
<transaction name="away">
<request>
<jabber type="presence:broadcast" show="away" status="Be right back ..." ack="no_ack"/>
</request>
</transaction> 模拟请勿打扰状态脚本
<transaction name="dnd">
<request>
<jabber type="presence:broadcast" show="dnd" status="Don't bother me!" ack="no_ack"/>
</request>
</transaction> -->

Jabber_register配置:

<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/local/tsung/share/tsung/tsung-1.0.dtd"> <!-- loglevel:工具写日志的标识,级别默认是"info",长时间运行建议调整为error -->
<!-- dumptraffic:运行的调试信息dump文件,如需要看脚本是否正确可以设置为"true",级别默认是"false",长时间运行建议调整为false -->
<tsung loglevel="notice" dumptraffic="false" version="1.0"> <!-- tsung集群Client的设置 -->
<clients>
<!-- host:填别名,需要先去host文件配置,如:
127.0.0.1 localhost
10.0.0.252 s252
10.0.0.52 sl52 --> <!-- weight: 节点上面用户的比例,一般设置为1即可 -->
<!-- maxusers: 一般设置为800,3000即可,根据机器配置来设置大小 -->
<!-- cpu: 根据机器硬件配置来设置,如果是4核CPU,最佳设置为3,以此类推 -->
<!-- use_controller_vm与maxusers="3000"表示:如果客户端模拟生成的用户超过3000,则将开启一个新的erlang虚拟机(VM),一般maxusers设置为800-3000 -->
<client host="localhost" use_controller_vm="true" maxusers="3000">
<!--要求能够用私钥ssh到本机,并且连通一次,留下记录在known_hosts-->
<!--如果use_controller_vm="false",那么每maxusers个连接后会创建一个新的erlangVM,maxuser默认是800-->
<!--否则达到上限就不再创建连接-->
<!--能打开了limits,就不要使用多个erlangVM,容易crash-->
</client>
</clients> <!-- Openfire集群servers的设置 -->
<servers>
<!-- host: 填别名,需要先去host文件配置 -->
<!-- port: 填可用对外端口,一般8080 -->
<!-- type: 协议类型,tsung支持tcp/udp,根据自己的需要 -->
<server host='172.16.34.15' port='5222' type='tcp'/>
</servers> <!-- 监控(cpu, network, memory). 使用erlang或SNMP,erlang是默认值,但是要保证监控的机器和server可以互相访问,装有erlang,否则用snmp -->
<monitoring>
<!-- host: 填别名,需要先去host文件配置 -->
<monitor host="127.0.0.1" type="erlang"></monitor>
</monitoring> <!-- register 200000 users in less than 15 minutes -->
<!-- 负载场景设置 -->
<load>
<!-- phase:阶段,填数字即可,系统会按顺序执行,可是设置多个阶段组合场景 -->
<!-- duration:持续时段,填数字即可,单位是unit="minute"设置,是分钟也,可设置小时,天,详细情况参考API -->
<!-- arrivalrate:虚拟用户数,填写数字即可,一般最大800,如过机器配置好,可自己调试最佳参数
有效单位unit="second" 是秒,每秒虚拟300个虚拟用户,实际执行情况可能超过,也可能达不到,需要根据调试得到最佳参数 --> <!-- phase="1"表示第一阶段,总的来说该标签表示第一阶段持续运行15分钟 -->
<arrivalphase phase="1" duration="15" unit="minute">
<!-- 每interarrival秒钟新增一个用户,最大新增maxnumber个用户second;arrivalrate每秒新增多少个用户 -->
<users maxnumber="400000" arrivalrate="500" unit="second"></users>
<!--总共启动的session数目,不过如果连接间隔是0.01的话,不是所有的session都能连接成功-->
</arrivalphase>
</load> <!-- 脚本执行的基本参数设置 -->
<options>
<!-- 此两处决定了你要建立人数的数量,由于受load标签和session标签的影响,因此可能会少于此处value值(value设置为10,实际上可能只创建了7人左右) -->
<option type="ts_jabber" name="global_number" value="5"></option>
<option type="ts_jabber" name="userid_max" value="400000"></option> <!-- 服务器域名(确保服务器/etc/hosts文件中做了ip和域名的映射) -->
<option type="ts_jabber" name="domain" value="testopenfire.cn"></option> <!-- 此两项代表用户名和密码,所建立用户的用户名与密码在value值后面加上一个整数。
注:如果需要模拟用户登录上线、下线操作,那么jabber.xml中对应的value值必须与此处value值一致 -->
<option type="ts_jabber" name="username" value="tsung"></option>
<option type="ts_jabber" name="passwd" value="tsung"></option>
</options> <sessions>
<!-- name:脚本名称,唯一值 -->
<!-- probability:压力比重,总值100,可按需求设置 -->
<!-- type:这里根据测试对象来,我这里是http请求,其他类型参考API -->
<session probability="100" name="jabber-example" type="ts_jabber"> <request>
<jabber type="connect" ack="local"></jabber>
</request> <request>
<match do="abort" when="match">error</match>
<jabber type="register" ack="local" id="new"></jabber>
</request> <request>
<jabber type="close" ack="local"></jabber>
</request> </session>
</sessions>
</tsung>
上一篇:UVA - 10817 Headmaster's Headache (状压类背包dp+三进制编码)


下一篇:CSS学习笔记——定位position属性的学习