Repeat the scenario with multiple exec actions

Hi,

I am trying to get a token through http rest calls, which i have written as a scenario. The scenario is as below.

val RenewToken = scenario("Renew Token before expiry")
  //Generating token
  .repeat(5)
{exec(http("Renew Token")
  .get("token")
  .basicAuth(cdapusername,cdappassword)
  .check(jsonPath("$.access_token").saveAs("token")))}
    //.repeat(5)
    .exec(session=> {
        token = session("token").as[String]
        println(token)
        session}).pause(30 seconds)

 setUp(
 
        
                RenewToken.inject(atOnceUsers(1)).protocols(httpConfss)

)

I want to repeat the scenario RenewToken as many times as i want with a pause of 30 seconds and both the exec has to be repeated every time. Can somebody suggest on how i can do that? is there a way from setup i can repeat the scenario with regular intervals of time?

Thanks,
Rohini 

Hi,

group your exec’s in repeat block like repeat(5){
//exec code goes here

.pause(30 seconds) //this will pause for 30 seconds.after 30 seconds,your scenario will run again.
}

example:

val RenewToken = scenario(“Renew Token before expiry”)
//Generating token
repeat(5){
{exec(http(“Renew Token”)
.get(“token”)
.basicAuth(cdapusername,cdappassword)
.check(jsonPath(“$.access_token”).saveAs(“token”)))}

  • hide quoted text -
    .exec(session=> {
    token = session(“token”).as[String]
    println(token)
    session}).pause(30 seconds)
    }
    setUp(
    RenewToken.inject(atOnceUsers(1)).protocols(httpConfss)
    )