Skip to content

Commit 433bea0

Browse files
He-PinCopilot
andcommitted
Fix EventSourcedBehaviorRetentionSpec non-determinism
Split the second batch of 10 increments into smaller batches (3+3+4) with intermediate assertions after each batch. This ensures snapshot and delete signals are observed in the expected order, preventing flaky test failures caused by interleaving of async operations. Upstream: akka/akka-core@f38f8cce11 Cherry-picked from akka/akka-core v2.8.0, which is now Apache licensed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5addd96 commit 433bea0

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

persistence-typed-tests/src/test/scala/org/apache/pekko/persistence/typed/scaladsl/EventSourcedBehaviorRetentionSpec.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,21 @@ class EventSourcedBehaviorRetentionSpec
286286
snapshotSignalProbe.expectSnapshotCompleted(9)
287287
snapshotSignalProbe.expectDeleteSnapshotCompleted(3, 0)
288288

289-
(1 to 10).foreach(_ => persistentActor ! Increment)
289+
(1 to 3).foreach(_ => persistentActor ! Increment)
290290
persistentActor ! GetValue(replyProbe.ref)
291-
replyProbe.expectMessage(State(20, (0 until 20).toVector))
291+
replyProbe.expectMessage(State(13, (0 until 13).toVector))
292292
snapshotSignalProbe.expectSnapshotCompleted(12)
293293
snapshotSignalProbe.expectDeleteSnapshotCompleted(6, 0)
294+
295+
(1 to 3).foreach(_ => persistentActor ! Increment)
296+
persistentActor ! GetValue(replyProbe.ref)
297+
replyProbe.expectMessage(State(16, (0 until 16).toVector))
294298
snapshotSignalProbe.expectSnapshotCompleted(15)
295299
snapshotSignalProbe.expectDeleteSnapshotCompleted(9, 3)
300+
301+
(1 to 4).foreach(_ => persistentActor ! Increment)
302+
persistentActor ! GetValue(replyProbe.ref)
303+
replyProbe.expectMessage(State(20, (0 until 20).toVector))
296304
snapshotSignalProbe.expectSnapshotCompleted(18)
297305
snapshotSignalProbe.expectDeleteSnapshotCompleted(12, 6)
298306

0 commit comments

Comments
 (0)