码迷,mamicode.com
首页 > 其他好文 > 详细

Tsung对openfire的简单压力测试

时间:2015-03-12 12:56:01      阅读:490      评论:0      收藏:0      [点我收藏+]

标签:

环境准备

  安装Tsung、安装openfire、安装Spark

 

Tsung使用

要对openfire进行压力测试,因此我们主要讲解如何利用jabber_register.xml在openfire上面注册用户,以及利用jabber.xml模拟用户登录openfire上线、离开、会话操作的压力测试

 

一、注册用户

1、执行以下命令进入到安装目录下的examples目录:

[root@localhost ~]# cd /usr/local/tsung/share/doc/tsung/examples/
[root@localhost examples]# ll
total 64
-rw-r--r--. 1 root root 3834 Mar  7 03:09 fs-nfs.xml
-rw-r--r--. 1 root root 6391 Mar  7 03:09 http_distributed.xml
-rw-r--r--. 1 root root 2609 Mar  7 03:09 http_setdynvars.xml
-rw-r--r--. 1 root root 2215 Mar  7 03:09 http_simple.xml
-rw-r--r--. 1 root root 3140 Mar  7 03:09 jabber_muc.xml
-rw-r--r--. 1 root root 1727 Mar  7 03:09 jabber_privacy.xml
-rw-r--r--. 1 root root 1332 Mar  7 03:09 jabber_register.xml
-rw-r--r--. 1 root root 2762 Mar  7 03:09 jabber_roster.xml
-rw-r--r--. 1 root root 4225 Mar  7 03:09 jabber.xml
-rw-r--r--. 1 root root 2506 Mar  7 03:09 ldap.xml
-rw-r--r--. 1 root root 1148 Mar  7 03:09 mysql.xml
-rw-r--r--. 1 root root 1833 Mar  7 03:09 pgsql.xml
-rw-r--r--. 1 root root 1211 Mar  7 03:09 thinks2.xml
-rw-r--r--. 1 root root 1221 Mar  7 03:09 thinks.xml

2、修改jabber_register.xml文件

技术分享

详细的jabber_register.xml

 

3、将修改后的jabber_register.xml放到/usr/local/tsung目录下

 再进入tsung的bin目录下,找到tsung执行的shell脚本文件

[root@localhost examples]# cp jabber_register.xml /usr/local/tsung
[root@localhost examples]# cd /usr/local/tsung/bin
[root@localhost bin]#

4、执行tsung脚本以驱动执行我们修改好的jabber_register.xml脚本,实现向openfire添加用户

[root@localhost bin]#  ./tsung -f   /usr/local/tsung/jabber_register.xml start
Starting Tsung
"Log directory is: /root/.tsung/log/20150311-2253"

5、查看openfire

技术分享

 

二、登陆用户模拟发送消息

利用jabber.xml模拟用户登录openfire后执行上线、离开、忙碌、下线、发送消息等操作

1、修改jabber.xml文件(存储路径/usr/local/tsung/share/doc/tsung/examples/)

1)模拟用户上线、下线、发送消息的操作时jabber.xml配置如下:

技术分享

  • 模拟上线与发消息脚本:
 <transaction name="online">
    <request> <jabber type="chat" ack="no_ack" size="16" destination="online"></jabber> </request>
    <request>
       <jabber type="raw" ack="no_ack" data="&lt;message to=‘admin@myopenfire‘&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>
     <request>
       <jabber type="raw" ack="no_ack" data="&lt;message to=‘admin@myopenfire‘&gt;&lt;body&gt;zhouhui&lt;/body&gt; &lt;/message&gt;"></jabber>
    </request>
   </transaction>

 jabber.xml

 

2)模拟用户含有可聊天、离开、忙碌状态时jabber.xml配置如下:

技术分享

  • 模拟空闲,可聊天状态脚本:
<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>

 

2、将修改后的jabber.xml放到/usr/local/tsung目录下

[root@localhost examples]# cp jabber.xml /usr/local/tsung
[root@localhost examples]# cd /usr/local/tsung/bin
[root@localhost bin]#

3、 执行jabber.xml模拟用户上线、下线、发送消息等操作

[root@localhost bin]#  ./tsung -f   /usr/local/tsung/jabber.xml start
Starting Tsung
"Log directory is: /root/.tsung/log/20150311-2331"

4、查看用户状态(登录openfire查看或者登录spark查看)

若要查看是否成功发送消息则要使用spark聊天工具(可以去openfire官网下载)

1)登录openfire查看:

技术分享

2)登录spark聊天工具查看

若使用spark查看其他人员状态时,必须人员双方相互注册为好友才能看到对方的状态变化,若仅验证消息接收,则无需注册好友

如:查看好友状态

技术分享

 

三、生成报表

启动Tsung后,Tsung会输出log的存放路径

Starting Tsung
"Log directory is: /root/.tsung/log/20150311-2256"

1、等待测试完毕,进入log目录(只有输出了log日志才会自动log目录,默认路径:/root/.tsung/log)

生成统计图表

[root@localhost bin]# cd /root/.tsung/log/20150311-2256
[root@localhost 20150311-2256]#  /usr/local/tsung/lib/tsung/bin/tsung_stats.pl 
creating subdirectory data 
creating subdirectory gnuplot_scripts 
creating subdirectory images 
warn, last interval (2) not equal to the first, use the first one (10)
No data for Event
No data for Async
No data for Errors

注意:一定要先进入log目录,才能生成统计图表

2、查看统计图表

使用xftp工具,将/root/.tsung/log/20150311-2256目录下的统计图表文件report.html下载到本地的Windows操作系统上进行查看。

用IE或firefox等浏览器打开产生的html文件,就能查看本次测试的结果(参数含义见后面说明):

技术分享

 

Tsung对openfire的简单压力测试

标签:

原文地址:http://www.cnblogs.com/yangxia-test/p/4331949.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!