Tests - Case sensitive lookups and backup cleanup in seven test files - #10670
Open
andreasjordan wants to merge 3 commits into
Open
Tests - Case sensitive lookups and backup cleanup in seven test files#10670andreasjordan wants to merge 3 commits into
andreasjordan wants to merge 3 commits into
Conversation
Found by a full run against case sensitive instances (SQL_Latin1_General_CP1_CS_AS): - Copy-DbaDbViewData.Tests.ps1 selects Id from a column called id. - New-DbaDatabase.Tests.ps1 creates the log file with -LogFileSuffix "_Log" and then looks it up as "<name>_log"; SMO collections follow the server collation, so the lookup returns nothing. - Enable-DbaForceNetworkEncryption.Tests.ps1 left the instance with force encryption enabled; both the Enable and the Disable test now remember the state and put it back. - Connect-DbaInstance.Tests.ps1 took two msdb backups with the same default name and removed them with a silenced Remove-Item, which once failed and left the file behind for every later test file; the backups now get unique names and the removal retries and asserts. - Measure-DbaBackupThroughput.Tests.ps1 removed its backup folder with a single Remove-Item seconds after the backup, which once left the whole folder behind; it retries now too. (do Copy-DbaDbViewData, New-DbaDatabase, Connect-DbaInstance, Measure-DbaBackupThroughput, *ForceNetworkEncryption)
…e the warning for real
The setup batch says USE Master, which a case sensitive instance rejects ("Database 'Master' does not exist"),
so the whole batch is dropped, the login never exists on the source and the sync finds nothing. The setup
now runs with EnableException like the other files, so a failing setup fails the file instead of two tests
later on. The test also passed -WarningVariable $warn, an empty variable name, which hid that warning and
made the warning assertion vacuous.
(do Sync-DbaLoginPermission)
…string literals (do Sync-DbaLoginPermission)
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.
Test-only. Found by a full suite run against three case sensitive instances (
SQL_Latin1_General_CP1_CS_AS) plus two leftovers the same run reported.Case sensitivity
Copy-DbaDbViewData.Tests.ps1: two query-mode tests select
Idfrom a column calledid- "Invalid column name 'Id'" on a case sensitive instance (the same defect inCopy-DbaDbTableData.Tests.ps1is part of Copy-DbaDbTableData - Map query columns onto the writable destination columns #10666).New-DbaDatabase.Tests.ps1: the tests create the log file with
-LogFileSuffix "_Log"and then look it up asLogFiles["<name>_log"]. SMO collections follow the server collation, so on a case sensitive instance the lookup returns$nulland the size and growth assertions fail. The lookups with the default suffix (randomDb) are untouched, they are_logfor real.Sync-DbaLoginPermission.Tests.ps1: the setup batch says
USE Master, which a case sensitive instance rejects, so the whole batch is dropped and the login never exists on the source - the sync then finds nothing and warns. The test also passed-WarningVariable $warn(an empty variable name), which hid exactly that warning. Nowmaster,warn, and the setup runs with EnableException so a failing setup fails the file.Leftovers
InstanceSingleand never put it back; the registry value survives everything except an explicit Disable, and four lab instances had drifted toTruethat way. Both the Enable and the Disable test now read the state inBeforeAlland restore it inAfterAll.Remove-Item. One removal failed silently once and the file was reported as a leftover by the 18 following test files. The backups now get unique names, and the removal retries a few times and then asserts that the file is gone.Remove-Item -Recurseseconds after the backup, which once left the whole folder behind (55 files flagged it). Same treatment: retry, and let the last attempt report its error.Neither leftover reproduced when the file ran alone, so both are timing races on the share rather than deterministic bugs; the retries make the cleanup robust either way.
Tests
All seven files green through the testing-dbatools harness against the case sensitive lab (SQL Server 2019/2022/2025), with the Enable/Disable pair verified to leave
ForceEncryptionas it found it.created by Claude and reviewed by Andreas Jordan
🤖 Generated with Claude Code