Skip to content
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 @@ -15,6 +15,8 @@
*/

using System;
using Adaptive.Aeron.Exceptions;
using AeronErrorCode = Adaptive.Aeron.ErrorCode;

namespace Adaptive.Archiver.IntegrationTests.Helpers
{
Expand All @@ -23,6 +25,8 @@ internal sealed class PersistentSubscriptionListener : IPersistentSubscriptionLi
public int LiveJoinedCount { get; private set; }
public int LiveLeftCount { get; private set; }
public int ErrorCount { get; private set; }
public int TerminalErrorCount { get; private set; }
public int NonTransientErrorCount { get; private set; }
public Exception LastException { get; private set; }

public void OnLiveJoined() => LiveJoinedCount++;
Expand All @@ -32,7 +36,18 @@ internal sealed class PersistentSubscriptionListener : IPersistentSubscriptionLi
public void OnError(Exception e)
{
ErrorCount++;
if (!IsTransient(e))
{
NonTransientErrorCount++;
}
if (e is PersistentSubscriptionException)
{
TerminalErrorCount++;
}
LastException = e;
}

private static bool IsTransient(Exception e) =>
e is RegistrationException re && re.ErrorCode() == AeronErrorCode.RESOURCE_TEMPORARILY_UNAVAILABLE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ public void ShouldStartFromStoppedRecordingAndErrorWhenLiveHasAdvanced()
() => Poll(persistentSubscription, fragmentHandler, 1));

Assert.That(fragmentHandler.ReceivedPayloads.Count, Is.EqualTo(recordedMessages.Count));
Assert.That(Listener.ErrorCount, Is.EqualTo(1));
Assert.That(Listener.TerminalErrorCount, Is.EqualTo(1));
Assert.That(Listener.LastException, Is.InstanceOf<PersistentSubscriptionException>());
Assert.That(
((PersistentSubscriptionException)Listener.LastException).ReasonValue,
Expand Down Expand Up @@ -1385,8 +1385,8 @@ public void ShouldReplayAndCatchUpWhenExtendedRecordingIsAheadOfLivePosition()
};

// Wait for one AWAIT_LIVE deadline breach.
Tests.ExecuteUntil(() => Listener.ErrorCount > 0, pollAndTrack, 30_000);
Assert.That(Listener.ErrorCount, Is.EqualTo(1));
Tests.ExecuteUntil(() => Listener.NonTransientErrorCount > 0, pollAndTrack, 30_000);
Assert.That(Listener.NonTransientErrorCount, Is.EqualTo(1));
Assert.That(persistentSubscription.IsLive, Is.False);
Assert.That(observedReplaying[0], Is.False);

Expand Down Expand Up @@ -1424,7 +1424,7 @@ public void ShouldReplayAndCatchUpWhenExtendedRecordingIsAheadOfLivePosition()
AssertPayloads(fragmentHandler.ReceivedPayloads, expected);
Assert.That(observedReplaying[0], Is.True,
"PS did not transition through REPLAY/ATTEMPT_SWITCH after revoke");
Assert.That(Listener.ErrorCount, Is.EqualTo(1));
Assert.That(Listener.NonTransientErrorCount, Is.EqualTo(1));
}

private void ArmDataDropFromPosition(LossGenController controller, long recordingId, long fromPosition)
Expand Down Expand Up @@ -1484,8 +1484,8 @@ public void ShouldRefreshAndReplayWhenLiveAheadOfStopPositionAfterResume()
};

// Wait for one AWAIT_LIVE deadline breach.
Tests.ExecuteUntil(() => Listener.ErrorCount > 0, pollAndTrack);
Assert.That(Listener.ErrorCount, Is.EqualTo(1));
Tests.ExecuteUntil(() => Listener.NonTransientErrorCount > 0, pollAndTrack);
Assert.That(Listener.NonTransientErrorCount, Is.EqualTo(1));
Assert.That(
Listener.LastException.Message,
Does.Contain("No image became available on the live subscription"));
Expand All @@ -1512,7 +1512,7 @@ public void ShouldRefreshAndReplayWhenLiveAheadOfStopPositionAfterResume()
"PS did not transition through REPLAY/ATTEMPT_SWITCH; refresh path was not exercised");
Assert.That(Listener.LiveJoinedCount, Is.EqualTo(1));
Assert.That(Listener.LiveLeftCount, Is.EqualTo(0));
Assert.That(Listener.ErrorCount, Is.EqualTo(1));
Assert.That(Listener.NonTransientErrorCount, Is.EqualTo(1));
}

[TestCase(1), TestCase(10), Timeout(20_000)]
Expand Down
Loading