Repeat the scenario with multiple exec actions

455 views
Skip to first unread message

Rohini Vasu

unread,
Mar 21, 2017, 10:47:44 AM3/21/17
to Gatling User Group
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
Message has been deleted
Message has been deleted

slvyr

unread,
Mar 21, 2017, 5:17:12 PM3/21/17
to Gatling User Group
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)
)
Reply all
Reply to author
Forward
0 new messages