use of org.camunda.bpm.engine.impl.persistence.entity.JobEntity in project camunda-bpm-platform by camunda.
the class HistoryCleanupTest method testLessThanThresholdCloseToBatchWindowEndTime.
@Test
public void testLessThanThresholdCloseToBatchWindowEndTime() {
// given
prepareData(5);
// we're within batch window
Date now = new Date();
ClockUtil.setCurrentTime(now);
processEngineConfiguration.setHistoryCleanupBatchWindowStartTime(new SimpleDateFormat("HH:mm").format(now));
processEngineConfiguration.setHistoryCleanupBatchWindowEndTime(new SimpleDateFormat("HH:mm").format(DateUtils.addMinutes(now, 30)));
processEngineConfiguration.initHistoryCleanup();
// when
String jobId = historyService.cleanUpHistoryAsync().getId();
for (int i = 1; i <= 9; i++) {
managementService.executeJob(jobId);
}
// then
JobEntity jobEntity = getJobEntity(jobId);
HistoryCleanupJobHandlerConfiguration configuration = getConfiguration(jobEntity);
// job rescheduled till next batch window start time
Date nextRun = getNextRunWithinBatchWindow(ClockUtil.getCurrentTime());
assertTrue(jobEntity.getDuedate().equals(nextRun));
// countEmptyRuns canceled
assertEquals(0, configuration.getCountEmptyRuns());
// data is still removed
assertResult(0);
}
use of org.camunda.bpm.engine.impl.persistence.entity.JobEntity in project camunda-bpm-platform by camunda.
the class HistoryCleanupTest method testLessThanThresholdManualRun.
@Test
public void testLessThanThresholdManualRun() {
// given
prepareData(5);
ClockUtil.setCurrentTime(new Date());
// when
String jobId = historyService.cleanUpHistoryAsync(true).getId();
managementService.executeJob(jobId);
// then
assertEquals(0, historyService.createHistoricProcessInstanceQuery().processDefinitionKey(ONE_TASK_PROCESS).count());
JobEntity jobEntity = getJobEntity(jobId);
assertEquals(SuspensionState.SUSPENDED.getStateCode(), jobEntity.getSuspensionState());
}
use of org.camunda.bpm.engine.impl.persistence.entity.JobEntity in project camunda-bpm-platform by camunda.
the class FoxJobRetryCmdTest method FAILING_testFailedRetryWithTimeShift.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/async/FoxJobRetryCmdTest.testFailedServiceTask.bpmn20.xml" })
public void FAILING_testFailedRetryWithTimeShift() throws ParseException {
// set date to hour before time shift (2015-10-25T03:00:00 CEST =>
// 2015-10-25T02:00:00 CET)
Date tenMinutesBeforeTimeShift = createDateFromLocalString("2015-10-25T02:50:00 CEST");
Date fiveMinutesBeforeTimeShift = createDateFromLocalString("2015-10-25T02:55:00 CEST");
Date twoMinutesBeforeTimeShift = createDateFromLocalString("2015-10-25T02:58:00 CEST");
ClockUtil.setCurrentTime(tenMinutesBeforeTimeShift);
ProcessInstance pi = runtimeService.startProcessInstanceByKey("failedServiceTask");
assertNotNull(pi);
// a job is acquirable
List<JobEntity> acquirableJobs = findAndLockAcquirableJobs();
assertEquals(1, acquirableJobs.size());
// execute job
waitForExecutedJobWithRetriesLeft(4);
// the job lock time is after the current time but before the time shift
JobEntity job = (JobEntity) fetchJob(pi.getProcessInstanceId());
assertTrue(tenMinutesBeforeTimeShift.before(job.getLockExpirationTime()));
assertEquals(fiveMinutesBeforeTimeShift, job.getLockExpirationTime());
assertTrue(twoMinutesBeforeTimeShift.after(job.getLockExpirationTime()));
// the job is not acquirable
acquirableJobs = findAndLockAcquirableJobs();
assertEquals(0, acquirableJobs.size());
// set clock to two minutes before time shift
ClockUtil.setCurrentTime(twoMinutesBeforeTimeShift);
// the job is now acquirable
acquirableJobs = findAndLockAcquirableJobs();
assertEquals(1, acquirableJobs.size());
// execute job
waitForExecutedJobWithRetriesLeft(3);
// the job lock time is after the current time
job = (JobEntity) refreshJob(job.getId());
assertTrue(twoMinutesBeforeTimeShift.before(job.getLockExpirationTime()));
// the job is not acquirable
acquirableJobs = findAndLockAcquirableJobs();
assertEquals("Job shouldn't be acquirable", 0, acquirableJobs.size());
ClockUtil.reset();
}
use of org.camunda.bpm.engine.impl.persistence.entity.JobEntity in project camunda-bpm-platform by camunda.
the class AsyncAfterTest method fetchFirstJobByHandlerConfiguration.
protected Job fetchFirstJobByHandlerConfiguration(List<Job> jobs, String configuration) {
for (Job job : jobs) {
JobEntity jobEntity = (JobEntity) job;
String jobConfig = jobEntity.getJobHandlerConfigurationRaw();
if (configuration.equals(jobConfig)) {
return job;
}
}
return null;
}
use of org.camunda.bpm.engine.impl.persistence.entity.JobEntity in project camunda-bpm-platform by camunda.
the class RetryIntervalsConfigurationTest method assertLockExpirationTime.
private void assertLockExpirationTime(Date expectedDate) throws ParseException {
Date lockExpirationTime = ((JobEntity) managementService.createJobQuery().singleResult()).getLockExpirationTime();
assertEquals(expectedDate, lockExpirationTime);
}
Aggregations