Currently i am facing challenge while building Scenario.
Use Case: Thread/user should exit in case request fail and thread/user should start with new iteration in the same scenario. I was exploring option with exiting available Gatling Feature (exitHereIfFails) but with this thread is exiting from scenario.
Please someone can help on this?
Hi Dharam,
I’m not sure to understand your use case.
Usually, users are unrelated to each other.
They only are based on the same scenario for developer’s sake.
The existHereIfFails
is indeed the instruction to use to make the current user stop the scenario.
About the new iteration, I think you should be able to use a feeder.
Hope it helps! (if not, please describe your use case step by step)
Cheers!
Thank you Sbrevet for quick reply
let me explain my use case
I do have multiple transactions in single scenario
Example:
val scn = scenario(“Login”).during(duration minutes) {
.exec(getLogin())
.exec(getRare())
.exec(get_Aff_loy_pref())
.exec(getAddressShipt())
.exec(get_Aff_wal())
.exec(getPreferredStore())
.exec(getGuestSavingSummaries())
}
setUp(
scn.inject(rampUsers(vUsers) during (rampUp seconds)
)).protocols(httpConf)
}
now lets say get_Aff_loy_pref() Transaction fails then I dont want to execute rest other transaction in subsequent break the iteration here only and start with fresh iteration which is getLogin()
hope this help to understand the use case.
let me know if such functionality already there and could not find.
Did you try with exitHereIfFailed()
?
val scn = scenario(“Login”)
.exec(getLogin())
.exitHereIfFailed
.exec(getRare())
.exitHereIfFailed
.exec(get_Aff_loy_pref())
.exitHereIfFailed
.exec(getAddressShipt())
.exitHereIfFailed
.exec(get_Aff_wal())
.exitHereIfFailed
.exec(getPreferredStore())
.exitHereIfFailed
.exec(getGuestSavingSummaries())
.exitHereIfFailed
setUp(
scn.inject(rampUsers(vUsers) during (rampUp seconds))
).protocols(httpConf)
Question: Why this during
for the scenario?
Usually, it is used for repeated action of the same virtual user…
Does this helps?
Cheers!
yes I tried this and in case of failure it is exiting the scenario but i would like to exit at point of failure and start with first transaction which is getLogin().
to your question on “during” - i wanted to achieve consistence transaction for the total duration so I have used it.
is there any other way to exit the iteration in case fail and restart with first transaction?
Oh! You do not want the user to exit the scenario. You want the user to restart at the beginning!
To answer your question, I propose:
val notFailed: Expression[Boolean] = (session: Session) => !session.isFailed
val scn = scenario("Login").during(duration.minutes) {
exec(_.markAsSucceeded) // reset
.exec(getLogin())
.doIf(notFailed)(getRare())
.doIf(notFailed)(get_Aff_loy_pref())
.doIf(notFailed)(getAddressShipt())
.doIf(notFailed)(get_Aff_wal())
.doIf(notFailed)(getPreferredStore())
.doIf(notFailed)(getGuestSavingSummaries())
}
Does it what you want?
About your usage of during
, I don’t understand your use case.
Most systems are in open model and such way of having a “constant” load are weird.
Anyway, I hope this one helps!
Cheers!