Skip to content

Commit

Permalink
fix PersistentActor_should_be_able_to_persist_events_that_happen_duri…
Browse files Browse the repository at this point in the history
…ng_recovery (#3805)

* fix PersistentActor_should_be_able_to_persist_events_that_happen_during_recovery

#3786 - fix PersistentActor_should_be_able_to_persist_events_that_happen_during_recovery by porting akka/akka#22232

* force PersistentActorRecoverySpec to use new SteppingMemoryJournal instance each time
  • Loading branch information
Aaronontheweb committed May 22, 2019
1 parent acd8156 commit c11f5b7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
16 changes: 15 additions & 1 deletion src/core/Akka.Persistence.Tests/PersistenceSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Akka.Configuration;
using Akka.TestKit;
using Akka.Util.Internal;
using FluentAssertions;
using Xunit.Abstractions;

namespace Akka.Persistence.Tests
Expand Down Expand Up @@ -70,9 +71,22 @@ protected void ExpectMsgInOrder(params object[] ordered)
{
var msg = ExpectMsg<object[]>();
msg
//.Select(x => x.ToString())
.ShouldOnlyContainInOrder(ordered);
}

protected void ExpectAnyMsgInOrder(params IEnumerable<object>[] expected)
{
var msg = ExpectMsg<object[]>();
foreach (var e in expected)
{
if (e.SequenceEqual(msg))
return;
}

false.Should()
.BeTrue(
$"[{string.Join(",", msg)}] should match any expected value {string.Join(",", expected.Select(x => "[" + string.Join(",", x) + "]"))}");
}
}

internal class Cleanup : IDisposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
using Akka.Event;
using Akka.Persistence.Tests.Journal;
using Akka.TestKit;
using Akka.Util.Internal;
using Xunit;

namespace Akka.Persistence.Tests
{

[Collection("PersistentActorRecoveryTimeout")] // force tests to run sequentially
public class PersistentActorRecoveryTimeoutSpec : PersistenceSpec
{
private const string JournalId = "persistent-actor-recovery-timeout-spec";
private static readonly AtomicCounter JournalIdNumber = new AtomicCounter(0);
private static readonly string JournalId = "persistent-actor-recovery-timeout-spec" + JournalIdNumber.GetAndIncrement();
private readonly IActorRef _journal;

#region internal test classes
Expand Down
4 changes: 1 addition & 3 deletions src/core/Akka.Persistence.Tests/PersistentActorSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,7 @@ public void PersistentActor_should_be_able_to_persist_events_that_happen_during_
{
var persistentActor = ActorOf(Props.Create(() => new PersistInRecovery(Name)));
persistentActor.Tell(GetState.Instance);
ExpectMsgInOrder("a-1", "a-2", "rc-1", "rc-2");
persistentActor.Tell(GetState.Instance);
ExpectMsgInOrder("a-1", "a-2", "rc-1", "rc-2", "rc-3");
ExpectAnyMsgInOrder(new[]{"a-1", "a-2", "rc-1", "rc-2" }, new[] { "a-1", "a-2", "rc-1", "rc-2", "rc-3" });
persistentActor.Tell(new Cmd("invalid"));
persistentActor.Tell(GetState.Instance);
ExpectMsgInOrder("a-1", "a-2", "rc-1", "rc-2", "rc-3", "invalid");
Expand Down

0 comments on commit c11f5b7

Please sign in to comment.