-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(engine): verify StackOverFlow during termination results in banning
This test verifies that when a process instance is terminated and results in a SO we will ban an instance. It is not the process instance that got terminated that gets banned! Instead it's one of the child instance for which the "bubbling up" caused the SO. (cherry picked from commit 83f22b0)
- Loading branch information
1 parent
79afa3d
commit be8e387
Showing
4 changed files
with
118 additions
and
2 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
...java/io/camunda/zeebe/engine/processing/processinstance/CancelProcessInstanceBanTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
* one or more contributor license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding copyright ownership. | ||
* Licensed under the Zeebe Community License 1.1. You may not use this file | ||
* except in compliance with the Zeebe Community License 1.1. | ||
*/ | ||
package io.camunda.zeebe.engine.processing.processinstance; | ||
|
||
import io.camunda.zeebe.engine.util.EngineRule; | ||
import io.camunda.zeebe.model.bpmn.Bpmn; | ||
import io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent; | ||
import io.camunda.zeebe.protocol.record.value.BpmnElementType; | ||
import io.camunda.zeebe.test.util.Strings; | ||
import io.camunda.zeebe.test.util.record.RecordingExporter; | ||
import io.camunda.zeebe.test.util.record.RecordingExporterTestWatcher; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.ClassRule; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TestWatcher; | ||
|
||
public final class CancelProcessInstanceBanTest { | ||
|
||
@ClassRule public static final EngineRule ENGINE = EngineRule.singlePartition(); | ||
@Rule public final TestWatcher recordingExporterTestWatcher = new RecordingExporterTestWatcher(); | ||
|
||
@Test // Regression of https://github.com/camunda/zeebe/issues/8955 | ||
public void shouldBanInstanceWhenTerminatingInstanceWithALotOfNestedChildInstances() { | ||
// given | ||
final var amountOfNestedChildInstances = 1000; | ||
final var processId = Strings.newRandomValidBpmnId(); | ||
ENGINE | ||
.deployment() | ||
.withXmlResource( | ||
Bpmn.createExecutableProcess(processId) | ||
.startEvent() | ||
.exclusiveGateway() | ||
.defaultFlow() | ||
.userTask() | ||
.endEvent() | ||
.moveToLastGateway() | ||
.conditionExpression("count < " + amountOfNestedChildInstances) | ||
.intermediateThrowEvent("preventStraightThroughLoop") | ||
.callActivity( | ||
"callActivity", | ||
c -> c.zeebeProcessId(processId).zeebeInputExpression("count + 1", "count")) | ||
.endEvent() | ||
.done()) | ||
.deploy(); | ||
|
||
final long processInstanceKey = | ||
ENGINE.processInstance().ofBpmnProcessId(processId).withVariable("count", 0).create(); | ||
|
||
RecordingExporter.processInstanceRecords(ProcessInstanceIntent.ELEMENT_ACTIVATED) | ||
.withElementType(BpmnElementType.USER_TASK) | ||
.getFirst(); | ||
|
||
// when | ||
final var errorRecordValue = | ||
ENGINE.processInstance().withInstanceKey(processInstanceKey).cancelWithError(); | ||
|
||
// then | ||
Assertions.assertThat(errorRecordValue.getValue().getStacktrace()) | ||
.contains("ChildTerminationStackOverflowException"); | ||
Assertions.assertThat(errorRecordValue.getValue().getExceptionMessage()) | ||
.contains( | ||
"Process instance", | ||
""" | ||
has too many nested child instances and could not be terminated. The deepest nested \ | ||
child instance has been banned as a result."""); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
test-util/src/main/java/io/camunda/zeebe/test/util/record/ErrorRecordStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
* one or more contributor license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding copyright ownership. | ||
* Licensed under the Zeebe Community License 1.1. You may not use this file | ||
* except in compliance with the Zeebe Community License 1.1. | ||
*/ | ||
package io.camunda.zeebe.test.util.record; | ||
|
||
import io.camunda.zeebe.protocol.record.Record; | ||
import io.camunda.zeebe.protocol.record.value.ErrorRecordValue; | ||
import java.util.stream.Stream; | ||
|
||
public class ErrorRecordStream extends ExporterRecordStream<ErrorRecordValue, ErrorRecordStream> { | ||
|
||
public ErrorRecordStream(final Stream<Record<ErrorRecordValue>> wrappedStream) { | ||
super(wrappedStream); | ||
} | ||
|
||
@Override | ||
protected ErrorRecordStream supply(final Stream<Record<ErrorRecordValue>> wrappedStream) { | ||
return new ErrorRecordStream(wrappedStream); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters