How to use four csv files in login object?

My question as followed:
I created 10 users to logon one system, but system check duplicate user, if one user logon system, next logon for the same user will be automatically log out.
I will test compound scenarios using 10 users.
I separate 10 users from one file to 4 files.
user and password in csv file.
2 users in 1.csv
3 users in 2.csv
2 users in 3.csv
3 users in 4.csv
when running the following script, error pops up.

  1. how to handle multiple files in login function?
  2. If above handle is incorrect, do you have other good advice?

Class CompoundPage extends Simulation {

val headers_0 = Map(
“”“Accept”"" → “”“text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8"”",
“”“Cache-Control”"" → “”“max-age=0"”")

val headers_1 = Map(
“”“Accept”"" → “”“text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8"”",
“”“Cache-Control”"" → “”“max-age=0"”",
“”“Content-Type”"" → “”“application/x-www-form-urlencoded”"",
“”“Origin”"" → “”“https://portal-qa1.everbridge.net”"")

val headers_2 = Map(
“”“Accept”"" → “”“text/css,/;q=0.1"”",
“”“Cache-Control”"" → “”“max-age=0"”")

val headers_79 = Map(""“Accept”"" → “”“text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8"”")

val contactuserinQA = csv(“1.csv”).circular
val notificationuserinQA = csv(“2.csv”).circular
val universeuserinQA = csv(“3”).circular
val dashboarduserinQA = csv(“4.csv”).circular

var logintype=""
def userInQAorStage(logintype: String) : io.gatling.core.feeder.FeederBuilder[_] = {
if(scenParse.baseurl.contains(“portal-qa1.everbridge.net”)) {
if (logintype.contains(“contact”)){
contactuserinQA
}
else if (logintype.contains(“notification”)){
notificationuserinQA
}
else if (logintype.contains(“universe”)){
universeuserinQA
}
else if (logintype.contains(“dashboard”)){
dashboarduserinQA
}
}
else userInStage
}

object object Login{
def login(logintype:String) = {
exec(http(“request_0”)
.get("""/login""")
.headers(headers_0))
.pause(2)
.feed(userInQAorStage(logintype))

.exec(http(“request_1”)
.post("""/check""")
.headers(headers_1)
.formParam(""“nc4Sourse”"", “”"""")
.formParam(""“nc4"”", “”"""")
.formParam(""“username”"", “${user}”)
.formParam(""“password”"", “${password}”)
.formParam(""“input1"”", “”“English (United States)”"")
.resources(http(“request_2”)
.get(uri1 + “”"/statics/stylesheets/jscss/ajax.css?version=V3.1.1-2014-08-28%2002:18:43""")
.headers(headers_2)
.check(status.is(200))
}

object Logout {
val logout = group(“Logout”){
exec(http(“request_204”)
.get("""/logout""")
.headers(headers_79)
.check(status.is(200)))
}
}

val logincontact = scenario(“ContacLogin”).repeat(5){
exec(Login.login(“contact”), Logout.logout)
}
setUp(scn.inject(atOnceUsers(2))).protocols(httpProtocol)

}

I’m not sure I get it right, but it looks like you could have one single scenario definition where you pass the feeder name, and then have multiple concurrent scenario instances:

def scn(feederName: String) = scenario(“foo”)…feed(csv(feederName))…

setUp(
scn(“file1.csv”).inject(atOnceUsers(2)),
scn(“file2.csv”).inject(atOnceUsers(2)),

scn(“file3.csv”).inject(atOnceUsers(2)),

scn(“file4.csv”).inject(atOnceUsers(2))

).protocols(httpProtocol)

Hi Stéphane,
Thank you very much, you suggested single scenario definition can work well for me.

Glad it helped :slight_smile:

Hi Stephane,

I have tried with the scenario which you have mentioned, but I’m getting an error as "Scenario names must be unique but found duplicates: ".

Can you please look into this.

The scenario you mentioned:

def scn(feederName: String) = scenario(“foo”)…feed(csv(feederName))…

setUp(
scn(“file1.csv”).inject(atOnceUsers(2)),
scn(“file2.csv”).inject(atOnceUsers(2)),

scn(“file3.csv”).inject(atOnceUsers(2)),

scn(“file4.csv”).inject(atOnceUsers(2))

).protocols(httpProtocol)

Thanks