Tests - Stop leaving backup files behind in the lab - #10539
Open
andreasjordan wants to merge 2 commits into
Open
Tests - Stop leaving backup files behind in the lab#10539andreasjordan wants to merge 2 commits into
andreasjordan wants to merge 2 commits into
Conversation
Three test files left backups behind, and because the environment check reports every file it finds after every test file, one leftover from the 34th file made 709 of 742 files in a full run look like they had left something in the lab. Connect-DbaInstance backed msdb up without a path, so the backup landed in the default backup folder of the instance. That is a path on the SQL Server, so the Remove-Item that was already there ran against a path that does not exist on the machine running the tests and silently did nothing. It backs up to the shared temp folder now, where the cleanup can actually reach it. Copy-DbaDatabase already said in a comment that the backups go to a directory that gets deleted at the end, but the variable pointed at the shared temp folder itself and nothing deleted anything. It now creates a directory per run and removes it in AfterAll. Invoke-DbaDbMirroring left the full backup and the log backup it uses to seed the mirror. Verified in the lab: the three files pass and the environment check reports no leftovers. (do Connect-DbaInstance, Copy-DbaDatabase, Invoke-DbaDbMirroring) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three test files left backup files behind in the lab. Found by running the full suite and checking the
environment after every test file.
The count is worth stating, because it is what makes this worth fixing rather than tidy-up: the environment
check reports every file it finds, so one leftover from the 34th test file made 709 of 742 files in a
full run look like they had left something behind. That buries a real leftover from a later file in noise.
Connect-DbaInstance
The cleanup was already there and looks correct, but it never worked against a remote instance. Without
-Paththe backup lands in the default backup folder of the instance, so$results.FullNameis a path onthe SQL Server.
Remove-Itemruns on the machine executing the tests, where that path does not exist, and-ErrorAction SilentlyContinueswallows the failure. The backup stayed on the instance every time.It now backs up to the shared temp folder, where the cleanup can actually reach the file. This test only cares
that
Connect-DbaInstanceclones the server object correctly, so where the backup goes is incidental.Copy-DbaDatabase
The file already said what should happen:
but the variable pointed at the shared temp folder itself and nothing ever deleted anything. It now creates a
directory per run and removes it in
AfterAll, which is what the comment always described.Invoke-DbaDbMirroring
Seeding the mirror leaves a full backup and a log backup in the shared folder.
AfterAllremoved the mirror,the databases and the endpoints, but not those two files.
Testing
All three files pass and the environment check reports no leftovers afterwards, with the shared temp folder
empty at the end:
Connect-DbaInstance.Tests.ps1Copy-DbaDatabase.Tests.ps1Invoke-DbaDbMirroring.Tests.ps1The one warning
Copy-DbaDatabase.Tests.ps1still writes (Set-DbaDbOwner ... is not accessible) is aseparate, real problem in its setup and is deliberately left visible rather than silenced.
馃 Generated with Claude Code