Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Persistence.TCK specs #5849

Merged
merged 3 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected override bool ReceiveCommand(object message)
DeleteSnapshots(new SnapshotSelectionCriteria(deleteTo, DateTime.MaxValue, deleteFrom));
break;
case DeleteMessagesFailure m:
Log.Warning("PersistentShard messages to [{0}] deletion failure: [{1}]", m.ToSequenceNr, m.Cause.Message);
Log.Warning(m.Cause, "PersistentShard messages to [{0}] deletion failure: [{1}]", m.ToSequenceNr, m.Cause.Message);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch

break;
case DeleteSnapshotsSuccess m:
Log.Debug("PersistentShard snapshots matching [{0}] deleted successfully", m.Criteria);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ private bool HandleSnapshotResult(object message)
DeleteSnapshots(new SnapshotSelectionCriteria(m.ToSequenceNr - 1));
break;
case DeleteMessagesFailure m:
Log.Warning("Persistent messages to {0} deletion failure: {1}", m.ToSequenceNr, m.Cause.Message);
Log.Warning(m.Cause, "Persistent messages to {0} deletion failure: {1}", m.ToSequenceNr, m.Cause.Message);
break;
case DeleteSnapshotsSuccess m:
Log.Debug("Persistent snapshots matching {0} deleted successfully", m.Criteria);
Expand Down
32 changes: 16 additions & 16 deletions src/core/Akka.Persistence.TCK/Journal/JournalSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,92 +155,92 @@ private AtomicWrite[] WriteMessages(int from, int to, string pid, IActorRef send
}

[Fact]
public void Journal_should_replay_all_messages()
public virtual void Journal_should_replay_all_messages()
{
Journal.Tell(new ReplayMessages(1, long.MaxValue, long.MaxValue, Pid, _receiverProbe.Ref));
for (int i = 1; i <= 5; i++) _receiverProbe.ExpectMsg<ReplayedMessage>(m => IsReplayedMessage(m, i));
_receiverProbe.ExpectMsg<RecoverySuccess>(m => m.HighestSequenceNr == 5L);
}

[Fact]
public void Journal_should_replay_messages_using_a_lower_sequence_number_bound()
public virtual void Journal_should_replay_messages_using_a_lower_sequence_number_bound()
{
Journal.Tell(new ReplayMessages(3, long.MaxValue, long.MaxValue, Pid, _receiverProbe.Ref));
for (int i = 3; i <= 5; i++) _receiverProbe.ExpectMsg<ReplayedMessage>(m => IsReplayedMessage(m, i));
_receiverProbe.ExpectMsg<RecoverySuccess>(m => m.HighestSequenceNr == 5L);
}

[Fact]
public void Journal_should_replay_messages_using_an_upper_sequence_number_bound()
public virtual void Journal_should_replay_messages_using_an_upper_sequence_number_bound()
{
Journal.Tell(new ReplayMessages(1, 3, long.MaxValue, Pid, _receiverProbe.Ref));
for (int i = 1; i <= 3; i++) _receiverProbe.ExpectMsg<ReplayedMessage>(m => IsReplayedMessage(m, i));
_receiverProbe.ExpectMsg<RecoverySuccess>(m => m.HighestSequenceNr == 5L);
}

[Fact]
public void Journal_should_replay_messages_using_a_count_limit()
public virtual void Journal_should_replay_messages_using_a_count_limit()
{
Journal.Tell(new ReplayMessages(1, long.MaxValue, 3, Pid, _receiverProbe.Ref));
for (int i = 1; i <= 3; i++) _receiverProbe.ExpectMsg<ReplayedMessage>(m => IsReplayedMessage(m, i));
_receiverProbe.ExpectMsg<RecoverySuccess>(m => m.HighestSequenceNr == 5L);
}

[Fact]
public void Journal_should_replay_messages_using_lower_and_upper_sequence_number_bound()
public virtual void Journal_should_replay_messages_using_lower_and_upper_sequence_number_bound()
{
Journal.Tell(new ReplayMessages(2, 3, long.MaxValue, Pid, _receiverProbe.Ref));
for (int i = 2; i <= 3; i++) _receiverProbe.ExpectMsg<ReplayedMessage>(m => IsReplayedMessage(m, i));
_receiverProbe.ExpectMsg<RecoverySuccess>(m => m.HighestSequenceNr == 5L);
}

[Fact]
public void Journal_should_replay_messages_using_lower_and_upper_sequence_number_bound_and_count_limit()
public virtual void Journal_should_replay_messages_using_lower_and_upper_sequence_number_bound_and_count_limit()
{
Journal.Tell(new ReplayMessages(2, 5, 2, Pid, _receiverProbe.Ref));
for (int i = 2; i <= 3; i++) _receiverProbe.ExpectMsg<ReplayedMessage>(m => IsReplayedMessage(m, i));
_receiverProbe.ExpectMsg<RecoverySuccess>(m => m.HighestSequenceNr == 5L);
}

[Fact]
public void Journal_should_replay_a_single_if_lower_sequence_number_bound_equals_upper_sequence_number_bound()
public virtual void Journal_should_replay_a_single_if_lower_sequence_number_bound_equals_upper_sequence_number_bound()
{
Journal.Tell(new ReplayMessages(2, 2, long.MaxValue, Pid, _receiverProbe.Ref));
_receiverProbe.ExpectMsg<ReplayedMessage>(m => IsReplayedMessage(m, 2));
_receiverProbe.ExpectMsg<RecoverySuccess>(m => m.HighestSequenceNr == 5L);
}

[Fact]
public void Journal_should_replay_a_single_message_if_count_limit_is_equal_one()
public virtual void Journal_should_replay_a_single_message_if_count_limit_is_equal_one()
{
Journal.Tell(new ReplayMessages(2, 4, 1, Pid, _receiverProbe.Ref));
_receiverProbe.ExpectMsg<ReplayedMessage>(m => IsReplayedMessage(m, 2));
_receiverProbe.ExpectMsg<RecoverySuccess>(m => m.HighestSequenceNr == 5L);
}

[Fact]
public void Journal_should_not_replay_messages_if_count_limit_equals_zero()
public virtual void Journal_should_not_replay_messages_if_count_limit_equals_zero()
{
Journal.Tell(new ReplayMessages(2, 4, 0, Pid, _receiverProbe.Ref));
_receiverProbe.ExpectMsg<RecoverySuccess>(m => m.HighestSequenceNr == 5L);
}

[Fact]
public void Journal_should_not_replay_messages_if_lower_sequence_number_bound_is_greater_than_upper_sequence_number_bound()
public virtual void Journal_should_not_replay_messages_if_lower_sequence_number_bound_is_greater_than_upper_sequence_number_bound()
{
Journal.Tell(new ReplayMessages(3, 2, long.MaxValue, Pid, _receiverProbe.Ref));
_receiverProbe.ExpectMsg<RecoverySuccess>(m => m.HighestSequenceNr == 5L);
}

[Fact]
public void Journal_should_not_replay_messages_if_the_persistent_actor_has_not_yet_written_messages()
public virtual void Journal_should_not_replay_messages_if_the_persistent_actor_has_not_yet_written_messages()
{
Journal.Tell(new ReplayMessages(0, long.MaxValue, long.MaxValue, "non-existing-pid", _receiverProbe.Ref));
_receiverProbe.ExpectMsg<RecoverySuccess>(m => m.HighestSequenceNr == 0L);
}

[Fact]
public void Journal_should_not_replay_permanently_deleted_messages_on_range_deletion()
public virtual void Journal_should_not_replay_permanently_deleted_messages_on_range_deletion()
{
var receiverProbe2 = CreateTestProbe();
var command = new DeleteMessagesTo(Pid, 3, receiverProbe2.Ref);
Expand All @@ -259,7 +259,7 @@ public void Journal_should_not_replay_permanently_deleted_messages_on_range_dele
}

[Fact]
public void Journal_should_not_reset_HighestSequenceNr_after_message_deletion()
public virtual void Journal_should_not_reset_HighestSequenceNr_after_message_deletion()
{
Journal.Tell(new ReplayMessages(0, long.MaxValue, long.MaxValue, Pid, _receiverProbe.Ref));
for (int i = 1; i <= 5; i++) _receiverProbe.ExpectMsg<ReplayedMessage>(m => IsReplayedMessage(m, i));
Expand All @@ -274,7 +274,7 @@ public void Journal_should_not_reset_HighestSequenceNr_after_message_deletion()
}

[Fact]
public void Journal_should_not_reset_HighestSequenceNr_after_journal_cleanup()
public virtual void Journal_should_not_reset_HighestSequenceNr_after_journal_cleanup()
{
Journal.Tell(new ReplayMessages(0, long.MaxValue, long.MaxValue, Pid, _receiverProbe.Ref));
for (int i = 1; i <= 5; i++) _receiverProbe.ExpectMsg<ReplayedMessage>(m => IsReplayedMessage(m, i));
Expand All @@ -288,7 +288,7 @@ public void Journal_should_not_reset_HighestSequenceNr_after_journal_cleanup()
}

[Fact]
public void Journal_should_serialize_events()
public virtual void Journal_should_serialize_events()
{
if (!SupportsSerialization) return;

Expand Down Expand Up @@ -340,7 +340,7 @@ public void GetObjectData(SerializationInfo info, StreamingContext context)
}

[Fact]
public void Journal_optionally_may_reject_non_serializable_events()
public virtual void Journal_optionally_may_reject_non_serializable_events()
{
if (!SupportsRejectingNonSerializableObjects) return;

Expand Down
1 change: 1 addition & 0 deletions src/core/Akka.Persistence.TCK/Query/TestActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ protected Receive WhileDeleting(IActorRef originalSender)
Stash.UnstashAll();
break;
case DeleteMessagesFailure failure:
Log.Error(failure.Cause, "Failed to delete messages to sequence number [{0}].", failure.ToSequenceNr);
originalSender.Tell($"{failure.ToSequenceNr}-deleted-failed");
Become(OnCommand);
Stash.UnstashAll();
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Persistence/Eventsourced.Lifecycle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ protected override void Unhandled(object message)
case DeleteMessagesFailure failure:
{
if (Log.IsWarningEnabled)
Log.Warning("Failed to DeleteMessages ToSequenceNr [{0}] for PersistenceId [{1}] due to: [{2}: {3}]", failure.ToSequenceNr, PersistenceId, failure.Cause, failure.Cause.Message);
Log.Warning(failure.Cause, "Failed to DeleteMessages ToSequenceNr [{0}] for PersistenceId [{1}] due to: {2}", failure.ToSequenceNr, PersistenceId, failure.Cause.Message);
break;
}
}
Expand Down