use of qa.tools.ikeeper.annotation.BZ in project jbpm by kiegroup.
the class LogCleanupCommandTest method deleteAllLogsOlderThanNow.
@Ignore
@Test(timeout = 10000)
@BZ("1190881")
public void deleteAllLogsOlderThanNow() throws Exception {
CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(1);
((ExecutorServiceImpl) getExecutorService()).addAsyncJobListener(countDownListener);
deleteAllLogsOlderThan(null, countDownListener);
Assertions.assertThat(getProcessLogSize(HELLO_WORLD_ID)).isZero();
Assertions.assertThat(getNodeInstanceLogSize(HELLO_WORLD_ID)).isZero();
}
use of qa.tools.ikeeper.annotation.BZ in project jbpm by kiegroup.
the class LogCleanupCommandTest method deleteAllLogsOlderThanPeriod.
@Ignore
@Test(timeout = 10000)
@BZ("1190881")
public void deleteAllLogsOlderThanPeriod() throws Exception {
CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(1);
((ExecutorServiceImpl) getExecutorService()).addAsyncJobListener(countDownListener);
// Generate data
KieSession kieSession = createKSession(HELLO_WORLD);
startProcess(kieSession, HELLO_WORLD_ID, 3);
countDownListener.waitTillCompleted();
startProcess(kieSession, HELLO_WORLD_ID, 2);
// Verify presence of data
Assertions.assertThat(getProcessLogSize(HELLO_WORLD_ID)).isEqualTo(5);
Assertions.assertThat(getNodeInstanceLogSize(HELLO_WORLD_ID)).isPositive();
// Schedule cleanup job
scheduleLogCleanup(false, false, false, null, "8s", HELLO_WORLD_ID);
countDownListener.waitTillCompleted();
// Verify absence of data
Assertions.assertThat(getProcessLogSize(HELLO_WORLD_ID)).isEqualTo(2);
}
use of qa.tools.ikeeper.annotation.BZ in project jbpm by kiegroup.
the class ExecutorLogCleanTest method deleteErrorLogsByDate.
@Test
@BZ("1188702")
public void deleteErrorLogsByDate() throws Exception {
CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(2);
((ExecutorServiceImpl) getExecutorService()).addAsyncJobListener(countDownListener);
KieSession ksession = createKSession(ASYNC_DATA_EXEC);
WorkItemManager wim = ksession.getWorkItemManager();
wim.registerWorkItemHandler("async", new AsyncWorkItemHandler(getExecutorService()));
Map<String, Object> pm = new HashMap<String, Object>();
pm.put("command", "org.jbpm.test.jobexec.UserFailingCommand");
ProcessInstance pi = ksession.startProcess(ASYNC_DATA_EXEC_ID, pm);
// Wait for the all retries to fail
countDownListener.waitTillCompleted();
// Assert completion of the job
List<ErrorInfo> errorList = getExecutorService().getAllErrors(new QueryContext());
Assertions.assertThat(errorList).hasSize(2);
// Delete a record
int resultCount = auditService.errorInfoLogDeleteBuilder().date(errorList.get(0).getTime()).build().execute();
Assertions.assertThat(resultCount).isEqualTo(1);
// Assert remaining records
Assertions.assertThat(getExecutorService().getAllErrors(new QueryContext())).hasSize(1);
// Abort running process instance
ksession.abortProcessInstance(pi.getId());
}
use of qa.tools.ikeeper.annotation.BZ in project jbpm by kiegroup.
the class ProcessInstanceLogCleanTest method deleteLogsByDate.
@Test
@BZ("1188702")
public void deleteLogsByDate() {
Date testStartDate = new Date();
KieSession kieSession = createKSession(HELLO_WORLD_PROCESS);
startProcess(kieSession, HELLO_WORLD_PROCESS_ID, 4);
List<ProcessInstanceLog> resultList = auditService.processInstanceLogQuery().startDateRangeStart(testStartDate).build().getResultList();
Assertions.assertThat(resultList).hasSize(4).extracting("processId").containsExactly(HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID);
// Delete the last 3 logs in the list
for (int i = resultList.size() - 1; i > 0; i--) {
int resultCount = auditService.processInstanceLogDelete().startDate(resultList.get(i).getStart()).build().execute();
Assertions.assertThat(resultCount).isEqualTo(1);
}
// Attempt to delete with a date later than end of all the instances
int resultCount = auditService.processInstanceLogDelete().startDate(new Date()).build().execute();
Assertions.assertThat(resultCount).isEqualTo(0);
// Check the last instance
List<ProcessInstanceLog> resultList2 = auditService.processInstanceLogQuery().startDateRangeStart(testStartDate).build().getResultList();
Assertions.assertThat(resultList2).hasSize(1);
Assertions.assertThat(resultList2.get(0)).isEqualTo(resultList.get(0));
}
use of qa.tools.ikeeper.annotation.BZ in project jbpm by kiegroup.
the class TaskLogCleanTest method testDeleteLogsByDate.
@Test
@BZ("1188702")
public void testDeleteLogsByDate() {
kieSession = createKSession(HUMAN_TASK);
processInstanceList = startProcess(kieSession, HUMAN_TASK_ID, 4);
abortProcess(kieSession, processInstanceList);
TaskService taskService = getRuntimeEngine().getTaskService();
// Delete the last two task logs
for (int i = processInstanceList.size() - 1; i > 0; i--) {
List<Long> taskIdList = taskService.getTasksByProcessInstanceId(processInstanceList.get(i).getId());
Assertions.assertThat(taskIdList).hasSize(1);
Task task = taskService.getTaskById(taskIdList.get(0));
Assertions.assertThat(task).isNotNull();
int resultCount = taskAuditService.auditTaskDelete().date(task.getTaskData().getCreatedOn()).build().execute();
Assertions.assertThat(resultCount).isEqualTo(1);
}
}
Aggregations