Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bring jenkins job to fail when Gatling load tests underperform

has anyone tried to fail the running Jenkins Job when Gatling asserts are not met or if the requests fail?

For instance:

  • mark a Jenkins build as unstable when the Global mean value for the 95th percentile is under a specific value, say 1.2 sec for response time
  • mark a Jenkins build as failed if a certain percent of requests are not answered

Does anyone have an idea how this can be achieved with the existing Maven / Jenkins plugins for Gatling.

my maven Plugin settings are:

                <plugin>
                    <groupId>io.gatling</groupId>
                    <artifactId>gatling-maven-plugin</artifactId>
                    <version>${gatling.version}</version>
                    <configuration>
                        <failOnError>true</failOnError>
                        <simulationsFolder>src/test/scala</simulationsFolder>
                        <runMultipleSimulations>true</runMultipleSimulations>
                        <configFolder>src/main/resources</configFolder>
                    </configuration>
                    <executions>
                        <execution>
                            <id>GoOrBust</id>
                            <phase>test</phase>
                            <goals>
                                <goal>execute</goal>
                            </goals>
                            <configuration>
                                <simulationClass>mine.OnePunch</simulationClass>
                                <failOnError>true</failOnError>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

the <failOnError>true</failOnError> will only influence the report generation but not the Jenkins Job (obviously).

I would prefer not to explicitly throw exceptions from inside the tests by doing custom exception monitoring / handling.

like image 352
VeRo Avatar asked Sep 05 '16 08:09

VeRo


2 Answers

  1. Gatling-specific solution: you need to define a global assertion in your Gatling script like:

    setUp(scn.inject( ... ))
        .protocols(httpProtocol)
        .assertions(
            global.successfulRequests.percent.greaterThan(99)
    )
    
  2. Alternative. You can consider running your Gatling script using Taurus tool as a wrapper. It can consume existing Gatling tests and apply flexible Pass/Fail Criteria to them. In case of failure trigger Taurus will return non-zero exit code hence Jenkins job will fail.

like image 89
Dmitri T Avatar answered Oct 22 '22 21:10

Dmitri T


If Dmitri's 1 failed for you, see https://groups.google.com/forum/#!topic/gatling/OjsdqXej2_s

setUp(scn.inject( ... )
    .protocols(httpProtocol))
  .assertions(
    global.successfulRequests.percent.greaterThan(99)
)
like image 20
serv-inc Avatar answered Oct 22 '22 20:10

serv-inc