Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwoctopusdeploy committed Dec 6, 2023
1 parent e4cf0a2 commit 6b77e55
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ public async Task WhenRpcRetriesTimeOut_DuringUploadFile_TheRpcCallIsCancelled(T
var duration = Stopwatch.StartNew();
var executeScriptTask = clientAndTentacle.TentacleClient.UploadFile(remotePath, dataStream, CancellationToken, inMemoryLog);

var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase, clientAndTentacle)
.ForFileTransferService(FileTransferServiceOperation.UploadFile).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

await AssertionExtensions.Should(async () => await executeScriptTask).ThrowExceptionContractAsync(expectedException);
duration.Stop();
Expand Down Expand Up @@ -125,8 +124,7 @@ public async Task WhenUploadFileFails_AndTakesLongerThanTheRetryDuration_TheCall
var dataStream = DataStream.FromString("The Stream");
var executeScriptTask = clientAndTentacle.TentacleClient.UploadFile(remotePath, dataStream, CancellationToken, inMemoryLog);

var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase, clientAndTentacle)
.ForFileTransferService(FileTransferServiceOperation.UploadFile).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

await AssertionExtensions.Should(async () => await executeScriptTask).ThrowExceptionContractAsync(expectedException);

Expand Down Expand Up @@ -187,8 +185,7 @@ public async Task WhenRpcRetriesTimeOut_DuringDownloadFile_TheRpcCallIsCancelled
var duration = Stopwatch.StartNew();
var executeScriptTask = clientAndTentacle.TentacleClient.DownloadFile(tempFile.File.FullName, CancellationToken, inMemoryLog);

var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase, clientAndTentacle)
.ForFileTransferService(FileTransferServiceOperation.DownloadFile).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

await AssertionExtensions.Should(async () => await executeScriptTask).ThrowExceptionContractAsync(expectedException);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public async Task FailedUploadsAreNotRetriedAndFail(TentacleConfigurationTestCas
var remotePath = Path.Combine(clientTentacle.TemporaryDirectory.DirectoryPath, "UploadFile.txt");
var uploadFileTask = clientTentacle.TentacleClient.UploadFile(remotePath, DataStream.FromString("Hello"), CancellationToken);

var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase, clientTentacle)
.ForFileTransferService(FileTransferServiceOperation.UploadFile).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase.TentacleType, clientTentacle).Build();

await AssertionExtensions.Should(async () => await uploadFileTask).ThrowExceptionContractAsync(expectedException);

Expand Down Expand Up @@ -86,8 +85,7 @@ public async Task FailedDownloadsAreNotRetriedAndFail(TentacleConfigurationTestC
await clientTentacle.TentacleClient.UploadFile(remotePath, DataStream.FromString("Hello"), CancellationToken);
var downloadFileTask = clientTentacle.TentacleClient.DownloadFile(remotePath, CancellationToken);

var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase, clientTentacle)
.ForFileTransferService(FileTransferServiceOperation.DownloadFile).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase.TentacleType, clientTentacle).Build();

await AssertionExtensions.Should(async () => await downloadFileTask).ThrowExceptionContractAsync(expectedException);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ public async Task DuringGetCapabilities_ScriptExecutionCanBeCancelled(TentacleCo
var (_, actualException, cancellationDuration) = await ExecuteScriptThenCancelExecutionWhenRpcCallHasStarted(clientAndTentacle, startScriptCommand, rpcCallHasStarted, ensureCancellationOccursDuringAnRpcCall);

// ASSERT
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ScriptExecutionCancelled, tentacleConfigurationTestCase, clientAndTentacle)
.ForScriptService(ScriptServiceOperation.GetCapabilities).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ScriptExecutionCancelled, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

actualException.ShouldMatchExceptionContract(expectedException);

Expand Down Expand Up @@ -187,8 +186,7 @@ public async Task DuringStartScript_ScriptExecutionCanBeCancelled(TentacleConfig
var (_, actualException, cancellationDuration) = await ExecuteScriptThenCancelExecutionWhenRpcCallHasStarted(clientAndTentacle, startScriptCommand, rpcCallHasStarted, ensureCancellationOccursDuringAnRpcCall);

// ASSERT
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ScriptExecutionCancelled, tentacleConfigurationTestCase, clientAndTentacle)
.ForScriptService(ScriptServiceOperation.StartScript).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ScriptExecutionCancelled, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

actualException.ShouldMatchExceptionContract(expectedException);

Expand Down Expand Up @@ -307,8 +305,7 @@ public async Task DuringGetStatus_ScriptExecutionCanBeCancelled(TentacleConfigur
var (_, actualException, cancellationDuration) = await ExecuteScriptThenCancelExecutionWhenRpcCallHasStarted(clientAndTentacle, startScriptCommand, rpcCallHasStarted, ensureCancellationOccursDuringAnRpcCall);

// ASSERT
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ScriptExecutionCancelled, tentacleConfigurationTestCase, clientAndTentacle)
.ForScriptService(ScriptServiceOperation.GetStatus).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ScriptExecutionCancelled, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

actualException.ShouldMatchExceptionContract(expectedException);

Expand Down Expand Up @@ -393,8 +390,7 @@ public async Task DuringCompleteScript_ScriptExecutionCanBeCancelled(TentacleCon
var (responseAndLogs, actualException, cancellationDuration) = await ExecuteScriptThenCancelExecutionWhenRpcCallHasStarted(clientAndTentacle, startScriptCommand, rpcCallHasStarted, new SemaphoreSlim(int.MaxValue, Int32.MaxValue));

// ASSERT
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ScriptExecutionCancelled, tentacleConfigurationTestCase, clientAndTentacle)
.ForScriptService(ScriptServiceOperation.CompleteScript).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ScriptExecutionCancelled, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

actualException.ShouldMatchExceptionContract(expectedException);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ public async Task DuringGetCapabilities_ScriptExecutionCanBeCancelled(TentacleCo
var (_, actualException, cancellationDuration) = await ExecuteScriptThenCancelExecutionWhenRpcCallHasStarted(clientAndTentacle, startScriptCommand, rpcCallHasStarted, ensureCancellationOccursDuringAnRpcCall);

// ASSERT
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ScriptExecutionCancelled, tentacleConfigurationTestCase, clientAndTentacle)
.ForScriptService(ScriptServiceOperation.GetCapabilities).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ScriptExecutionCancelled, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

actualException.ShouldMatchExceptionContract(expectedException);

Expand Down Expand Up @@ -237,8 +236,7 @@ public async Task DuringStartScript_ScriptExecutionCanBeCancelled(TentacleConfig
var (_, actualException, cancellationDuration) = await ExecuteScriptThenCancelExecutionWhenRpcCallHasStarted(clientAndTentacle, startScriptCommand, rpcCallHasStarted, ensureCancellationOccursDuringAnRpcCall);

// ASSERT
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ScriptExecutionCancelled, tentacleConfigurationTestCase, clientAndTentacle)
.ForScriptService(ScriptServiceOperation.StartScript).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ScriptExecutionCancelled, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

actualException.ShouldMatchExceptionContract(expectedException);

Expand Down Expand Up @@ -394,8 +392,7 @@ public async Task DuringGetStatus_ScriptExecutionCanBeCancelled(TentacleConfigur
var (_, actualException, cancellationDuration) = await ExecuteScriptThenCancelExecutionWhenRpcCallHasStarted(clientAndTentacle, startScriptCommand, rpcCallHasStarted, ensureCancellationOccursDuringAnRpcCall);

// ASSERT
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ScriptExecutionCancelled, tentacleConfigurationTestCase, clientAndTentacle)
.ForScriptService(ScriptServiceOperation.GetStatus).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ScriptExecutionCancelled, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

actualException.ShouldMatchExceptionContract(expectedException);

Expand Down Expand Up @@ -492,8 +489,7 @@ public async Task DuringCompleteScript_ScriptExecutionCanBeCancelled(TentacleCon
var (responseAndLogs, actualException, cancellationDuration) = await ExecuteScriptThenCancelExecutionWhenRpcCallHasStarted(clientAndTentacle, startScriptCommand, rpcCallHasStarted, new SemaphoreSlim(int.MaxValue, int.MaxValue));

// ASSERT
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ScriptExecutionCancelled, tentacleConfigurationTestCase, clientAndTentacle)
.ForScriptService(ScriptServiceOperation.CompleteScript).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ScriptExecutionCancelled, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

actualException.ShouldMatchExceptionContract(expectedException);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ await clientTentacle.TentacleClient.ExecuteScript(startScriptCommand,
actualException = ex;
}

var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ScriptExecutionCancelled, tentacleConfigurationTestCase, clientTentacle)
.ForScriptService(ScriptServiceOperation.CancelScript).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ScriptExecutionCancelled, tentacleConfigurationTestCase.TentacleType, clientTentacle).Build();

actualException!.ShouldMatchExceptionContract(expectedException);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ public async Task WhenRpcRetriesTimeOut_DuringGetCapabilities_TheRpcCallIsCancel

await action.Should().ThrowAsync<HalibutClientException>();

var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase, clientAndTentacle)
.ForScriptService(ScriptServiceOperation.GetCapabilities).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

await AssertionExtensions.Should(async () => await executeScriptTask).ThrowExceptionContractAsync(expectedException);

Expand Down Expand Up @@ -134,8 +133,7 @@ public async Task WhenGetCapabilitiesFails_AndTakesLongerThanTheRetryDuration_Th

var executeScriptTask = clientAndTentacle.TentacleClient.ExecuteScript(startScriptCommand, CancellationToken, null, inMemoryLog);

var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase, clientAndTentacle)
.ForScriptService(ScriptServiceOperation.GetCapabilities).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

await AssertionExtensions.Should(async () => await executeScriptTask).ThrowExceptionContractAsync(expectedException);

Expand Down Expand Up @@ -199,8 +197,7 @@ public async Task WhenRpcRetriesTimeOut_DuringStartScript_TheRpcCallIsCancelled(
var duration = Stopwatch.StartNew();
var executeScriptTask = clientAndTentacle.TentacleClient.ExecuteScript(startScriptCommand, CancellationToken, null, inMemoryLog);

var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase, clientAndTentacle)
.ForScriptService(ScriptServiceOperation.StartScript).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

await AssertionExtensions.Should(async () => await executeScriptTask).ThrowExceptionContractAsync(expectedException);

Expand Down Expand Up @@ -252,8 +249,7 @@ public async Task WhenStartScriptFails_AndTakesLongerThanTheRetryDuration_TheCal

var executeScriptTask = clientAndTentacle.TentacleClient.ExecuteScript(startScriptCommand, CancellationToken, null, inMemoryLog);

var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase, clientAndTentacle)
.ForScriptService(ScriptServiceOperation.StartScript).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

await AssertionExtensions.Should(async () => await executeScriptTask).ThrowExceptionContractAsync(expectedException);

Expand Down Expand Up @@ -321,8 +317,7 @@ public async Task WhenRpcRetriesTimeOut_DuringGetStatus_TheRpcCallIsCancelled(Te
var duration = Stopwatch.StartNew();
var executeScriptTask = clientAndTentacle.TentacleClient.ExecuteScript(startScriptCommand, CancellationToken, null, inMemoryLog);

var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase, clientAndTentacle)
.ForScriptService(ScriptServiceOperation.GetStatus).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

await AssertionExtensions.Should(async () => await executeScriptTask).ThrowExceptionContractAsync(expectedException);

Expand Down Expand Up @@ -377,8 +372,7 @@ public async Task WhenGetStatusFails_AndTakesLongerThanTheRetryDuration_TheCallI

var executeScriptTask = clientAndTentacle.TentacleClient.ExecuteScript(startScriptCommand, CancellationToken, null, inMemoryLog);

var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase, clientAndTentacle)
.ForScriptService(ScriptServiceOperation.GetStatus).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

await AssertionExtensions.Should(async () => await executeScriptTask).ThrowExceptionContractAsync(expectedException);

Expand Down Expand Up @@ -460,8 +454,7 @@ public async Task WhenRpcRetriesTimeOut_DuringCancelScript_TheRpcCallIsCancelled
// We cancel script execution via the cancellation token. This should trigger the CancelScript RPC call to be made
testCancellationTokenSource.Cancel();

var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase, clientAndTentacle)
.ForScriptService(ScriptServiceOperation.CancelScript).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

await AssertionExtensions.Should(async () => await executeScriptTask).ThrowExceptionContractAsync(expectedException);

Expand Down Expand Up @@ -528,8 +521,7 @@ public async Task WhenCancelScriptFails_AndTakesLongerThanTheRetryDuration_TheCa
// We cancel script execution via the cancellation token. This should trigger the CancelScript RPC call to be made
testCancellationTokenSource.Cancel();

var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase, clientAndTentacle)
.ForScriptService(ScriptServiceOperation.CancelScript).Build();
var expectedException = new ExceptionContractAssertionBuilder(FailureScenario.ConnectionFaulted, tentacleConfigurationTestCase.TentacleType, clientAndTentacle).Build();

await AssertionExtensions.Should(async () => await executeScriptTask).ThrowExceptionContractAsync(expectedException);

Expand Down
Loading

0 comments on commit 6b77e55

Please sign in to comment.