There are different reasons for running the Gatling simulations in the command prompt.
batch file consists of the executable commands which need 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 have their own shell platforms like the AppleScript and UNIX terminal. But in the case of Windows, the command prompt is the only way to run the 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 the 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 the simulation, the 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 of the simulation. In the description, we are supposed to write anything about 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 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 user's chart displays the active users at the time of the simulation of the Scala file. Total and individual scenario active users try to represent a mix of arrival rate and the number of concurrent users.
The Active user's chart is computed in the following way. A 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 on 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 shows the complete response time distribution in percentiles.
The response time in the 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 the second chart shows the number of requests sent per second overtime.
The Response chart shows the number of responses received in one second overtime.
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 the desired output in the graphical format.
http("My Request").get("myUrl").check(status.is)(200))It should be added that not only, one check function, but many check functions may be used to perform various task
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 the Tuple number from Tuple2 to Tuple8.
header(headerName)It targets the HTTP response header of the given name. It may be notified that the header name may be a plain String or any String using Gatling EL or an Expression[String]. The other type is
headerRegex(headerName, pattern)In this case, a pattern is used to apply a regex on the header value. HTTP response body: This may include more than four different functions.
responseTimeInMillis: This function will return the response time of the request in milliseconds which equals the time between starting to send the request and finishing to receive the response.
body String: It returns the full response body String. It may be noted that this can be matched or compared with the content from the file system.
bodyBytes: It returns the full response body byte array.
substring(expression): It scans for the indices of a given substring inside the body string. It can be noted that an expression can be a plain string, a string using Gatling EL or an
regex(expression): It defines a java regular expression that can be applied to any text response body. Example:
regex(expression).ofType[T]:Gatling provides built-in support for extracting String tuples. Tuples range from Tuple2[String] to Tuple8[String].
is(expected): It checks whether the value is the same as expected.
not(expected) : It checks whether the value is different from the expected one.
exists: It checks whether the value exists and is not empty in case of multiple results.
not exist: It checks whether the value does not exist and is empty in case of multiple results.
in(sequence): It checks whether the value belongs to a particular sequence.
Saving: Similarly there are functions for saving also.
saves(key): Saving is an option for storing the result of the previous steps of extraction or transformation into the virtual user Session, which can be reused later.
And the last one is:
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.