I have created a simple gatling maven application to test performance, verify API rate limit(so if sent requests more than its rate limit it should fail) . In order to run each api as an independent operation and not concurrently, I have created separate simulation classes for each API call to test.
In order to run them in a sequential order I have enabled runMultipleSimulations .
Following eg from galting doc: https://gatling.io/docs/3.0/extensions/maven_plugin/
But I don’t think they are running in sequential order and one scenario that I see from logs, is mostly showing failed user requests with 500 internal server errors, neither I see all test scenarios in logs . Do I need anything else beyond including this dependency ? Here is my pom.xml :
`
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>rate-limiting</groupId>
<artifactId>rate-limiting</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<gatling-plugin.version>3.0.1</gatling-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>io.gatling.highcharts</groupId>
<artifactId>gatling-charts-highcharts</artifactId>
<version>3.1.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>${gatling-plugin.version}</version>
<configuration>
<runMultipleSimulations>true</runMultipleSimulations>
</configuration>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
`
Below is how my project structure looks and action class as well as scenario simulation classes resides under src/test/scala:
ratelimiting
- src
- test
- resources
- scala
- Actions
- CreateAPISimulation
- GetAPISimulation
- DeleteAPISimulation
Eg: of a scenario file :
`
class DeleteAPISimulation extends Simulation {
var test = ""
val preScenario = scenario(" DELETE API PRE-SCENARIO")
.exec(CreateResource())
.exec(session => {
test = session("resourceId").as[String].trim
println("%%%%%%%%%%% resource ID =====>>>>>>>>>> " + test)
session}
)
val deleteResourceScenario = scenario("DELETE API TEST SCENARIO")
// Set it here
.exec(_.set("resourceId", test))
.exec(DeleteResource())
setUp(
preScenario.inject(atOnceUsers(1)),
deleteResourceScenario.inject(rampUsers(520) during(60))
)
}
`
Similarly I created one .scala file for each API scenario.
Actions class just has the DSL http requests implementations for APIs. Eg:
`
object Actions{
def DeleteResource():HttpRequestBuilder = {
http("DELETE_RESOURCE_OPERATION")
.delete(Host+ "/items/${resourceId}")
.header("Authorization", "Bearer "+ Token)
.check(status.is(200))
}
.
.
//and so on
// similar api method requests so on
.
}
`
Can someone please look at this and guide me if I’m doing correctly and whether they should be executed in sequential order just with above defined manner.