一、Windows环境下测试
1.下载:
官网地址:http://apache.fayea.com//jmeter/binaries/apache-jmeter-2.12.zip
2.打开:
进入bin目录下 运行jmeter.bat
3.使用:
0>.在测试计划中添加一个线程组
1> 配置线程组,主要是取样器错误后执行动作、线程数、循环次数
2> 添加一个测试对象 即取样器。主要参数:IP,Port,协议,方法,路径,传递的参数。
其中参数部分,可以直接在Parameters框体中填入 参数名+参数值。也可以将参数写入.CSV文件,在Parameters框体中填入参数和引用参数变量名。以满足每次提交改变参数的值得需求。
这次测试中 我将参数写在 zset.CSV中,见 图2.1 ,在.CSV文件中,每行为一个参数组,参数之间用,隔开。
2.1>注意 .CSV文件格式以及参数变量名。
2.2> 响应断言,用来验证是否请求成功,从而才能得出测试结果。根据实际情况选择响应字段与测试模式。
2.3> 断言结果,即每次请求是否满足断言要求。如果出错这里会打印出来。
2.4>图形结果,展示测试结果
2.5>总结报告 展示测试结果
在测试时候遇到的问题:
能将响应结果保存到文件(可以在取样器里面添加),但是error% 一直是100%,断言结果也全是错误。原因是我将断言结果 图形结果 Summary Report添加到线程组那一层了。应该添加到取样器这一层。在那里取样就在哪里设置断言,监听断言。
二、Linux环境下测试
我拿到的一个几乎空白的RedHat服务器。上面只装了要测试的SSDB。按照java-resin-jmeter的顺序配置环境完成测试。
1> 配置java环境
先查看系统32/64: uname -a
oracle官网下载jdk : http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html 下载 .tar.gz 文件即可
安装jdk
配置JAVA环境变量:
vi /etc/profile
追加:
JAVA_HOME=/opt/jdk1.6.0_20
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
其中的JAVA_HOME为jdk的安装路径
验证 echo $PATH 或者 java -version
2> 安装resin
下载:http://caucho.com/products/resin/download/gpl#download
解压
运行 ./resin.sh console
打印出:
Resin-4.0.41 (built Mon, 22 Sep 2014 09:54:25 PDT)
Copyright(c) 1998-2012 Caucho Technology. All rights reserved.
Using Resin(R) Open Source under the GNU Public License (GPL).
See http://www.caucho.com for information on Resin Professional,
including caching, clustering, JNI acceleration, and OpenSSL integration.
[14-12-29 16:12:45.169] {main} Using Resin(R) Open Source under the GNU Public License (GPL).
See http://www.caucho.com for information on Resin Professional,
including caching, clustering, JNI acceleration, and OpenSSL integration.
Starting Resin on Mon, 29 Dec 2014 16:12:44 +0800 (CST)
[14-12-29 16:12:45.446] {main} <proxy-cache> requires Resin Professional. Please see http://www.caucho.com for Resin Professional information and licensing.
[14-12-29 16:12:45.600] {main}
[14-12-29 16:12:45.600] {main} Resin-4.0.41 (built Mon, 22 Sep 2014 09:54:25 PDT)
[14-12-29 16:12:45.600] {main}
[14-12-29 16:12:45.600] {main} Linux 2.6.18-371.3.1.el5xen i386
[14-12-29 16:12:45.601] {main} Java(TM) SE Runtime Environment 1.7.0_67-b01, ISO-8859-1, en
[14-12-29 16:12:45.601] {main} Java HotSpot(TM) Server VM 24.65-b04, 32, mixed mode, Oracle Corporation
[14-12-29 16:12:45.601] {main}
[14-12-29 16:12:45.601] {main} user.name = root
[14-12-29 16:12:45.686] {main}
[14-12-29 16:12:45.693] {main} server listening to localhost.localdomain:6800
[14-12-29 16:12:45.698] {main}
[14-12-29 16:12:45.808] {main}
[14-12-29 16:12:45.809] {main} resin.home = /usr/local/resin-4.0.41/
[14-12-29 16:12:45.809] {main} resin.root = /usr/local/resin-4.0.41/
[14-12-29 16:12:45.809] {main} resin.conf = /usr/local/resin-4.0.41/conf/resin.xml
[14-12-29 16:12:45.809] {main}
[14-12-29 16:12:45.809] {main} server = 127.0.0.1:6800 (app:app-0)
[14-12-29 16:12:45.810] {main} stage = production
[14-12-29 16:12:46.234] {resin-32} WebApp[production/webapp/default/resin-admin] active
[14-12-29 16:12:46.262] {resin-33} WebApp[production/webapp/default/ROOT] active
[14-12-29 16:12:46.696] {resin-34} WebApp[production/webapp/default/resin-doc] active
[14-12-29 16:12:46.697] {main} Host[production/host/default] active
[14-12-29 16:12:46.697] {main} ServletService[id=app-0,cluster=app] active
[14-12-29 16:12:46.697] {main}
[14-12-29 16:12:46.698] {main} http listening to *:8080
[14-12-29 16:12:46.698] {main}
[14-12-29 16:12:46.699] {main} Resin[id=app-0] started in 2685ms
然后在自己pc上访问 server ip:port 看到resin默认欢迎页面即说明安装成功。
Resin? Default Home Page
This is the default page for the Resin web server.
Documentation is available at /resin-doc.
Administration is available at /resin-admin.
之后把在Windows下的web项目的war包拷进 ren目录下的webapps 文件夹内,即可在外网访问服务器上的web项目了。
3> 安装jmeter
下载:同样在jemeter官网下载 对应的安装包
解压:
执行:./jmeter -n -t ../ssdb_test.jmx -l ../log.jtl
说明:
a.-n 参数说明不用验证是否安装了图形库
b. .jmx文件可以在windows环境下的用jmeter图形化生成,涉及参数以及测试结果的.csv文件路径可以直接 用notepad++ vi 等修改.jmx文件,确保其相对于.jmx文件路径正确。
c.log.jtl 保存测试结果 既然没装图形界面库,那么测试结果.jtl文件就只能在windows下用jmeter来查看了。
[@zjm_44_250 bin]# jmeter
-bash: jmeter: command not found
[@zjm_44_250 bin]# ./jmeter
An error occurred:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
[@zjm_44_250 bin]# ./jmeter.sh
An error occurred:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
[@zjm_44_250 bin]# ./jmeter -n -t ../ssdb_test.jmx -l ../log.jtl
Creating summariser <summary>
Created the tree successfully using ../ssdb_test.jmx
Starting the test @ Mon Dec 29 18:43:20 CST 2014 (1419849800772)
Waiting for possible shutdown message on port 4445
summary = 100 in 0.3s = 289.9/s Avg: 105 Min: 3 Max: 285 Err: 0 (0.00%)
Tidying up ... @ Mon Dec 29 18:43:21 CST 2014 (1419849801734)
... end of run
[@zjm_44_250 bin]#