diff --git a/source/Octopus.Tentacle.Tests.Integration/ClientScriptExecutionCanBeCancelledWhenRetriesAreDisabled.cs b/source/Octopus.Tentacle.Tests.Integration/ClientScriptExecutionCanBeCancelledWhenRetriesAreDisabled.cs index 7a368a3fa..1d2cd33bc 100644 --- a/source/Octopus.Tentacle.Tests.Integration/ClientScriptExecutionCanBeCancelledWhenRetriesAreDisabled.cs +++ b/source/Octopus.Tentacle.Tests.Integration/ClientScriptExecutionCanBeCancelledWhenRetriesAreDisabled.cs @@ -55,8 +55,6 @@ public async Task DuringGetCapabilities_ScriptExecutionCanBeCancelled(TentacleCo nameof(IAsyncClientCapabilitiesServiceV2.GetCapabilitiesAsync), async (_, _) => { - ensureCancellationOccursDuringAnRpcCall.Release(); - if (!hasPausedOrStoppedPortForwarder) { hasPausedOrStoppedPortForwarder = true; @@ -68,6 +66,8 @@ public async Task DuringGetCapabilities_ScriptExecutionCanBeCancelled(TentacleCo await tcpConnectionUtilities.EnsurePollingQueueWontSendMessageToDisconnectedTentacles(); } } + + ensureCancellationOccursDuringAnRpcCall.Release(); }, async (_, _) => { await ensureCancellationOccursDuringAnRpcCall.WaitAsync(CancellationToken); @@ -148,8 +148,6 @@ public async Task DuringStartScript_ScriptExecutionCanBeCancelled(TentacleConfig nameof(IAsyncClientScriptServiceV2.StartScriptAsync), async (_, _) => { - ensureCancellationOccursDuringAnRpcCall.Release(); - if (!hasPausedOrStoppedPortForwarder) { hasPausedOrStoppedPortForwarder = true; @@ -160,6 +158,8 @@ public async Task DuringStartScript_ScriptExecutionCanBeCancelled(TentacleConfig await tcpConnectionUtilities.EnsurePollingQueueWontSendMessageToDisconnectedTentacles(); } } + + ensureCancellationOccursDuringAnRpcCall.Release(); }) .HookServiceMethod(tentacleConfigurationTestCase, nameof(IAsyncClientScriptServiceV2.CancelScriptAsync), @@ -258,8 +258,6 @@ public async Task DuringGetStatus_ScriptExecutionCanBeCancelled(TentacleConfigur nameof(IAsyncClientScriptServiceV2.GetStatusAsync), async (_, _) => { - ensureCancellationOccursDuringAnRpcCall.Release(); - if (!hasPausedOrStoppedPortForwarder) { hasPausedOrStoppedPortForwarder = true; @@ -271,6 +269,7 @@ public async Task DuringGetStatus_ScriptExecutionCanBeCancelled(TentacleConfigur } } + ensureCancellationOccursDuringAnRpcCall.Release(); timer.Restart(); }, async (_, _) => diff --git a/source/Octopus.Tentacle.Tests.Integration/ClientScriptExecutionCanBeCancelledWhenRetriesAreEnabled.cs b/source/Octopus.Tentacle.Tests.Integration/ClientScriptExecutionCanBeCancelledWhenRetriesAreEnabled.cs index be4e4e898..52be5a27b 100644 --- a/source/Octopus.Tentacle.Tests.Integration/ClientScriptExecutionCanBeCancelledWhenRetriesAreEnabled.cs +++ b/source/Octopus.Tentacle.Tests.Integration/ClientScriptExecutionCanBeCancelledWhenRetriesAreEnabled.cs @@ -60,8 +60,6 @@ public async Task DuringGetCapabilities_ScriptExecutionCanBeCancelled(TentacleCo nameof(IAsyncClientCapabilitiesServiceV2.GetCapabilitiesAsync), async (_, _) => { - ensureCancellationOccursDuringAnRpcCall.Release(); - if (rpcCall == RpcCall.RetryingCall && capabilitiesMethodUsages.For(nameof(IAsyncClientCapabilitiesServiceV2.GetCapabilitiesAsync)).LastException == null) { @@ -81,6 +79,8 @@ public async Task DuringGetCapabilities_ScriptExecutionCanBeCancelled(TentacleCo await tcpConnectionUtilities.EnsurePollingQueueWontSendMessageToDisconnectedTentacles(); } } + + ensureCancellationOccursDuringAnRpcCall.Release(); }, async (_, _) => { await ensureCancellationOccursDuringAnRpcCall.WaitAsync(CancellationToken); @@ -179,8 +179,6 @@ public async Task DuringStartScript_ScriptExecutionCanBeCancelled(TentacleConfig nameof(IAsyncClientScriptServiceV2.StartScriptAsync), async (_, _) => { - ensureCancellationOccursDuringAnRpcCall.Release(); - if (rpcCall == RpcCall.RetryingCall && recordedUsages.For(nameof(IAsyncClientScriptServiceV2.StartScriptAsync)).LastException is null) { @@ -202,6 +200,7 @@ public async Task DuringStartScript_ScriptExecutionCanBeCancelled(TentacleConfig } } + ensureCancellationOccursDuringAnRpcCall.Release(); timer.Restart(); }, async (_, _) => @@ -335,8 +334,6 @@ public async Task DuringGetStatus_ScriptExecutionCanBeCancelled(TentacleConfigur nameof(IAsyncClientScriptServiceV2.GetStatusAsync), async (_, _) => { - ensureCancellationOccursDuringAnRpcCall.Release(); - if (rpcCall == RpcCall.RetryingCall && recordedUsages.For(nameof(IAsyncClientScriptServiceV2.GetStatusAsync)).LastException is null) { @@ -358,6 +355,7 @@ public async Task DuringGetStatus_ScriptExecutionCanBeCancelled(TentacleConfigur } } + ensureCancellationOccursDuringAnRpcCall.Release(); timer.Restart(); }, async (_, _) =>