Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failing maven-build when Gatling-test has too high fail-percentage

I am trying to run a simple performance-test through Gatling. I use maven to run the process. In order to easely pick up when changes in the code breaks my gatling-tests I want the maven-build to fail. I have made sure to add <failOnError>true</failOnError> in my pom.xml file.

My current script is something like this:

class MySim extends Simulation {
    val httpProtocol = http.baseURL("http://localhost:8080")
    val scn = scenario("Test")
         .exec(http("request_1")
           .get("""/helloworld""")
           .check(status.is(200))
         )
    setUp(scn.inject(ramp(1 users) over (1 seconds))).protocols(httpProtocol)
}

I run the build using maven (with the gatling-maven-plugin) using mvn clean gatling:execute which will allways succeed. (even when the server isn't running). I am looking for a way to make sure the maven builds fails when gatling-test fails (or has a too high fail-percentage).

like image 553
Etse Avatar asked Sep 04 '14 11:09

Etse


1 Answers

So I figured out a solution: All I had to do was add assertions to the setUp, with the criteria I wanted. So the following code would fail the maven-build if the successrate was lover than 90%.

setUp(scn.inject( ... ))
    .protocols(httpProtocol)
    .assertions(
        global.successfulRequests.percent.greaterThan(90)
    )
like image 91
Etse Avatar answered Sep 30 '22 14:09

Etse