我想在以下情形中添加一個條件。
我想從方案退出if(counter=8 or WorkflowStatus=true)
添加每個http請求都會增加的計數器
有誰知道如何添加這將增加8後高達8次,每次請求,並退出計數器,以及上述條件下,如果要求得到WorkflowStatus = true,則退出在下面的情況?
讓我知道你是否需要更多的澄清。 謝謝。
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)
}
就實現了這個,.asLongAs(會話=>會話重用此。屬性(「WorkflowStatus」)!=「false」&& count.getAndIncrement()<8){...}它工作。 – Peter
如何讓這些請求失敗?像, 我有以下代碼中的3個條件, 1.如果請求Count> 8,則退出循環 2.如果WorkflowStatus == False,則退出循環 3.如果WorkflowFailed == True,則退出循環 在上述任何情況下,有許多請求失敗的機會,例如,如果在觸發請求8次後WorkflowStatus未獲得「真」,那麼該請求應失敗。但不是顯示失敗計數顯示成功計數。 如何計算並顯示在上述條件下失敗的失敗請求 – Peter