用两台主机坐Tigase的Tsung测试,其中1台运行Tigase,另1台运行Tsung。
1.Tigase服务器设置
tigase.conf:
#osgiEnabled=(true|false)
#osgiEnabled=false
OSGI=${osgiEnabled}
ENC="-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8"
DRV="-Djdbc.drivers=com.mysql.jdbc.Driver:org.postgresql.Driver:org.apache.derby.jdbc.EmbeddedDriver"
#GC="-XX:+UseBiasedLocking -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:ParallelCMSThreads=2 -XX:-ReduceInitialCardMarks"
#EX="-XX:+OptimizeStringConcat -XX:+DoEscapeAnalysis -XX:+UseNUMA"
JAVA_HOME="${JAVA_HOME}"
CLASSPATH=""
JAVA_OPTIONS="${GC} ${EX} ${ENC} ${DRV} -server -Xms100M -Xmx200M -XX:PermSize=32m -XX:MaxPermSize=256m -XX:MaxDirectMemorySize=128m "
TIGASE_CONFIG="etc/tigase.xml"
TIGASE_OPTIONS=" --property-file etc/init.properties --test "
增加了1行:
TIGASE_OPTIONS=" --property-file etc/init.properties --test "
参数"--test"有两个作用:(1)不加载Tigase的offline message plugin;(2)降低默认的登录级别。
init.properties:
config-type=--gen-config-def
--admins=admin@tsung213
--virt-hosts =tsung213
--debug=server
--monitoring=jmx:9050,http:9080,snmp:9060
--auth-db=tigase-auth
--user-db=mysql
--user-db-uri=jdbc:mysql://localhost:3306/tigase_db?user=tigase_user&password=123456&useUnicode=true&characterEncoding=UTF-8&autoCreateUser=true
--user-repo-pool-size=12
--comp-name-1 = muc
--comp-class-1 = tigase.muc.MUCComponent
--comp-name-2 = pubsub
--comp-class-2 = tigase.pubsub.PubSubComponent
设置好以后启动Tigase服务器,准备接受测试。
2.Tsung主机设置
测试用的jabber_register.xml文件如下,该文件用于测试注册用户时的性能。
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/local/tsung/share/tsung/tsung-1.0.dtd">
<tsung loglevel="notice" dumptraffic="false" version="1.0"> <!-- Tsung客户端的IP地址和端口号 -->
<clients>
<client host="localhost" use_controller_vm="true">
</client>
</clients> <!-- Tigase服务器的IP地址和端口号 -->
<servers>
<server host='10.3.93.213' port='5222' type='tcp'/>
</servers> <load>
<!-- 第1阶段,持续时间5分钟 -->
<arrivalphase phase="1" duration="5" unit="minute">
<!-- 最多注册20个用户,每10秒钟注册1个用户 -->
<users maxnumber="20" interarrival="10" unit="second"></users>
</arrivalphase>
</load> <options>
<option type="ts_jabber" name="global_number" value="20"></option>
<!-- 用户编号最大值为20-->
<option type="ts_jabber" name="userid_max" value="20"></option>
<!-- Tigase服务器域名为tsung213 -->
<option type="ts_jabber" name="domain" value="tsung213"></option>
<!-- 用户名以tsung开头,即tsung1、tsung2、...... -->
<option type="ts_jabber" name="username" value="tsung"></option>
<!-- 密码以tsung开头,即tsung1、tsung2、...... -->
<option type="ts_jabber" name="passwd" value="tsung"></option>
</options> <sessions>
<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>
设置好以后,运行/usr/local/tsung/bin/tsung -f /usr/local/tsung/share/doc/tsung/examples/jabber_register.xml start命令,开始测试。
测试结束以后,cd到/root/.tsung/log/20140827-1500文件夹,运行/usr/local/tsung/lib/tsung/bin/tsung_stats.pl,生成测试结果报告。
将生成的测试报告复制到Windows主机,用浏览器打开如下。
远程登录与Tigase服务器连接的MySQL数据库,可见虽然我们设置注册20个用户,但是由于种种原因,只注册了6个用户,这也是正常的。