Sunday, February 7, 2016

Simple Gatling setup with Maven

Just add the following maven pom snippet to your project pom.xml.

Create maven style project structure of src/test/scala. As per the example below your default simulation class is com.company.project.MySimulation. If you want to create different name/package pass -Dsimulation= to execute that simulation.

All of the properties mentioned in the pom can be overridden via command line using -D option.

Execute mvn test to run your gatling performance simulation.

<project>
    <properties>
        <simulation>com.company.project.MySimulation</simulation>
        <applicationUrl>http://localhost:8080/application</applicationUrl>
        <noOfUsers>1</noOfUsers>
        <durationInMinutes>1</durationInMinutes>
        <rampUpInMinutes>1</rampUpInMinutes>
    </properties>
    <dependencies>
        <dependency>
            <groupId>io.gatling.highcharts</groupId>
            <artifactId>gatling-charts-highcharts</artifactId>
            <version>2.2.0-M3</version>
        </dependency>
        <dependency>
            <groupId>io.gatling</groupId>
            <artifactId>gatling-app</artifactId>
            <version>2.2.0-M3</version>
        </dependency>
        <dependency>
            <groupId>net.liftweb</groupId>
            <artifactId>lift-json_2.11</artifactId>
            <version>3.0-M7</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>3.2.2</version>
            </plugin>
            <plugin>
                <groupId>io.gatling</groupId>
                <artifactId>gatling-maven-plugin</artifactId>
                <version>2.2.0-M2</version>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <configFolder>src/test/resources</configFolder>
                            <simulationsFolder>src/test/scala</simulationsFolder>
                            <simulationClass>${simulation}</simulationClass>
                            <noReports>false</noReports>
                            <jvmArgs>
                                <jvmArg>-DapplicationUrl=${applicationUrl}</jvmArg>
                                <jvmArg>-DnoOfUsers=${noOfUsers}</jvmArg>
                                <jvmArg>-DdurationInMinutes=${durationInMinutes}</jvmArg>
                                <jvmArg>-DrampUpInMinutes=${rampUpInMinutes}</jvmArg>
                                <jvmArg>-Xms2048M</jvmArg>
                                <jvmArg>-Xmx2048M</jvmArg>
                            </jvmArgs>
                            <propagateSystemProperties>true</propagateSystemProperties>
                            <failOnError>true</failOnError>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

No comments:

Post a Comment