status.find.is(200), but actually found 200

75 views
Skip to first unread message

Luis Pugoy

unread,
Dec 5, 2017, 2:07:16 AM12/5/17
to Gatling User Group
I have a csv file that contains the URL and the expected status for the URL. Code is below.

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._

class MySimulation extends Simulation {

  object Request {

    val request = exec(http("Test")
          .get("${URL}")
          .check(status.is(session => session("status").as[Int])))
  }

  val httpConf = http.baseURL("https://test.com")

  val records = csv("data.csv").records

  val users = scenario("Users")
    .foreach(records, "record") {
      exec(flattenMapIntoAttributes("${record}"))
      .exec(Request.request)
    }

  setUp(users.inject(atOnceUsers(1)))
    .protocols(httpConf)
}

When running the simulation I get the message shown in the subject line. It is actually shown for all expected status, like if the test expects 401 then the message would be status.find.is(401), but actually found 401.

Thanks for the help.

MP

unread,
Dec 5, 2017, 6:58:19 AM12/5/17
to Gatling User Group
try with .check(status.is(200)

Luis Pugoy

unread,
Dec 5, 2017, 7:20:46 AM12/5/17
to gat...@googlegroups.com
I want to check if the returned status is the same as the expected status in the CSV file. Like for example for /foo the expected status is 200 while for /bar the expected status is 401.

On Tue, Dec 5, 2017 at 10:58 PM, MP <polya.mi...@softwaregroup.com> wrote:
try with .check(status.is(200)

--
You received this message because you are subscribed to a topic in the Google Groups "Gatling User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gatling/5bIEPSM1zzw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gatling+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stéphane LANDELLE

unread,
Dec 5, 2017, 7:33:10 AM12/5/17
to gat...@googlegroups.com
See https://github.com/gatling/gatling/issues/3395 fro explanation on what you're doing wrong.

Stéphane Landelle
GatlingCorp CEO


On Tue, Dec 5, 2017 at 1:20 PM, Luis Pugoy <lui...@gmail.com> wrote:
I want to check if the returned status is the same as the expected status in the CSV file. Like for example for /foo the expected status is 200 while for /bar the expected status is 401.

On Tue, Dec 5, 2017 at 10:58 PM, MP <polya.mislyashka@softwaregroup.com> wrote:
try with .check(status.is(200)

--
You received this message because you are subscribed to a topic in the Google Groups "Gatling User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gatling/5bIEPSM1zzw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gatling+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
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.

Luis Pugoy

unread,
Dec 5, 2017, 7:45:02 AM12/5/17
to gat...@googlegroups.com
Cool, thanks. Do you know of a possible workaround for now? Also, wouldn't as[Int] return an Int? I confess I know very little of Scala.

Luis Pugoy

unread,
Dec 5, 2017, 5:50:13 PM12/5/17
to gat...@googlegroups.com
Changing .check(status.is(...)) to
.check(status.is(session => Integer.parseInt(session("status").as[String]))) worked.
Reply all
Reply to author
Forward
0 new messages