Jmeter+ant +Jenkins

  • 怎么使用jmeter自行百度
  • 安装ant

配置ant

主要是配置build.xml




    
        
    
    
    
    
    
    
    
    
            
        
    

    
        

        
        
            
                
                
            
        
    

Jenkins配置

  • Jenkins 上安装 “Publish performance test result report” ,“Publish HTML reports” 的插件,配置一下。

ant的配置

Jmeter+ant +Jenkins_第1张图片
Paste_Image.png

运行效果如下:

Jmeter+ant +Jenkins_第2张图片
Paste_Image.png

错误解决方案

发现jenkins上性能图显示不出来

解决方案:

  • Jmeter/bin 下将 jmeter.properties 中
  • jmeter.save.saveservice.output_format=csv的csv改成xml
    ji

结果如下

Jmeter+ant +Jenkins_第3张图片
Paste_Image.png

出现报错日志

Started by user anonymous
Building in workspace C:\Users\Administrator.jenkins\jobs\我的测试\workspace
[testCase] $ cmd.exe /C '"ant.bat -file build.xml && exit %%ERRORLEVEL%%"'
Buildfile: E:\apps\jmeter\testCase\build.xml
all:
test:
[jmeter] Executing test plan: E:\apps\jmeter\testCase\web.jmx ==> E:\apps\jmeter\resultLog\jtl\TestReport201506080830.jtl
[jmeter] Creating summariser 
[jmeter] Created the tree successfully using E:\apps\jmeter\testCase\web.jmx
[jmeter] Starting the test @ Mon Jun 08 20:30:19 CST 2015 (1433766619320)
[jmeter] Waiting for possible shutdown message on port 4445
[jmeter] summary = 10 in 1.1s = 8.8/s Avg: 190 Min: 141 Max: 254 Err: 0 (0.00%)
[jmeter] Tidying up ... @ Mon Jun 08 20:30:20 CST 2015 (1433766620505)
[jmeter] ... end of run
report:
[xslt] Processing E:\apps\jmeter\resultLog\jtl\TestReport201506080830.jtl to E:\apps\jmeter\resultLog\html\TestReport201506080830.html
[xslt] Loading stylesheet D:\app\apache-jmeter-2.13\extras\jmeter-results-detail-report_21.xsl
BUILD SUCCESSFUL
Total time: 2 seconds
Performance: Percentage of errors greater or equal than 1% sets the build as unstable
Performance: Percentage of errors greater or equal than 2% sets the build as failure
Performance: Recording JMeter reports '/apps/jmeter/resultLog/jtl/*.jtl'
Performance: no JMeter files matching '/apps/jmeter/resultLog/jtl/*.jtl' have been found. Has the report generated?. Setting Build to FAILURE
Build step 'Publish Performance test result report' changed build result to FAILURE
Finished: FAILURE
我确定我的jtl文件目录是没有错的

终于解决了

  • 根据日志文件报错,发现工作目录为:Building in workspace C:\Users\Administrator.jenkins\jobs\我的测试\workspace
    然而我的日志文件却在e盘,于是我构建了一个shell 命名,把e盘的日志文件收到复制到工作目录:cd $WORKSPACEcp -r E:/apps/jmeter/resultLog/* .
    我的配置的JMeter Report files: */jtl/.jtl

    再次运行:

Jmeter+ant +Jenkins_第4张图片
Paste_Image.png
但是还有有点问题就是默认列表进来显示的数据为空图片,要点击进去才能看到具体的某一个图片
Jmeter+ant +Jenkins_第5张图片
Paste_Image.png

解决方式:
[https://issues.jenkins-ci.org/browse/JENKINS-27100]
插件的bug,有老外已经修复,直接下载了替换即可

生成的报告没有min和max的time的时间,显示的为NaN,但是在执行命名过程中是可以看到max和min的时间

直接在build.xml加入以下几行就解决了:






实际操作下来,并没有解决,问题依旧存在。
多次尝试后发现,仅需要从Jmeter的lib包里把xalan-2.7.2.jar和serializer-2.7.2.jar copy到Ant的lib包里即可,不用修改build.xml

  • 参考这个帖子

你可能感兴趣的:(Jmeter+ant +Jenkins)