Install-DbaMaintenanceSolution: make off switches work and increase test coverage#10172
Merged
potatoqualitee merged 5 commits intodataplat:developmentfrom Feb 19, 2026
Merged
Conversation
See dataplat#10133 for why we need so many. We need to check: * That turning off particular settings actually works. * That Ola's checks for if the instance has checksum on do not break anything. * That Verify with backing up to NUL breaks. * That ModificationLevel is not added to LOG backups. Additionally added check to make sure that the T-SQL in whatever job steps we are running tests on is valid.
Member
|
Your first time with Pester looks great 🙌🏼 It LGTM but if anyone would like to give a second approval, pls do. |
…sum off at the instance level (do Install-DbaMaintenanceSolution)
Contributor
Author
|
Thanks! I was worried that there was too much boilerplate in my tests. Just committed a fix to a really minor issue in one of them. One of the bits was the wrong way around. |
Member
|
Thank you! Will release today. |
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.
Type of Change
Invoke-ManualPester)Purpose
Closes #10133 and every problem I found along the way. In summary:
Install-DbaMaintenanceSolutioncan now be turned off (Verify,Checksum,Compress). We previously incorrectly claimed they could be. For example, any attempts to turn off backup verification would fail.ModificationLevelparameter to the log backup job and updated the documentation to remove the false claim that this worked.CopyOnlyandModificationLevelwere not tested.AfterEachblock to the tests, so we know that the Agent Job commands that we generate are valid SQL. This helps to protect against things like typos and extra commas.Approach
Classic TDD, which isn't something I often get to do as a SQL guy. The first commit in this PR adds a lot of tests and is by far the biggest part of this PR. If you pull only the first commit and run the tests, 8 will fail:
Additional backup parameters all enabled.Should NOT add ModificationLevel parameter to LOG backup jobAdditional backup parameters all disabled.Should have Compress parameter set to N in backup jobsAdditional backup parameters all disabled.Should have Verify parameter set to N in backup jobsAdditional backup parameters all disabled.Should have CheckSum parameter set to N in backup jobsAdditional backup parameters all but Verify disabled.Should have Compress parameter set to N in backup jobsAdditional backup parameters all but Verify disabled.Should have CheckSum parameter set to N in backup jobsBackup to Nul with Verify on.Should error out and tell us our mistakeChecksum tests when instance defaults to checksum on.Should have CheckSum parameter set to N in backup jobsBy the end of this PR, everything passes.
The scariest part of this PR is my edit to the
if ($InstallJobs -and ($ChangeBackupType -or $Compress -or $CopyOnly -or $Verify -or $CheckSum -or $ModificationLevel)guard clause.Commands to test
Install-DbaMaintenanceSolution. Test it extremely! Trust nothing I've done! I really don't want to break something this important.Learning
This is my first time getting serious with Pester! It may not be up to standard.