在java 1.7上运行jmeter 2.13
我有一个测试用例,它由简单的groovy脚本采样器组成,它采用一个参数指定为$ {__ P(var,foo)}和printlns args [0]。我可以下载apache jmeter 2.13并运行测试用例并按预期打印出“foo”。但是,如果我使用maven工件构建jmeter,则相同的.jmx测试用例输出“$ {__ P(var,foo)}”。所以它似乎没有将参数识别为变量。我的pom文件如下:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>jicd-4.2-tools-onboarding</artifactId>
<groupId>com.ticomgeo.jicd42</groupId>
<version>0.2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>onboarding-tests</artifactId>
<packaging>jar</packaging>
<name>validation-tests</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jmeter-version>2.13</jmeter-version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_core</artifactId>
<version>${jmeter-version}</version>
<exclusions>
<exclusion>
<artifactId>commons-math3</artifactId>
<groupId>commons-math3</groupId>
</exclusion>
<exclusion>
<artifactId>commons-pool2</artifactId>
<groupId>commons-pool2</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_components</artifactId>
<version>${jmeter-version}</version>
<exclusions>
<exclusion>
<artifactId>commons-math3</artifactId>
<groupId>commons-math3</groupId>
</exclusion>
<exclusion>
<artifactId>commons-pool2</artifactId>
<groupId>commons-pool2</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_java</artifactId>
<version>${jmeter-version}</version>
<exclusions>
<exclusion>
<artifactId>commons-math3</artifactId>
<groupId>commons-math3</groupId>
</exclusion>
<exclusion>
<artifactId>commons-pool2</artifactId>
<groupId>commons-pool2</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter</artifactId>
<version>${jmeter-version}</version>
<exclusions>
<exclusion>
<artifactId>commons-math3</artifactId>
<groupId>commons-math3</groupId>
</exclusion>
<exclusion>
<artifactId>commons-pool2</artifactId>
<groupId>commons-pool2</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_config</artifactId>
<version>${jmeter-version}</version>
<exclusions>
<exclusion>
<artifactId>commons-math3</artifactId>
<groupId>commons-math3</groupId>
</exclusion>
<exclusion>
<artifactId>commons-pool2</artifactId>
<groupId>commons-pool2</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_report</artifactId>
<!-- <version>${jmeter-version}</version> -->
<version>2.12</version>
<exclusions>
<exclusion>
<artifactId>commons-math3</artifactId>
<groupId>commons-math3</groupId>
</exclusion>
<exclusion>
<artifactId>commons-pool2</artifactId>
<groupId>commons-pool2</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_functions</artifactId>
<version>${jmeter-version}</version>
<exclusions>
<exclusion>
<artifactId>commons-math3</artifactId>
<groupId>commons-math3</groupId>
</exclusion>
<exclusion>
<artifactId>commons-pool2</artifactId>
<groupId>commons-pool2</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_monitors</artifactId>
<version>${jmeter-version}</version>
<exclusions>
<exclusion>
<artifactId>commons-math3</artifactId>
<groupId>commons-math3</groupId>
</exclusion>
<exclusion>
<artifactId>commons-pool2</artifactId>
<groupId>commons-pool2</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_mail</artifactId>
<version>${jmeter-version}</version>
<exclusions>
<exclusion>
<artifactId>commons-math3</artifactId>
<groupId>commons-math3</groupId>
</exclusion>
<exclusion>
<artifactId>commons-pool2</artifactId>
<groupId>commons-pool2</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_junit</artifactId>
<version>${jmeter-version}</version>
<exclusions>
<exclusion>
<artifactId>commons-math3</artifactId>
<groupId>commons-math3</groupId>
</exclusion>
<exclusion>
<artifactId>commons-pool2</artifactId>
<groupId>commons-pool2</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>jorphan</artifactId>
<version>${jmeter-version}</version>
<exclusions>
<exclusion>
<artifactId>commons-math3</artifactId>
<groupId>commons-math3</groupId>
</exclusion>
<exclusion>
<artifactId>commons-pool2</artifactId>
<groupId>commons-pool2</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter</artifactId>
<version>${jmeter-version}</version>
<exclusions>
<exclusion>
<artifactId>commons-math3</artifactId>
<groupId>commons-math3</groupId>
</exclusion>
<exclusion>
<artifactId>commons-pool2</artifactId>
<groupId>commons-pool2</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- fix jmeter build bug -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.3</version>
</dependency>
<!-- groovy -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.6</version>
</dependency>
<!-- appgeo -->
<dependency>
<groupId>com.ticomgeo.jicd42</groupId>
<artifactId>appgeo-jaxb</artifactId>
</dependency>
<dependency>
<groupId>com.techma.nxm</groupId>
<artifactId>nextmidas</artifactId>
<classifier>sys</classifier>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>gov.oio.jicd42</groupId>
<artifactId>app-geo-api</artifactId>
<version>2.0.3</version>
</dependency>
<!-- <dependency> <groupId>org.apache.jmeter</groupId> <artifactId>ApacheJMeter_parent</artifactId>
<version>${jmeter-version}</version> </dependency> -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<configurationDirectory>config</configurationDirectory>
<!-- Copy the contents from "/src/main/config" to the
target configuration directory in the assembled application -->
<copyConfigurationDirectory>true</copyConfigurationDirectory>
<includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath>
<repositoryLayout>flat</repositoryLayout>
<repositoryName>lib</repositoryName>
<programs>
<program>
<mainClass>org.apache.jmeter.NewDriver</mainClass>
<name>validationTest</name>
</program>
</programs>
</configuration>
<executions>
<execution>
<configuration>
<extraJvmArguments />
</configuration>
<id>create-executables</id>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/bin.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>bin</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
答案 0 :(得分:0)
很可能你有一些包装问题,它不是与JMeter或Maven有关的东西,因为我无法使用JMeter Maven Plugin重现您的问题
示例pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jmeter.test</groupId>
<artifactId>onboarding-tests</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.10.1</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.6</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
示例输出:
[INFO] -------------------------------------------------------
[INFO] P E R F O R M A N C E T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO]
[info]
[debug] JMeter is called with the following command line arguments: -n -t /private/tmp/jmeter-maven/src/test/jmeter/example.jmx -l /private/tmp/jmeter-maven/target/jmeter/results/20160413-example.jtl -d /private/tmp/jmeter-maven/target/jmeter -j /private/tmp/jmeter-maven/target/jmeter/logs/example.jmx.log
[info] Executing test: example.jmx
[debug] Creating summariser <summary>
[debug] Created the tree successfully using /private/tmp/jmeter-maven/src/test/jmeter/example.jmx
[debug] Starting the test @ Wed Apr 13 06:39:54 CEST 2016 (1460522394158)
[debug] Waiting for possible shutdown message on port 4445
[debug] foo
[debug] summary = 1 in 0.3s = 2.9/s Avg: 282 Min: 282 Max: 282 Err: 0 (0.00%)
[debug] Tidying up ... @ Wed Apr 13 06:39:55 CEST 2016 (1460522395204)
[debug] ... end of run
[info] Completed Test: example.jmx
[INFO]
[INFO] Test Results:
[INFO]
[INFO] Tests Run: 1, Failures: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
所以也许值得考虑切换到该插件而不是手动触发JMeter测试,因为您可能会错过重要的配置步骤。
参考文献:
答案 1 :(得分:0)
好的,找到了答案。我正在使用appassembler插件。这将所有罐子放入类路径中。我依靠jmeter来找到它的插件。我将插件移动到一个单独的目录,并将search_paths jmeter属性设置为该目录,即
search_paths=../apache
这不仅解决了属性无法解决的问题,而且还解决了GUI未运行的问题。
An error occurred: No action handlers found - check JMeterHome and libraries
注意只添加appassembler生成的lib目录不起作用。在这种情况下发生以下错误:
An error occurred: class "org.bouncycastle.cms.BaseDigestCalculator"'s signer information does not match signer information of other classes in the same package