protected void verifyBooleanParameterQueryInvocations() { verify(mockedQuery).creationLog(); verify(mockedQuery).failureLog(); verify(mockedQuery).successLog(); verify(mockedQuery).deletionLog(); verify(mockedQuery).list(); }
@Override public void execute(PerfTestRunContext context) { long failedJobs = processEngine.getHistoryService().createHistoricJobLogQuery().failureLog().count(); long createdJobs = processEngine.getHistoryService().createHistoricJobLogQuery().creationLog().count(); long successfulJobs = processEngine.getHistoryService().createHistoricJobLogQuery().successLog().count(); System.out.println("Number of created jobs: " + createdJobs); System.out.println("Number of failed jobs: " + failedJobs); System.out.println("Number of successful jobs: " + successfulJobs); }
protected List<ByteArrayEntity> findByteArrays() { List<HistoricJobLog> jobLogs = historyService.createHistoricJobLogQuery() .failureLog() .list(); List<ByteArrayEntity> byteArrays = new ArrayList<>(); for (HistoricJobLog jobLog: jobLogs) { byteArrays.add(findByteArrayById(((HistoricJobLogEventEntity) jobLog).getExceptionByteArrayId())); } return byteArrays; }
@Test public void getHistoricJobLogExceptionStacktraceWithAuthenticatedTenant() { testRule.deployForTenant(TENANT_ONE, FAILING_BPMN_PROCESS); String processInstanceId = startProcessInstance(null); testRule.executeAvailableJobs(); HistoricJobLog log = historyService.createHistoricJobLogQuery() .processInstanceId(processInstanceId).failureLog().listPage(0, 1).get(0); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); String historicJobLogExceptionStacktrace = historyService.getHistoricJobLogExceptionStacktrace(log.getId()); assertThat(historicJobLogExceptionStacktrace, notNullValue()); }
public void testGetHistoricJobLogExceptionStacktraceWithReadHistoryPermissionOnProcessDefinition() { // given startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY); disableAuthorization(); String jobLogId = historyService.createHistoricJobLogQuery().failureLog().listPage(0, 1).get(0).getId(); enableAuthorization(); createGrantAuthorization(PROCESS_DEFINITION, ONE_INCIDENT_PROCESS_KEY, userId, READ_HISTORY); // when String stacktrace = historyService.getHistoricJobLogExceptionStacktrace(jobLogId); // then assertNotNull(stacktrace); }
public void testGetHistoricJobLogExceptionStacktraceWithReadHistoryPermissionOnAnyProcessDefinition() { // given startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY); disableAuthorization(); String jobLogId = historyService.createHistoricJobLogQuery().failureLog().listPage(0, 1).get(0).getId(); enableAuthorization(); createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_HISTORY); // when String stacktrace = historyService.getHistoricJobLogExceptionStacktrace(jobLogId); // then assertNotNull(stacktrace); }
@Test public void getHistoricJobLogExceptionStacktraceWithDisabledTenantCheck() { testRule.deployForTenant(TENANT_ONE, FAILING_BPMN_PROCESS); String processInstanceId = startProcessInstance(TENANT_ONE); testRule.executeAvailableJobs(); HistoricJobLog log = historyService.createHistoricJobLogQuery() .processInstanceId(processInstanceId).failureLog().listPage(0, 1).get(0); identityService.setAuthentication("user", null, null); processEngineConfiguration.setTenantCheckEnabled(false); String historicJobLogExceptionStacktrace = historyService.getHistoricJobLogExceptionStacktrace(log.getId()); assertThat(historicJobLogExceptionStacktrace, notNullValue()); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml"}) public void testQueryByFailureLog() { runtimeService.startProcessInstanceByKey("process"); String jobId = managementService.createJobQuery().singleResult().getId(); try { managementService.executeJob(jobId); fail(); } catch (Exception e) { // expected } HistoricJobLogQuery query = historyService.createHistoricJobLogQuery().failureLog(); verifyQueryResults(query, 1); }
public void testGetHistoricJobLogExceptionStacktraceWithoutAuthorization() { // given startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY); disableAuthorization(); String jobLogId = historyService.createHistoricJobLogQuery().failureLog().listPage(0, 1).get(0).getId(); enableAuthorization(); try { // when historyService.getHistoricJobLogExceptionStacktrace(jobLogId); fail("Exception expected: It should not be possible to get the historic job log exception stacktrace"); } catch (AuthorizationException e) { // then String message = e.getMessage(); assertTextPresent(userId, message); assertTextPresent(READ_HISTORY.getName(), message); assertTextPresent(ONE_INCIDENT_PROCESS_KEY, message); assertTextPresent(PROCESS_DEFINITION.resourceName(), message); } }
.failureLog() .singleResult(); .failureLog() .orderByJobRetries() .desc()
@Deployment public void testThrowExceptionWithoutMessage() { // given runtimeService.startProcessInstanceByKey("process").getId(); String jobId = managementService.createJobQuery().singleResult().getId(); // when try { managementService.executeJob(jobId); fail(); } catch (Exception e) { // expected } // then HistoricJobLog failedHistoricJobLog = historyService .createHistoricJobLogQuery() .failureLog() .singleResult(); String failedHistoricJobLogId = failedHistoricJobLog.getId(); assertNull(failedHistoricJobLog.getJobExceptionMessage()); String stacktrace = historyService.getHistoricJobLogExceptionStacktrace(failedHistoricJobLogId); assertNotNull(stacktrace); assertTextPresent(ThrowExceptionWithoutMessageDelegate.class.getName(), stacktrace); }
@Deployment public void testThrowExceptionMessageTruncation() { // given String exceptionMessage = randomString(10000); ThrowExceptionWithOverlongMessageDelegate delegate = new ThrowExceptionWithOverlongMessageDelegate(exceptionMessage); runtimeService.startProcessInstanceByKey("process", Variables.createVariables().putValue("delegate", delegate)); Job job = managementService.createJobQuery().singleResult(); // when try { managementService.executeJob(job.getId()); fail(); } catch (Exception e) { // expected } // then HistoricJobLog failedHistoricJobLog = historyService .createHistoricJobLogQuery() .failureLog() .singleResult(); assertNotNull(failedHistoricJobLog); assertEquals(exceptionMessage.substring(0, JobEntity.MAX_EXCEPTION_MESSAGE_LENGTH), failedHistoricJobLog.getJobExceptionMessage()); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml"}) public void testExceptionStacktrace() { // given runtimeService.startProcessInstanceByKey("process"); String jobId = managementService.createJobQuery().singleResult().getId(); // when try { managementService.executeJob(jobId); fail(); } catch (Exception e) { // expected } // then String failedHistoricJobLogId = historyService .createHistoricJobLogQuery() .failureLog() .singleResult() .getId(); String stacktrace = historyService.getHistoricJobLogExceptionStacktrace(failedHistoricJobLogId); assertNotNull(stacktrace); assertTextPresent(FailingDelegate.EXCEPTION_MESSAGE, stacktrace); }
.failureLog() .singleResult();
@Test public void shouldCleanupByteArray() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS_INCIDENT); runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String jobId = managementService.createJobQuery() .singleResult() .getId(); try { managementService.executeJob(jobId); } catch (Exception ignored) { } HistoricJobLogEventEntity jobLog = (HistoricJobLogEventEntity) historyService.createHistoricJobLogQuery() .failureLog() .singleResult(); ByteArrayEntity byteArray = findByteArrayById(jobLog.getExceptionByteArrayId()); // assume assertThat(byteArray, notNullValue()); managementService.setJobRetries(jobId, 0); managementService.executeJob(jobId); ClockUtil.setCurrentTime(END_DATE); String taskId = taskService.createTaskQuery().singleResult().getId(); taskService.complete(taskId); ClockUtil.setCurrentTime(addDays(END_DATE, 5)); // when runHistoryCleanup(); byteArray = findByteArrayById(jobLog.getExceptionByteArrayId()); // then assertThat(byteArray, nullValue()); }
@Test public void testHistoricExceptionStacktraceBinary() { // given BpmnModelInstance instance = createFailingProcess(); testRule.deploy(instance); runtimeService.startProcessInstanceByKey("Process"); String jobId = managementService.createJobQuery().singleResult().getId(); // when try { managementService.executeJob(jobId); fail(); } catch (Exception e) { // expected } HistoricJobLogEventEntity entity = (HistoricJobLogEventEntity) historyService .createHistoricJobLogQuery() .failureLog() .singleResult(); assertNotNull(entity); ByteArrayEntity byteArrayEntity = configuration.getCommandExecutorTxRequired().execute(new GetByteArrayCommand(entity.getExceptionByteArrayId())); checkBinary(byteArrayEntity); }
HistoricJobLogQuery failedQuery = historyService.createHistoricJobLogQuery().jobId(jobId).failureLog().orderByJobRetries().desc();
.createHistoricJobLogQuery() .jobId(jobId) .failureLog() .singleResult(); assertNotNull(historicJob);
.failureLog() .singleResult(); assertNotNull(historicJob);