How to fail the requests in gatling that has status FAILURE in its response XML


I am posting a soap request in gatling. Gatling Request is as below

package com.flexera.lfsperformance.scenarios

import io.gatling.core.Predef._
import io.gatling.http.Predef._

class DeleteRequest extends Simulation {

 val httpProtocol = http
  .userAgentHeader("Apache-HttpClient/4.1.1 (java 1.5)")

 val headers_0 = Map(
  "Proxy-Connection" -> "Keep-Alive",
  "SOAPAction" -> """""""")

 val clientIdFeeder = Iterator.from(1).map(i => Map("id" -> "%03d".format(i)))

 val scn = scenario("DELETE_REQUEST")
   .repeat(10 ) {
     .post("/ / / /")
     .basicAuth("username", "Password"))


**Soap body is :**

 <soapenv:Envelope xmlns:soapenv="" xmlns:urn="">
         <!--1 or more repetitions:-->

**The actual response we receive is :**

HTTP/1.1 200 OK
Expires: 0
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Set-Cookie: JSESSIONID=wC2WtCaN9GITVdC3AE4sSFuZ.localhost; path=/flexnet; HttpOnly
Server: jboss
X-XSS-Protection: 1; mode=block
Pragma: no-cache
X-Frame-Options: SAMEORIGIN
Connection: keep-alive
X-Content-Type-Options: nosniff
Transfer-Encoding: chunked
Content-Type: text/xml;charset=utf-8 

<soapenv:Envelope xmlns:soapenv=“” xmlns:xsd=“XML Schema” xmlns:xsi=“”>

      <deleteDeviceResponse xmlns="">
               <reason>**LFSError_HOST_NOT_FOUND:  Unable to find CLIENT host with unique keys [hostId=FNO1], [hostIdType=STRING], and [publisherName=fnetest] in tenant ADMN**.</reason>

The actual response is FAILURE but, according to gatling since the status code is 200 OK all the requests are pass(OK). (Attached the gatling simulation graph)

Is there any way I can fail(KO) all the requets that has FAILURE in its response?  

Please put a regular expression check for your valid response which when found the request passes otherwise it will fail(KO).

The other option you can use is ignoreDefaultChecks which checks for a status 200 and passes your request.

Thanks for the solution Manjunath. It worked.

I have another query.

Is there any way we can write the for FAILURE into simulation.log file.

I am not sure how we can write this to simulation.log but you could write this to the console log and parse as per your necessity. To write the log to console you just need to add this to your logback.xml under tyhe logger section. You also could redirect this console log to a file if needed. hope this helps

<appender-ref ref="CONSOLE"/>

Yes, I had found the solution to write into a different file (Like the one you suggested). But, I was wondering if there could be any way we can append messages to simultion.log file. Apparently, I found from other websites that, writing into simultion.log file is not possible as it is is a private API and they haven’t made it public.

Thank you

Yes, that would be indie the gatling framework and default. Maybe that is reason you could not append to simulation directly.