Skip to content

Commit

Permalink
Hopefully fixed MID-3192: TestOrgSync occasional failures
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jun 18, 2016
1 parent d5cad60 commit e07f015
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Expand Up @@ -1953,7 +1953,45 @@ public void timeout() {
};
IntegrationTestTools.waitFor("Waiting for " + task + " finish", checker, timeout, sleepTime);
}


protected void waitForTaskCloseOrSuspend(String taskOid) throws Exception {
waitForTaskCloseOrSuspend(taskOid, DEFAULT_TASK_WAIT_TIMEOUT);
}

protected void waitForTaskCloseOrSuspend(String taskOid, final int timeout) throws Exception {
waitForTaskCloseOrSuspend(taskOid, timeout, DEFAULT_TASK_SLEEP_TIME);
}

protected void waitForTaskCloseOrSuspend(final String taskOid, final int timeout, long sleepTime) throws Exception {
final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskCloseOrSuspend");
Checker checker = new Checker() {
@Override
public boolean check() throws CommonException {
Task task = taskManager.getTask(taskOid, waitResult);
waitResult.summarize();
display("Task execution status = " + task.getExecutionStatus());
return task.getExecutionStatus() == TaskExecutionStatus.CLOSED
|| task.getExecutionStatus() == TaskExecutionStatus.SUSPENDED;
}
@Override
public void timeout() {
Task task = null;
try {
task = taskManager.getTask(taskOid, waitResult);
} catch (ObjectNotFoundException|SchemaException e) {
LOGGER.error("Exception during task refresh: {}", e,e);
}
OperationResult result = null;
if (task != null) {
result = task.getResult();
LOGGER.debug("Result of timed-out task:\n{}", result.debugDump());
}
assert false : "Timeout ("+timeout+") while waiting for "+taskOid+" to close or suspend. Last result "+result;
}
};
IntegrationTestTools.waitFor("Waiting for " + taskOid + " close/suspend", checker, timeout, sleepTime);
}

protected void waitForTaskFinish(String taskOid, boolean checkSubresult) throws CommonException {
waitForTaskFinish(taskOid, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT);
}
Expand Down
Expand Up @@ -1052,6 +1052,7 @@ public void test500ReconcileOpenDJDefault() throws Exception {
TestUtil.displayThen(TEST_NAME);

waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false);
waitForTaskCloseOrSuspend(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID);

// THEN
TestUtil.displayThen(TEST_NAME);
Expand Down Expand Up @@ -1092,6 +1093,7 @@ public void test502ReconcileOpenDJDefaultAgain() throws Exception {
TestUtil.displayThen(TEST_NAME);

waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false);
waitForTaskCloseOrSuspend(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID);

// THEN
TestUtil.displayThen(TEST_NAME);
Expand Down Expand Up @@ -1132,6 +1134,7 @@ public void test510ReconcileOpenDJLdapGroup() throws Exception {
TestUtil.displayThen(TEST_NAME);

waitForTaskFinish(TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_OID, false);
waitForTaskCloseOrSuspend(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID);

// THEN
TestUtil.displayThen(TEST_NAME);
Expand Down Expand Up @@ -1183,6 +1186,7 @@ public void test550ReconcileOpenDJAfterMembershipChange() throws Exception {
TestUtil.displayThen(TEST_NAME);

waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false);
waitForTaskCloseOrSuspend(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID);

// THEN
TestUtil.displayThen(TEST_NAME);
Expand Down

0 comments on commit e07f015

Please sign in to comment.