I am really new at Gatling so please don’t crucify me. I am tried to read thorough the wiki docs. I am using gatling 2.
I am just trying to test and application that sends 3 posts after I do a get. After each post more and more data is returned. I can’t tell that if once the application is under a lot of load if the application will only send 3 posts. I assume it will keep sending them as long as it need to collect the data.
I am trying to run a report and there is an ajax call that happens. So I noticed that every 30 seconds there is a new post that is returned.
Therefore, what I want to do is keep executing the post until I find the word “test” in the body of the post.
Is something like this possible with Gatling?
.doWhile("${myvalue}" does not contain “test”) {
exec(http(“Post”))
once I find “test” exit loop
}
@Stéphane Thank you so much for your help. I had to make a small change. Instead of: .asLongAs(session => session(“myvalue”).asOption[String].map(myValue => !myValue.contains(“test”)).getOrElse(true)) { I had to use: .asLongAs(session => session(“myvalue”).asOption[String].map(myValue => !myValue.contains(“test”)).getOrElseBoolean) { I was getting a compilation error. It works as expected. @Floris Nice one indeed!
We’re reaching the limits of the Scala compiler type inference here.
The reason is that asLongAs actually expects a Session => Validation[Boolean], not a Session => Boolean.
There’s an implicit converting from Foo to Validation[Foo], but the compiler doesn’t seem to be able to revolve this implicit AND infer the getOrElse type parameter.
With current snapshot, you could write:
.asLongAs(session => session(“myvalue”).validate[String].map(myvalue => !myvalue.contains(“test”)).recover(true)) {