Skip to content
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

Fix flakey WhenScriptServiceIsRunning_ThenWorkspaceIsNotDeleted test #745

Conversation

nathanwoctopusdeploy
Copy link
Contributor

@nathanwoctopusdeploy nathanwoctopusdeploy commented Dec 18, 2023

Background

The test WhenScriptServiceIsRunning_ThenWorkspaceIsNotDeleted was written to ensure that a running script did not have it's workspace cleaned up by the background cleanup job while it was still running / not completed.

The test then went on to verify that the workspace was cleaned up when CompleteScript was called. This turns out to be somewhat flakey as the CompleteScript call does a best effort attempt to delete the workspace before silently failing!!

While it would be nice to have a reliable test that asserts that complete script always cleans up the workspace it seems the code to try and silently fail is by design and the intent of this test was to make sure the workspace isn't unexpectedly deleted by the background cleanup job.

Test has been modified to remove the assertion that CompleteScript cleans up the workspace.

image

How to review this PR

Quality ✔️

Pre-requisites

  • I have read How we use GitHub Issues for help deciding when and where it's appropriate to make an issue.
  • I have considered informing or consulting the right people, according to the ownership map.
  • I have considered appropriate testing for my change.

@nathanwoctopusdeploy
Copy link
Contributor Author

[sc-67411]

@nathanwoctopusdeploy nathanwoctopusdeploy enabled auto-merge (squash) December 18, 2023 06:10

runningScriptResult.LogExecuteScriptOutput(Logger);

runningScriptResult.ScriptExecutionResult.ExitCode.Should().Be(0, "Script should have completed successfully");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could keep the tests to ensure that runningScriptTask succeeded (as it was the Directory.Exists(startScriptWorkspaceDirectory) check that failed).

I know it's much like Directory.Exists(startScriptWorkspaceDirectory), and technically not part of what's being tested. But still 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only recently added those asserts into the test to see if there was something else causing the test to fail!! Log / assert as much as possible to try and track down the issue (which is by design 😆 )

If the script fails or not should not really matter for the intent of the test. We await the execute script operation so the orchestration of the script should have been successful which is all we really care about

Copy link
Contributor

@sburmanoctopus sburmanoctopus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nathanwoctopusdeploy nathanwoctopusdeploy merged commit f8f8d12 into main Dec 18, 2023
2 checks passed
@nathanwoctopusdeploy nathanwoctopusdeploy deleted the sast/fix-flakey-WhenScriptServiceIsRunning_ThenWorkspaceIsNotDeleted branch December 18, 2023 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants