Skip to content

Commit

Permalink
merge: camunda#13986
Browse files Browse the repository at this point in the history
13986: Resolve flaky `ResourceDeletionMultiPartitionTest` r=remcowesterhoud a=remcowesterhoud

## Description

<!-- Please explain the changes you made here. -->

Please find the explanation [here](camunda#13980 (comment)).

## Related issues

<!-- Which issues are closed by this PR or are related -->

closes camunda#13980 



Co-authored-by: Remco Westerhoud <[email protected]>
  • Loading branch information
zeebe-bors-camunda[bot] and remcowesterhoud authored Aug 23, 2023
2 parents ba3f3ba + 108f062 commit e59b1d5
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private void transformAndDistributeDeployment(final TypedRecord<DeploymentRecord
private void processDistributedRecord(final TypedRecord<DeploymentRecord> command) {
final var deploymentEvent = command.getValue();
createBpmnResources(deploymentEvent);
createDmnResources(command, deploymentEvent);
createDmnResources(deploymentEvent);
final var recordWithoutResource = createDeploymentWithoutResources(deploymentEvent);
stateWriter.appendFollowUpEvent(
command.getKey(), DeploymentIntent.CREATED, recordWithoutResource);
Expand All @@ -187,22 +187,22 @@ private void createBpmnResources(final DeploymentRecord deploymentEvent) {
});
}

private void createDmnResources(
final TypedRecord<DeploymentRecord> command, final DeploymentRecord deploymentEvent) {
private void createDmnResources(final DeploymentRecord deploymentEvent) {
deploymentEvent.decisionRequirementsMetadata().stream()
.filter(not(DecisionRequirementsMetadataRecord::isDuplicate))
.map(drg -> createDrgRecord(deploymentEvent, drg))
.forEach(
decisionRequirementsRecord ->
stateWriter.appendFollowUpEvent(
command.getKey(),
decisionRequirementsRecord.getDecisionRequirementsKey(),
DecisionRequirementsIntent.CREATED,
decisionRequirementsRecord));
deploymentEvent.decisionsMetadata().stream()
.filter(not(DecisionRecord::isDuplicate))
.forEach(
(record) ->
stateWriter.appendFollowUpEvent(command.getKey(), DecisionIntent.CREATED, record));
stateWriter.appendFollowUpEvent(
record.getDecisionKey(), DecisionIntent.CREATED, record));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
import io.camunda.zeebe.protocol.record.Record;
import io.camunda.zeebe.protocol.record.RecordType;
import io.camunda.zeebe.protocol.record.intent.CommandDistributionIntent;
import io.camunda.zeebe.protocol.record.intent.DecisionIntent;
import io.camunda.zeebe.protocol.record.intent.DecisionRequirementsIntent;
import io.camunda.zeebe.protocol.record.intent.DeploymentIntent;
import io.camunda.zeebe.protocol.record.intent.ProcessIntent;
import io.camunda.zeebe.protocol.record.value.CommandDistributionRecordValue;
import io.camunda.zeebe.protocol.record.value.DeploymentRecordValue;
import io.camunda.zeebe.protocol.record.value.deployment.DecisionRecordValue;
import io.camunda.zeebe.protocol.record.value.deployment.DecisionRequirementsMetadataValue;
import io.camunda.zeebe.protocol.record.value.deployment.ProcessMetadataValue;
import io.camunda.zeebe.test.util.Strings;
import io.camunda.zeebe.test.util.record.RecordingExporter;
import io.camunda.zeebe.test.util.record.RecordingExporterTestWatcher;
import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -408,6 +412,60 @@ public void shouldNotFilterDifferentDmnResource() {
repeatedDrgs.forEach(r -> assertDifferentDrg(originalDrg.get(0), r));
}

@Test
public void shouldWriteProcessCreatedEventsWithSameKeys() {
// given
final var processId = Strings.newRandomValidBpmnId();

// when
ENGINE
.deployment()
.withXmlResource(
"process.bpmn", Bpmn.createExecutableProcess(processId).startEvent().endEvent().done())
.deploy();

// then
assertThat(
RecordingExporter.processRecords()
.withIntents(ProcessIntent.CREATED)
.withBpmnProcessId(processId)
.limit(3)
.map(Record::getKey)
.distinct())
.describedAs("All created events get the same key")
.hasSize(1);
}

@Test
public void shouldWriteDrgAndDecisionCreatedEventsWithSameKeys() {
// given
final var drgId = "force_users";
final var decisionId = "jedi_or_sith";

// when
ENGINE.deployment().withXmlClasspathResource(DMN_DECISION_TABLE).deploy();

// then
assertThat(
RecordingExporter.decisionRequirementsRecords()
.withIntents(DecisionRequirementsIntent.CREATED)
.withDecisionRequirementsId(drgId)
.limit(3)
.map(Record::getKey)
.distinct())
.describedAs("All created events get the same key")
.hasSize(1);
assertThat(
RecordingExporter.decisionRecords()
.withIntents(DecisionIntent.CREATED)
.withDecisionId(decisionId)
.limit(3)
.map(Record::getKey)
.distinct())
.describedAs("All created events get the same key")
.hasSize(1);
}

private void assertDeploymentRecordWithoutResources(
final Record<DeploymentRecordValue> deployment,
final Record<DeploymentRecordValue> createdDeployment) {
Expand Down

0 comments on commit e59b1d5

Please sign in to comment.