Jmeter-Maven-Plugin高级应用:Modifying Properties

Modifying Properties

Pages 12

Modifying Properties


Using Your Own Properties Files

The easiest way to configure JMeter with this plugin is to supply your own properties files. When it starts up the plugin will scan the ${project.base.directory}/src/test/jmeter directory for the following files:

  • jmeter.properties
  • saveservice.properties
  • upgrade.properties
  • system.properties
  • user.properties
  • global.properties

Adding Additional Properties To <propertiesJMeter>

It is possible to set properties that configure the main JMeter library. To set those properties you will need to specify each property in your pom.xml in the config element <propertiesJmeter>(The example below shows a property called log_level.jmeter being set).

Each property specified is merged into the JMeter properties file jmeter.properties, it will overwrite any identical properties within the file.

+---+
<project>
    [...]
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId>
                    <artifactId>jmeter-maven-plugin</artifactId>
                    <version>2.0.3</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <propertiesJMeter>
                            <log_level.jmeter>DEBUG</log_level.jmeter>
                        </propertiesJMeter>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    [...]
</project>
+---+

Adding Additional Properties To <propertiesSaveService>

It is possible to set properties that configure the Saveservice of the main JMeter library. To set those properties you will need to specify each property in your pom.xml in the config element<propertiesSaveservice> (The example below shows a property called HTTPSampler2 being set).

Each property specified is merged into the JMeter properties file saveservice.properties, it will overwrite any identical properties within the file.

+---+
<project>
    [...]
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId>
                    <artifactId>jmeter-maven-plugin</artifactId>
                    <version>2.0.3</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <propertiesSaveService>
                            <HTTPSampler2>org.apache.jmeter.protocol.http.sampler.HTTPSampler2</HTTPSampler2>
                        </propertiesSaveService>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    [...]
</project>
+---+

Adding Additional Properties To <propertiesUpgrade>

It is possible to set properties that are used in the oldValue to newValue upgrade mapping of the main JMeter library. To set those properties you will need to specify each property in yourpom.xml in the config element <propertiesUpgrade>. (The example below shows a property called my.old.ClassName being set).

Each property specified is merged into the JMeter properties file upgrade.properties, it will overwrite any identical properties within the file.

+---+
<project>
    [...]
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId>
                    <artifactId>jmeter-maven-plugin</artifactId>
                    <version>2.0.3</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <propertiesUpgrade>
                            <my.old.ClassName>my.new.ClassName</my.old.ClassName>
                        </propertiesUpgrade>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    [...]
</project>
+---+

Adding Additional Properties To <propertiesUser>

JMeter user properties are properties supplied to JMeter that can be used in JMeter tests. To set user properties you will need to specify each property in your pom.xml in the config element<propertiesUser> (The example below shows a property called threads and a propery calledtestIterations being set).

Each property specified is merged into the JMeter properties file user.properties, it will overwrite any identical properties within the file.

+---+
<project>
    [...]
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId>
                    <artifactId>jmeter-maven-plugin</artifactId>
                    <version>2.0.3</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <propertiesUser>
                            <threads>10</threads>
                            <testIterations>5</testIterations>
                        </propertiesUser>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    [...]
</project>
+---+

Adding Additional Properties To <propertiesGlobal>

Global properties are properties that are sent to the remote machines. To set those properties you will need to specify each property in your pom.xml in the config element<propertiesGlobal> (The example below shows a property called threads and a property calledtestIterations being set).

Each property specified is merged into the JMeter properties file global.properties, it will overwrite any identical properties within the file.

+---+
<project>
    [...]
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId>
                    <artifactId>jmeter-maven-plugin</artifactId>
                    <version>2.0.3</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <propertiesGlobal>
                            <threads>10</threads>
                            <testIterations>5</testIterations>
                        </propertiesGlobal>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    [...]
</project>
+---+

Adding Additional Properties To <propertiesSystem>

JMeter can set system properties, these are global environment properties accessible by all applications running in the same JVM (They are not accessible outside the JVM). To set system properties you will need to specify each property in your pom.xml in the config element<propertiesSystem> (The example below shows a property called my.system.property being set).

Each property specified is merged into the JMeter properties file system.properties, it will overwrite any identical properties within the file.

+---+
<project>
    [...]
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId>
                    <artifactId>jmeter-maven-plugin</artifactId>
                    <version>2.0.3</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <propertiesSystem>
                            <my.system.property>my.system.property.value</my.system.property>
                        </propertiesSystem>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    [...]
</project>
+---+

Setting <propertiesReplacedByCustomFiles>

By default all properties specified in the settings above will be merged with any existing properties. If you want them to be replaced instead you can do this by setting<propertiesReplacedByCustomFiles> to true (it is false by default). Please think very carefullybefore doing this, the reason we merge properties by default is to ensure that all properties are merged into the latest valid versions of the properties files supplied with JMeter. If you overwrite the properties files but are missing a property that is required by JMeter things will most likely break.

+---+
<project>
    [...]
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId>
                    <artifactId>jmeter-maven-plugin</artifactId>
                    <version>2.0.3</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <propertiesReplacedByCustomFiles>${basedir}true</propertiesReplacedByCustomFiles>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    [...]
</project>
+---+

Specifying A <customPropertiesFile>

This will allow you to set an absolute path to JMeter custom (test dependent) properties file. This is the equivalent of setting " --addprop my.properties" on the command line.

+---+
<project>
    [...]
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId>
                    <artifactId>jmeter-maven-plugin</artifactId>
                    <version>2.0.3</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <customPropertiesFiles>
                            <file>/user/home/myuser/myCustom.properties</file>
                        </customPropertiesFiles>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    [...]
</project>
+---+

Specifying The <propertiesFilesDirectory>

You can specify the directory where the .properties files are located in your file system (by default the plugin will assume they are in ${project.base.directory}/src/test/jmeter)

+---+
<project>
    [...]
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId>
                    <artifactId>jmeter-maven-plugin</artifactId>
                    <version>2.0.3</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <propertiesFilesDirectory>/user/home/myuser/properties</propertiesFilesDirectory>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    [...]
</project>
+---+
时间: 2024-09-29 11:56:47

Jmeter-Maven-Plugin高级应用:Modifying Properties的相关文章

Jmeter+Maven+Jenkins+Git接口自动化流程

最近在实现 Jmeter+Maven+Jenkins+Git 接口自动化,研究不到两周,实现了 Jmeter+Maven+Jenkins+Git  接口自动化 的整体流程. 仅以此博客简单记录下自己实现的过程. 一. 职责.角色明确 Jmeter: 执行者,录制接口测试脚本,运行脚本,得到结果,生成报告,统计数据: Maven,Git :管理者, Maven 主要负责项目的依赖管理,Git 主要负责项目的代码管理: Jenkins:调度者,持续集成(CI)工具:构建.部署自动化:可以持续编译,运

Jmeter+maven+Jenkins构建云性能测试平台(mark 推荐)

转自:http://www.cnblogs.com/victorcai0922/archive/2012/06/20/2555502.html Jmeter+maven+Jenkins构建云性能测试平台(一) 最近在利用Jmeter来做一套自动化性能测试框架,做自动化性能测试框架的目的 是希望能够针对系统做一个benchmark的性能测试,能够快速的在每个版本发布后,对该版本进行benchmark性能测试,以比较与上一个版本的性 能是否发生变化,若发生变化便可以快速的通知开发人员以确定性能发生变

利用Swagger Maven Plugin生成Rest API文档

利用Swagger Maven Plugin生成Rest API文档 Swagger Maven Plugin This plugin enables your Swagger-annotated project to generate Swagger specs and customizable, templated static documents during the maven build phase. Unlike swagger-core, swagger-maven-plugin

Maven实现Web应用集成測试自己主动化 -- 部署自己主动化(WebTest Maven Plugin)

上篇:Maven实现Web应用集成測试自己主动化 -- 測试自己主动化(WebTest Maven Plugin) 之前介绍了怎样在maven中使用webtest插件实现web的集成測试,这里有个遗留问题,就是在运行maven的intergation測试时候web应用已经部署在容器中处于in service的状态,那么web应用的部署能否够自己主动化呢?在我们公司的系统中,因为使用了weblogic的cluster,自己写了脚步来实现部署,花费了不少人力物力,事实上java web应用早就有福音

Maven实现Web应用集成测试自动化 -- 部署自动化(WebTest Maven Plugin)

上篇:Maven实现Web应用集成测试自动化 -- 测试自动化(WebTest Maven Plugin) 之前介绍了如何在maven中使用webtest插件实现web的集成测试,这里有个遗留问题,就是在执行maven的intergation测试时候web应用已经部署在容器中处于in service的状态,那么web应用的部署是否可以自动化呢?在我们公司的系统中,由于使用了weblogic的cluster,自己写了脚步来实现部署,花费了不少人力物力,其实java web应用早就有福音了,是一款自

解决Jetty Maven Plugin:Please initialize the log4j system properly(转)

解决Jetty Maven Plugin:Please initialize the log4j system properly.Jetty Maven Plugin环境: <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>8.1.10.v20130312</version>

Tomcat Maven Plugin部署Maven Web应用

Tomcat官方提供了Maven插件用于部署基于Maven的Web应用,不同版本Tomcat使用的插件不同,不同版本插件的使用也有一定区别,详细信息可参考http://tomcat.apache.org/maven-plugin.html.下面记录的是我在Eclipse环境中使用Tomcat Maven Plugin-2.2在Tomcat7中部署Maven Web应用的配置过程: 第一步:配置Tomcat manager用户: 打开Tomcat根目录下conf目录中的tomcat_user.xm

eclipse maven plugin 插件 安装 和 配置

环境准备: eclipse(Helios) 3.6 maven 3.0.4 maven3 安装: 安装 Maven 之前要求先确定你的 JDK 已经安装配置完成.Maven是 Apache 下的一个项目,目前最新版本是 3.0.4,我用的也是这个. 首先去官网下载 Maven:http://www.apache.org/dyn/closer.cgi/maven/binaries/apache-maven-3.0.4-bin.tar.gz 下载完成之后将其解压,我将解压后的文件夹重命名成 mave

Spring Boot Maven Plugin -- repackage目标

简介 Spring Boot Maven Plugin插件提供spring boot在maven中的支持.允许你打包可运行的jar包或war包. 插件提供了几个maven目标和Spring Boot 应用一起工作.总的有: spring-boot:repackage spring-boot:run spring-boot:start and spring-boot:stop spring-boot:build-info repackage:创建一个自动可执行的jar或war文件.它可以替换常规的