Powerful open-source Performance Test tool released in December, 2011. Gatling is a lightweight DSL written in Scala that comes with the interesting premise of "treating your performance tests as production code".
- Install Homebrew
Run this command on the terminal: /usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
- Install Java and
Now that you have homebrew,you can get JDK using Homebrew cask. $ brew cask install java
- Install gradle
We have installed using homebrew $ brew install gradle
-
Install the IDE (optional)
-
We have used community edition of Intellij from https://www.jetbrains.com/idea/
Add Scala plugin to IDE On Startup IntelliJ gives an option to add Scala plugin. You can check it and install on launching IntelliJ for the first time. Otherwise, as soon as you add “apply plugin: “scala” in your build.gradle, IntelliJ prompts you to download scala plugin.
-
Install Java(JRE & JDK)
-
Install gradle
-
Install the IDE(or any other IDE – optional) We have used community edition of Intellij from https://www.jetbrains.com/idea/
-
Add Scala plugin to IDE On Startup IntelliJ gives an option to add Scala plugin. You can check it and install on launching IntelliJ for the first time. Otherwise, as soon as you add “apply plugin: “scala” in your build.gradle, IntelliJ prompts you to download scala plugin.
Step 1 : Configure Browser Change the proxy settings, give address as 'localhost' and port as say - 8080
Step 2 : Recording the Scenario For mac: naviagte to the bin folder of Gatling in terminal and run $sh recorder.sh
For Windows: Go to the bin folder of Gatling bundle and open the "recorder.bat" file
-
Enter the port number in localhost box - 8080
-
Enter the package and class name
-
Check “Follow Redirects”, “Infer HTML resources”, “Remove Cache Headers” and “Automatic Referrers” options
-
Click on Start button
-
Record the scenario you want to test
-
Close the browser
-
Click on “Stop & save” button and Gatling recorder window is closed
Note: for more info on the options on recorder, please refer http://gatling.io/docs/current/http/recorder/
Step 3 : Executing load testing using Gatling For mac: naviagte to the bin folder of Gatling in terminal and run $sh gatling.sh
For Windows: Go to the bin folder of Gatling bundle and open the "gatling.bat" file
- Select the file to be executed, enter the simulation number and enter the simulation description (optional)
Step 4 : Viewing results Results would be generated in HMRL format on running the simulation file as mentioned in Step 3. Open the html file in any browser to view the same.
Note: For more on understanding the results, refer : http://gatling.io/docs/current/general/reports/
- HTTP protocol configuration – This will define your base URL that you will be running your tests against. Also, you can define some other configurations such as user agent, language header, connection and so on.
- Headers definition – This provides the headers for each request that will be sent to the server. This is relevant because the headers also add a bit of load to the server you are testing.
- Scenario definition - The core of your test! A Scenario is a group of actions (GET, POST, etc.) that will be executed in order to simulate a user interaction with your application.
- Simulation definition - This defines the load (amount of users) that will concurrently execute your scenario for a period of time.
Use the following command (Here 'simulation1' is the name of the task mentioned in build.gradle file):
./gradlew simulation1