use of org.camunda.bpm.engine.batch.history.HistoricBatch in project camunda-bpm-platform by camunda.
the class HistoryCleanupHistoricBatchTest method testCleanupHistoricJobLog.
@Test
public void testCleanupHistoricJobLog() {
initBatchOperationHistoryTimeToLive(DEFAULT_TTL_DAYS);
int daysInThePast = -11;
// given
prepareHistoricBatches(1, daysInThePast);
HistoricBatch batch = historyService.createHistoricBatchQuery().singleResult();
String batchId = batch.getId();
// when
String jobId = historyService.cleanUpHistoryAsync(true).getId();
managementService.executeJob(jobId);
// then
assertEquals(0, historyService.createHistoricBatchQuery().count());
assertEquals(0, historyService.createHistoricJobLogQuery().jobDefinitionConfiguration(batchId).count());
}
use of org.camunda.bpm.engine.batch.history.HistoricBatch in project camunda-bpm-platform by camunda.
the class HistoryCleanupHistoricBatchTest method testMixedConfiguration.
@Test
public void testMixedConfiguration() {
Map<String, String> map = new HashMap<String, String>();
map.put("instance-modification", "P20D");
processEngineConfiguration.setBatchOperationHistoryTimeToLive(DEFAULT_TTL_DAYS);
processEngineConfiguration.setBatchOperationsForHistoryCleanup(map);
processEngineConfiguration.initHistoryCleanup();
Date startDate = ClockUtil.getCurrentTime();
int daysInThePast = -11;
ClockUtil.setCurrentTime(DateUtils.addDays(startDate, daysInThePast));
Batch modificationBatch = createModificationBatch();
List<String> batchIds = new ArrayList<String>();
batchIds.add(modificationBatch.getId());
int migrationCountBatch = 10;
batchIds.addAll(createMigrationBatchList(migrationCountBatch));
int cancelationCountBatch = 20;
batchIds.addAll(createCancelationBatchList(cancelationCountBatch));
ClockUtil.setCurrentTime(DateUtils.addDays(startDate, -8));
for (String batchId : batchIds) {
managementService.deleteBatch(batchId, false);
}
ClockUtil.setCurrentTime(new Date());
// when
List<HistoricBatch> historicList = historyService.createHistoricBatchQuery().list();
assertEquals(31, historicList.size());
String jobId = historyService.cleanUpHistoryAsync(true).getId();
managementService.executeJob(jobId);
// then
// the other batches should be cleaned
HistoricBatch modificationHistoricBatch = historyService.createHistoricBatchQuery().singleResult();
assertEquals(modificationBatch.getId(), modificationHistoricBatch.getId());
assertEquals(2, historyService.createHistoricJobLogQuery().jobDefinitionConfiguration(modificationBatch.getId()).count());
batchIds.remove(modificationBatch.getId());
for (String batchId : batchIds) {
assertEquals(0, historyService.createHistoricJobLogQuery().jobDefinitionConfiguration(batchId).count());
}
}
use of org.camunda.bpm.engine.batch.history.HistoricBatch in project camunda-bpm-platform by camunda.
the class HistoryCleanupHistoricBatchTest method testCleanupHistoricIncident.
@Test
public void testCleanupHistoricIncident() {
initBatchOperationHistoryTimeToLive(DEFAULT_TTL_DAYS);
ClockUtil.setCurrentTime(DateUtils.addDays(new Date(), -11));
BatchEntity batch = (BatchEntity) createFailingMigrationBatch();
migrationHelper.executeSeedJob(batch);
List<Job> list = managementService.createJobQuery().list();
for (Job job : list) {
if (((JobEntity) job).getJobHandlerType().equals("instance-migration")) {
managementService.setJobRetries(job.getId(), 1);
}
}
migrationHelper.executeJobs(batch);
List<String> byteArrayIds = findExceptionByteArrayIds();
ClockUtil.setCurrentTime(DateUtils.addDays(new Date(), -10));
managementService.deleteBatch(batch.getId(), false);
ClockUtil.setCurrentTime(new Date());
// given
HistoricBatch historicBatch = historyService.createHistoricBatchQuery().singleResult();
String batchId = historicBatch.getId();
// when
String jobId = historyService.cleanUpHistoryAsync(true).getId();
managementService.executeJob(jobId);
assertEquals(0, historyService.createHistoricBatchQuery().count());
assertEquals(0, historyService.createHistoricJobLogQuery().jobDefinitionConfiguration(batchId).count());
assertEquals(0, historyService.createHistoricIncidentQuery().count());
verifyByteArraysWereRemoved(byteArrayIds.toArray(new String[] {}));
}
use of org.camunda.bpm.engine.batch.history.HistoricBatch in project camunda-bpm-platform by camunda.
the class HistoricBatchQueryTest method testBatchQueryOrderByEndTimeAsc.
@Test
public void testBatchQueryOrderByEndTimeAsc() {
// given
ClockTestUtil.setClockToDateWithoutMilliseconds();
Batch batch1 = helper.migrateProcessInstancesAsync(1);
helper.completeBatch(batch1);
ClockTestUtil.incrementClock(1000);
Batch batch2 = helper.migrateProcessInstancesAsync(1);
helper.completeBatch(batch2);
// when
List<HistoricBatch> orderedBatches = historyService.createHistoricBatchQuery().orderByEndTime().asc().list();
// then
verifySorting(orderedBatches, historicBatchByEndTime());
}
use of org.camunda.bpm.engine.batch.history.HistoricBatch in project camunda-bpm-platform by camunda.
the class HistoricBatchQueryTest method testBatchQuery.
@Test
public void testBatchQuery() {
// given
Batch batch1 = helper.migrateProcessInstancesAsync(1);
Batch batch2 = helper.migrateProcessInstancesAsync(1);
// when
List<HistoricBatch> list = historyService.createHistoricBatchQuery().list();
// then
assertEquals(2, list.size());
List<String> batchIds = new ArrayList<String>();
for (HistoricBatch resultBatch : list) {
batchIds.add(resultBatch.getId());
}
Assert.assertTrue(batchIds.contains(batch1.getId()));
Assert.assertTrue(batchIds.contains(batch2.getId()));
}
Aggregations