Advertisement
Guest User

Untitled

a guest
Oct 6th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. class LaunchResources extends Simulation {
  2.  
  3. val scenarioRepeatCount = Integer.getInteger("scenarioRepeatCount", 1).toInt
  4. val userCount = Integer.getInteger("userCount", 1).toInt
  5. val UUID = System.getProperty("UUID", "24d0e03")
  6. val username = System.getProperty("username", "p1")
  7. val password = System.getProperty("password", "P12")
  8. val testServerUrl = System.getProperty("testServerUrl", "https://someurl.net")
  9. val count = new java.util.concurrent.atomic.AtomicInteger(0)
  10.  
  11. val httpProtocol = http
  12. .baseURL(testServerUrl)
  13. .basicAuth(username, password)
  14. .connection("""keep-alive""")
  15. .contentTypeHeader("""application/vnd+json""")
  16.  
  17.  
  18. val headers_0 = Map(
  19. """Cache-Control""" -> """no-cache""",
  20. """Origin""" -> """chrome-extension://fdmmgasdw1dojojpjoooidkmcomcm""")
  21.  
  22.  
  23. val scn = scenario("LaunchAction")
  24. .repeat (scenarioRepeatCount) {
  25. exec(http("LaunchAResources")
  26. .post( """/api/actions""")
  27. .headers(headers_0)
  28. .body(StringBody(s"""{"UUID": "$UUID", "stringVariables" : {"externalFilePath" : "/Test.mp4"}}"""))
  29. .check(jsonPath("$.id").saveAs("WorkflowID")))
  30.  
  31. .exec(http("SaveWorkflowStatus")
  32. .get("""/api/actions/{$WorkflowID}""")
  33. .headers(headers_0)
  34. .check(jsonPath("$.status").saveAs("WorkflowStatus")))
  35.  
  36. }
  37.  
  38.  
  39. .asLongAs(session => session.attributes("WorkflowStatus") != "false" && count.getAndIncrement() < 8) {
  40. doIf(session => session("WorkflowFailed").validate[String].map(WorkflowFailed => !WorkflowFailed.contains("true")).recover(true))
  41. {
  42. pause(pauseTime)
  43. .exec(http("SaveWorkflowStatus")
  44. .get("""/api/actions/${WorkflowID}""")
  45. .headers(headers_0)
  46. .check(jsonPath("$.running").saveAs("WorkflowStatus"))
  47. .check(jsonPath("$.failed").saveAs("WorkflowFailed")))
  48.  
  49. .exec(session => {
  50. val wflowStatus1 = session.get("WorkflowStatus").asOption[String]
  51. val wflowFailed1 = session.get("WorkflowFailed").asOption[String]
  52. println("Inner Loop Workflow Status: ========>>>>>>>> " + wflowStatus1.getOrElse("COULD NOT FIND STATUS"))
  53. println("Inner Loop Workflow Failed?? ========>>>>>>>> " + wflowFailed1.getOrElse("COULD NOT FIND STATUS"))
  54. println("Count =====>> " + count)
  55. session})
  56.  
  57. }
  58. }
  59.  
  60. setUp(scn.inject(atOnceUsers(userCount))).protocols(httpProtocol)
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement