Chaining Actionbuilders in .repeat loop

Good day,

background: After collaberation with my tester we came to the conclusion we want to let scenario’s use the .repeat(int x) loop and inject this with the atOnceUsers(y) to simulate y users repeating a call x amount of times. Because the infrastructure only allows y amount of calls at once.

problem: I want to chain a registration request and a annulment request in the same Simulation. The problem is dat annulment request needs an id that is recieved in the registration response. I want to pass this id from the scenario that makes a registration to the scenario that annulles the registration.

question: how do I chain Actionbuilders in a repeat loop? If I put the two Actionbuilders in an exec() they work asynchronize. But the chain1 is needed to be excecuted to perform the saveData ActionBuilder.

Another solution would be that I’m capable to chain1 and savaData functionality in one ActionBuilder. Personaly, this would be my most prefered solution, as this keeps the code more compact.

Code:

val scenario: ScenarioBuilder = scenario(“register person”)
.repeat(1000) {
exec(chain1)

exec(saveData)
}

val chain1 = http(“register person”)
.put(urlRegister)
.headers(header)
.body(PebbleFileBody(“body.json”))
.check(
jsonPath("$.id")
.saveAs(“id”)
)

val saveData = exec { session =>
DequeHolder.DataDeque.offerLast(session(“id”).as[String])
session
}

Important data about the annulment scenario is that it needs the id from the registration and uses another HttpProtocol

Thank you for taking the time to read my post!

.repeat(1000) {
exec(chain1)

.exec(saveData) // <= DOT!
}

Thanks for the reply Stéphane,

For some reason Intellij indicated that the code was not correct. So I never tried to compile and run the code you suggested. Thanks to you I tried it out and it worked!

Many thanks!

P.S. sorry for the late reply