性能测试与持续集成(JMeter+Jenkins)

Posted 马哥Linux运维

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了性能测试与持续集成(JMeter+Jenkins)相关的知识,希望对你有一定的参考价值。

目的
将性能测试与持续集成挂接起来
性能测试: JMeter
持续集成: Jenkins
JMeter
下载JMeter,官网: http://jmeter.apache.org/
创建测试计划: 访问 http://www.cnblog.com ,验证Response的返回值中存在cnblog
Thread组配制
性能测试与持续集成(JMeter+Jenkins)
Http请求
性能测试与持续集成(JMeter+Jenkins)
Response断言

使用GUI的JMeter查看运行测试结果
性能测试与持续集成(JMeter+Jenkins)
GUI JMeter测试结果
使用命令行执行测试
-J 指定生成的结果格式为xml,-t 指定测试文件,-l 测试结果
结果
Writing log file to: /Users/yjshi/Downloads/apache-jmeter-3.0/bin/jmeter.log
Creating summariser <summary>
Created the tree successfully using /Users/yjshi/Downloads/TestPlan.jmx
Starting the test @ Thu Aug 04 18:41:43 CST 2016 (1470307303526)
Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
summary =     10 in 00:00:01 =    8.3/s Avg:   333 Min:   183 Max:   539 Err:     0 (0.00%)
Tidying up ...    @ Thu Aug 04 18:41:44 CST 2016 (1470307304767)
... end of run

JMeter已经可以通过命令行来执行
Jenkins
配制JMeter
下载Jenkins包,官网: https://jenkins.io/
启动Jenkins
Running from: /Users/yjshi/Downloads/All/Software/jenkins/jenkins.war
webroot: $user.home/.jenkins
Aug 04, 2016 5:52:13 PM winstone.Logger logInternal
INFO: Beginning extraction from war file
Aug 04, 2016 5:52:13 PM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: jetty-winstone-2.9
Aug 04, 2016 5:52:19 PM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: NO JSP Support for , did not find org.apache.jasper.servlet.JspServlet
Jenkins home directory: /Users/yjshi/.jenkins found at: $user.home/.jenkins
Aug 04, 2016 5:52:26 PM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: Started SelectChannelConnector@0.0.0.0:8080
Aug 04, 2016 5:52:26 PM winstone.Logger logInternal
INFO: Winstone Servlet Engine v2.0 running: controlPort=disabled
Aug 04, 2016 5:52:26 PM jenkins.InitReactorRunner$1 onAttained
INFO: Started initialization
Aug 04, 2016 5:52:32 PM jenkins.InitReactorRunner$1 onAttained
INFO: Listed all plugins
Aug 04, 2016 5:52:32 PM jenkins.InitReactorRunner$1 onAttained
INFO: Prepared all plugins
Aug 04, 2016 5:52:32 PM jenkins.InitReactorRunner$1 onAttained
INFO: Started all plugins
Aug 04, 2016 5:52:32 PM jenkins.InitReactorRunner$1 onAttained
INFO: Augmented all extensions
Aug 04, 2016 5:52:35 PM jenkins.InitReactorRunner$1 onAttained
INFO: Loaded all jobs
Aug 04, 2016 5:52:35 PM hudson.model.AsyncPeriodicWork$1 run
INFO: Started Download metadata
Aug 04, 2016 5:52:35 PM org.jenkinsci.main.modules.sshd.SSHD start
INFO: Started SSHD at port 54488
Aug 04, 2016 5:52:35 PM jenkins.InitReactorRunner$1 onAttained
INFO: Completed initialization
Aug 04, 2016 5:52:35 PM hudson.UDPBroadcastThread run
INFO: Cannot listen to UDP port 33,848, skipping: java.net.SocketException: Can't assign requested address
Aug 04, 2016 5:52:35 PM jenkins.InitReactorRunner$1 onAttained
INFO: Started initialization
Aug 04, 2016 5:52:35 PM jenkins.InitReactorRunner$1 onAttained
INFO: Listed all plugins
Aug 04, 2016 5:52:35 PM jenkins.InitReactorRunner$1 onAttained
INFO: Prepared all plugins
Aug 04, 2016 5:52:35 PM jenkins.InitReactorRunner$1 onAttained
INFO: Started all plugins
Aug 04, 2016 5:52:35 PM jenkins.InitReactorRunner$1 onAttained
INFO: Augmented all extensions
Aug 04, 2016 5:52:35 PM jenkins.InitReactorRunner$1 onAttained
INFO: Loaded all jobs
Aug 04, 2016 5:52:35 PM jenkins.InitReactorRunner$1 onAttained
INFO: Completed initialization
Aug 04, 2016 5:52:35 PM hudson.WebAppMain$3 run
INFO: Jenkins is fully up and running

安装Performance plugin插件: Performance Plugin
性能测试与持续集成(JMeter+Jenkins)

配制Jenkins中的JOB
echo 'begin testing'
java -jar /Users/yjshi/Downloads/apache-jmeter-3.0/bin/ApacheJMeter.jar -Jjmeter.save.saveservice.output_format=xml -n -t /Users/yjshi/Downloads/TestPlan.jmx -l TestPlan.jtl
echo 'testing end'
运行JOB,查看结果
性能测试与持续集成(JMeter+Jenkins)
在JOB的workspace下会生成两个文件jmeter.log TestPlan.jtl
性能测试与持续集成(JMeter+Jenkins)
配制运行报告

添加测试报告
性能测试与持续集成(JMeter+Jenkins)
查看统计结果
性能测试与持续集成(JMeter+Jenkins)
后续
可将jmx文件存放到仓库中,便于维护和管理

将JOB添加到版本构建中,在版本构建完成后,自动执行性能,确保每次的版本Build均满足性能需求

原文链接:http://www.jianshu.com/p/edc0d171a6d1


性能测试与持续集成(JMeter+Jenkins)
马哥教育
马哥教育历经近10年发展,已成为面向企业级资深运维工程师、架构师的专业集训营式高端就业Linux培训学院。凭借多年良好口碑,其已经成为业内知名互联网公司重要人才战略合作伙伴,获得了百度、腾讯、阿里、大众点评、51CTO、唯品会、京东、中移动、新浪、红帽等互联网巨头的合作支持。毕业学员平均薪资达10K以上,累计受益人员达百万+。
性能测试与持续集成(JMeter+Jenkins)
详询咨询QQ:
课程顾问-云豆:1661815153
课程顾问-豌豆:1660809109
课程顾问-土豆:2813150558
课程顾问-糖豆:371238871
课程顾问-仙豆:875259688

马哥教育
微信号:magedu-Linux


以上是关于性能测试与持续集成(JMeter+Jenkins)的主要内容,如果未能解决你的问题,请参考以下文章

此处有干货~jmeter+ant+jenkins持续集成配置及过程中问题解决思路

JMeter - 连续性能测试 - JMeter + ANT + Jenkins集成 - 第2部分

持续集成:jmeter+ant+jenkins搭建接口自动化测试环境

Jenkins+Jmeter持续集成笔记(三:集成到Jenkins)

Meter - 连续性能测试 - JMeter + ANT + Jenkins集成 - 第1部分

Jmeter+Jenkins持续集成(三集成到Jenkins)