Search in sources :

Example 1 with BZ

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();
}
Also used : CountDownAsyncJobListener(org.jbpm.test.listener.CountDownAsyncJobListener) ExecutorServiceImpl(org.jbpm.executor.impl.ExecutorServiceImpl) Ignore(org.junit.Ignore) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Example 2 with BZ

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);
}
Also used : CountDownAsyncJobListener(org.jbpm.test.listener.CountDownAsyncJobListener) ExecutorServiceImpl(org.jbpm.executor.impl.ExecutorServiceImpl) KieSession(org.kie.api.runtime.KieSession) Ignore(org.junit.Ignore) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Example 3 with BZ

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());
}
Also used : ExecutorServiceImpl(org.jbpm.executor.impl.ExecutorServiceImpl) HashMap(java.util.HashMap) ErrorInfo(org.kie.api.executor.ErrorInfo) QueryContext(org.kie.api.runtime.query.QueryContext) CountDownAsyncJobListener(org.jbpm.test.listener.CountDownAsyncJobListener) AsyncWorkItemHandler(org.jbpm.executor.impl.wih.AsyncWorkItemHandler) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkItemManager(org.kie.api.runtime.process.WorkItemManager) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Example 4 with BZ

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));
}
Also used : KieSession(org.kie.api.runtime.KieSession) Date(java.util.Date) ProcessInstanceLog(org.kie.api.runtime.manager.audit.ProcessInstanceLog) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Example 5 with BZ

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);
    }
}
Also used : Task(org.kie.api.task.model.Task) AuditTask(org.kie.internal.task.api.AuditTask) TaskService(org.kie.api.task.TaskService) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Aggregations

Test (org.junit.Test)53 BZ (qa.tools.ikeeper.annotation.BZ)53 KieSession (org.kie.api.runtime.KieSession)47 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)29 HashMap (java.util.HashMap)14 TaskService (org.kie.api.task.TaskService)10 ArrayList (java.util.ArrayList)9 TrackingProcessEventListener (org.jbpm.test.listener.TrackingProcessEventListener)9 Task (org.kie.api.task.model.Task)9 TaskSummary (org.kie.api.task.model.TaskSummary)8 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)6 ExecutorServiceImpl (org.jbpm.executor.impl.ExecutorServiceImpl)5 Command (org.kie.api.command.Command)5 Date (java.util.Date)4 AsyncWorkItemHandler (org.jbpm.executor.impl.wih.AsyncWorkItemHandler)4 CountDownAsyncJobListener (org.jbpm.test.listener.CountDownAsyncJobListener)4 SystemOutWorkItemHandler (org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler)3 IterableProcessEventListener (org.jbpm.test.listener.IterableProcessEventListener)3 ResourceType (org.kie.api.io.ResourceType)3 ProcessInstanceLog (org.kie.api.runtime.manager.audit.ProcessInstanceLog)3