Able to refresh token , but Running refresh token scenario in Sequential Scenarios - is not working

I do have a scenarios where scenarios are supposed to be running in sequential fashion, and the scenario runs for about 4 hours, hence i have to refresh token, and token refresh is working fine for every 15v mins.

  val executionTime = 2.hours
  val authTimeout = 5.minutes
  val safetyMargin = 30.seconds

  val authenticate : ChainBuilder = exec(AuthRequest.auth_token)
    .exec(session => session.set("timeout", authTimeout.fromNow))

  private val refreshPing: ScenarioBuilder = scenario("scenarioXYZ")
    .exec(authenticate)
    .during(executionTime) {
      doIf(session =>  {session("timeout").as[Deadline].timeLeft <= safetyMargin}) {
        exec(authenticate)
      }

However in the set up file, i used andThen() to run scenarios sequentially, I tried all the below combinations, after refreshing token, it is not moving to the next scenario, it is just waiting for refresh token scenario to completely finish looks like, can you please advise how to proceed?

setUp(
  AuctionSimulation_round1.inject(
    nothingFor(1),
    atOnceUsers(1),
  ).andThen(
     refreshToken.inject(atOnceUsers(1)),
      openBids_Round.inject(nothingFor(1),
    atOnceUsers(1))).
       andThen(
            submitBids_round1.inject(nothingFor(1),
              atOnceUsers(1), rampUsers(10).during(50))).
              andThen(
                  closeBids_Round.inject(nothingFor(1),
                    atOnceUsers(1)))
       )

setUp(
  AuctionSimulation_round1.inject(
    nothingFor(1),
    atOnceUsers(1))
  .andThen(refreshToken.inject(atOnceUsers(1)
  ).andThen(openBids_Round.inject(nothingFor(1),
    atOnceUsers(1)).
    andThen(submitBids_round1.inject(nothingFor(1),
      atOnceUsers(1),
      rampUsers(10).during(50))).
    andThen(closeBids_Round.inject(nothingFor(1),
      atOnceUsers(1))))))
10:54
setUp(
  AuctionSimulation_round1.inject(
    nothingFor(1),
    atOnceUsers(1),
  //refreshToken.inject(atOnceUsers(1)
  ).andThen(refreshToken.inject(nothingFor(1),
    atOnceUsers(1)).
    andThen(openBids_Round.inject(nothingFor(1),
      atOnceUsers(1)).
    andThen(submitBids_round1.inject(nothingFor(1),
      atOnceUsers(1),
      rampUsers(10).during(50))).
    andThen(closeBids_Round.inject(nothingFor(1),
      atOnceUsers(1))))))

andThen means that Gatling will start injecting users in the next block once all the users of the previous block completes. So in your case, they will only start after 2 hours.

Your refreshToken scenario is supposed to run concurrently with the other scenarios, not sequentially. Delay the start of the other first scenarios for a few second to let it grab the first token.

Not sure how i can Concurrently run refreshToken scenario, I wanted other scenarios openBids, submitBids, closeBids to run sequentially, using andThen() after AuctionSimulation scanrio, and I am not sure how I can run only refreshToken scenario concurrently, Can you please advise?

setUp(
  AuctionSimulation_round1.inject(
    nothingFor(1),
    atOnceUsers(1),
refreshToken.inject(atOnceUsers(1) --->.  I tried adding here, but it is waiting for 2 hours like you mentioned.
  ).andThen(refreshToken.inject(nothingFor(1),
    atOnceUsers(1)).
    andThen(openBids_Round.inject(nothingFor(1),
      atOnceUsers(1)).
    andThen(submitBids_round1.inject(nothingFor(1),
      atOnceUsers(1),
      rampUsers(10).during(50))).
    andThen(closeBids_Round.inject(nothingFor(1),
      atOnceUsers(1))))))
setUp(
  AuctionSimulation_round1.inject(
    nothingFor(1),
    atOnceUsers(1),
  ).andThen(
     refreshToken.inject(atOnceUsers(1)),   ---> I added refresh token to run concurrently, 
      openBids_Round.inject(nothingFor(1),
    atOnceUsers(1))).
       andThen(
            submitBids_round1.inject(nothingFor(1), ---> and but submitBids needs to wait for open bids to run sequentially
              atOnceUsers(1), rampUsers(10).during(50))).
              andThen(
                  closeBids_Round.inject(nothingFor(1),
                    atOnceUsers(1)))
       )

Delay the start of the other first scenarios for a few second to let it grab the first token. → and yes, i will delay the first scenario.

setUp(
  refreshToken.inject(atOnceUsers(1)),
  AuctionSimulation_round1.inject(nothingFor(1), atOnceUsers(1))
    .andThen(openBids_Round.inject(atOnceUsers(1)))
    .andThen(submitBids_round1.inject(rampUsers(10).during(50)))
    .andThen(closeBids_Round.inject(atOnceUsers(1)))
)

For information,
@GeMi made a full implementation about such use case: Case0022SetOrRefreshTokenSimulation.

(Thank you @GeMi)

Cheers!

1 Like

@ slandelle @ sbrevet Thank you so much for your time! Much appreciated!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.