Hello,
We are doing a load test on the distributed system using Gatling.
We send a request to Rest endpoint, which sends a bunch of messages to Kafka Topic for the consumers to process it.
One approach we are doing is to send 1000 request to the endpoint and want to check the Kafka Consumer lag using custom code, once all the messages are processed i.e lag is 0 will end the simulation.
how do I implement this in Gatling?
My First cut is
// First Scenario to post to Http Endpoint
val scn: ScenarioBuilder = scenario(scenarioName).repeat(10, "n") {
exec { session =>
session.set("id", random.nextInt(10000))
}
.exec(http("testendpoint")
.post("/data")
.body(ElFileBody("data.json"))
.headers(httpHeaders)
)
}
// Custom Action Builder
val readLabelsBuilder = new ActionBuilder {
override def build(ctx: ScenarioContext, next: Action): Action = {
new LagMonitorAction()
}
}
//Action. ( Ideally I want to check the Lag in Kafka Topics, but for now I just want to print something for debugging)
class LagMonitorAction extends ChainableAction {
override def name: String = "LagMonitor"
override def next: Action = null
override def execute(session: Session): Unit = {
println ("I'm a custom Action")
}
}
// Scenario with my custom Action Builder
val checkForKafkaConsumption = scenario("KafkaConsumption").exec(readLabelsBuilder)
val end2End = scenario("LoadTest").exec(scn).exec(checkForKafkaConsumption)
//Set up to execute the scenarios
setUp(
end2End.inject(atOnceUsers(noOfUsers)).protocols(httpConf)
)
When I run the simulation, it executes the test i.e post 10 requests to the HTTP endpoint, then prints I'm a custom Action
After that the simulation continues does not end right after printing 'I'm a custom action', it waits for for-ever
What am I doing wrong?
How can I handle testing like this?
-Siva