Problem with multiple users, csv feeders and sessions

Hi All,

I am a newbie in Gatling. I’m having problem in handling multiple users with the use of csv feeders.

Here’s the case:

In the first csv file:

  • column 1 - 20 emails
  • column 2 - 1 password (since server has been bypassed)

In the second csv file:

  • column 1 - 20 emails (same as in csv file #1)
  • column 2 - 100 isbn (since server has been bypassed)

Here’s the scenario:

  1. Login
  2. Search ISBN
  3. Logout

Every user is entitled with 5 isbn.

What I need to do is perform a load test with my app, injecting 100 users.

So far, here’s what I have done:

//Scenario
val scn = scenario(“GMSLoadTest”).exec(Login.log_in, Logout.logout)

// LOGIN

object Login {

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

val log_in = exec(http(“NavigateIntranet”)
.get(uri1 + “/ListApplications.do”))

.feed(userCredentials)
.exec(session => session.set(“email”, session(“email”).as[String]))
.exec(session => session.set(“password”, session(“password”).as[String]))

.exec(http(“Login”)
.post(uri1 + “/login.do”)
.formParam(“email”, “${email}”)
.formParam(“password”, “${password}”))

def lalala(username: String, app_id: String, session_id: String, userid: String) =
exec { session =>
session.set(“username”, “${userName}”)
session.set(“app_id”, “${appId}”)
session.set(“session_id”, “${sessionId}”)
session.set(“userid”, “${userId}”)

// println("username: " + “${userName}”)
// println("app_id: " + “${appId}”)
// println("session_id: " + “${sessionId}”)
// println("userid: " + “${userId}”)
}

.exec(http(“GMS-UAT”)
.get("/nams/login.do?username=" + “${userName}” + “&app_id=” + “${appId}” + “&session_id=” + “${sessionId}” + “&userid=” + “${userId}”))
//.get("/nams/login.do/")
//.queryParam(“username”,"${userName}")
//.queryParam(“app_id”,“164002”)
//.queryParam(“session_id”,“0BB10F24174309F54AF7C676D1532C80.tomcat2”)
//.queryParam(“userid”,“44764”))
}

// SEARCH ISBN
object SearchISBN {

val search_isbn = exec(http(“SearchISBN”)
.post("/nams/nams_search.do"))
.feed(isbnToSearch)
.exec(http(“SearchISBN”)
.post("/nams/nams_search.do")
.queryParam(“searchWord”, “${isbn}”))
}

// LOGOUT

object Logout {
val logout = exec(http(“Logout”)
.get("/nams/logout.do"))
.exec(http(“request_26”)
.get(uri1 + “/ListApplications.do”))
}

setUp(scn.inject(atOnceUsers(100))).protocols(httpProtocol)

Simplify your life. Don’t try to treat your csv files like a relational database. Put the logic in the csv file. One file, 100 lines, emails and passwords replicated 5 times, but only one ISBN per line.

Alternatively, don’t assign an ISBN to an email. Use the first file for username and password, and the second has an ISBN only. Whether or not that will work for you depends on the constraints of the system under test.

Hi John,

First of all, thank you very much for responding.

As per your advise, my csv files contain the same. One file, 100 lines, emails and passwords replicated 5 times. The only difference is that the second file has one column for email and another for isbn, which, as you have said, must contain column for isbn only.
What I need to know is the proper approach on how to make this work. I also want to know if the script that I have made makes sense. Am I using session/csv correctly? Please, could you give me any advise on these?
Thanks.

I’m having a hard time following you.

But to know if you are doing the right thing, you need to understand the constraints of the system. Does it matter if different users search for the same ISBN number? If the answer is yes, then why not? What happens if they do? Similarly, does it matter if the same user has two concurrent queries? Why would the system care?

Step one of any simulation is to decide what the simulation must do, and why. The “why” is important, because it informs your decisions as you writ

Thanks, John. Your advise is indeed helpful.

Sorry if you got confused with my explanation. I have posted a more concise explanation here: https://groups.google.com/forum/#!topic/gatling/jKybEx_GcA8
I hope this would make more sense for you. :slight_smile:
I’m hoping for your immediate response.

Again, thanks.

J.