use of com.evolveum.midpoint.test.Checker in project midpoint by Evolveum.
the class TestSanityLegacy method test999Shutdown.
@Test
public void test999Shutdown() throws Exception {
taskManager.shutdown();
waitFor("waiting for task manager shutdown", new Checker() {
@Override
public boolean check() throws CommonException {
try {
return taskManager.getLocallyRunningTasks(new OperationResult("dummy")).isEmpty();
} catch (TaskManagerException e) {
throw new SystemException(e);
}
}
@Override
public void timeout() {
// No reaction, the test will fail right after return from this
}
}, 10000);
AssertJUnit.assertEquals("Some tasks left running after shutdown", new HashSet<Task>(), taskManager.getLocallyRunningTasks(new OperationResult("dummy")));
}
use of com.evolveum.midpoint.test.Checker in project midpoint by Evolveum.
the class ConsistencyTest method test999Shutdown.
@Test
public void test999Shutdown() throws Exception {
taskManager.shutdown();
waitFor("waiting for task manager shutdown", new Checker() {
@Override
public boolean check() throws CommonException {
try {
return taskManager.getLocallyRunningTasks(new OperationResult("dummy")).isEmpty();
} catch (TaskManagerException e) {
throw new SystemException(e);
}
}
@Override
public void timeout() {
// No reaction, the test will fail right after return from this
}
}, 10000);
AssertJUnit.assertEquals("Some tasks left running after shutdown", new HashSet<Task>(), taskManager.getLocallyRunningTasks(new OperationResult("dummy")));
}
use of com.evolveum.midpoint.test.Checker in project midpoint by Evolveum.
the class TestQuartzTaskManagerContract method test008MoreHandlers.
/*
* Single-run task with more handlers.
*/
@Test(enabled = true)
public void test008MoreHandlers() throws Exception {
final String test = "008MoreHandlers";
final OperationResult result = createResult(test);
// reset 'has run' flag on handlers
singleHandler1.resetHasRun();
singleHandler2.resetHasRun();
singleHandler3.resetHasRun();
addObjectFromFile(taskFilename(test));
waitFor("Waiting for task manager to execute the task", new Checker() {
public boolean check() throws ObjectNotFoundException, SchemaException {
Task task = taskManager.getTask(taskOid(test), result);
IntegrationTestTools.display("Task while waiting for task manager to execute the task", task);
return task.getExecutionStatus() == TaskExecutionStatus.CLOSED;
}
@Override
public void timeout() {
}
}, 15000, 2000);
// Check task status
Task task = taskManager.getTask(taskOid(test), result);
AssertJUnit.assertNotNull(task);
System.out.println(task.debugDump());
PrismObject<TaskType> o = repositoryService.getObject(TaskType.class, taskOid(test), null, result);
System.out.println(ObjectTypeUtil.dump(o.getValue().getValue()));
// .. it should be closed
AssertJUnit.assertEquals(TaskExecutionStatus.CLOSED, task.getExecutionStatus());
// .. and released
// AssertJUnit.assertEquals(TaskExclusivityStatus.RELEASED, task.getExclusivityStatus());
// .. and last run should not be zero
AssertJUnit.assertNotNull(task.getLastRunStartTimestamp());
assertFalse(task.getLastRunStartTimestamp().longValue() == 0);
AssertJUnit.assertNotNull("Last run finish timestamp not set", task.getLastRunFinishTimestamp());
assertFalse("Last run finish timestamp is 0", task.getLastRunFinishTimestamp().longValue() == 0);
// The progress should be more than 0 as the task has run at least once
AssertJUnit.assertTrue("Task reported no progress", task.getProgress() > 0);
// Test for presence of a result. It should be there and it should
// indicate success
OperationResult taskResult = task.getResult();
AssertJUnit.assertNotNull("Task result is null", taskResult);
AssertJUnit.assertTrue("Task did not yield 'success' status", taskResult.isSuccess());
// Test for no presence of handlers
AssertJUnit.assertNotNull("Handler is gone", task.getHandlerUri());
AssertJUnit.assertTrue("Other handlers are still present", task.getOtherHandlersUriStack() == null || task.getOtherHandlersUriStack().getUriStackEntry().isEmpty());
// Test if all three handlers were run
AssertJUnit.assertTrue("Handler1 has not run", singleHandler1.hasRun());
AssertJUnit.assertTrue("Handler2 has not run", singleHandler2.hasRun());
AssertJUnit.assertTrue("Handler3 has not run", singleHandler3.hasRun());
}
use of com.evolveum.midpoint.test.Checker in project midpoint by Evolveum.
the class TestQuartzTaskManagerContract method test012Suspend.
/*
* Suspends a running task.
*/
@Test(enabled = true)
public void test012Suspend() throws Exception {
final String test = "012Suspend";
final OperationResult result = createResult(test);
addObjectFromFile(taskFilename(test));
// check if we can read the extension (xsi:type issue)
Task taskTemp = taskManager.getTask(taskOid(test), result);
PrismProperty delay = taskTemp.getExtensionProperty(SchemaConstants.NOOP_DELAY_QNAME);
AssertJUnit.assertEquals("Delay was not read correctly", 2000, delay.getRealValue());
waitFor("Waiting for task manager to execute the task", new Checker() {
public boolean check() throws ObjectNotFoundException, SchemaException {
Task task = taskManager.getTask(taskOid(test), result);
IntegrationTestTools.display("Task while waiting for task manager to execute the task", task);
return task.getProgress() >= 1;
}
@Override
public void timeout() {
}
}, 10000, 2000);
// Check task status (task is running 5 iterations where each takes 2000 ms)
Task task = taskManager.getTask(taskOid(test), result);
AssertJUnit.assertNotNull(task);
System.out.println(task.debugDump());
AssertJUnit.assertEquals("Task is not running", TaskExecutionStatus.RUNNABLE, task.getExecutionStatus());
// Now suspend the task
boolean stopped = taskManager.suspendTask(task, 0, result);
task.refresh(result);
System.out.println("After suspend and refresh: " + task.debugDump());
AssertJUnit.assertTrue("Task is not stopped", stopped);
AssertJUnit.assertEquals("Task is not suspended", TaskExecutionStatus.SUSPENDED, task.getExecutionStatus());
AssertJUnit.assertNotNull("Task last start time is null", task.getLastRunStartTimestamp());
assertFalse("Task last start time is 0", task.getLastRunStartTimestamp().longValue() == 0);
// The progress should be more than 0
AssertJUnit.assertTrue("Task has not reported any progress", task.getProgress() > 0);
// Thread.sleep(200); // give the scheduler a chance to release the task
// task.refresh(result);
// AssertJUnit.assertEquals("Task is not released", TaskExclusivityStatus.RELEASED, task.getExclusivityStatus());
}
use of com.evolveum.midpoint.test.Checker in project midpoint by Evolveum.
the class TestQuartzTaskManagerContract method test010CycleCronLoose.
@Test(enabled = true)
public void test010CycleCronLoose() throws Exception {
final String test = "010CycleCronLoose";
final OperationResult result = createResult(test);
addObjectFromFile(taskFilename(test));
waitFor("Waiting for task manager to execute the task", new Checker() {
public boolean check() throws ObjectNotFoundException, SchemaException {
Task task = taskManager.getTask(taskOid(test), result);
IntegrationTestTools.display("Task while waiting for task manager to execute the task", task);
return task.getProgress() >= 2;
}
@Override
public void timeout() {
}
}, 15000, 2000);
// Check task status
Task task = taskManager.getTask(taskOid(test), result);
AssertJUnit.assertNotNull(task);
System.out.println(task.debugDump());
TaskType t = repositoryService.getObject(TaskType.class, taskOid(test), null, result).getValue().getValue();
System.out.println(ObjectTypeUtil.dump(t));
AssertJUnit.assertEquals(TaskExecutionStatus.RUNNABLE, task.getExecutionStatus());
// .. and last run should not be zero
AssertJUnit.assertNotNull(task.getLastRunStartTimestamp());
assertFalse(task.getLastRunStartTimestamp().longValue() == 0);
AssertJUnit.assertNotNull(task.getLastRunFinishTimestamp());
assertFalse(task.getLastRunFinishTimestamp().longValue() == 0);
// The progress should be at least 2 as the task has run at least twice
AssertJUnit.assertTrue("Task has not been executed at least twice", task.getProgress() >= 2);
// Test for presence of a result. It should be there and it should
// indicate success
OperationResult taskResult = task.getResult();
AssertJUnit.assertNotNull("Task result is null", taskResult);
AssertJUnit.assertTrue("Task did not yield 'success' status", taskResult.isSuccess());
// Suspend the task (in order to keep logs clean), without much waiting
taskManager.suspendTask(task, 100, result);
}
Aggregations