Longhorns’ Actual Si...
Once upon a time, CSI wasn’t a...
In the previous posts of the Karate series, we discussed topics such as BDD Syntax and Elegant DSL. We examined in detail how Karate facilitates our work with super-readable, well-formed assertion capabilities. In this blog post, which is the last article of the series, we will examine how Karate service tests can be used as performance tests thanks to the integration with Gatling.
Some of our customers want to use them as performance tests when creating service tests, and we recommend Karate + Gatling integration where such a demand occurs. Developing service tests and performance tests at the same time with the same scenarios significantly reduces automation development costs. Karate + Gatling infrastructure is a great combination for this optimization.
Gatling is an open-source load and performance-testing framework based on Scala, Akka, and Netty. The software is designed to be used as a load testing tool for analyzing and measuring the performance of various services, with a focus on web applications.
Karate with Gatling
The Karate Framework improved its integration with Gatling in 2018.
It enabled the reuse of Service tests written with Gherkin Syntax in load tests with Gatling and Scala. It can also be used to develop functional performance tests.
First of all, to use Karate and Gatling together, you need to configure your dependencies in the pom.xml. For this, you need to add the <dependency> and <plugin> parts to the corresponding places in the pom.xml. When you add these parts and the IntelliJ Scala plug-in, it supports the use of .scala.
https://search.maven.org/search?q=g:io.gatling%20AND%20a:gatling-maven-plugin&core=gav for latest Gatling version
After creating the necessary infrastructure for installation, you can create your Gatling load test models for your existing scenarios.
As an example, we used the PET API users endpoint we used before, and you can configure it yourself.
Now let's create load tests by integrating these Karate scenarios with Gatling.
You can use Gatling load models to configure your load tests with Gatling.
This declares a whole Karate feature as a "flow"
Note: how you can have concurrent flows in the same Gatling simulation.
is required, as Gatling cannot intercept HTTP requests. To create the Gatling report correctly, you need to transfer the URL models included in your test with the Karate Framework to Gatling.
You can also set pause times (in milliseconds) per URL pattern and HTTP method (get, post, etc.) if needed. If non-zero, this pause will be applied before the invocation of the matching HTTP request.
During (y sec/min), Injects a given number of users with a linear ramp during a given duration.
Organize your scenario's code and tune the behavior of Gatling's HTTP client.
For more load models, you can use https://gatling.io/docs/current/general/simulation_setup/
After the load test class you created, your file structure should be as follows.
│ ├── PetSimulation.scala
│ ├── Pets.feature
You can run test suite with the command "mvn test", which has a set execution goal on pom.xml. You can free your service tests from your performance tests by removing the execution target on pom.xml. You can run your service tests with the "mvn test" command and your Gatling performance tests with the "mvn clean test-compile gatling:test" command.
After execution, 30 users can send receive and requests within 10 seconds. Here you can try more users or more settings. These settings can vary depending on the resources of the server you are testing. After processing, Gatling will generate a report based on visual data. You can find the data of the load test in this report.
In the last article of Mastering Karate in Five Steps, we talked about the Karate and Gatling infrastructure that allows you to develop your load tests with your API tests. By using Karate and Gatling together, you can significantly increase your performance test development speed by integrating additional Performance tests into your Service tests. Additionally, you save on the potential costs of running a performance test.
Ümit Özdemir, Software Development Engineer in Test, is currently working as Software Test Consultant at Kloia.
Once upon a time, CSI wasn’t a...
If you have events/messages th...
Introduction Over a decade, th...
Tigera is an active Cloud-Nati...
The kloia team is excited to b...