From d946304f1e4203c5c6336938524cd1c8b20c392f Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Sun, 8 Apr 2018 16:02:59 +0200 Subject: [PATCH] PR fixed --- .../Orleans/Bootstrap.cs | 2 +- .../Grains/OrleansEventNotifierTests.cs | 1 - .../Orleans/BootstrapTests.cs | 39 +++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/Squidex.Infrastructure/Orleans/Bootstrap.cs b/src/Squidex.Infrastructure/Orleans/Bootstrap.cs index cf1f03145..254d31b49 100644 --- a/src/Squidex.Infrastructure/Orleans/Bootstrap.cs +++ b/src/Squidex.Infrastructure/Orleans/Bootstrap.cs @@ -36,7 +36,7 @@ namespace Squidex.Infrastructure.Orleans return; } - catch (OrleansMessageRejectionException) + catch (OrleansException) { if (i == NumTries) { diff --git a/tests/Squidex.Infrastructure.Tests/EventSourcing/Grains/OrleansEventNotifierTests.cs b/tests/Squidex.Infrastructure.Tests/EventSourcing/Grains/OrleansEventNotifierTests.cs index 536e8829f..4c3e54e11 100644 --- a/tests/Squidex.Infrastructure.Tests/EventSourcing/Grains/OrleansEventNotifierTests.cs +++ b/tests/Squidex.Infrastructure.Tests/EventSourcing/Grains/OrleansEventNotifierTests.cs @@ -29,7 +29,6 @@ namespace Squidex.Infrastructure.EventSourcing.Grains [Fact] public void Should_wakeup_manager_with_stream_name() { - sut.Initialize(); sut.NotifyEventsStored("my-stream"); A.CallTo(() => manager.ActivateAsync("my-stream")) diff --git a/tests/Squidex.Infrastructure.Tests/Orleans/BootstrapTests.cs b/tests/Squidex.Infrastructure.Tests/Orleans/BootstrapTests.cs index 153a9d276..037aab083 100644 --- a/tests/Squidex.Infrastructure.Tests/Orleans/BootstrapTests.cs +++ b/tests/Squidex.Infrastructure.Tests/Orleans/BootstrapTests.cs @@ -6,10 +6,13 @@ // All rights reserved. // ========================================================================== +using System; using System.Threading; using System.Threading.Tasks; using FakeItEasy; using Orleans; +using Orleans.Runtime; +using Squidex.Infrastructure.Tasks; using Xunit; namespace Squidex.Infrastructure.Orleans @@ -37,5 +40,41 @@ namespace Squidex.Infrastructure.Orleans A.CallTo(() => grain.ActivateAsync()) .MustHaveHappened(); } + + [Fact] + public async Task Should_fail_on_non_rejection_exception() + { + A.CallTo(() => grain.ActivateAsync()) + .Throws(new InvalidOperationException()); + + await Assert.ThrowsAsync(() => sut.Execute(CancellationToken.None)); + } + + [Fact] + public async Task Should_retry_after_rejection_exception() + { + A.CallTo(() => grain.ActivateAsync()) + .Returns(TaskHelper.Done); + + A.CallTo(() => grain.ActivateAsync()) + .Throws(new OrleansException()).Once(); + + await sut.Execute(CancellationToken.None); + + A.CallTo(() => grain.ActivateAsync()) + .MustHaveHappened(Repeated.Exactly.Twice); + } + + [Fact] + public async Task Should_fail_after_10_rejection_exception() + { + A.CallTo(() => grain.ActivateAsync()) + .Throws(new OrleansException()); + + await Assert.ThrowsAsync(() => sut.Execute(CancellationToken.None)); + + A.CallTo(() => grain.ActivateAsync()) + .MustHaveHappened(Repeated.Exactly.Times(10)); + } } }