I am trying to write gatling performance test where I am using the before and after blocks of the Gatling Simulation to make one-time HTTP post
Based on this - Gatling DSL doesn't work inside hooks. I wish there was a warning or something to not waste time on that.
I had to perform the actual POST request without using Gatling DSL as below.
def CallStop(consumerConfig : ConsumerConfig, stopEndpoint : String ) = {
val jsonBody = consumerConfig.asJson
val valuedJsonBody = Printer.noSpaces.copy(dropNullValues = true).print(jsonBody)
println(valuedJsonBody)
println("stopEndpoint:" + stopEndpoint)
val post = new HttpPost(stopEndpoint)
post.setHeader("Content-type", "application/json")
post.setEntity(new StringEntity(valuedJsonBody))
// send the post request
val client = new DefaultHttpClient
val response = client.execute(post)
println("Response:" + response)
}