|
12 | 12 |
|
13 | 13 | @Tag("e2e")
|
14 | 14 | public class EndToEndTests {
|
15 |
| - private static final String hostHealthPingPath = "/admin/host/ping"; |
16 |
| - private static final String startOrchestrationPath = "/api/StartOrchestration"; |
17 |
| - private static final String approvalWorkFlow = "/api/ApprovalWorkflowOrchestration"; |
18 |
| - private static final String rewindInstance = "/api/RewindInstance"; |
| 15 | + private static final String hostHealthPingUrl = "/admin/host/ping"; |
| 16 | + private static final String startOrchestrationUrl = "/api/StartOrchestration"; |
| 17 | + private static final String startApprovalWorkflowUrl = "/api/ApprovalWorkflowOrchestration"; |
| 18 | + private static final String rewindInstanceFunctionUrl = "/api/RewindInstance"; |
| 19 | + private static final String resetApprovalUrl = "/api/ResetApprovalFlag"; |
19 | 20 |
|
20 | 21 | @Order(1)
|
21 | 22 | @Test
|
22 | 23 | public void setupHost() {
|
23 |
| - post(hostHealthPingPath).then().statusCode(200); |
| 24 | + post(hostHealthPingUrl).then().statusCode(200); |
24 | 25 | }
|
25 | 26 |
|
26 | 27 | @Test
|
27 | 28 | public void basicChain() throws InterruptedException {
|
28 |
| - Response response = post(startOrchestrationPath); |
29 |
| - JsonPath jsonPath = response.jsonPath(); |
30 |
| - String statusQueryGetUri = jsonPath.get("statusQueryGetUri"); |
31 |
| - String runTimeStatus = null; |
| 29 | + Response response = post(startOrchestrationUrl); |
| 30 | + JsonPath startOrchestrationResponseJson = response.jsonPath(); |
| 31 | + String statusQueryGetUri = startOrchestrationResponseJson.get("statusQueryGetUri"); |
| 32 | + String runtimeStatus = null; |
32 | 33 | for (int i = 0; i < 15; i++) {
|
33 | 34 | Response statusResponse = get(statusQueryGetUri);
|
34 |
| - runTimeStatus = statusResponse.jsonPath().get("runtimeStatus"); |
35 |
| - if (!"Completed".equals(runTimeStatus)) { |
| 35 | + runtimeStatus = statusResponse.jsonPath().get("runtimeStatus"); |
| 36 | + if (!"Completed".equals(runtimeStatus)) { |
36 | 37 | Thread.sleep(1000);
|
37 | 38 | } else break;
|
38 | 39 | }
|
39 |
| - assertEquals("Completed", runTimeStatus); |
| 40 | + assertEquals("Completed", runtimeStatus); |
40 | 41 | }
|
41 | 42 |
|
42 | 43 | @Order(2)
|
43 | 44 | @Test
|
44 |
| - public void testRewindInstanceAPI() throws InterruptedException { |
45 |
| - Response response = post(approvalWorkFlow); |
46 |
| - JsonPath rewindTestJsonPath = response.jsonPath(); |
| 45 | + public void testRewindInstanceJavaAPI() throws InterruptedException { |
| 46 | + Response response = post(startApprovalWorkflowUrl); |
| 47 | + JsonPath startOrchestrationResponseJson = response.jsonPath(); |
47 | 48 |
|
48 | 49 | // Wait for the ApprovalWorkflowOrchestration to fail
|
49 | 50 | Thread.sleep(3000);
|
50 | 51 |
|
51 |
| - String instanceId = rewindTestJsonPath.get("id"); |
52 |
| - String statusQueryGetUri = rewindTestJsonPath.get("statusQueryGetUri"); |
| 52 | + String instanceId = startOrchestrationResponseJson.get("id"); |
| 53 | + String statusQueryGetUri = startOrchestrationResponseJson.get("statusQueryGetUri"); |
53 | 54 | Response statusResponse = get(statusQueryGetUri);
|
54 |
| - String runTimeStatus = statusResponse.jsonPath().get("runtimeStatus"); |
55 |
| - assertEquals("Failed", runTimeStatus); |
| 55 | + String runtimeStatus = statusResponse.jsonPath().get("runtimeStatus"); |
| 56 | + assertEquals("Failed", runtimeStatus); |
56 | 57 |
|
57 |
| - // Rewind the instance |
58 |
| - String rewindPostUri = rewindInstance + "?instanceId=" + instanceId; |
59 |
| - response = post(rewindPostUri); |
| 58 | + // Rewind the instance using Java API |
| 59 | + String rewindInstanceUrl = rewindInstanceFunctionUrl + "?instanceId=" + instanceId; |
| 60 | + response = post(rewindInstanceUrl); |
60 | 61 | assertEquals("Failed orchestration instance is scheduled for rewind.", response.toString());
|
61 | 62 |
|
62 | 63 | // Wait for orchestration to rewind and complete
|
63 | 64 | Thread.sleep(3000);
|
64 | 65 |
|
65 | 66 | for (int i = 0; i < 5; i++) {
|
66 | 67 | statusResponse = get(statusQueryGetUri);
|
67 |
| - runTimeStatus = statusResponse.jsonPath().get("runtimeStatus"); |
68 |
| - if (!"Completed".equals(runTimeStatus)) { |
| 68 | + runtimeStatus = statusResponse.jsonPath().get("runtimeStatus"); |
| 69 | + if (!"Completed".equals(runtimeStatus)) { |
69 | 70 | Thread.sleep(1000);
|
70 | 71 | } else break;
|
71 | 72 | }
|
72 |
| - assertEquals("Completed", runTimeStatus); |
| 73 | + assertEquals("Completed", runtimeStatus); |
| 74 | + |
| 75 | + // Reset approval for other test cases |
| 76 | + post(resetApprovalUrl); |
| 77 | + } |
| 78 | + |
| 79 | + @Order(3) |
| 80 | + @Test |
| 81 | + public void testRewindInstanceHttpAPI() throws InterruptedException { |
| 82 | + Response response = post(startApprovalWorkflowUrl); |
| 83 | + JsonPath startOrchestrationResponseJson = response.jsonPath(); |
| 84 | + |
| 85 | + // Wait for the ApprovalWorkflowOrchestration to fail |
| 86 | + Thread.sleep(3000); |
| 87 | + |
| 88 | + String statusQueryGetUri = startOrchestrationResponseJson.get("statusQueryGetUri"); |
| 89 | + Response statusResponse = get(statusQueryGetUri); |
| 90 | + String runtimeStatus = statusResponse.jsonPath().get("runtimeStatus"); |
| 91 | + assertEquals("Failed", runtimeStatus); |
| 92 | + |
| 93 | + // Rewind the instance using Http API |
| 94 | + String rewindPostUri = startOrchestrationResponseJson.get("rewindPostUri"); |
| 95 | + post(rewindPostUri); |
| 96 | + |
| 97 | + // Wait for orchestration to rewind and complete |
| 98 | + Thread.sleep(3000); |
| 99 | + |
| 100 | + for (int i = 0; i < 5; i++) { |
| 101 | + statusResponse = get(statusQueryGetUri); |
| 102 | + runtimeStatus = statusResponse.jsonPath().get("runtimeStatus"); |
| 103 | + if (!"Completed".equals(runtimeStatus)) { |
| 104 | + Thread.sleep(1000); |
| 105 | + } else break; |
| 106 | + } |
| 107 | + assertEquals("Completed", runtimeStatus); |
| 108 | + |
| 109 | + // Reset approval for other test cases |
| 110 | + post(resetApprovalUrl); |
73 | 111 | }
|
74 | 112 | }
|
0 commit comments