-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional Logging for Flakey Workspace Cleanup Test and removal of Sync over Async while deleting a workspace #740
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Octopus.Tentacle.Client.Scripts; | ||
using Octopus.Tentacle.Contracts; | ||
using Serilog; | ||
|
||
namespace Octopus.Tentacle.Tests.Integration.Support.ExtensionMethods | ||
{ | ||
public static class ScriptExecutionResultExtensionMethods | ||
{ | ||
public static void LogExecuteScriptOutput(this (ScriptExecutionResult ScriptExecutionResult, List<ProcessOutput> ProcessOutput) result, ILogger logger) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
{ | ||
var scriptOutput = new StringBuilder(); | ||
|
||
scriptOutput.AppendLine(""); | ||
scriptOutput.AppendLine(""); | ||
scriptOutput.AppendLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); | ||
scriptOutput.AppendLine("~~ Start Execute Script Output ~~"); | ||
scriptOutput.AppendLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); | ||
|
||
scriptOutput.AppendLine($"ScriptExecutionResult.State: {result.ScriptExecutionResult.State}"); | ||
scriptOutput.AppendLine($"ScriptExecutionResult.ExitCode: {result.ScriptExecutionResult.ExitCode}"); | ||
scriptOutput.AppendLine(""); | ||
|
||
result.ProcessOutput.ForEach(x => scriptOutput.AppendLine($"{x.Source} {x.Occurred} {x.Text}")); | ||
|
||
scriptOutput.AppendLine($@"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); | ||
scriptOutput.AppendLine($@"~~~ End Execute Script Output ~~~"); | ||
scriptOutput.AppendLine($@"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); | ||
|
||
logger.Information(scriptOutput.ToString()); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,11 @@ | |
using FluentAssertions; | ||
using NUnit.Framework; | ||
using Octopus.Tentacle.CommonTestUtils.Builders; | ||
using Octopus.Tentacle.Contracts; | ||
using Octopus.Tentacle.Contracts.ClientServices; | ||
using Octopus.Tentacle.Scripts; | ||
using Octopus.Tentacle.Tests.Integration.Support; | ||
using Octopus.Tentacle.Tests.Integration.Support.ExtensionMethods; | ||
using Octopus.Tentacle.Tests.Integration.Util; | ||
using Octopus.Tentacle.Tests.Integration.Util.Builders; | ||
using Octopus.Tentacle.Tests.Integration.Util.Builders.Decorators; | ||
|
@@ -49,9 +51,13 @@ public async Task WhenScriptServiceIsRunning_ThenWorkspaceIsNotDeleted(TentacleC | |
Directory.Exists(startScriptWorkspaceDirectory).Should().BeTrue("Workspace should not have been cleaned up"); | ||
|
||
File.WriteAllText(waitBeforeCompletingScriptFile, "Write file that makes script continue executing"); | ||
await runningScriptTask; | ||
var runningScriptResult = await runningScriptTask; | ||
|
||
Directory.Exists(startScriptWorkspaceDirectory).Should().BeFalse("Workspace should be naturally cleaned up after completion"); | ||
runningScriptResult.LogExecuteScriptOutput(Logger); | ||
|
||
runningScriptResult.ScriptExecutionResult.ExitCode.Should().Be(0, "Script should have completed successfully"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trying to ensure everything works in the test and there is not another side effect causing the test to fail |
||
runningScriptResult.ScriptExecutionResult.State.Should().Be(ProcessState.Complete, "Script should have completed successfully"); | ||
Directory.Exists(startScriptWorkspaceDirectory).Should().BeFalse($"Workspace {startScriptWorkspaceDirectory} should have been cleaned up when CompleteScript was called"); | ||
} | ||
|
||
[Test] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,11 +82,6 @@ public string ResolvePath(string fileName) | |
return path; | ||
} | ||
|
||
public void Delete() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing Sync code path that does a Wait on an Async call as we can be fully async now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leaving FileSystem.DeleteDirectory sync method as it is used in other places in the tests. Future cleanup task. |
||
{ | ||
FileSystem.DeleteDirectory(WorkingDirectory, DeletionOptions.TryThreeTimesIgnoreFailure); | ||
} | ||
|
||
public async Task Delete(CancellationToken cancellationToken) | ||
{ | ||
await FileSystem.DeleteDirectory(WorkingDirectory, cancellationToken, DeletionOptions.TryThreeTimesIgnoreFailure); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slightly easier to read log
