Unable to increment value from a csv file (looping)

Hi,

I’m trying to loop the log in step in my scenario with several users (which are stored in a csv file). Feeder works fine. I put “repeat” action for looping and increment to get values in sequence [user1, user2, …, user(n)], but only the first value is being returned.

My script goes like this:

val userCredentials = csv(“user.csv”).circular

val userIdFeeder = Iterator.from(0).map(i => Map(“email” → i))
val iterations = 1;

val scn = scenario(“LoadTest”)

.feed(userIdFeeder)
.repeat(iterations, “index”){
exec(session => {
val userIdFeeder = session(“userIdFeeder”).as[Int]
val index = session(“index”).as[Int]
val email = iterations * userIdFeeder + index
session.set("${email}", “email”)
println("SESSION: " + session)
session
})

.feed(userCredentials)
.exec(http(“EnterCredentials”)
.post(uri1 + “/login.do”)
.headers(headers_2)
.formParam(“location”, " ")
.formParam(“email”, “${email}”)
.formParam(“password”, “${password}”))
//.pause(13)
}

Thanks in advance for your help.

Hi,

Two things here:

  • A new element is extracted from a feeder only once per user, so it is normal that you get the same “userIdFeeder” for each step inside the repeat
  • The session is immutable, meaning that setting something on it and not saving the result will result in discarding the modified session. Therefore, the “session” returned at the end of the exec is the original one.
    Cheers!

Hi Guillaume,

Thanks for your response!

  • A new element is extracted from a feeder only once per user, so it is normal that you get the same “userIdFeeder” for each step inside the repeat

I just tried that one out to know if that would help in incrementing the values from my feeder. But it doesn’t work as expected. All I know is that I must use session since email/username are varied. But I really am having trouble in incrementing the values from the feeder.
What’s the best way to do it? Teach me, master. I’m desperate.

  • The session is immutable, meaning that setting something on it and not saving the result will result in discarding the modified session. Therefore, the “session” returned at the end of the exec is the original one

Will eliminating the last “session” do the trick?