There are different reasons for running the Gatling simulations in the command prompt. The
batch file consists of the
executable commands which needs to be executed one by one, serially. Another importance of using command prompt is that, it is the only way of inheriting the shell
properties which is very much required to run any scripts.
It may be noted that, Apple and UNIX has it's own shell platform like the AppleScript and UNIX terminal. But in case of Windows the command prompt is the only way to run script. There are other ways such as the secure shell , etc , but those are also the Linux properties.
To run the script in the command line interface, the folder containing the
gatling.bat must be inside the C Drive of the system.
To open the file, go to the
bin folder and copy the path. Then, go to the command prompt and change the existing path to the copied path.
Step 1: Copy the path
Step 2: Change the path to copied path:
Step 3: Run the
gatling.bat inside the command prompt. Wait a few seconds and let the simulations load.
After a few seconds, you should see the following on the screen.
Before we get the out required file in the simulation list, it is required to copy our Scala script into the
result in the Gatling folder itself.
The simulation we require will appear along with the other lists with the simulation number. First we copy the Scala script
test01.scala into the
To run the simulations select the simulation number and press
enter. In our case out simulation number is
6 as the
test01.scala comes at this number.
After selecting the appropriate simulation number, we could be asked to write a description about the simulation. In the description, we are supposed to write anything of our choice, but it is advisable to use keywords related to our test scenario.
anythingofmychoice not including any extra spaces while writing the description.
After writing the description and hitting
enter we should be able to the below screen, showing all details about the test scenario.
Now as the report is generated, it's corresponding
html file is also created inside the folder
These are the different charts obtained after the
index.html file of the required simulation is run:
This chart mainly shows about how response times are distributed over standard ranges. The OK/KO requests are shown on the right panel.
In our case, the request number was 10 but, it did not reach up to ten. Instead, we interrupted killing the process. This file can also be modified by editing the file
gatling.conf inside the gatling folder itself.
The top panel of the statistics chart is broadly divided into two parts. One is the Execution and the other is the Response Time.
The statistics chart also shows some of the standard statistics such as the min, max, average, standard deviation and percentiles globally and per individual request also.
We should also mention that, if our scenario contains groups, then each group is a non leaf node, and each request is a descendant leaf of a group.
Group timings are generally the cumulative response times of all the elements inside the group. The duration of a group can be displayed instead of group cumulative response time by editing the file
The Active users chart displays the active users at the time of the simulation of the Scala file. Total and
individual scenario active users tries to represent a mix of arrival rate and the number of concurrent users.
The Active users chart is computed in the following way. Number of previous users at the previous second plus the number of users that started during this second plus the number of users that were terminated during the previous second. The number of active users can be an abstract way to analyzing the traffic in the website of any of the web applications.
This response time distribution chart shows the response time distribution of the response times. The next chart show the complete response time distribution in percentiles.
The response time in percentiles chart shows different responses over time, in percentiles. This chart only works for successful requests. It may be noted that any failed requests can end prematurely, or it may be caused to timeouts. If so happen, that would cause a drastic effect on the percentile computations.
The request per second chart shows the number of requests sent per second over time.
The Response chart shows the number of responses received in one second over time.
It may be noted that the Scala script will be executed in default without the functions inside being modified by the user.
But the Scala script can be modified by the user to change the parameters of the functions to get customized out. Therefore, it is mandatory to learn some of the basic Scala syntaxes to get
desirable output in the graphical format.
checkmethod. For example. HTTP Request:
http("My Request").get("myUrl").check(status.is)(200)). It should be added that not only, one check functions, but many check functions may be used to perform various tasks.
currentLocation: This function targets the current page absolute URL. This can be used to check, whether the page to which it is redirecting, is the expected one. The other is the
currentLocationRegex(pattern): This function applying
regexon the location.
currentLocationRegex(pattern).ofType[T].Gatling allows us to use Tuple number from Tuple2 to Tuple8.
header(headerName). It targets the HTTP response header of the given name. It may be notified that, headerName may be a plain String or any String using Gatling EL or an Expression[String].
headerRegex(headerName, pattern)In this case, pattern is used to apply a regex on the header value. HTTP response body: This may include more than four different functions.
So, far we have seen how to install Gatling and JDK. Then we have seen how to create test performance scenarios and then
we have seen how to run the Scala script, and how to create the graphical interpretation of the test report.
We have also understood the different parameters in the output of the Gatling. Then we have also seen how to read and understand the script and also how can we modify some functions by knowing the work done by those functions.