首页 > 解决方案 > Jmeter:在 Windows 中运行的测试计划在 Centos 中失败

问题描述

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

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

我已经提供了 CSV 路径,因为\testdata\csvtest1.csv这个目录位于src\test\jmeter\testdata,当我运行这个计划时,它可以在 Windows 中通过 maven 在 GUI 模式和非 gui 模式下工作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 and commented on answer,但它没有用。

难道我做错了什么?

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>

标签: jmetermaven-3centos7

解决方案


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


推荐阅读