From 26d84483d2c99f14efb68920b2b72df26e0a541f Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Mon, 6 Sep 2021 19:58:19 +0100 Subject: [PATCH 1/2] Added retry on transaction post --- .../Common/Retry.cs | 2 ++ .../Shared/SharedSteps.cs | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/TransactionProcessor.IntegrationTests/Common/Retry.cs b/TransactionProcessor.IntegrationTests/Common/Retry.cs index f4742dad..bd4bf266 100644 --- a/TransactionProcessor.IntegrationTests/Common/Retry.cs +++ b/TransactionProcessor.IntegrationTests/Common/Retry.cs @@ -6,6 +6,7 @@ namespace TransactionProcessor.IntegrationTests { using System.Threading; using System.Threading.Tasks; + using global::Shared.Logger; public static class Retry { @@ -55,6 +56,7 @@ public static async Task For(Func action, catch (Exception e) { lastException = e; + Logger.LogError(e); // wait before retrying Thread.Sleep(retryInterval ?? Retry.DefaultRetryInterval); diff --git a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs index b1f15e08..192d0a2a 100644 --- a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs @@ -534,10 +534,15 @@ private async Task PerformSaleTransaction(Guid estateId, Guid TypeNameHandling = TypeNameHandling.All }); - SerialisedMessage responseSerialisedMessage = - await this.TestingContext.DockerHelper.TransactionProcessorClient.PerformTransaction(this.TestingContext.AccessToken, - serialisedMessage, - cancellationToken); + SerialisedMessage responseSerialisedMessage = null; + await Retry.For(async () => + { + responseSerialisedMessage = + await this.TestingContext.DockerHelper.TransactionProcessorClient.PerformTransaction(this.TestingContext.AccessToken, + serialisedMessage, + cancellationToken); + }, TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(15)); + return responseSerialisedMessage; } From 85b2fb6311f8ccd76c00281be84d8313f774085f Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Mon, 6 Sep 2021 20:03:40 +0100 Subject: [PATCH 2/2] :| --- TransactionProcessor.IntegrationTests/Common/Retry.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/TransactionProcessor.IntegrationTests/Common/Retry.cs b/TransactionProcessor.IntegrationTests/Common/Retry.cs index bd4bf266..ee8b5651 100644 --- a/TransactionProcessor.IntegrationTests/Common/Retry.cs +++ b/TransactionProcessor.IntegrationTests/Common/Retry.cs @@ -56,7 +56,6 @@ public static async Task For(Func action, catch (Exception e) { lastException = e; - Logger.LogError(e); // wait before retrying Thread.Sleep(retryInterval ?? Retry.DefaultRetryInterval);