问题
I have created a simple feeder in Gatling with CSV. The script is working well and not getting any errors. I know values are fetching from the CSV during the load test. But how can I ensure which value is getting for each user. I have to ensure that first user should login with UserName: user1 and Password: password1. As I am very very new to Gatling I could not find a solution for this. Hence please help me to get a solution , Thanks in advance......
My CSV contains-
Username Password
user1 password1
user2 password2
user3 password3
And my gatling script for the feeder is:
val userCredentails= csv("user_credentials.csv").random
val scn = scenario("RecordedSimulation")
.exec(http("request_0")
.get("/thulasi/myhome.php")
.headers(headers_0)
.resources(http("request_1")
.post(uri1 + "/scripts/index.php")
.headers(headers_1)
.formParam("Action", "Offline"),
http("request_2")
.get(uri1 + "/images/footer.jpg"),
.pause(75)
// Login
.feed(userCredentails)
.exec(http("request_3")
.post("/thulasi/index.php")
.headers(headers_0)
.formParam("cand_user_cd", "${Username}")
.formParam("passwd", "${Password}")
.resources(http("request_4")
.post(uri1 + "/scripts/index.php")
.headers(headers_1)
.formParam("Action", "Offline"))
)
setUp(scn.inject(atOnceUsers(3))).protocols(httpProtocol)
}
回答1:
Check Feeder docs: http://gatling.io/docs/2.2.0/session/feeder.html?highlight=feeders
just don't use random on feeder:
val userCredentails= csv("user_credentials.csv")
- this will go from first record to last, and crash when there is no more records in CSV = so you have to be sure your tests won't load more records then you have
or use circular:
val userCredentails= csv("user_credentials.csv").circular
- this will go from first to last record, over and over again.
来源:https://stackoverflow.com/questions/37188040/ensure-csv-records-in-gatling-using-feeder