aslongas http response not OK

55 views
Skip to first unread message

michael...@hellosign.com

unread,
Jun 15, 2018, 7:40:26 PM6/15/18
to Gatling User Group
Hello Group,

I'm trying to do an aslongas check that seems like it should be pretty simple, but it doesn't seem to be working for me.  Here's the gist:

class Demo extends Simulation
{
  setUp(
    scenario("Demo Start")
      .exec(_.set("rs", "0"))
      .exec(_.set("workflowGuid", "D1O5KIBJo4BEB1Kt"))
      .exec(Test.printSession)
      .exec(Test.checkCallback)
      .exec(Test.printSession)
      .inject( atOnceUsers(1) )
  )
}

object Test {
  val checkCallback: ChainBuilder = asLongAs(session => session("i").as[Int] < 10 && session("rs").as[String] != "200", "i") {
    exec(
      http("Look for callbacks")
        .get(Constants.callbackUrl + "?workflow_id=${workflowGuid}")
        .check(status.saveAs("rs"))
    )
  }
  val printSession: ChainBuilder = exec(session => {
    session.foreach(print)
    session
  })
}

That outputs:
Session(Demo Start,1,Map(gatling.http.cache.dns -> io.gatling.http.resolver.ShuffleJdkNameResolver@1f9ea9a7, rs -> 0, workflowGuid -> D1O5KIBJo4BEB1Kt),1529105538251,0,OK,List(),io.gatling.core.protocol.ProtocolComponentsRegistry$$Lambda$380/848102479@671ea959)16:32:18.353 [INFO ] i.g.c.c.Controller - InjectionStopped expectedCount=1
Session(Demo Start,1,Map(gatling.http.cache.dns -> io.gatling.http.resolver.ShuffleJdkNameResolver@1f9ea9a7, rs -> 200, workflowGuid -> D1O5KIBJo4BEB1Kt),1529105538251,40,OK,List(),io.gatling.core.protocol.ProtocolComponentsRegistry$$Lambda$380/848102479@671ea959)16:32:20.340 [INFO ] i.g.c.c.Controller - All users are stopped

================================================================================
2018-06-15 16:32:20                                           3s elapsed
---- Requests ------------------------------------------------------------------
> Global                                                   (OK=10     KO=0     )
> Look for callbacks                                       (OK=10     KO=0     )

---- Demo Start ----------------------------------------------------------------

As you can see, the value is initially zero, then 200, but it executes 10 times.  I know that I'm getting a 200 the first time I call it in this scenario but it doesn't exit the loop as expected.

I'm using gatling version 2.3.0.

Thanks in advance!



Vu Nguyen

unread,
Jun 16, 2018, 7:30:33 PM6/16/18
to Gatling User Group
Message has been deleted

michael...@hellosign.com

unread,
Jun 18, 2018, 11:14:34 AM6/18/18
to Gatling User Group

Hi Vu,
Thanks for your reply.  changed to string comparison, exactly the same effect:

  val checkCallback: ChainBuilder = asLongAs(session => session("i").as[Int] < 10 && session("rs").as[String] != "200", "i") {

I also enabled trace logging and have verified that the very first request is returning 200 and yet request it made 10 times:

Request:
Look for callbacks: OK 
=========================
Session:
Session(Demo Start,1,Map(gatling.http.cache.dns -> io.gatling.http.resolver.ShuffleJdkNameResolver@4137634e, rs -> 200, workflowGuid -> D1O5KIBJo4BEB1Kt, i -> 1),1529334171391,40,OK,List(ExitOnCompleteLoopBlock(i)),io.gatling.core.protocol.ProtocolComponentsRegistry$$Lambda$379/721395199@1aa94fb5)
=========================
HTTP request:
headers=
Accept: */*
=========================
HTTP response:
status=
200 OK

I have also tried adding exitAsap = true, same result.

Stéphane LANDELLE

unread,
Jun 18, 2018, 11:18:56 AM6/18/18
to gat...@googlegroups.com
Status code is an INT!!!

Stéphane Landelle
GatlingCorp CEO


--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

michael...@hellosign.com

unread,
Jun 18, 2018, 11:51:58 AM6/18/18
to Gatling User Group
Oop, misread.  I actually did try that initially:
session("rs").as[Int] != 200
But that throws an exception:
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.

michael...@hellosign.com

unread,
Jun 18, 2018, 12:19:48 PM6/18/18
to Gatling User Group
Ah hah!  I was initializing it as a string!  

Thanks for your help, works as expected!
Reply all
Reply to author
Forward
0 new messages