乐哈哈yoyo 发表于 2017-7-20 11:15:55

【转帖】性能测试与持续集成

目的1.将性能测试与持续集成挂接起来2.性能测试: JMeter3.持续集成: JenkinsJMeter1.下载JMeter,官网: http://jmeter.apache.org/2.创建测试计划: 访问 http://www.cnblog.com ,验证Response的返回值中存在cnblogThread组配制Http请求Response断言3.使用GUI的JMeter查看运行测试结果GUI JMeter测试结果4.使用命令行执行测试-J 指定生成的结果格式为xml,-t 指定测试文件,-l 测试结果

java -jar ApacheJMeter.jar -Jjmeter.save.saveservice.output_format=xml -n -t/Users/yjshi/Downloads/TestPlan.jmx -l TestPlan.jtl

结果

Writing log file to: /Users/yjshi/Downloads/apache-jmeter-3.0/bin/jmeter.logCreating summariser <summary>Created the tree successfully using /Users/yjshi/Downloads/TestPlan.jmxStarting the test @ Thu Aug 04 18:41:43 CST 2016 (1470307303526)Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445summary = 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配制JMeter1.下载Jenkins包,官网: https://jenkins.io/2.启动Jenkins

Running from: /Users/yjshi/Downloads/All/Software/jenkins/jenkins.warwebroot: $user.home/.jenkinsAug 04, 2016 5:52:13 PM winstone.Logger logInternalINFO: Beginning extraction from war fileAug 04, 2016 5:52:13 PM org.eclipse.jetty.util.log.JavaUtilLog infoINFO: jetty-winstone-2.9Aug 04, 2016 5:52:19 PM org.eclipse.jetty.util.log.JavaUtilLog infoINFO: NO JSP Support for , did not find org.apache.jasper.servlet.JspServletJenkins home directory: /Users/yjshi/.jenkins found at: $user.home/.jenkinsAug 04, 2016 5:52:26 PM org.eclipse.jetty.util.log.JavaUtilLog infoINFO: Started SelectChannelConnector@0.0.0.0:8080Aug 04, 2016 5:52:26 PM winstone.Logger logInternalINFO: Winstone Servlet Engine v2.0 running: controlPort=disabledAug 04, 2016 5:52:26 PM jenkins.InitReactorRunner$1 onAttainedINFO: Started initializationAug 04, 2016 5:52:32 PM jenkins.InitReactorRunner$1 onAttainedINFO: Listed all pluginsAug 04, 2016 5:52:32 PM jenkins.InitReactorRunner$1 onAttainedINFO: Prepared all pluginsAug 04, 2016 5:52:32 PM jenkins.InitReactorRunner$1 onAttainedINFO: Started all pluginsAug 04, 2016 5:52:32 PM jenkins.InitReactorRunner$1 onAttainedINFO: Augmented all extensionsAug 04, 2016 5:52:35 PM jenkins.InitReactorRunner$1 onAttainedINFO: Loaded all jobsAug 04, 2016 5:52:35 PM hudson.model.AsyncPeriodicWork$1 runINFO: Started Download metadataAug 04, 2016 5:52:35 PM org.jenkinsci.main.modules.sshd.SSHD startINFO: Started SSHD at port 54488Aug 04, 2016 5:52:35 PM jenkins.InitReactorRunner$1 onAttainedINFO: Completed initializationAug 04, 2016 5:52:35 PM hudson.UDPBroadcastThread runINFO: Cannot listen to UDP port 33,848, skipping: java.net.SocketException: Can't assign requested addressAug 04, 2016 5:52:35 PM jenkins.InitReactorRunner$1 onAttainedINFO: Started initializationAug 04, 2016 5:52:35 PM jenkins.InitReactorRunner$1 onAttainedINFO: Listed all pluginsAug 04, 2016 5:52:35 PM jenkins.InitReactorRunner$1 onAttainedINFO: Prepared all pluginsAug 04, 2016 5:52:35 PM jenkins.InitReactorRunner$1 onAttainedINFO: Started all pluginsAug 04, 2016 5:52:35 PM jenkins.InitReactorRunner$1 onAttainedINFO: Augmented all extensionsAug 04, 2016 5:52:35 PM jenkins.InitReactorRunner$1 onAttainedINFO: Loaded all jobsAug 04, 2016 5:52:35 PM jenkins.InitReactorRunner$1 onAttainedINFO: Completed initializationAug 04, 2016 5:52:35 PM hudson.WebAppMain$3 runINFO: Jenkins is fully up and running

乐哈哈yoyo 发表于 2017-7-20 11:17:30

3.安装Performance plugin插件: Performance Plugin.Performance plugin4.配制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.jtlecho 'testing end'

5.运行JOB,查看结果
Jenkins执行结果6.在JOB的workspace下会生成两个文件jmeter.log TestPlan.jtljmeter.log TestPlan.jtl配制运行报告1.添加测试报告报告读取2.查看统计结果统计结果后续1.可将jmx文件存放到仓库中,便于维护和管理2.将JOB添加到版本构建中,在版本构建完成后,自动执行性能,确保每次的版本Build均满足性能需求参考1.JMeter2.Jenkins3.Performance Plugin4.Continuous Integration 101: How to Run JMeter With Jenkins
页: [1]
查看完整版本: 【转帖】性能测试与持续集成