Hi ,
i have been working with Gatling for a week now.
i have created the following scenario and i am running the test from the terminal in IntelliJ IDEA.
I am able to see the console output of the POST Call but i am unable to see the GET Call during the polling.
This makes me wonder if the scenario is working as intended.
I have tried putting the log lines using exec(println(“This is a Log Line”)) but i see a error for the line where i put it.
i intend to put the log line to verify the value of varable execUID.
where can i put the line println(“execUID is “+”${execUID}” ?
val scn: ScenarioBuilder = scenario("Stress test scenario for records_included=All")
.feed(feeder.customFeeder)
.repeat(3 , "counterName" ) {
doWhile("$execState".equals("COMPLETED")) {
exec(http("Submit Alerts for Execution").post("/_execute/?wait_for_completion_seconds=0")
.body(StringBody(execution))
.check(status.is(200))
//.check(substring("COMPLETED").exists)
.check(jsonPath("$.uid").saveAs("execUID")))
.pause(1)
.exec(
polling.pollerName("Poller")
.every(10)
//.exec(http("Retrieve Execution Status").get("/_execute/"+"${execUID}"+"?wait_for_completion_seconds="+TestConfig.duration)
.exec(http("Retrieve Execution Status").get("/_execute/" + "${execUID}" + "?wait_for_completion_seconds=" + TestConfig.duration)
.check(status.is(200))
.check(jsonPath("$.state").saveAs("execState"))
.check(substring("COMPLETED").exists)))
.pause(1)
.exec(polling.pollerName("Poller").stop)
}
}
setUp(
scn.inject(atOnceUsers(TestConfig.usersFile))
).protocols(httpConf)
place the code before polling & after pause(1) to get to know the value exits or not.
.exec(session => {
println(“execUID:” + session(“execUID”).as[String])
println(session)
session.set(“temp”,“temp”)
})
If value “execUID” doesn’t exists then it would not go to GET call.
Hi Madhana ,
The log lines are printing as below. i put the same block inside the polling after the GET Call as well.
The session value cannot be accessed as ${execUID}.
how can i save the value of session(“execUID”).as[String]) in a variable and then use it within the GET Call ?
Because i can’t use session(“execUID”).as[String]) within the GET call.
.exec(http(“Retrieve Execution Status”).get("/_execute/" + session(“execUID”).as[String]) + “?wait_for_completion_seconds=” + TestConfig.duration)
hi Madhana ,
I was able to save the value in a var but still not able to invoke the GET.
why is the GET within the polling not working . Latest code with he use of var below :
var execUID = "";
val scn: ScenarioBuilder = scenario("Stress test scenario for records_included=All")
.feed(feeder.customFeeder)
.repeat(2, "counterName") {
doWhile("$execState".equals("COMPLETED")) {
exec(http("Submit Alerts for Execution").post("/_execute/?wait_for_completion_seconds=0")
.body(StringBody(execution))
.check(status.is(200))
//.check(substring("COMPLETED").exists)
.check(jsonPath("$.uid").saveAs("execUID")))
.pause(1)
.exec(session => {
execUID = session("execUID").as[String]
println("execUID ( Var ) :>>>>>>>>>>" + execUID)
//println(session)
session.set("temp","temp")
})
.exec(
//polling.pollerName("Poller")
polling.pollerName("Poller")
.every(10)
//.exec(http("Retrieve Execution Status").get("/_execute/"+"${execUID}"+"?wait_for_completion_seconds="+TestConfig.duration)
.exec(http("Retrieve Execution Status").get("/_execute/" + execUID + "?wait_for_completion_seconds=" + TestConfig.duration)
.check(status.is(200))
.check(jsonPath("$.state").saveAs("execState"))
.check(substring("COMPLETED").exists)))
.pause(1)
.exec(session => {
println("execUID:>>>>>>>>>>222" + session("execUID").as[String])
println("execUID:>>>>>>>>>>222" + "${execUID}")
println("execUID ( Var2 ) :>>>>>>>>>>" + execUID)
//println(session)
session.set("temp","temp")
})
.exec(polling.pollerName("Poller").stop)
}
}
setUp(
scn.inject(atOnceUsers(TestConfig.usersFile))
).protocols(httpConf)
you can not pass variable directly to the GET call the one you shared. instead save the value and pass as parameter.
e.g…exec(http(“Retrieve Execution Status”).get("/_execute/" + “${execUID}” + “?wait_for_completion_seconds=” + "${TestConfig.duration})
Hi Madhana ,
The commented line above the current GET call was the original implementation.
But the GAT call is not invoked. the call is working if i remove the polling.
what is wrong with this implementation.
This is my original implementation which is now commented.
The execUID varibale is saved using saveas durong the first POST call.
//.exec(http("Retrieve Execution Status").get("/_execute/"+"${execUID}"+"?wait_for_completion_seconds="+TestConfig.duration)