Search code examples
jmetermaven-3centos7

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


I have a test plan which has two threads.

Each thread takes two CSV files as test data.

I have provided the CSV path as \testdata\csvtest1.csv this directory is located at src\test\jmeter\testdata, when I run this plan it works in Windows both in GUI mode and in non-gui mode via maven mvn clean verify.

But when I run this in Centos 7, it is giving below error I found in logs.

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

So I manually copy-pasted test data directory with both CSV files inside Jmeter's bin directory. Still, it is giving the same error.

I have also tried solution here jMeter java.lang.IllegalArgumentException: File example.csv must exist and be readable and commented on answer but it didnt work.

Am I doing something wrong?

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>

Solution

  • Have you tried to read 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.

    So:

    1. Copy your csvtest1.csv, csvtest2.csv, etc to the same location where your .jmx test(s) live, to wit src/test/jmeter folder
    2. Reference them in the CSV Data Set Config elements just by name, i.e. csvtest1.csv

    See Five Ways To Launch a JMeter Test without Using the JMeter GUI article for more information on various approaches to running JMeter tests, including using JMeter Maven Plugin.