From 303e38e5b4f29c2b5b7f6e3d5498180937c1559d Mon Sep 17 00:00:00 2001 From: Remco Westerhoud Date: Tue, 9 May 2023 10:22:25 +0200 Subject: [PATCH] test(engine): fix flaky test The test was flaky because it could occur that the messages got published before the subscription were opened. As the messages have no TTL this means they were not getting correlated, as expected. --- .../bpmn/subprocess/EmbeddedSubProcessTest.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/engine/src/test/java/io/camunda/zeebe/engine/processing/bpmn/subprocess/EmbeddedSubProcessTest.java b/engine/src/test/java/io/camunda/zeebe/engine/processing/bpmn/subprocess/EmbeddedSubProcessTest.java index 42f375d4ef7a..b23a08647ed1 100644 --- a/engine/src/test/java/io/camunda/zeebe/engine/processing/bpmn/subprocess/EmbeddedSubProcessTest.java +++ b/engine/src/test/java/io/camunda/zeebe/engine/processing/bpmn/subprocess/EmbeddedSubProcessTest.java @@ -24,6 +24,7 @@ import io.camunda.zeebe.protocol.record.ValueType; import io.camunda.zeebe.protocol.record.intent.JobIntent; import io.camunda.zeebe.protocol.record.intent.MessageIntent; +import io.camunda.zeebe.protocol.record.intent.MessageSubscriptionIntent; import io.camunda.zeebe.protocol.record.intent.ProcessEventIntent; import io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent; import io.camunda.zeebe.protocol.record.intent.VariableIntent; @@ -623,10 +624,15 @@ public void shouldNotTriggerBoundaryEventWhenFlowscopeIsInterrupted() { .withVariable("correlationKey", "correlationKey") .create(); - RecordingExporter.processInstanceRecords(ProcessInstanceIntent.ELEMENT_ACTIVATED) - .withProcessInstanceKey(processInstanceKey) - .withElementId("task") - .await(); + assertThat( + RecordingExporter.messageSubscriptionRecords(MessageSubscriptionIntent.CREATED) + .withProcessInstanceKey(processInstanceKey) + .limit(2)) + .describedAs( + "The 2 message subscriptions must be created before we publish the " + + "messages. As the messages have a TTL of 0 seconds") + .describedAs("") + .hasSize(2); // when // We need to make sure no records are written in between the publish commands. This could