From 165b39d1e0ec7987299e65161d93edcd4645088d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Andr=C3=A9n?= Date: Wed, 22 Jul 2020 12:19:03 +0200 Subject: [PATCH] Incorrect assumption about event ordering in test fixed (#29411) --- .../persistence/typed/ActiveActiveSpec.scala | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/akka-persistence-typed-tests/src/test/scala/akka/persistence/typed/ActiveActiveSpec.scala b/akka-persistence-typed-tests/src/test/scala/akka/persistence/typed/ActiveActiveSpec.scala index 5ae2cf87a0..3c6ea4e25b 100644 --- a/akka-persistence-typed-tests/src/test/scala/akka/persistence/typed/ActiveActiveSpec.scala +++ b/akka-persistence-typed-tests/src/test/scala/akka/persistence/typed/ActiveActiveSpec.scala @@ -301,7 +301,7 @@ class ActiveActiveSpec r1 ! StoreMe("from r1 2", probe.ref) probe.expectMessage(Done) - // r2 + // r2, in order because we wrote them both in r1 eventProbeR2.expectMessage(EventAndContext("from r1 1", ReplicaId("R1"), false, false)) eventProbeR2.expectMessage(EventAndContext("from r1 2", ReplicaId("R1"), false, false)) @@ -310,13 +310,17 @@ class ActiveActiveSpec r2 ! StoreMe("from r2 2", probe.ref) probe.expectMessage(Done) - // r3 should only get the events 1, not R2s stored version of them + // r3 should only get the events 1, not R2s stored version of them, but we don't know the + // order they will arrive val eventProbeR3 = createTestProbe[EventAndContext]() spawn(testBehavior(entityId, "R3", eventProbeR3.ref)) - eventProbeR3.expectMessage(EventAndContext("from r1 1", ReplicaId("R1"), false, false)) - eventProbeR3.expectMessage(EventAndContext("from r1 2", ReplicaId("R1"), false, false)) - eventProbeR3.expectMessage(EventAndContext("from r2 1", ReplicaId("R2"), false, false)) - eventProbeR3.expectMessage(EventAndContext("from r2 2", ReplicaId("R2"), false, false)) + val eventAndContexts = eventProbeR3.receiveMessages(4).toSet + eventAndContexts should ===( + Set( + EventAndContext("from r1 1", ReplicaId("R1"), false, false), + EventAndContext("from r1 2", ReplicaId("R1"), false, false), + EventAndContext("from r2 1", ReplicaId("R2"), false, false), + EventAndContext("from r2 2", ReplicaId("R2"), false, false))) eventProbeR3.expectNoMessage() }