Home > database >  Gatling EL not getting replaced in ElFileBody
Gatling EL not getting replaced in ElFileBody

Time:05-04

I'm very new to gatling performance test and i'm trying to write one simulation for our service. I'm using gatling 3.7.6 version.

I have below request json for my post http method;

{
  "id": "${id}",
  "party": "${party}"
}

below is the feeder data from csv

id,party
 ID333,MC

Below is my simulation class

val data: BatchableFeederBuilder[String] = csv("data/myData.csv").circular


  val scenario: ScenarioBuilder = scenario("my-API")
    .feed(data)
    .exec(Helper.formRequest("apiname", url, "request/request.json", "myResponse"))


  setUp(/*standard setup call */)

Helper look like below

def formRequest(apiName: String, url:String, requestJson: String, response: String): ChainBuilder = {
    println("....Executing api call....");
    toDefaultChainBuilder({
      createPrivateAuthPlusPostReqBuilderFromSession(apiName, url)
        .body(ElFileBody(requestJson)).asJson
        .check(status.is(200),(regex(".*\"errors\".*").notExists))
        .check(bodyString.saveAs(response)) // captures the response body of this request and saves it in session as response
    })
  }
    .exec(session => {
      println("=========================START " apiName " POSTMethod Response=====================================")
      val responseBody = session(response).as[String];
      println("Response ------------>"  responseBody);
      println("\n=========================END " apiName " POSTMethod Response=====================================")
      session;
    })

createPrivateAuthPlusPostReqBuilderFromSession look like below

http(apiName).post(postUrl).header("identifier", "sample_" Util.randomString())

In above, everything is working fine but out of 2 EL expression id and party only party get resolved and replaced while id don't get resolved at all.

Any one know why its happening ?

CodePudding user response:

It means the key in the Gatling EL String and the column header in your feeder file don't match.

Check for any typo or extra non-printable character (use a hex editor) in your feeder file and your template file. My bet is a non-printable char in the CV header line.

Note: since Gatling 3.7, the recommended Gatling EL syntax is #{}, not ${}.

  • Related