can't get doIf with session check to work

773 views
Skip to first unread message

enterprise.software.janitor

unread,
Apr 29, 2015, 9:16:18 AM4/29/15
to gat...@googlegroups.com
Hi Guys,

I'm extracting an Id (optional) using a regex and with a check and saving that into a session. When I try to use doIf to verify if the session key exists in order to proceed, it keeps returning false even when I enabled debug and verify my session is there. What can be doing wrong? I've tried gatling 2.1.4 and 2.1.5 and using maven plugin.

Here is the extraction

Object MyObj {
val sc
= sncenario("MyScenario")
  http
("getsomeids")
 
.get("www.mysite.com")
 
.check(regex("myregexhere").optional.saveAs("myId"))
 
}

Here is the check

class mySimulation extends Simulation {

    val myscn = scenario("MyScenario")
            .exec(MyObj.sc)
            .pause(3)
            doIf(_.contains("myId")){
            exec(http("anotherRequest")
            .get("www.mysite.com/anotherpage")
        }
}


This always returns false even though I enable logging (logback-test.xml) and I can see myId and it's value (myId -> 123). I've also tried many other different ways.

doIf(session => session.contains("myId")){
 exec(...)
}


doIf(session => session("myId").as[String].length > 0 ){
 exec(...)
}

Any ideas what I could be doing wrong?


Thanks!

Pierre DAL-PRA

unread,
Apr 29, 2015, 9:18:56 AM4/29/15
to gat...@googlegroups.com
Missing dot before doIf: the part of your scenario which set myId in the session does not get executed :)
Simply add a dot before doIf and it should work.

Cheers,

Pierre

--
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/d/optout.

enterprise.software.janitor

unread,
Apr 29, 2015, 9:38:27 AM4/29/15
to gat...@googlegroups.com
Wow. Can't believe I overlooked that and kept scratching my head.

Thanks much for fast reply!
Reply all
Reply to author
Forward
0 new messages