use of org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport in project camunda-bpm-platform by camunda.
the class EnsureCleanDbPlugin method postProcessApplicationUndeploy.
@SuppressWarnings("resource")
@Override
public void postProcessApplicationUndeploy(ProcessApplicationInterface processApplication) {
// best example is TestWarDeploymentWithBrokenBpmnXml in integration-test-engine test suite
if (counter.get() == 0 || counter.decrementAndGet() == 0) {
final ProcessEngine defaultProcessEngine = BpmPlatform.getDefaultProcessEngine();
try {
logger.log(Level.INFO, "=== Ensure Clean Database ===");
ManagementServiceImpl managementService = (ManagementServiceImpl) defaultProcessEngine.getManagementService();
PurgeReport report = managementService.purge();
if (report.isEmpty()) {
logger.log(Level.INFO, "Clean DB and cache.");
} else {
StringBuilder builder = new StringBuilder();
DatabasePurgeReport databasePurgeReport = report.getDatabasePurgeReport();
if (!databasePurgeReport.isEmpty()) {
builder.append(DATABASE_NOT_CLEAN).append(databasePurgeReport.getPurgeReportAsString());
}
CachePurgeReport cachePurgeReport = report.getCachePurgeReport();
if (!cachePurgeReport.isEmpty()) {
builder.append(CACHE_IS_NOT_CLEAN).append(cachePurgeReport.getPurgeReportAsString());
}
logger.log(Level.INFO, builder.toString());
}
} catch (Throwable e) {
logger.log(Level.SEVERE, "Could not clean DB:", e);
}
}
}
use of org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport in project camunda-bpm-platform by camunda.
the class PurgeDatabaseTest method testPurgeCmmnProcess.
// CMMN //////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Test
public void testPurgeCmmnProcess() {
// given cmmn process which is not managed by process engine rule
engineRule.getRepositoryService().createDeployment().addClasspathResource("org/camunda/bpm/engine/test/standalone/db/entitymanager/PurgeDatabaseTest.testPurgeCmmnProcess.cmmn").deploy();
VariableMap variables = Variables.createVariables();
variables.put("key", "value");
engineRule.getCaseService().createCaseInstanceByKey(PROCESS_DEF_KEY, variables);
// when purge is executed
ManagementServiceImpl managementService = (ManagementServiceImpl) engineRule.getManagementService();
PurgeReport purge = managementService.purge();
// then database and cache is cleaned
assertAndEnsureCleanDbAndCache(engineRule.getProcessEngine(), true);
// and report contains deleted entities
assertFalse(purge.isEmpty());
CachePurgeReport cachePurgeReport = purge.getCachePurgeReport();
assertEquals(1, cachePurgeReport.getReportValue(CachePurgeReport.CASE_DEF_CACHE).size());
DatabasePurgeReport databasePurgeReport = purge.getDatabasePurgeReport();
assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RE_DEPLOYMENT"));
assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_TASK"));
assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_GE_BYTEARRAY"));
assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RE_CASE_DEF"));
assertEquals(3, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_CASE_EXECUTION"));
assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_VARIABLE"));
assertEquals(2, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_CASE_SENTRY_PART"));
if (processEngineConfiguration.getHistoryLevel().equals(HistoryLevel.HISTORY_LEVEL_FULL)) {
assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_DETAIL"));
assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_TASKINST"));
assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_VARINST"));
assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_CASEINST"));
assertEquals(2, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_CASEACTINST"));
}
}
use of org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport in project camunda-bpm-platform by camunda.
the class PurgeDatabaseTest method testPurgeDmnProcess.
// DMN ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Test
public void testPurgeDmnProcess() {
// given dmn process which is not managed by process engine rule
engineRule.getRepositoryService().createDeployment().addClasspathResource("org/camunda/bpm/engine/test/standalone/db/entitymanager/PurgeDatabaseTest.testPurgeDmnProcess.dmn").deploy();
VariableMap variables = Variables.createVariables().putValue("key", "value").putValue("season", "Test");
engineRule.getDecisionService().evaluateDecisionByKey("decisionId").variables(variables).evaluate();
// when purge is executed
ManagementServiceImpl managementService = (ManagementServiceImpl) engineRule.getManagementService();
PurgeReport purge = managementService.purge();
// then database and cache is cleaned
assertAndEnsureCleanDbAndCache(engineRule.getProcessEngine(), true);
// and report contains deleted entities
assertFalse(purge.isEmpty());
CachePurgeReport cachePurgeReport = purge.getCachePurgeReport();
assertEquals(2, cachePurgeReport.getReportValue(CachePurgeReport.DMN_DEF_CACHE).size());
assertEquals(1, cachePurgeReport.getReportValue(CachePurgeReport.DMN_REQ_DEF_CACHE).size());
DatabasePurgeReport databasePurgeReport = purge.getDatabasePurgeReport();
assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RE_DEPLOYMENT"));
assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_GE_BYTEARRAY"));
assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RE_DECISION_REQ_DEF"));
assertEquals(2, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RE_DECISION_DEF"));
if (processEngineConfiguration.getHistoryLevel().equals(HistoryLevel.HISTORY_LEVEL_FULL)) {
assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_DECINST"));
assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_DEC_IN"));
assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_DEC_OUT"));
}
}
use of org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport in project camunda-bpm-platform by camunda.
the class PurgeDatabaseAndCacheCmd method execute.
@Override
public PurgeReport execute(CommandContext commandContext) {
PurgeReport purgeReport = new PurgeReport();
// purge the database
DatabasePurgeReport databasePurgeReport = purgeDatabase(commandContext);
purgeReport.setDatabasePurgeReport(databasePurgeReport);
// purge the deployment cache
DeploymentCache deploymentCache = commandContext.getProcessEngineConfiguration().getDeploymentCache();
CachePurgeReport cachePurgeReport = deploymentCache.purgeCache();
purgeReport.setCachePurgeReport(cachePurgeReport);
return purgeReport;
}
use of org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport in project camunda-bpm-platform by camunda.
the class TestHelper method assertAndEnsureCleanDbAndCache.
/**
* Ensures that the deployment cache and database is clean after a test. If not the cache
* and database will be cleared.
*
* @param processEngine the {@link ProcessEngine} to test
* @param fail if true the method will throw an {@link AssertionError} if the deployment cache or database is not clean
* @throws AssertionError if the deployment cache or database was not clean
*/
public static String assertAndEnsureCleanDbAndCache(ProcessEngine processEngine, boolean fail) {
ProcessEngineConfigurationImpl processEngineConfiguration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration();
// clear user operation log in case some operations are
// executed with an authenticated user
clearUserOperationLog(processEngineConfiguration);
LOG.debug("verifying that db is clean after test");
PurgeReport purgeReport = ((ManagementServiceImpl) processEngine.getManagementService()).purge();
String paRegistrationMessage = assertAndEnsureNoProcessApplicationsRegistered(processEngine);
StringBuilder message = new StringBuilder();
CachePurgeReport cachePurgeReport = purgeReport.getCachePurgeReport();
if (!cachePurgeReport.isEmpty()) {
message.append("Deployment cache is not clean:\n").append(cachePurgeReport.getPurgeReportAsString());
} else {
LOG.debug("Deployment cache was clean.");
}
DatabasePurgeReport databasePurgeReport = purgeReport.getDatabasePurgeReport();
if (!databasePurgeReport.isEmpty()) {
message.append("Database is not clean:\n").append(databasePurgeReport.getPurgeReportAsString());
} else {
LOG.debug("Database was clean.");
}
if (paRegistrationMessage != null) {
message.append(paRegistrationMessage);
}
if (fail && message.length() > 0) {
Assert.fail(message.toString());
}
return message.toString();
}
Aggregations