Testing Node.Js Application with Gatling

In one of our project we needed to test a node.js application, so in this blog, I’ll be discussing node.js application using Gatlingjs.

Gatlingjs

Gatlingjs is an npm library to run gatling from a node.js project by placing the simulation files in your project repository.

Prerequisites

In order to setup Gatling, your system should have JDK8 and Scala installed so following are the links to install them:

1. JDK 8 installation guide

2. Scala installation guide

If you are using an IDE (i.e IntelliJ) you just need to install scala plugin.

Installation of gatlingjs

Execute following commands to install gatlingjs:

Sudo apt-get install npm

npm i gatlingjs -D

Configuration of Project Structure

To run simulations you have to configure your project library. Gatlingjs requires following directories where you keep your simulation files so that gatlingjs can identify the specific simulation to perform testing.

oie_pCJ9V08vhwdz

As you can see in the above picture, various directories are created which required by gatlingjs in the project root

  • test/performance/results

    This directory contains the HTML representation of the report

  • test/performance/user-files/simulations 

    This directory contains the .scala files for the simulation

  • test/performance/user-files/data

    This directory contains the data feeds

  • test/performance/user-files/bodies

    This directory contains the things related to request body

Starting Gatlingjs simulation

To start the simulation you need to execute the following command

./node_modules/gatlingjs/dist/index.js

After executing the command in the terminal the testing simulation will start running

Screenshot from 2018-10-17 13-17-37

You can see in the above picture an example of running simulation.

After completing the simulation you can check the HTML report generated in the result directory or you can open the report in any browser by copying the path of the index.js file from the end of your simulation and directly paste it into your browser.

oie_SBMZ1b7G0T4f

oie_d86bsl6qSLAx

As you can see above pictures are example report generated.

Thanks!

References :

https://www.npmjs.com/package/gatlingjs

https://gatling.io/docs/current

 


knoldus-advt-sticker

 

Leave a Reply

%d bloggers like this: