当前位置: 首页 > news >正文

使用Jenkins和Jmeter搭建性能测试平台

参考文档:http://blog.csdn.net/liuchunming033/article/details/52186157

jenkins的性能测试结果展现插件:https://wiki.jenkins-ci.org/display/JENKINS/Performance+Plugin

maven执行使用的jmeter插件:https://github.com/jmeter-maven-plugin/jmeter-maven-plugin

Jmeter-maven-plugin高级配置之选择测试脚本

在pom.xml文件中可以指定运行哪些jmx脚本。

运行所有的测试脚本

Jmeter默认运行${project.base.directory}/src/test/jmeter文件夹中的所有脚本,下面是示例。

 1 <project>
 2         [...]
 3             <build>
 4                 <plugins>
 5                     <plugin>
 6                         <groupId>com.lazerycode.jmeter</groupId>
 7                         <artifactId>jmeter-maven-plugin</artifactId>
 8                         <version>1.9.0</version>
 9                         <executions>
10                             <execution>
11                                 <id>jmeter-tests</id>
12                                 <phase>verify</phase>
13                                 <goals>
14                                     <goal>jmeter</goal>
15                                 </goals>
16                             </execution>
17                         </executions>
18                     </plugin>
19                 </plugins>
20             </build>
21         [...]
22     </project>
View Code

运行mvn verify即可。

使用<testFilesIncluded>指定运行的脚本文件

我们可以通过<testFilesIncluded>这个标签来手动指定jmx文件。样例如下:

 1 <plugin>
 2         <groupId>com.lazerycode.jmeter</groupId>
 3         <artifactId>jmeter-maven-plugin</artifactId>
 4         <version>1.9.0</version>
 5         <executions>
 6              <execution>
 7                  <id>jmeter-tests</id>
 8                  <phase>verify</phase>
 9                  <goals>
10                      <goal>jmeter</goal>
11                  </goals>
12                  <configuration>
13                       <testFilesIncluded>
14                           <jMeterTestFile>test1.jmx</jMeterTestFile>
15                           <jMeterTestFile>test2.jmx</jMeterTestFile>
16                       </testFilesIncluded>
17                  </configuration>
18             </execution>
19        </executions>
20     </plugin> 
View Code

当我们执行mvn verify时,只有${project.base.directory}/src/test/jmeter文件夹中的test1.jmx、test2.jmx会执行。

在<testFilesIncluded>中使用正则表达式

<testFilesIncluded>标签支持正则表达式,下面的示例,指定以foo开头的所有jmx文件。

 
 1 <plugin>
 2                 <groupId>com.lazerycode.jmeter</groupId>
 3                 <artifactId>jmeter-maven-plugin</artifactId>
 4                 <version>1.9.0</version>
 5                 <executions>
 6                     <execution>
 7                         <id>jmeter-tests</id>
 8                         <phase>verify</phase>
 9                         <goals>
10                             <goal>jmeter</goal>
11                         </goals>
12                         <configuration>
13                             <testFilesIncluded>
14                                 <jMeterTestFile>foo*.jmx</jMeterTestFile>
15                             </testFilesIncluded>
16                         </configuration>
17                     </execution>
18                 </executions>
19             </plugin>
View Code

使用<testFilesExcluded>标签反向指定jmx文件

我们还可以使用排除法,来指定不要运行${project.base.directory}/src/test/jmeter文件夹中的文件。样例:

 
 1 <plugin>
 2                 <groupId>com.lazerycode.jmeter</groupId>
 3                 <artifactId>jmeter-maven-plugin</artifactId>
 4                 <version>1.9.0</version>
 5                 <executions>
 6                     <execution>
 7                         <id>jmeter-tests</id>
 8                         <phase>verify</phase>
 9                         <goals>
10                             <goal>jmeter</goal>
11                         </goals>
12                         <configuration>
13                             <testFilesExcluded>
14                                 <excludeJMeterTestFile>test3.jmx</excludeJMeterTestFile>
15                                 <excludeJMeterTestFile>test4.jmx</excludeJMeterTestFile>
16                             </testFilesExcluded>
17                         </configuration>
18                     </execution>
19                 </executions>
20             </plugin>
View Code

当我们运行mvn verify时,${project.base.directory}/src/test/jmeter文件夹中除了test3.jmx和test4.jmx,其他的jmx文件都会执行。

<testFilesExcluded>标签使用正则表达式

反向指定jmx文件时,也可以使用正则表达式,样例:

 1 <plugin>
 2                 <groupId>com.lazerycode.jmeter</groupId>
 3                 <artifactId>jmeter-maven-plugin</artifactId>
 4                 <version>1.9.0</version>
 5                 <executions>
 6                     <execution>
 7                         <id>jmeter-tests</id>
 8                         <phase>verify</phase>
 9                         <goals>
10                             <goal>jmeter</goal>
11                         </goals>
12                         <configuration>
13                             <testFilesExcluded>
14                                 <excludeJMeterTestFile>*bar.jmx</excludeJMeterTestFile>
15                             </testFilesExcluded>
16                         </configuration>
17                     </execution>
18                 </executions>
19             </plugin>
View Code

运行时,以bar结束的jmx文件都会排除在外。

<testFilesDirectory>标签指定jmx文件夹

我们还可以自定义jmx文件的位置(默认是${project.base.directory}/src/test/jmeter)。

 1 <plugin>
 2                 <groupId>com.lazerycode.jmeter</groupId>
 3                 <artifactId>jmeter-maven-plugin</artifactId>
 4                 <version>1.9.0</version>
 5                 <executions>
 6                     <execution>
 7                         <id>jmeter-tests</id>
 8                         <phase>verify</phase>
 9                         <goals>
10                             <goal>jmeter</goal>
11                         </goals>
12                         <configuration>
13                             <testFilesDirectory>/scratch/testfiles/</testFilesDirectory>
14                         </configuration>
15                     </execution>
16                 </executions>
17             </plugin>
View Code

 

各个配置含义及解读:https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/wiki/Advanced-Configuration

转载于:https://www.cnblogs.com/shengulong/p/6646844.html

相关文章:

  • Android手机通过APN设置上网的方法
  • NSDate
  • 1
  • 电子测量
  • JS实现的图片预览功能
  • docker 安装centos 7
  • 深入理解计算机系统之存储器层次结构学习笔记
  • hihocoder offer收割编程练习赛12 C 矩形分割
  • css 样式表 基础 样式
  • 函数装饰器
  • 第二百一十节,jQuery EasyUI,SearchBox(搜索框)组件
  • UVa 10917 林中漫步
  • Ruby 写文件
  • Python学习日记之读取中文目录
  • STL List::sort() 解析
  • “Material Design”设计规范在 ComponentOne For WinForm 的全新尝试!
  • 【笔记】你不知道的JS读书笔记——Promise
  • 【知识碎片】第三方登录弹窗效果
  • HTTP请求重发
  • input的行数自动增减
  • js中forEach回调同异步问题
  • Solarized Scheme
  • vue总结
  • #include<初见C语言之指针(5)>
  • #我与Java虚拟机的故事#连载04:一本让自己没面子的书
  • #在 README.md 中生成项目目录结构
  • %3cli%3e连接html页面,html+canvas实现屏幕截取
  • (1)STL算法之遍历容器
  • (LeetCode C++)盛最多水的容器
  • (Matalb时序预测)PSO-BP粒子群算法优化BP神经网络的多维时序回归预测
  • (Python第六天)文件处理
  • (二)斐波那契Fabonacci函数
  • (三)模仿学习-Action数据的模仿
  • (十五)devops持续集成开发——jenkins流水线构建策略配置及触发器的使用
  • (四)图像的%2线性拉伸
  • (五) 一起学 Unix 环境高级编程 (APUE) 之 进程环境
  • (自适应手机端)响应式新闻博客知识类pbootcms网站模板 自媒体运营博客网站源码下载
  • .NET Project Open Day(2011.11.13)
  • .NET 使用 XPath 来读写 XML 文件
  • .Net 知识杂记
  • @converter 只能用mysql吗_python-MySQLConverter对象没有mysql-connector属性’...
  • @在php中起什么作用?
  • [ vulhub漏洞复现篇 ] JBOSS AS 5.x/6.x反序列化远程代码执行漏洞CVE-2017-12149
  • [2016.7 test.5] T1
  • [AI]文心一言出圈的同时,NLP处理下的ChatGPT-4.5最新资讯
  • [Angular] 笔记 7:模块
  • [BZOJ 4034][HAOI2015]T2 [树链剖分]
  • [Codeforces] probabilities (R1600) Part.1
  • [codeforces]Levko and Permutation
  • [Hive] INSERT OVERWRITE DIRECTORY要注意的问题
  • [IE9] GPU硬件加速到底是实用创新还是噱头
  • [linux]linux命令学习-netstat
  • [Luogu 2816]宋荣子搭积木
  • [NSSRound#16 Basic]RCE但是没有完全RCE
  • [office] excel中weekday函数的使用方法 #学习方法#微信#媒体