I am trying to call a custom function to generate a map of headers, then use that map to pass to the http.headers() function. However, while attempting this in the body of an exec method, the test runs, but doesn’t execute the actual GET call.
Perhaps there is a better what to do this altogether. Thanks in advance for any help.
`
class RecordedSimulation extends Simulation {
val httpProtocol = http
.inferHtmlResources()
.acceptEncodingHeader(“gzip, identity”)
.connection(“Keep-Alive, TE”)
.contentTypeHeader(“application/json”)
.userAgentHeader(“Gatling”)
val director = “http://google.com”
var feeder = Iterator.continually(Map(“deviceId” → CreateDeviceId()))
val scn = scenario(“RecordedSimulation”)
.feed(feeder)
.exec(session =>
{
val headers = CreateHeader(“test”, session(“deviceId”).as[String])
http(“Director”)
.get(director)
.headers(headers)
.check(status.is(200))
.check(jsonPath("$.serverUrl").saveAs(“serverUrl”))
session
})
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}
`
CreateHeader is from an imported class ( if it matters ):
`
def CreateHeader(time : String, deviceId : String): Map[String, String] = {
val headers = Map(
“TE” → “identity”,
“deviceId” → deviceId,
“time” → time,
“token” → GetTokenHeaderValue(time, deviceId))
return headers;
}
`
Test results: ( i have tracing enabled in logback config )
GATLING_HOME is set to /usr/local/gatling/2.1.4
Simulation xxx.RecordedSimulation started…
Creds: 4833b584-3098-4486-868f-d8a49e8b50e5:test