Skip to content

Commit

Permalink
Added retry example for failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gardusig committed Jan 17, 2023
1 parent 715d769 commit 0d4c7e6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
public class GroupPermissionTests {

@Test
public void testGroupRelatedPermissions() {
public void testGroupRelatedPermissions() throws Exception {
ApiClient apiUser1Client = ApiUtil.getUser1Client();
WorkflowClient user1WorkflowClient = new OrkesWorkflowClient(apiUser1Client);
MetadataClient user1MetadataClient = new OrkesMetadataClient(apiUser1Client);
Expand Down Expand Up @@ -134,11 +134,20 @@ public void testGroupRelatedPermissions() {
}catch(Exception e){}
});

// Wait for workflow to get completed
await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
Workflow workflow1 = user2WorkflowClient.getWorkflow(finalWorkflowId, false);
assertEquals(workflow1.getStatus().name(), WorkflowStatus.StatusEnum.COMPLETED.name());
});
int retryAttemptsLimit = 5;
for (int retry = 0; retry < retryAttemptsLimit; retry += 1) {
try{
// Wait for workflow to get completed
await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
Workflow workflow1 = user2WorkflowClient.getWorkflow(finalWorkflowId, false);
assertEquals(workflow1.getStatus().name(), WorkflowStatus.StatusEnum.COMPLETED.name());
});
break;
} catch (Exception e) {
Thread.sleep((retry + 5) * 1000);
}
}


user1MetadataClient.unregisterWorkflowDef(workflowName1, 1);
user1MetadataClient.unregisterTaskDef(taskName1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void testRerunSimpleWorkflow() {

@Test
@DisplayName("Check workflow with sub_workflow task and rerun functionality")
public void testRerunWithSubWorkflow() {
public void testRerunWithSubWorkflow() throws Exception {

apiClient = ApiUtil.getApiClientWithCredentials();
workflowClient = new OrkesWorkflowClient(apiClient);
Expand Down Expand Up @@ -173,11 +173,18 @@ public void testRerunWithSubWorkflow() {
taskResult.setStatus(TaskResult.Status.COMPLETED);
taskClient.updateTask(taskResult);

// Wait for workflow to get completed
await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
Workflow workflow1 = workflowClient.getWorkflow(workflowId, false);
assertEquals(workflow1.getStatus().name(), WorkflowStatus.StatusEnum.COMPLETED.name());
});
int retryAttemptsLimit = 5;
for (int retry = 0; retry < retryAttemptsLimit; retry += 1) {
try{
// Wait for workflow to get completed
await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
Workflow workflow1 = workflowClient.getWorkflow(workflowId, false);
assertEquals(workflow1.getStatus().name(), WorkflowStatus.StatusEnum.COMPLETED.name());
});
} catch (Exception e) {
Thread.sleep((retry + 5) * 1000);
}
}

metadataClient.unregisterWorkflowDef(workflowName, 1);
metadataClient.unregisterTaskDef("simple");
Expand Down

0 comments on commit 0d4c7e6

Please sign in to comment.