Hello
I am running a gatling simulation using the gatling maven plugin 3.0.5 and Gatling version is : 3.3.1
scenario : to give you visibility on the scenario: I am testing user authentication after creating users for my web application.(my application is remote in AWS and my Load Test scripts also running in EC2 instance in AWS)
1/ I recover the email and the password which are in a csv file
**2/**in the response header I recover the token and save it in a csv file (because after each request I must pass the token in the header request)
here you can see the simulation code :
class TestLoginManyUsersWithDiffProfile extends Simulation {
val sessionHeaders = Map(
"acceptLanguageHeader" -> "fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7",
"Content-Type" -> "application/json",
"acceptEncodingHeader"-> "gzip, deflate, br"
)
var properties = new java.util.Properties()
var input = new FileInputStream("src/test/resources/data/gatling.properties")
properties.load(input)
val httpProtocol = http
.baseUrl(properties.getProperty("URL_MicroService_Security"))
object LoginPage {
val loginProperties = csv("src/test/resources/data/FileOfLoginPassword.csv").circular
val login = feed(loginProperties)
.exec(http("LoginPage")
.post("/login")
.body(StringBody("""{ "email": "${email}","password":"${password}" }""")).asJson
.headers(sessionHeaders)
.check(header("authorization").saveAs("access_token"))
)
.exec { session =>
println("--------------------------------OUTPUT-------------------------");
println(session);
session }
.exec { session =>
val file = new File("src/test/resources/data/Token.csv")
if(file.exists()){
val writer = new PrintWriter(new FileOutputStream(new File("src/test/resources/data/Token.csv"), true))
writer.write(session("access_token").as[String].trim)
writer.write(",")
writer.write("\n")
writer.close()
}
else {
val writer = new PrintWriter(new FileOutputStream(new File("src/test/resources/data/Token.csv"), true))
writer.println("token")
writer.write(session("access_token").as[String].trim)
writer.write(",")
writer.write("\n")
writer.close()
}
session
}
}
val scenario1 = scenario("Authentication Scenario of many users with diff profile ")
.exec(LoginPage.login)
setUp(scenario1.inject(
atOnceUsers(300)
))
.protocols(httpProtocol)
}
Whenever i run this simulation I get this error:
header(authorization).find.exists, found nothing===>I know that this error means that the 2 requests that are failed have not returned the response header, that’s why the display of this error. but by debugging i found that email and password recover are right and i can connect to the app with them.I don’t know why then it can’t retrieve the token
and the result of the simulation is:
Also I don’t know why the response time for 50 virtual user is between 5s and 26s–>this response time doesn’t make sense for just 50 users(huge response time)