How to bring jenkins job to fail when Gatling load tests underperform
Asked Answered
A

2

11

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.

Allen answered 5/9, 2016 at 8:53 Comment(0)
P
9
  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.

Papist answered 5/9, 2016 at 14:39 Comment(1)
The API has changed since, it seems. This works for me on the latest gatling 3.0.5: assertions(global.successfulRequests.percent.gt(99))Crampton
S
1

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)
)
Smoot answered 17/10, 2019 at 12:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.