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.

VeRo
  • 956
  • 13
  • 27

2 Answers2

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.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • The API has changed since, it seems. This works for me on the latest gatling 3.0.5: assertions(global.successfulRequests.percent.gt(99)) – RobertG May 06 '20 at 06:51
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)
)
serv-inc
  • 35,772
  • 9
  • 166
  • 188