Hello
I would like to describe my problem.
The scenario is this, when each new user enters, I would like to set the new token for that user. After that use the token and other info to register the feature.
I’m using the index variable, index =0 is the first user, index = 1 is for the next user …
But the problem is I don’t know how to increment the index so that when the second user enters, they will use the new index.
Could someone help me to increment the index variable? Or could you suggest me do another way.
Thank you!
Here is my code:
package tci3accountPro
import baseConfig.BaseSimulation
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import tci3accountPro.models.bodyRegisterSubs
import core.api.ApiUtil
import scala.concurrent.duration._
class registerSubscriptions extends BaseSimulation{
var username = Array("105C169260","105C100808")
var index = 0
val cashAccount = "11111"
val proCode = "IWEALTH_PRO"
val typeText = "TRIAL"
val referrerId105C = "105C310885"
var ini = new GetTokenApi
var token = ini.getToken(username(index))
val registerSubs = http.baseUrl(accountProDomain + accountProSubs)
.header("Content-Type","application/json")
var feeder = Iterator.continually(Map(
"cashAccount" -> cashAccount,
"code105C" -> username(index),
"proCode" -> proCode,
"type" -> typeText,
"referrerId105C" -> referrerId105C
))
/* def extractJson(): = {
}*/
def registerSub() = {
feed(feeder).
exec(http("register Subscriptions")
.post("")
.body(ElFileBody("bodies/bodyRegisterSubs.json")).asJson
.header("Authorization", token)
.check(status.is(200)))
}
val scn = scenario("register Subscriptions")
.exec(registerSub).exec{session => session.set("index",index + 1)}
setUp(scn.inject(atOnceUsers(1),rampUsers(1).during(10)).protocols(registerSubs)).maxDuration(1 minutes)
.assertions(global.responseTime.max.lt(10000), global.successfulRequests.percent.gt(95))
}