I have a few questions based on the following code. I’m trying to repeat creating new users multiple times serially and create a 6 digit identity number each time. I’m attempting to pad the repeat index number with this, otherwise once it gets over 9 the creation process fails since it’s adding too many digits. I may not be doing that right, but I think I’m on the right track with that. I’m using gatling 2.0 m4 I believe.
val CreateNewUserScenario = scenario(“Create New Users”)
.repeat(3, “n”) {
exec(session => {
var intN: java.lang.Integer = Integer.parseInt(session(“n”).as[String])
var identSuffix = String.format("%03d", intN)
session.set(“identSuffix”, identSuffix)
println(“session follows”)
println(session)
// return the original session
session
})
exec(http(“CNU_get_ext_home”)
.get("""/external/"""))
.pause(4)
.exec(http(“CNU_get_create_acct”)
.get("""/external/createAccount"""))
.pause(10)
.exec(http(“CNU_save_user”)
.post("""/external/user/saveSelf""")
.formParam(""“user_company_ident”"", “”“123${identSuffix}”"")
.check(regex(""“User Account Created”"").exists))
}
Questions are…
-
I get the following error with the above “> No attribute named ‘identSuffix’ is defined 3 (100.0%)” How do I set this session var in the repeat loop so it’s available later in my http calls?
-
I never see the println output despite setting the logback to DEBUG once and INFO another time. How do I use println within a scenario to output the session? I attempted to follow the example from the guide but I’m not seeing anything.
-
Should I have the execs inside the repeat as two separate exec statements or is there some way to get these to work fluently? I tried adding a . in front of the second exec block but it threw errors.
Thanks!
- Galen Fisher