Last Vuser not incrementing session var - Custom Data allocation

Hello,
I have the following code - attached

I’m trying to allocate X amount of data to each of the users from the csv file (i.e) first 5 values to 1st Vuser and second 5 values to 2nd Vuser and so on
and I’m trying to move the user out of the test, after using those 5 values

When I run it:
the expected result - all the feedCount of each Vuser should get incremented until 6
the actual result - only the final Vuser(in this case 3rd Vuser) is not incrementing the feedCount to 6

if I reduce the Vusers to atOnceUsers(2), the 2nd Vuser is not incrementing the feedCount to 6

I couldnt find where I’m making the mistake, any idea ?

Thanks
Sujin Sam

batchUsers.zip (6.62 KB)

Your loop (repeat 6 times) and exit (exit on feedCount > 5) conditions are wrong.
As a result, during last iteration:

  • virtual user 1 is trying to read index 5, which is wrong, it belongs to user 2

  • virtual user 2 is trying to read index 10, which is wrong, it belongs to user 3

  • virtual user 3 is trying to read index 15, which throws because your (0 based) array’s length is 15.

Now, there’s something weird, because you’re supposed to get a stracktrace on such an error. I’m investigating this.

I had a doubt that if I add condition inside the session will not work, so added it after the session
I modified the conditions as like below, inside the repeat loop to make it work

exec(session => {
if(session(“feedCount”).as[Int] == allocateCount){
session.markAsFailed
}
else{
session
.set(“p_user”, userRecords(((session.userId).toInt * allocateCount) - allocateCount + session(“feedCount”).as[Int]).get(“p_user”).get)
.set(“feedCount”, (session(“feedCount”).as[Int] + 1))
}
})
.exitHereIfFailed

regarding that un-catched error, will a ticket be created in GitHub?

Thanks
Sujin Sam

There’s actually no logging bug in the Gatling.
The issue is with your logback.xml configuration that’s explicitly filtering out not ERROR level.

oh, ok got it, Thanks Stephane
I have two doubts here:

  1. if it’s trying to access something that is out of bounds, then the simulation or that Vuser should fail isnt it? is that a good practice?
  2. I haven’t seen this session.markAsFailed in the gatling docs, I learnt this when one of the Dev used it, it is useful. Can this be added to the docs and are there any hidden features like this?