Hi All,
I am creating a data mart and polling for its status till it is complete easily enough in JAVA but find it challenging in Gatling. Following is my code so far:
- val scn = scenario(scenarioName = “Materialization”)
- // .exec(session => {session.set(“status”, “”); session})
- .exec(http(requestName = “Initiate”)
- .post(baseurl+"/materialize/datamart/initiate")
- .headers()
- .body(StringBody("""{"…}"""))
- .basicAuth("","")
- .check(jsonPath("$.martRequestId").saveAs(“martID”)))
- .asLongAs(session => session(“status”).asOption[String] != “CMPLT”) {
- (exec(http(requestName = “Wait for completion of materialization”)
- .post(baseurl + “/services/statuses”)
- .headers(headers_API_Diver_G)
- .body(StringBody("""{“martRequestIds”: ["${martID}"],“bulkRequestIds”: []}"""))
- .basicAuth("", “”)
- .check(jsonPath("$.martRequestStatuses[*].statusCode").saveAs(“status”)))
- .exec(session=> {
- println(“Status:” + session(“status”).as[String])
- val newSession = session.set(“status”,"${status}")
- newSession
- })
- .pause(10))
- }
The outputs I get from the println in the last exec block are all the status transitions, including CMPLT. This means that the session variable has been updated successfully but the loop still does not terminate, because the session condition is not satisfied somehow.
Kindly advise on how I can fix this.
Thanks,
Hasan