0

I need to be able to run jmeter tests from jenkins using mvn and jmeter-maven-plugin.

Here is the file setup:

test_dev.jmx
test_dev.txt
test_dev_regression.jmx
test_dev_regression.txt

Here is the pom file used by the mvn command (below):

<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.example</groupId>
    <artifactId>JmeterTest</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>JMeter Example </name>
    <properties>
        <input.jmx.folder>${project.basedir}/src/test/jmeter</input.jmx.folder>
        <input.jmx.file>test_${Environment}.jmx</input.jmx.file>
        <input.csv>${project.basedir}/src/test/jmeter/test_${Environment}.txt</input.csv>
    </properties>

    <build>
        <sourceDirectory>src</sourceDirectory>

        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.lazerycode.jmeter</groupId>
                <artifactId>jmeter-maven-plugin</artifactId>
                <version>2.9.0</version>
                <configuration>
                    <propertiesUser>
                        <threadgroup00.dataFile>${input.csv}</threadgroup00.dataFile>
                    </propertiesUser>
                    <testFilesIncluded>
                        <!-- If spcified, only particular file will be processed. -->
                        <jMeterTestFile>${input.jmx.file}</jMeterTestFile> 
                    </testFilesIncluded>
                    <testResultsTimestamp>false</testResultsTimestamp>
                    <!-- This will pick up all the jmx file at below folder. -->
                    <testFilesDirectory>${input.jmx.folder}</testFilesDirectory>
                    <generateReports>true</generateReports>
                    <resultsFileFormat>csv</resultsFileFormat>
                </configuration>

                <executions>
                    <execution>
                        <id>jmeter-tests</id>
                        <phase>test</phase>
                        <goals>
                            <goal>jmeter</goal>
                            <goal>results</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>

And here is the command we are using to run the tests:

mvn verify -DEnvironment=$TEST_ENVIRONMENT

As you can see, currently there are no regression tests being run. I'd like to add the regression test and it's input file into this pom so that both tests get run one after the other. The hang-up for me is the <threadgroup00.dataFile> property. What needs to be specified here to use another input file for the regression test? Or is there another way to run multiple tests with multiple inputs using this framework?

Thanks in advance!

jmess
  • 83
  • 5
  • See https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/issues/137 – Ori Marko Oct 03 '19 at 16:58
  • That's fine with tests that don't have any input files. My requirements are that multiple tests need to be run each with their own input file. I think this is possible, but I'm not sure. – jmess Oct 04 '19 at 17:27
  • 1
    The plugin does not currently support running multiple .jmx files in parallel. To do that you would need to run multiple instances in different terminal windows/tabs – Ardesco Oct 21 '19 at 12:40

1 Answers1

0

As of version 3.0.0 you should now be able to do this, an example execution block showing the setup is:

<executions>
    <execution>
        <id>configuration-one</id>
        <goals>
            <goal>configure</goal>
        </goals>
        <configuration>
            <resultsFileFormat>xml</resultsFileFormat>
        </configuration>
    </execution>
    <execution>
        <id>configuration-two</id>
        <goals>
            <goal>configure</goal>
        </goals>
        <configuration>
            <resultsFileFormat>csv</resultsFileFormat>
        </configuration>
    </execution>
    <execution>
        <id>performance test one</id>
        <goals>
            <goal>jmeter</goal>
        </goals>
        <configuration>
            <selectedConfiguration>configuration-one</selectedConfiguration>
            <testFilesIncluded>
                <jMeterTestFile>test1.jmx</jMeterTestFile>
            </testFilesIncluded>
        </configuration>
    </execution>
    <execution>
        <id>performance test two</id>
        <goals>
            <goal>jmeter</goal>
        </goals>
        <configuration>
            <selectedConfiguration>configuration-two</selectedConfiguration>
            <testFilesIncluded>
                <jMeterTestFile>test2.jmx</jMeterTestFile>
            </testFilesIncluded>
        </configuration>
    </execution>
</executions>

The IT test showing this behaviour (Which the above execution example was taken from) is available at here.

Ardesco
  • 7,281
  • 26
  • 49