Jmeter:在 windows 中运行的测试计划在 Centos 中失败

Jmeter: Test plan which was working in windows failing in Centos

我有一个包含两个线程的测试计划。

每个线程取两个CSV文件作为测试数据。

我提供了 CSV 路径 \testdata\csvtest1.csv 这个目录位于 src\test\jmeter\testdata,当我 运行 这个计划它在 Windows GUI 模式和在非图形用户界面模式下通过 maven mvn clean verify.

但是当我 运行 在 Centos 7 中执行此操作时,它给出了我在日志中发现的以下错误。

2018-10-04 13:56:24,739 INFO o.a.j.s.FileServer: Stored: \testdata\csvtest1.csv
2018-10-04 13:56:24,743 INFO o.a.j.s.FileServer: Stored: \testdata\csvtest2.csv
2018-10-04 13:56:24,740 ERROR o.a.j.t.JMeterThread: Test failed!
java.lang.IllegalArgumentException: File \testdata\csvtest2.csv must exist and be readable

所以我在 Jmeter 的 bin 目录中手动复制粘贴了两个 CSV 文件的测试数据目录。尽管如此,它还是给出了同样的错误。

我也尝试过这里的解决方案 jMeter java.lang.IllegalArgumentException: File example.csv must exist and be readable 并对答案发表评论,但它没有用。

我是不是做错了什么?

POM.xml

<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>com.demo.performancetesting</groupId>
    <artifactId>demo-performance-testing</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>com.lazerycode.jmeter</groupId>
                <artifactId>jmeter-maven-plugin</artifactId>
                <version>2.7.0</version>
                <configuration>
                        <resultsFileFormat>xml</resultsFileFormat>
                        <generateReports>false</generateReports>
                    </configuration>
                <executions>
                    <execution>
                        <id>jmeter-tests</id>
                        <goals>
                            <goal>jmeter</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>de.codecentric</groupId>
                <artifactId>jmeter-graph-maven-plugin</artifactId>
                <version>0.1.0</version>
                <configuration>
                    <inputFile>${project.build.directory}/jmeter/results/*.jtl</inputFile>
                    <graphs>
                        <graph>
                            <pluginType>ResponseTimesOverTime</pluginType>
                            <width>800</width>
                            <height>600</height>
                            <outputFile>${project.build.directory}/jmeter/results/BlazeDemoRequest.png</outputFile>
                        </graph>
                    </graphs>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

尝试使用 /(斜杠)作为文件分隔符,并确保执行测试计划的用户可以读取文件。

您是否尝试阅读 documentation

Reference JMX files and CSV data

Once you have created your JMeter tests, you'll need to copy them to <Project Dir>/src/test/jmeter. By default this plugin will pick up all the .jmx files in that directory, to specify which tests should be run please see the project documentation. You can also put data files in this folder and reference them in your plan.

所以:

  1. 将您的 csvtest1.csvcsvtest2.csv 等复制到您的 .jmx 测试所在的相同位置,即 src/test/jmeter 文件夹
  2. 仅按名称在 CSV 数据集配置元素中引用它们,即 csvtest1.csv

有关 运行 JMeter 测试的各种方法的更多信息,包括使用 JMeter Maven 插件,请参阅 Five Ways To Launch a JMeter Test without Using the JMeter GUI 文章。