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

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.

try with .check(status.is(200)

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.

See https://github.com/gatling/gatling/issues/3395 fro explanation on what you’re doing wrong.

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.

Changing .check(status.is(…)) to

.check([status.is](http://status.is)(session => Integer.parseInt(session("status").as[String]))) worked.