3
votes

i'm using gatling 2.0.3, and i'm looking to execute a single chain and store the auth token before running some complex scenario's. But i can't find a way to share the token across scenarios with out first executing the auth chain and writing it to a file, to be picked up by a feeder. Is there a correct way to do this?

before{
    scenario_get_auth.inject(
        //make auth call and save to file for feeder
    )
}.protocols(default_http)

setUp{
    scenario_load_one.inject(
       constantUsersPerSec(10).during(test_duration_secs)
    )
    scenario_load_two.inject(
       constantUsersPerSec(1-).during(test_duration_secs)
    )
}.protocols(default_http)
2

2 Answers

4
votes

A similar question has been answer recently on our mailing list.

Basically, you have to use a global ConcurrentHashMap.

0
votes

I was looking for something similar but could not use Concurrent HashMap as @Stephane suggested as my access tokens were expiring after an hour.

Here is a gist of code snippet where I have created a wrapper on top of Guava Cache taking dependency on ScalaCache.

This allows us to expire the cache entries before the actual token get expired. So, we need not add additional handling of 401 status codes in Simulations.