Hello. I need the advice on how to improve my scenario, I found the way of how to implement it though not sure that it is the best way to implement things.
I need to run N number of users within scenario 1 and when they finished, I want to trigger scenario 2 for only one user. Basically, for my system, it means that users publish N requests to the system and then we trigger the job which process all those requests. Afterwards, the system will generate N new events and I want to measure how long it takes to process all requests. I implemented it the following way though if there is any way to avoid doing the loop in scenario2 please share it with me.
class SettlementsSimulation extends Simulation {
setUp(
sendFundsRequestsScn.inject(
constantUsersPerSec(2) during (2 seconds)
),
triggerScriptScn.inject(
atOnceUsers(1)
)
).protocols(Settlements.jmsConfig, AutomationProperties.httpConf)
}
lazy val sendFundsRequestsScn: ScenarioBuilder = scenario("Send Funds Requests")
.feed(csv("cards.csv").circular)
.feed(customFeeder)
.exec(jms("SendMessage")
.requestReply
.queue(fromBoQueue)
.replyQueue(toBoQueue)
.textMessage(ElFileBody("FundsRequest.json"))
)
.exec { session =>
fundsRequests = fundsRequests + 1
session
}
lazy val triggerScriptScn: ScenarioBuilder = scenario("Trigger End-Of-Period script")
.asLongAs(session => fundsRequests < 5) {
doIf(session => fundsRequests == 4) {
exec(
http("Trigger End-Of-Period script")
.post("/pmstatus")
.body(StringBody("{\"command\": \"run\", \"parameters\": [\"settlement_ci\"]}"))
.check(
status.in(200)
)
)
}
.doIf(session => fundsRequests == 4) {
exec { session =>
fundsRequests = fundsRequests + 1
println("Finishing scenario: " + fundsRequests)
session
}
}
// .exitHereIfFailed
.pause(1 second)
}
var fundsRequests = 0
}