force check result to "KO"

Hi,

I guess a simple(?) question:

the response check in below post will always succeed, i.e. session result “OK”, as any webServiceError value string ending with “}” will be accepted.
But if I want to set result “KO” if “webServiceError” != “null” - how can it be implemented??

OK: “webServiceError”:null}
KO: “webServiceError”:{"some application error description… "}

.exec(http(“scn008_request_8”)
.post("""/xxxxxx/xxxxxx/xxxxxx""")
.headers(headers_1)
.body(ELFileBody(“scn003_request_8.txt”))
.check(regex("""“webServiceError”:(.*(?=}))""")
.find.saveAs(“webServiceError”)))

rgds Juha

…some additional info:

tried also following, but didn’t seem to bite, not sure what this .markAsFailed really does, couldn’t find much by googling.

.doIf(session => session(“webServiceError”).as[String] != “null”) {exec(chain_applerror).exec(session => session.markAsFailed)}

/rgds Juha

Still haven’t found any workaround on this issue… anybody?

Running 2.0.0-M3a.

/rgds Juha

You’d have to do that in the check.

2M3a: matchWith: https://github.com/excilys/gatling/blob/2.0.0-M3X/gatling-core/src/main/scala/io/gatling/core/check/CheckBuilder.scala#L54
master: validate(Validator): https://github.com/excilys/gatling/blob/master/gatling-core/src/main/scala/io/gatling/core/check/CheckBuilder.scala#L102

Thanks for your comments Stephane.

I had a look at the links you provided: I’m afraid it’s a bit out of my league to modify/implement this thing (changing “OK” to “KO” in a session, after additional value checks).
I can live with current situation, and just generate session data printout whenever a specific response value is considered as faulty.

Still, wondering what is the true purpose and functionality of exec(session => session.markAsFailed).
If a session actually can be set to “failed” like this - why is it recorded as “OK” in stats? I can see clear use of this feature if the session result would change to “KO” as well.
But I’m still a newbe here, and have this awkward feeling that I’m misunderstanding something here…?

rgds Juha

Thanks for your comments Stephane.

I had a look at the links you provided: I'm afraid it's a bit out of my
league to modify/implement this thing (changing "OK" to "KO" in a session,
after additional value checks).
I can live with current situation, and just generate session data printout
whenever a specific response value is considered as faulty.

Implementing this will be easier with upcoming version/current snapshot.

Still, wondering what is the true purpose and functionality of exec(session
=> session.markAsFailed).
If a session actually can be set to "failed" like this - why is it
recorded as "OK" in stats? I can see clear use of this feature if the
session result would change to "KO" as well.
But I'm still a newbe here, and have this awkward feeling that I'm
misunderstanding something here...?

markAsFailed is what's being used to control exitHereIfFailed:

failing checks set markAsFailed, not the other way around.