Gatling version: 3.11.5
Gatling flavor: java kotlin scala javascript typescript
Gatling build tool: maven gradle sbt bundle npm
Hi,
I have a question about a simple simulation with Gatling.
Before a request will be send to a server an JWT token must be fetched and before five minutes the token should be refreshed.
private final ScenarioBuilder scenario = scenario("Fetch order")
.exec(
http("Authenticate")
.post(AUTHENTICATION_URL)
.asFormUrlEncoded()
.formParam("username", "username")
.formParam("password", "password")
.check(status().is(OK.code()))
.check(jsonPath("$.token").saveAs("token"))
)
.feed(feeder)
.tryMax(3).on(
exec(
http("Fetch order")
.get("#{auftragId}")
.header(AUTHORIZATION, "Bearer #{token}")
.header(ACCEPT, "application/json")
)
); private final ScenarioBuilder scenario = scenario("Fetch order")
.exec(
http("Authenticate")
.post(AUTHENTICATION_URL)
.asFormUrlEncoded()
.formParam("username", "username")
.formParam("password", "password")
.check(status().is(OK.code()))
.check(jsonPath("$.token").saveAs("token"))
)
.feed(feeder)
.tryMax(3).on(
exec(
http("Fetch order")
.get("#{auftragId}")
.header(AUTHORIZATION, "Bearer #{token}")
.header(ACCEPT, "application/json")
)
);
Now I spend my time to find out how to refresh the token efficently. But I did not found a solution.
Some sources I read was:
But at the end I didn’t get it.
private final HttpProtocolBuilder httpProtocol = http
.baseUrl(BASE_URL);
{
this.setUp(scenario.injectOpen(atOnceUsers(1))).protocols(httpProtocol);
}
How to get a Gatling simulation to run where I have to create/refresh a JWT token and query a server for some data?
Thanks in advance,
Markus