diff --git a/src/Adaptive.Archiver.IntegrationTests/Helpers/PersistentSubscriptionListener.cs b/src/Adaptive.Archiver.IntegrationTests/Helpers/PersistentSubscriptionListener.cs index a3cbd1f..d0516f3 100644 --- a/src/Adaptive.Archiver.IntegrationTests/Helpers/PersistentSubscriptionListener.cs +++ b/src/Adaptive.Archiver.IntegrationTests/Helpers/PersistentSubscriptionListener.cs @@ -15,6 +15,8 @@ */ using System; +using Adaptive.Aeron.Exceptions; +using AeronErrorCode = Adaptive.Aeron.ErrorCode; namespace Adaptive.Archiver.IntegrationTests.Helpers { @@ -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++; @@ -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; } } diff --git a/src/Adaptive.Archiver.IntegrationTests/PersistentSubscriptionTest.cs b/src/Adaptive.Archiver.IntegrationTests/PersistentSubscriptionTest.cs index 7255ece..b0dd5eb 100644 --- a/src/Adaptive.Archiver.IntegrationTests/PersistentSubscriptionTest.cs +++ b/src/Adaptive.Archiver.IntegrationTests/PersistentSubscriptionTest.cs @@ -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()); Assert.That( ((PersistentSubscriptionException)Listener.LastException).ReasonValue, @@ -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); @@ -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) @@ -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")); @@ -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)]