Retry a request with increasing pause

1183 views
Skip to first unread message

Jean-Baptiste Reich

unread,
Jun 4, 2013, 7:09:29 AM6/4/13
to gat...@googlegroups.com
Hello,

I am trying to achieve the following behavior:
Send a request
If failed, pause 500 ms and retry 
If failed, pause 1 s and retry
If failed, pause 2 s and retry
...
If failed 8 times, exit user

I don' t know if it is a good way to implement that but I tried

val myReq = exec(http("MyReq")
    .post("/badPath}")
    .check(status.is(200)))
...
.exec(session => session.set("retryPause" -> (0 millisecond)))
.tryMax(8) {
  pause(session => session("retryPause").asOption[Duration].getOrElse(0 millisecond).success)
  .exec(session => session.set("retryPause", 2 * session("retryPause").asOption[Duration].getOrElse(0 millisecond)))
  .exec(myReq) }.exitHereIfFailed

I had some problems with tryMax using gatling-2.0.0-M2 so I tried gatling-2.0.0-SNAPSHOT (master)  because I saw some modifications in TryMax history. But with last version I have no retry and even if my request fails with a 501 the user is not stopped by .exitHereIfFailed

Is my code working ? Is there a better way to achieve my goal ?


Thank you

Stéphane Landelle

unread,
Jun 4, 2013, 10:48:06 AM6/4/13
to gat...@googlegroups.com
A bug indeed, stay tuned!


2013/6/4 Jean-Baptiste Reich <jeanbapti...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Stéphane Landelle

unread,
Jun 4, 2013, 11:22:51 AM6/4/13
to gat...@googlegroups.com
Fixed.

There's a much more simple way:

def computePause(loopIndex: Int): Duration = ???


tryMax(8, "loopIndex") {

pause(session => computePause(session("loopIndex").as[Int]))

....
}

Got it?


2013/6/4 Stéphane Landelle <slan...@excilys.com>

Jean-Baptiste Reich

unread,
Jun 4, 2013, 11:28:03 AM6/4/13
to gat...@googlegroups.com
Yes !

Thank you for the example it is easier indeed ! I will try this as soon as possible


2013/6/4 Stéphane Landelle <slan...@excilys.com>

Jean-Baptiste Reich

unread,
Jun 5, 2013, 6:19:09 AM6/5/13
to gat...@googlegroups.com
I confirm that it works !

Thanks a lot :-)


2013/6/4 Jean-Baptiste Reich <jeanbapti...@gmail.com>

Stéphane Landelle

unread,
Jun 5, 2013, 9:27:02 AM6/5/13
to gat...@googlegroups.com
Thanks for your feedback and your testing.


2013/6/5 Jean-Baptiste Reich <jeanbapti...@gmail.com>
Reply all
Reply to author
Forward
0 new messages