With the need to do some more effective load testing I am getting started with Gatling. Why Gatling and not JMeter? I have not used either so I don’t have a valid opinion. I made my choice based on:
- reduced GUI dependency
- newer code base
- documentation conciseness
- personal preference to scala vs straight java
- some blog posts including:
Working through the Gatling Quickstart
Next step is working through the basic doc: http://gatling.io/docs/2.2.1/quickstart.html#quickstart. Pretty simple and straightforward.
Moving on to the more advanced tutorial: http://gatling.io/docs/2.2.1/advanced_tutorial.html#advanced-tutorial. This included:
- creating objects for process isolation
- virtual users
- dynamic data with Feeders and Checks
- First usage of Gatling’s Expression Language (not rly a language o_O)
The most interesting function:
object Search { val feeder = csv("search.csv").random val search = exec(http("Home") .get("/")) .pause(1) .feed(feeder) .exec(http("Search") .get("/computers?f=${searchCriterion}") .check(css("a:contains('${searchComputerName}')", "href").saveAs("computerURL"))) .pause(2) .exec(http("Select") .get("${computerURL}")) .pause(3) }
…Simulation‘s are plain Scala classes so we can use all the power of the language if needed.
Next covered off the key concepts in Gatling:
- Virtual User -> logical grouping of behaviours ie: Administrator(login, update user, add user, logout)
- Scenario -> define Virtual Users behaviours ie: (login, update user, add user, logout)
- Simulation -> is a description of the load test (group of scenarios, users – how many and what rampup)
- Session -> Each virtual user is back by a Session this can allow for sharing of data between operations (see above)
- Feeders -> Method for getting input data for tests ie: login values, search and response values
- Checks -> Can verify HTTP response codes and capture elements of the response body
- Assertions -> Define acceptance criteria (slower than x means failure)
- Reports -> Aggregated output
Last review for today was of presentation by Stephane Landelle and Romain Sertelon, the authors of Gatling:
Next step is to implement some test and figure out a good way to separate simulations/scenarios and reports.