Search in sources :

Example 6 with CachePurgeReport

use of org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport in project camunda-bpm-platform by camunda.

the class TestHelper method assertAndEnsureCleanDeploymentCache.

/**
 * Ensures that the deployment cache is empty after a test. If not the cache
 * 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 is not clean
 * @return the deployment cache summary if fail is set to false or null if deployment cache was clean
 * @throws AssertionError if the deployment cache was not clean and fail is set to true
 */
public static String assertAndEnsureCleanDeploymentCache(ProcessEngine processEngine, boolean fail) {
    StringBuilder outputMessage = new StringBuilder();
    ProcessEngineConfigurationImpl processEngineConfiguration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration();
    CachePurgeReport cachePurgeReport = processEngineConfiguration.getDeploymentCache().purgeCache();
    outputMessage.append(cachePurgeReport.getPurgeReportAsString());
    if (outputMessage.length() > 0) {
        outputMessage.insert(0, "Deployment cache not clean:\n");
        LOG.error(outputMessage.toString());
        if (fail) {
            Assert.fail(outputMessage.toString());
        }
        return outputMessage.toString();
    } else {
        LOG.debug("Deployment cache was clean");
        return null;
    }
}
Also used : CachePurgeReport(org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) ProcessEngineImpl(org.camunda.bpm.engine.impl.ProcessEngineImpl)

Example 7 with CachePurgeReport

use of org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport in project camunda-bpm-platform by camunda.

the class PurgeDatabaseTest method testPurgeComplexProcess.

@Test
public void testPurgeComplexProcess() {
    // given complex process with authentication
    // process is executed two times
    // metrics are reported
    BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_DEF_KEY).startEvent().camundaAsyncBefore().parallelGateway("parallel").serviceTask("external").camundaType("external").camundaTopic("external").boundaryEvent().message("message").moveToNode("parallel").serviceTask().camundaAsyncBefore().camundaExpression("${1/0}").moveToLastGateway().userTask().done();
    createAuthenticationData();
    engineRule.getRepositoryService().createDeployment().addModelInstance(PROCESS_MODEL_NAME, modelInstance).deploy();
    executeComplexBpmnProcess(true);
    executeComplexBpmnProcess(false);
    processEngineConfiguration.getDbMetricsReporter().reportNow();
    // when purge is executed
    ManagementServiceImpl managementService = (ManagementServiceImpl) engineRule.getManagementService();
    PurgeReport purge = managementService.purge();
    // then database and cache are empty
    assertAndEnsureCleanDbAndCache(engineRule.getProcessEngine(), true);
    // and report contains deleted data
    assertFalse(purge.isEmpty());
    CachePurgeReport cachePurgeReport = purge.getCachePurgeReport();
    assertEquals(1, cachePurgeReport.getReportValue(CachePurgeReport.PROCESS_DEF_CACHE).size());
    DatabasePurgeReport databasePurgeReport = purge.getDatabasePurgeReport();
    assertEquals(2, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_ID_TENANT_MEMBER"));
    assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_EVENT_SUBSCR"));
    assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RE_DEPLOYMENT"));
    assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_EXT_TASK"));
    assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_ID_MEMBERSHIP"));
    assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_TASK"));
    assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_JOB"));
    assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_GE_BYTEARRAY"));
    assertEquals(2, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_JOBDEF"));
    assertEquals(2, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_ID_USER"));
    assertEquals(5, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_EXECUTION"));
    assertEquals(10, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_METER_LOG"));
    assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_VARIABLE"));
    assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RE_PROCDEF"));
    assertEquals(2, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_ID_TENANT"));
    assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_ID_GROUP"));
    assertEquals(2, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_AUTHORIZATION"));
    if (processEngineConfiguration.getHistoryLevel().equals(HistoryLevel.HISTORY_LEVEL_FULL)) {
        assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_INCIDENT"));
        assertEquals(9, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_ACTINST"));
        assertEquals(2, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_PROCINST"));
        assertEquals(2, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_DETAIL"));
        assertEquals(2, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_TASKINST"));
        assertEquals(7, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_JOB_LOG"));
        assertEquals(2, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_VARINST"));
        assertEquals(3, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_OP_LOG"));
    }
}
Also used : ManagementServiceImpl(org.camunda.bpm.engine.impl.ManagementServiceImpl) DatabasePurgeReport(org.camunda.bpm.engine.impl.management.DatabasePurgeReport) CachePurgeReport(org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) PurgeReport(org.camunda.bpm.engine.impl.management.PurgeReport) CachePurgeReport(org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport) DatabasePurgeReport(org.camunda.bpm.engine.impl.management.DatabasePurgeReport) Test(org.junit.Test)

Aggregations

CachePurgeReport (org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport)7 DatabasePurgeReport (org.camunda.bpm.engine.impl.management.DatabasePurgeReport)6 PurgeReport (org.camunda.bpm.engine.impl.management.PurgeReport)6 ManagementServiceImpl (org.camunda.bpm.engine.impl.ManagementServiceImpl)5 Test (org.junit.Test)3 ProcessEngineImpl (org.camunda.bpm.engine.impl.ProcessEngineImpl)2 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)2 VariableMap (org.camunda.bpm.engine.variable.VariableMap)2 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)1 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)1 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)1