jmeter-3-linux下環境搭建jmeter+ant


前言

繼上篇Windows搭建 jmeter + ant +jenkins實現后,那么我們平時一般都是集成在linux服務器上。

所以這次我們來Linux下搭建 jmeter + ant +jenkins,廢話不多說,走起!!!

一、環境准備

1、jdk1.8以上:

jdk安裝教程詳細參考(docker安裝jenkins的小伙伴請忽略此步驟):linux下安裝jdk:https://www.cnblogs.com/gsxl/p/12128768.html

 或者yum安裝:yum install java-1.8.0-openjdk.x86_64

2、jmeter:

所有版本:https://archive.apache.org/dist/jmeter/binaries/

本篇直接點擊此鏈接下載:https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.3.tgz  下載后上傳至linux直接解壓,或者wget下載

wget 下載:

wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.3.tgz

注意Linux后綴為.zip,如:apache-jmeter-5.3.tgz 

解壓:tar -xvf apache-jmeter-5.3.tgz

[root@iZbp19lugf22zbsubsf1y6Z jmeter-ant]# tar -xvf apache-jmeter-5.3.tgz 
apache-jmeter-5.3/
apache-jmeter-5.3/LICENSE
apache-jmeter-5.3/NOTICE

3、ant:

所有版本:https://downloads.apache.org/ant/binaries/

本篇直接點擊此鏈接下載:https://downloads.apache.org/ant/binaries/apache-ant-1.9.15-bin.tar.gz   下載后直接解壓:

注意Windows后綴為.zip,如:apache-ant-1.9.15-bin.tar.gz

設置環境變量:

①將bin、lib目錄添加至環境變量中的系統變量path即可,如下圖我的解壓路徑:

編輯,命令:vi /etc/profile

復制以下添加保存退出后,輸入:source /etc/profile

# ANT_HOME
ANT_HOME=/root/jmeter-ant/apache-ant-1.9.15
export PATH=$PATH:$ANT_HOME/bin
export PATH=$PATH:$ANT_HOME/lib

輸入命令驗證版本:ant -version

 

二、jmeter、ant各種配置

1、jmeter配置:

①將jmeter目錄bin\jmeter.properties的490行-528行改為如下:

注意:是jmeter.properties文件在490-528行中,凡是有jmeter開頭的且有#號都需要去掉,或者直接復制下面替換490-528行;

復制代碼
jmeter.save.saveservice.output_format=xml

# The below properties are true when field should be saved; false otherwise
#
# assertion_results_failure_message only affects CSV output
jmeter.save.saveservice.assertion_results_failure_message=true
#
# legitimate values: none, first, all
jmeter.save.saveservice.assertion_results=true
#
jmeter.save.saveservice.data_type=true
jmeter.save.saveservice.label=true
jmeter.save.saveservice.response_code=true
# response_data is not currently supported for CSV output
jmeter.save.saveservice.response_data=true
# Save ResponseData for failed samples
jmeter.save.saveservice.response_data.on_error=true
jmeter.save.saveservice.response_message=true
jmeter.save.saveservice.successful=true
jmeter.save.saveservice.thread_name=true
jmeter.save.saveservice.time=true
jmeter.save.saveservice.subresults=true
jmeter.save.saveservice.assertions=true
jmeter.save.saveservice.latency=true
# Only available with HttpClient4
jmeter.save.saveservice.connect_time=true
jmeter.save.saveservice.samplerData=true
jmeter.save.saveservice.responseHeaders=true
jmeter.save.saveservice.requestHeaders=true
jmeter.save.saveservice.encoding=true
jmeter.save.saveservice.bytes=true
# Only available with HttpClient4
jmeter.save.saveservice.sent_bytes=true
jmeter.save.saveservice.url=true
jmeter.save.saveservice.filename=true
jmeter.save.saveservice.hostname=true
jmeter.save.saveservice.thread_counts=true
jmeter.save.saveservice.sample_count=true
jmeter.save.saveservice.idle_time=true
復制代碼

更改完成后,我是ftp上傳(或者vi編輯):

2、ant 配置

 ①將apache-jmeter-5.3\extras目錄下的:ant-jmeter-1.1.1.jar 復制到apache-ant-1.9.15\lib\

命令:cp 文件路徑 復制到哪文件路徑

[root@iZbp19lugf22zbsubsf1y6Z apache-jmeter-5.3]# cp extras/ant-jmeter-1.1.1.jar ../apache-ant-1.9.15/lib/ant-jmeter-1.1.1.jar
[root@iZbp19lugf22zbsubsf1y6Z apache-jmeter-5.3]# 

②創建以下目錄文件(網盤下載的不需要再新建了):

推薦直接網盤下載完整文件夾,鏈接:https://pan.baidu.com/s/1dKy6GpHFDMBIYK0qQixdiA    提取碼:gsxl

 ③編輯build.xml:(vi編輯或者在自己Windows電腦編輯好再上傳)

將你的(1)-(5)都改為自己的路徑,保存:

 三、運行ant run

1、在目錄下運行:ant

[root@iZbp19lugf22zbsubsf1y6Z standard-catalog]# ant
Buildfile: /root/jmeter-ant/standard-catalog/build.xml
  [taskdef] Could not load definitions from resource net/sf/antcontrib/antlib.xml. It could not be found.

run:
  [taskdef] Could not load definitions from resource net/sf/antcontrib/antlib.xml. It could not be found.

test:
   [jmeter] Executing test plan: /root/jmeter-ant/standard-catalog/xxx-business.jmx ==> /root/jmeter-ant/standard-catalog/jtl/InterfaceReport202009181126.jtl
   [jmeter] Creating summariser <summary>
   [jmeter] Created the tree successfully using /root/jmeter-ant/standard-catalog/xxx-business.jmx
   [jmeter] Starting standalone test @ Fri Sep 18 23:26:06 CST 2020 (1600442766325)
   [jmeter] Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4445
   [jmeter] summary =      9 in 00:00:01 =    7.4/s Avg:    92 Min:    12 Max:   659 Err:     0 (0.00%)
   [jmeter] Tidying up ...    @ Fri Sep 18 23:26:08 CST 2020 (1600442768253)
   [jmeter] ... end of run
   [jmeter] Executing test plan: /root/jmeter-ant/standard-catalog/xxx-shopping.jmx ==> /root/jmeter-ant/standard-catalog/jtl/InterfaceReport202009181126.jtl
   [jmeter] Creating summariser <summary>
   [jmeter] Created the tree successfully using /root/jmeter-ant/standard-catalog/xxx-shopping.jmx
   [jmeter] Starting standalone test @ Fri Sep 18 23:26:10 CST 2020 (1600442770591)
   [jmeter] Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4445
   [jmeter] summary =      6 in 00:00:01 =    4.3/s Avg:   175 Min:    19 Max:   784 Err:     0 (0.00%)
   [jmeter] Tidying up ...    @ Fri Sep 18 23:26:12 CST 2020 (1600442772678)
   [jmeter] ... end of run
  [taskdef] Could not load definitions from resource net/sf/antcontrib/antlib.xml. It could not be found.

report:
     [xslt] Processing /root/jmeter-ant/standard-catalog/jtl/InterfaceReport202009181126.jtl to /root/jmeter-ant/standard-catalog/html/InterfaceReport.html
     [xslt] Loading stylesheet /root/jmeter-ant/standard-catalog/xsl/jmeter.results.shanhe.me.xsl
     [copy] Copying 2 files to /root/jmeter-ant/standard-catalog/html

BUILD SUCCESSFUL
Total time: 10 seconds

 2、html目錄下:查看報告

 利用:anywhere生成外網可訪問

anywhere安裝請參考:https://www.cnblogs.com/gsxl/p/13193939.html  第二大點,標題:二、 node.js +Anywhere + html

[root@iZbp19lugf22zbsubsf1y6Z standard-catalog]# cd html/
[root@iZbp19lugf22zbsubsf1y6Z html]# anywhere -p 8055
Running at http://xxx.16.xx.2xx:8055/
Also running at https://xxx.16.1xx.2xx:8056/

附加:

Windows搭建傳送門:https://www.cnblogs.com/gsxl/p/13655788.html
Linux搭建傳送門:https://www.cnblogs.com/gsxl/p/13694071.html

 

歡迎來大家QQ交流群一起學習:482713805


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM