|
21 | 21 |
|
22 | 22 | @Tag("e2e") |
23 | 23 | public class EndToEndTests { |
24 | | - private static final String hostHealthPingPath = "/admin/host/ping"; |
25 | | - private static final String startOrchestrationPath = "/api/StartOrchestration"; |
26 | | - private static final String approvalWorkFlow = "/api/ApprovalWorkflowOrchestration"; |
27 | | - private static final String rewindInstance = "/api/RewindInstance"; |
| 24 | + private static final String hostHealthPingUrl = "/admin/host/ping"; |
| 25 | + private static final String startOrchestrationUrl = "/api/StartOrchestration"; |
| 26 | + private static final String startApprovalWorkflowUrl = "/api/ApprovalWorkflowOrchestration"; |
| 27 | + private static final String rewindInstanceFunctionUrl = "/api/RewindInstance"; |
| 28 | + private static final String resetApprovalUrl = "/api/ResetApprovalFlag"; |
28 | 29 |
|
29 | 30 | @Order(1) |
30 | 31 | @Test |
@@ -80,6 +81,15 @@ public void retryTestSuccess() throws InterruptedException { |
80 | 81 | String statusQueryGetUri = jsonPath.get("statusQueryGetUri"); |
81 | 82 | boolean pass = pollingCheck(statusQueryGetUri, "Completed", null, Duration.ofSeconds(10)); |
82 | 83 | assertTrue(pass); |
| 84 | + String runtimeStatus = null; |
| 85 | + for (int i = 0; i < 15; i++) { |
| 86 | + Response statusResponse = get(statusQueryGetUri); |
| 87 | + runtimeStatus = statusResponse.jsonPath().get("runtimeStatus"); |
| 88 | + if (!"Completed".equals(runtimeStatus)) { |
| 89 | + Thread.sleep(1000); |
| 90 | + } else break; |
| 91 | + } |
| 92 | + assertEquals("Completed", runtimeStatus); |
83 | 93 | } |
84 | 94 |
|
85 | 95 | @Test |
@@ -209,35 +219,72 @@ private boolean pollingCheck(String statusQueryGetUri, |
209 | 219 |
|
210 | 220 | @Order(2) |
211 | 221 | @Test |
212 | | - public void testRewindInstanceAPI() throws InterruptedException { |
213 | | - Response response = post(approvalWorkFlow); |
214 | | - JsonPath rewindTestJsonPath = response.jsonPath(); |
| 222 | + public void testRewindInstanceJavaAPI() throws InterruptedException { |
| 223 | + Response response = post(startApprovalWorkflowUrl); |
| 224 | + JsonPath startOrchestrationResponseJson = response.jsonPath(); |
215 | 225 |
|
216 | 226 | // Wait for the ApprovalWorkflowOrchestration to fail |
217 | 227 | Thread.sleep(3000); |
218 | 228 |
|
219 | | - String instanceId = rewindTestJsonPath.get("id"); |
220 | | - String statusQueryGetUri = rewindTestJsonPath.get("statusQueryGetUri"); |
| 229 | + String instanceId = startOrchestrationResponseJson.get("id"); |
| 230 | + String statusQueryGetUri = startOrchestrationResponseJson.get("statusQueryGetUri"); |
221 | 231 | Response statusResponse = get(statusQueryGetUri); |
222 | | - String runTimeStatus = statusResponse.jsonPath().get("runtimeStatus"); |
223 | | - assertEquals("Failed", runTimeStatus); |
| 232 | + String runtimeStatus = statusResponse.jsonPath().get("runtimeStatus"); |
| 233 | + assertEquals("Failed", runtimeStatus); |
224 | 234 |
|
225 | | - // Rewind the instance |
226 | | - String rewindPostUri = rewindInstance + "?instanceId=" + instanceId; |
227 | | - response = post(rewindPostUri); |
| 235 | + // Rewind the instance using Java API |
| 236 | + String rewindInstanceUrl = rewindInstanceFunctionUrl + "?instanceId=" + instanceId; |
| 237 | + response = post(rewindInstanceUrl); |
228 | 238 | assertEquals("Failed orchestration instance is scheduled for rewind.", response.toString()); |
229 | 239 |
|
230 | 240 | // Wait for orchestration to rewind and complete |
231 | 241 | Thread.sleep(3000); |
232 | 242 |
|
233 | 243 | for (int i = 0; i < 5; i++) { |
234 | 244 | statusResponse = get(statusQueryGetUri); |
235 | | - runTimeStatus = statusResponse.jsonPath().get("runtimeStatus"); |
236 | | - if (!"Completed".equals(runTimeStatus)) { |
| 245 | + runtimeStatus = statusResponse.jsonPath().get("runtimeStatus"); |
| 246 | + if (!"Completed".equals(runtimeStatus)) { |
237 | 247 | Thread.sleep(1000); |
238 | 248 | } else break; |
239 | 249 | } |
240 | | - assertEquals("Completed", runTimeStatus); |
| 250 | + assertEquals("Completed", runtimeStatus); |
| 251 | + |
| 252 | + // Reset approval for other test cases |
| 253 | + post(resetApprovalUrl); |
| 254 | + } |
| 255 | + |
| 256 | + @Order(3) |
| 257 | + @Test |
| 258 | + public void testRewindInstanceHttpAPI() throws InterruptedException { |
| 259 | + Response response = post(startApprovalWorkflowUrl); |
| 260 | + JsonPath startOrchestrationResponseJson = response.jsonPath(); |
| 261 | + |
| 262 | + // Wait for the ApprovalWorkflowOrchestration to fail |
| 263 | + Thread.sleep(3000); |
| 264 | + |
| 265 | + String statusQueryGetUri = startOrchestrationResponseJson.get("statusQueryGetUri"); |
| 266 | + Response statusResponse = get(statusQueryGetUri); |
| 267 | + String runtimeStatus = statusResponse.jsonPath().get("runtimeStatus"); |
| 268 | + assertEquals("Failed", runtimeStatus); |
| 269 | + |
| 270 | + // Rewind the instance using Http API |
| 271 | + String rewindPostUri = startOrchestrationResponseJson.get("rewindPostUri"); |
| 272 | + post(rewindPostUri); |
| 273 | + |
| 274 | + // Wait for orchestration to rewind and complete |
| 275 | + Thread.sleep(3000); |
| 276 | + |
| 277 | + for (int i = 0; i < 5; i++) { |
| 278 | + statusResponse = get(statusQueryGetUri); |
| 279 | + runtimeStatus = statusResponse.jsonPath().get("runtimeStatus"); |
| 280 | + if (!"Completed".equals(runtimeStatus)) { |
| 281 | + Thread.sleep(1000); |
| 282 | + } else break; |
| 283 | + } |
| 284 | + assertEquals("Completed", runtimeStatus); |
| 285 | + |
| 286 | + // Reset approval for other test cases |
| 287 | + post(resetApprovalUrl); |
241 | 288 | } |
242 | 289 | } |
243 | 290 |
|
0 commit comments