I want to add condition on http request. like this scenario,
using API,
-
I have one action from where I find ‘Action ID’
-
That ‘Action Id’ returns ‘true/false’ which means that action which is ‘Running/Not running’ and save it in variable
I did this this two steps, Now I want to do
3. I have to check status on condition every 15 minutes if status is ‘true’ (Running) wait for 15 minutes, re-check status every 15 minutes if status = ‘false’ then exit oR exit after 2 Hours automatically (evenif status is ‘true’)
Want to put condition like this,
`
Check status = true
{
pause for 15minutes
request once again after 15minutes
if(status = false)
{
exit
}
else
{
request once again and check status, if true wait for 15minutes
If total waiting time is more than 2 hours then exit
}
}
else
{
exit
}
`
below is the code snippet what I did,
`
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class LaunchResources extends Simulation {
val scenarioRepeatCount = Integer.getInteger(“scenarioRepeatCount”, 1).toInt
val userCount = Integer.getInteger(“userCount”, 1).toInt
val UUID = System.getProperty(“UUID”, “24d0e03”)
val username = System.getProperty(“username”, “p1”)
val password = System.getProperty(“password”, “P12”)
val testServerUrl = System.getProperty(“testServerUrl”, “https://someurl.net”)
val httpProtocol = http
.baseURL(testServerUrl)
.basicAuth(username, password)
.connection(""“keep-alive”"")
.contentTypeHeader(""“application/vnd+json”"")
val headers_0 = Map(
“”“Cache-Control”"" → “”“no-cache”"",
“”“Origin”"" → “”“chrome-extension://fdmmgasdw1dojojpjoooidkmcomcm”"")
val scn = scenario(“LaunchAction”)
.repeat (scenarioRepeatCount) {
exec(http(“LaunchAResources”)
.post( “”"/api/actions""")
.headers(headers_0)
.body(StringBody(s"""{“UUID”: “$UUID”, “stringVariables” : {“externalFilePath” : “/Test.mp4”}}"""))
.check(jsonPath("$.id").saveAs(“WorkflowID”)))
.exec(http(“SaveWorkflowStatus”)
.get("""/api/actions/{$WorkflowID}""")
.headers(headers_0)
.check(jsonPath("$.status").saveAs(“WorkflowStatus”)))
}
setUp(scn.inject(atOnceUsers(userCount))).protocols(httpProtocol)
}
`
Let me know if you need more info. Thanks.