Use Gatling for Performance Test – I
When talking about performance test or load test, you may think about LoadRunner or JMeter. Today I’d like to introduce another interesting tool Gatling.
Gatling is an opensource tool for load and performance testing. It is based on Scala. I know the word Scala may scare some people away. Well, actually we don’t need to write too much complicated Scala code when using Gatling. Thus I suggest you to move forward to try. It is DSL expressive self-explanatory with comprehensive HTML Report. Since it has Maven and Jenkins plugins, we can easily integrate it into our Continuous Integration framework. Thus Gatling is becoming an excellent option for web site, web service and Database load/performance testing.
In this session, I’d like to introduce the easier approach — to download the bundle directly and use it from command line. I will have a second session introduce how to the maven plugin which can be used for Continuous Integration.
1. Download
Firstly go to https://gatling.io/open-source to download the zip file–I am using windows now, unzip the file into a specific folder. After that, the folder structure looks something like following.
Then add environment variable GATLING_HOME. Change the variable value based on your situation.
Open a command prompt, type gatling. It should have following prompt.
2. First script
Build APITest.scala. Write the class extends from Simulation class. This test defines a scenario which simulates 10 end users to sending post request. Each user repeats sending 10 requests. We can verify the response of each request actually. Skip it in the first example.
3.Execute the Test and Check Report
Open Command Prompt, navigate to the directory where the scala file located, type gatling. In following prompt, choose the first option, that is 0.
After the test execution, you can see where is the html report. There are rich information the report present. We can illustrate them in detail later.
There are some other topics like test data driven, virtual users configuration are mandatory if you use Gatling in your own project. I will introduce how to integrate Gatling with Maven and Intellij IDE in the second session.