Repeat loop - how to make it work

I am trying to get the repeat API to work in my simulation but no matter what I do, I can’t get the HTTP delete call to happen.
Inside that repeat loop, I evaluate the URL string, print that out to the console then make the HTTP call.
Any idea on how to get this code to work?

What I see printed on the console

Thanks,
Khiem

Please read https://gatling.io/docs/gatling/reference/current/core/concepts/#immutability

You have to use Gatling DSL components (eg Gatling’s foreach).

Thanks, Stephane for the prompt response. I don’t find a lot of information on the foreach loop but managed to change my loop and got “No attribute named ‘list’ is defined”. I may miss something very basic and make the wrong assumption. What is my issue now?

Thanks,
\KT

  1. bad session API usage: https://gatling.io/docs/gatling/reference/current/core/session/session_api/#setting-attributes
  2. what’s this “foreach().run”??? It should be named “on”, not “run”, see https://gatling.io/docs/gatling/reference/current/core/scenario/#foreach

Thanks. My latest code below still giving me “[ERROR] i.g.c.s.LoopBlock$ - Condition evaluation crashed with message ‘No attribute named ‘listoflists’ is defined’, exiting loop”. It seems that line 104 has no effect.

100: }).then (exec
101:    { session ->
102:     val subLists = session.getList<String>("personaIds").chunked(50)
103:        println("subLists:${subLists}")
104:        session.set("listoflists", subLists)
105:        session
106:    }.foreach("#{listoflists}", "list").on(
107:        exec { session ->
108:            println(session.getList<String>("list"))
109:            http("Remove Realm Personas").delete("/v1/personas?ids=${session.getList<kotlin.String>("list")}")

Clearly, you didn’t properly read the documentation. There’s a big warning block exactly explaining your error.

Sorry for being ignorant and careless but I couldn’t find the warning that you referred to. Is it related to the use of $ and # to reference a session attribute?

I still don’t understand why “#{listoflists}” is not available to the foreach loop. I had “session.set(“listoflists”, subLists)” before the foreach loop.

I think I got it now. Session is immutable.