Reading unique values from JSON file feeder per virtual user

I’m fairly new to Gatling and maybe this has been answered before here but I would appreciate any help:

So I have code to delete a single file per user that I inject through a feeder

No, Gatling does exactly that.
You have duplicate entries in your file.

that was a copy-paste mistake. They’re all unique guids. So is there a solution to grab one guid per unique user ?

I don’t know if my previous response got posted, but I replied saying that the guids are unique, it was a copy paste error. Sorry about that.
But are you saying that gatling does not have a way to give each user unique data

No, I’m saying the exact opposite: with queue (which is the default behavior), you’re guaranteed to have unique values (as long as you don’t create multiple feeder instances out of the same file of course).

Note that the format of you JSON file is incorrect: Gatling requires an array of OBJECTS.

  {"foo": "f194d49b-a284-4013-b599-2465d355a08f"},
  {"foo": "2219d23c-46fe-4af3-930f-210aee65c4d3"},
  {"foo": "6b3e854c-f4d1-49bd-abba-1bfcc1788661"},
  {"foo": "ba595ede-12d0-465e-a1d5-0342d6b19f13"},
  {"foo": "5f7f5dea-4f93-4588-bce4-4b25bd2aeb32"},
  {"foo": "22382a31-c2ca-40e2-8e4b-543ceb80ecd0"},
  {"foo": "996d1f1f-bc02-4b10-8c7b-9b9a444bffd3"},
  {"foo": "3c919365-db85-4316-942b-c27cfea33e85"},
  {"foo": "ae4a928a-b55a-4ca7-9853-3590c1770dc5"},
  {"foo": "575391e5-1fea-486d-88ee-d3cb14176ae4"},
  {"foo": "575391e5-1fea-486d-88ee-d3cb14176ae5"}

class TestSimu extends Simulation {

  private val scn = scenario("TestSimulation")
        .header("X-Delay", "65000")


Simulation Foo started…

Yes that works fine if I inject 1 user , but I’m talking about more than 1 user.

Example :

I inject 10 users and this is what I’m trying to achieve :

“f194d49b-a284-4013-b599-2465d355a08f” → Feed to User1
“2219d23c-46fe-4af3-930f-210aee65c4d3” → Feed to User2
“6b3e854c-f4d1-49bd-abba-1bfcc1788661” → Feed to User3
“ba595ede-12d0-465e-a1d5-0342d6b19f13” → Feed to User4
“5f7f5dea-4f93-4588-bce4-4b25bd2aeb32” → Feed to User5
“22382a31-c2ca-40e2-8e4b-543ceb80ecd0” → Feed to User6
“996d1f1f-bc02-4b10-8c7b-9b9a444bffd3” → Feed to User7
“3c919365-db85-4316-942b-c27cfea33e85” → Feed to User8
“ae4a928a-b55a-4ca7-9853-3590c1770dc5” → Feed to User9
“575391e5-1fea-486d-88ee-d3cb14176ae4” → Feed to User10

I want one unique guid per unique user that I inject,

Example : User 3 should not be able to access the first guid, it should only be able to access the third guid

Does that make sense? I will try to elaborate more if its not clear.

Sorry, I didn’t paste the correct Simulation (but the results were the right ones) in my previous message.
I’ve slightly edited the logged information in the new version below.

import io.gatling.core.Predef._

class Foo extends Simulation {

  val feeder = jsonFile("deleteGuids.json")

  val scn = scenario("Foo")
    .exec { session =>
      println(s"userId=${session.userId} foo=${session("foo").as[String]}")

  setUp(scn.inject(constantUsersPerSec(2) during 5))

userId=1 foo=f194d49b-a284-4013-b599-2465d355a08f
userId=2 foo=2219d23c-46fe-4af3-930f-210aee65c4d3
userId=3 foo=6b3e854c-f4d1-49bd-abba-1bfcc1788661
userId=4 foo=ba595ede-12d0-465e-a1d5-0342d6b19f13
userId=5 foo=5f7f5dea-4f93-4588-bce4-4b25bd2aeb32
userId=6 foo=22382a31-c2ca-40e2-8e4b-543ceb80ecd0
userId=7 foo=996d1f1f-bc02-4b10-8c7b-9b9a444bffd3
userId=8 foo=3c919365-db85-4316-942b-c27cfea33e85
userId=9 foo=ae4a928a-b55a-4ca7-9853-3590c1770dc5
userId=10 foo=575391e5-1fea-486d-88ee-d3cb14176ae4

Again, a queue feeder instance can’t possibly feed the same record to multiple virtual users.
If you can provide a reproduce that defeats this logic, please provide it.
Your problem is most likely on your side, either in your Simulation’s logic or in your system under test.

Sorry for the late reply, but it worked as you explained. :))