Pulling Values from Feeder File

** Using Gatling 2.1.4 on Ubuntu 14.10

I have a scenario where I create a workspace (context) as user1 and after I create that workspace I want to assign a randomly chosen different user to that workspace from the same feeder file. How would I randomly choose another user from that same feeder file?

This is the format of my feeder file:

login-user-name,login-password,account-urid,access-token,mac-key
gatling1,password,[https://server.com/resources/data/accounts/c945b1f0-c106-11e4-86b1-695fd0c942fc,69be32d8-45c9-4c77-a49b-c245b1b0be27,L5V3GcR1UdXns4sAS6hH](https://server.com/resources/data/accounts/c945b1f0-c106-11e4-86b1-695fd0c942fc,69be32d8-45c9-4c77-a49b-c245b1b0be27,L5V3GcR1UdXns4sAS6hH)

This is what my scenario looks like:

object CreateWorkspaceScenario extends BaseScenario {

  val mainScenario =  scenario("create-workspace-scenario")
                      .group("create-workspace-group") {
                        feed(calculatedUsersFeederFile.circular)

                        .exec(SetSessionTokenAndMacKeyModule.execute)

                        .exec(session => {  val newSession : Session = session.set("context-request-name", "create-workspace-request")
                                                                              .set("context-type", "COLLABORATION")
                                                                              .set("context-label", session("login-user-name").as[String] + "-" + UUID.randomUUID() + "-Workspace")

                                            newSession})

                        .exec(CreateContextRequest.postRequest)
                      }
}

I am going to be adding another request at the end called AssignUserToWorkspace and in that I need a randomly chosen user other than the “login-user-name” from the same feeder file that is already in that session.

Thanks,
Steve

Any ideas how to do this?

Thanks,
Steve

I do not know that this will work, but you can try this:

val feeder = csv( filename )
val sequential = feeder.circular
val random = feeder.random

If the feeder is an immutable object, and the call to circular and random return a new object with new behavior, which knowing Stéphane it probably is, then when you feed from one or from the other, it will behave as you would expect. Try it, and see what happens.

Assuming it works as expected, there will be a very small chance that the request from the random feeder will pull the same record as the one the sequential one returned. The more users in the feeder, the less often it will happen. If that condition is unacceptable, then add code to loop until you get a new record.

Hey John,

Thanks for the info!

I read on http://gatling.io/docs/2.1.4/session/feeder.html#feeders that you can feed multiple records at once and if you do they are appended with the index you specify in the feed method like this:

feed(feederFile, 2)

In my case I can just add this to my script:

feed(calculatedUsersFeederFile.circular).feed(calculatedUsersFeederFile.random, 2)

I can then reference the second user by using ${login-user-name2}

I am trying to figure out how to handle the scenario you mentioned above where the random and sequential feeder will have the same record. I can write some simple code to check if they are the same but I am not sure how to pull the next record off the random feeder if they are.

Any idea how to do that?

Thanks,
Steve

feed( sequential )
.exec( do what you need to do with it )
.exec( session => session.set( ‘save-id-name’, session( ‘id-field’ ).as[String] ) )
.feed( random )
.asLongAs( session => session(‘save-id-name’).as[String] == session(‘id-field’).as[String] ) {
feed( random )
}
.exec( do what you need to do with the next user )

Ah! That is much easier than I was doing. Thanks!