Skip to content

Commit 57cd961

Browse files
authored
Merge branch 'main' into copilot/fix-2221
2 parents 75624f3 + 77d1c88 commit 57cd961

File tree

261 files changed

+4734
-563
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

261 files changed

+4734
-563
lines changed

.github/instructions/SqlServerDsc-guidelines.instructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ applyTo: "**"
66
# SqlServerDsc Requirements
77

88
## Build & Test Workflow Requirements
9-
- Run PowerShell script files from repository root
9+
- Never use VS Code task, always use PowerShell scripts via terminal, from repository root
1010
- Setup build and test environment (once per `pwsh` session): `./build.ps1 -Tasks noop`
1111
- Build project before running tests: `./build.ps1 -Tasks build`
1212
- Run tests without coverage (wildcards allowed): `Invoke-PesterJob -Path '{tests filepath}' -SkipCodeCoverage`
13+
- Run tests with coverage (wildcards allowed): `Invoke-PesterJob -Path '{tests filepath}' -EnableSourceLineMapping -FilterCodeCoverageResult '{pattern}'`
1314
- Run QA tests: `Invoke-PesterJob -Path 'tests/QA' -SkipCodeCoverage`
1415
- Never run integration tests locally
1516

@@ -36,7 +37,6 @@ applyTo: "**"
3637
## Tests Requirements
3738
- Unit tests: Add `$env:SqlServerDscCI = $true` in `BeforeAll`, remove in `AfterAll`
3839
- Integration tests:
39-
- If requiring SQL Server DB, start the Windows service in `BeforeAll`, stop it in `AfterAll`.
4040
- Use `Connect-SqlDscDatabaseEngine` for SQL Server DB session, and always with correct CI credentials
4141
- Use `Disconnect-SqlDscDatabaseEngine` after `Connect-SqlDscDatabaseEngine`
4242
- Test config: tests/Integration/Commands/README.md and tests/Integration/Resources/README.md

CHANGELOG.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,87 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- Added integration tests for `Get-SqlDscDatabasePermission` command to ensure
1111
database permission retrieval functions correctly in real environments
1212
[issue #2221](https://github.com/dsccommunity/SqlServerDsc/issues/2221).
13+
- Added integration tests for `Get-SqlDscManagedComputer` command to ensure it
14+
functions correctly in real environments
15+
[issue #2220](https://github.com/dsccommunity/SqlServerDsc/issues/2220).
1316
- Added integration tests for `Remove-SqlDscAudit` command to ensure it functions
1417
correctly in real environments
1518
[issue #2241](https://github.com/dsccommunity/SqlServerDsc/issues/2241).
19+
- Added integration tests for `Get-SqlDscAudit` command to ensure it functions
20+
correctly in real environments
21+
[issue #2222](https://github.com/dsccommunity/SqlServerDsc/issues/2222).
22+
- Added integration tests for `Disconnect-SqlDscDatabaseEngine` command to ensure
23+
command reliability in real environments
24+
[issue #2224](https://github.com/dsccommunity/SqlServerDsc/issues/2224).
25+
- Added integration tests for `Invoke-SqlDscQuery` command to ensure it functions
26+
correctly in real environments
27+
[issue #2227](https://github.com/dsccommunity/SqlServerDsc/issues/2227).
28+
- Added integration tests for `New-SqlDscAudit` command to ensure it functions
29+
correctly in real environments
30+
[issue #2226](https://github.com/dsccommunity/SqlServerDsc/issues/2226).
31+
- Added integration tests for `Test-SqlDscIsLogin` command to ensure it functions
32+
correctly in real environments
33+
[issue #2230](https://github.com/dsccommunity/SqlServerDsc/issues/2230).
34+
- Added integration tests for `Set-SqlDscAudit` command to ensure it functions
35+
correctly in real environments
36+
[issue #2236](https://github.com/dsccommunity/SqlServerDsc/issues/2236).
37+
- Added integration tests for `Set-SqlDscStartupParameter` command to ensure
38+
reliable startup parameter configuration
39+
[issue #2233](https://github.com/dsccommunity/SqlServerDsc/issues/2233).
40+
- Added integration tests for `Set-SqlDscServerPermission` command to ensure it
41+
functions correctly in real environments
42+
[issue #2234](https://github.com/dsccommunity/SqlServerDsc/issues/2234).
43+
- Added integration tests for `Save-SqlDscSqlServerMediaFile` command to ensure
44+
it functions correctly in real environments
45+
[issue #2237](https://github.com/dsccommunity/SqlServerDsc/issues/2237).
46+
- Added integration tests for `Disable-SqlDscAudit` command to ensure it functions
47+
correctly in real environments
48+
[issue #2206](https://github.com/dsccommunity/SqlServerDsc/issues/2206).
49+
- Added integration tests for `ConvertTo-SqlDscDatabasePermission` command to
50+
ensure command reliability
51+
[issue #2209](https://github.com/dsccommunity/SqlServerDsc/issues/2209).
52+
- Added integration tests for `Set-SqlDscDatabasePermission` command to ensure
53+
command reliability
54+
[issue #2235](https://github.com/dsccommunity/SqlServerDsc/issues/2235).
55+
- Added integration test for `ConvertTo-SqlDscEditionName` command to ensure
56+
command reliability in real environments
57+
[issue #2208](https://github.com/dsccommunity/SqlServerDsc/issues/2208).
58+
- Added integration tests for `Import-SqlDscPreferredModule` command to ensure
59+
proper module import functionality in real environments
60+
[issue #2225](https://github.com/dsccommunity/SqlServerDsc/issues/2225).
61+
- Added integration tests for `Test-SqlDscIsSupportedFeature` command to ensure
62+
it functions correctly in real environments
63+
[issue #2228](https://github.com/dsccommunity/SqlServerDsc/issues/2228).
64+
- Added integration test for `Get-SqlDscManagedComputerService` command to ensure
65+
command reliability [issue #2219](https://github.com/dsccommunity/SqlServerDsc/issues/2219).
66+
- Added integration tests for `Set-SqlDscTraceFlag` command to ensure it functions
67+
correctly in real environments
68+
[issue #2232](https://github.com/dsccommunity/SqlServerDsc/issues/2232).
69+
- Added integration tests for `ConvertFrom-SqlDscServerPermission` command to
70+
ensure it functions correctly in real environments
71+
[issue #2210](https://github.com/dsccommunity/SqlServerDsc/issues/2210).
72+
- `Remove-SqlDscTraceFlag`
73+
- Added missing integration test to ensure command reliability ([issue #2239](https://github.com/dsccommunity/SqlServerDsc/issues/2239)).
74+
- `Remove-SqlDscAudit`
75+
- Added missing integration test to ensure command reliability ([issue #2241](https://github.com/dsccommunity/SqlServerDsc/issues/2241)).
76+
- Added integration tests for `Test-SqlDscIsRole` command to ensure it functions
77+
correctly in real environments
78+
[issue #2229](https://github.com/dsccommunity/SqlServerDsc/issues/2229).
79+
- Added integration tests for `Add-SqlDscTraceFlag` command to ensure it functions
80+
correctly in real environments
81+
[issue #2214](https://github.com/dsccommunity/SqlServerDsc/issues/2214).
1682

1783
### Fixed
1884

85+
- `Add-SqlDscTraceFlag` and `Remove-SqlDscTraceFlag`
86+
- Fixed parameter binding error when `ErrorAction` was specified both
87+
explicitly and via `PSBoundParameters` by using `Remove-CommonParameter`
88+
instead of manual parameter removal
89+
([issue #2239](https://github.com/dsccommunity/SqlServerDsc/issues/2239)).
90+
- `Remove-SqlDscTraceFlag`
91+
- Optimized to skip unnecessary Set operations when removal results in no
92+
effective change
93+
([issue #2239](https://github.com/dsccommunity/SqlServerDsc/issues/2239)).
1994
- Updated `.gitattributes` to enforce LF line endings for PowerShell files to
2095
ensure cross-platform compatibility.
2196
- Updated GitHub Copilot setup workflow to fix environment variable assignment
@@ -160,6 +235,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
160235

161236
### Changed
162237

238+
- Optimized integration test performance by leaving the DSCSQLTEST service running
239+
for subsequent tests, significantly improving CI build times.
163240
- Improved code quality by ensuring all function invocations in the private
164241
and public functions use named parameters instead of positional parameters.
165242
- SqlServerDsc

azure-pipelines.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,26 +286,39 @@ stages:
286286
# Run the integration tests in a specific group order.
287287
# Group 0
288288
'tests/Integration/Commands/Prerequisites.Integration.Tests.ps1'
289+
'tests/Integration/Commands/Save-SqlDscSqlServerMediaFile.Integration.Tests.ps1'
290+
'tests/Integration/Commands/Import-SqlDscPreferredModule.Integration.Tests.ps1'
289291
# Group 1
290292
'tests/Integration/Commands/Install-SqlDscServer.Integration.Tests.ps1'
291293
'tests/Integration/Commands/Connect-SqlDscDatabaseEngine.Integration.Tests.ps1'
294+
'tests/Integration/Commands/Disconnect-SqlDscDatabaseEngine.Integration.Tests.ps1'
292295
# Group 2
293296
'tests/Integration/Commands/Assert-SqlDscLogin.Integration.Tests.ps1'
294297
'tests/Integration/Commands/New-SqlDscLogin.Integration.Tests.ps1'
295298
'tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1'
296299
'tests/Integration/Commands/Get-SqlDscConfigurationOption.Integration.Tests.ps1'
297300
'tests/Integration/Commands/Set-SqlDscConfigurationOption.Integration.Tests.ps1'
298301
'tests/Integration/Commands/Test-SqlDscConfigurationOption.Integration.Tests.ps1'
302+
'tests/Integration/Commands/Set-SqlDscStartupParameter.Integration.Tests.ps1'
303+
'tests/Integration/Commands/Test-SqlDscIsSupportedFeature.Integration.Tests.ps1'
304+
'tests/Integration/Commands/Get-SqlDscManagedComputer.Integration.Tests.ps1'
305+
'tests/Integration/Commands/Set-SqlDscTraceFlag.Integration.Tests.ps1'
299306
'tests/Integration/Commands/Get-SqlDscManagedComputerInstance.Integration.Tests.ps1'
307+
'tests/Integration/Commands/Get-SqlDscManagedComputerService.Integration.Tests.ps1'
300308
'tests/Integration/Commands/Get-SqlDscServerProtocolName.Integration.Tests.ps1'
309+
'tests/Integration/Commands/ConvertTo-SqlDscEditionName.Integration.Tests.ps1'
301310
'tests/Integration/Commands/Get-SqlDscServerProtocol.Integration.Tests.ps1'
302311
'tests/Integration/Commands/Disable-SqlDscLogin.Integration.Tests.ps1'
303312
'tests/Integration/Commands/Enable-SqlDscLogin.Integration.Tests.ps1'
313+
'tests/Integration/Commands/Test-SqlDscIsLogin.Integration.Tests.ps1'
304314
'tests/Integration/Commands/Test-SqlDscIsLoginEnabled.Integration.Tests.ps1'
305315
'tests/Integration/Commands/New-SqlDscRole.Integration.Tests.ps1'
306316
'tests/Integration/Commands/Get-SqlDscRole.Integration.Tests.ps1'
317+
'tests/Integration/Commands/Test-SqlDscIsRole.Integration.Tests.ps1'
307318
'tests/Integration/Commands/Grant-SqlDscServerPermission.Integration.Tests.ps1'
308319
'tests/Integration/Commands/Get-SqlDscServerPermission.Integration.Tests.ps1'
320+
'tests/Integration/Commands/Set-SqlDscServerPermission.Integration.Tests.ps1'
321+
'tests/Integration/Commands/ConvertFrom-SqlDscServerPermission.Integration.Tests.ps1'
309322
'tests/Integration/Commands/Test-SqlDscServerPermission.Integration.Tests.ps1'
310323
'tests/Integration/Commands/Deny-SqlDscServerPermission.Integration.Tests.ps1'
311324
'tests/Integration/Commands/Revoke-SqlDscServerPermission.Integration.Tests.ps1'
@@ -314,8 +327,12 @@ stages:
314327
'tests/Integration/Commands/Set-SqlDscDatabase.Integration.Tests.ps1'
315328
'tests/Integration/Commands/Test-SqlDscDatabase.Integration.Tests.ps1'
316329
'tests/Integration/Commands/Get-SqlDscDatabasePermission.Integration.Tests.ps1'
330+
'tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1'
331+
'tests/Integration/Commands/Set-SqlDscDatabasePermission.Integration.Tests.ps1'
332+
'tests/Integration/Commands/ConvertTo-SqlDscDatabasePermission.Integration.Tests.ps1'
317333
'tests/Integration/Commands/Get-SqlDscAgentAlert.Integration.Tests.ps1'
318334
'tests/Integration/Commands/New-SqlDscAgentAlert.Integration.Tests.ps1'
335+
'tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1'
319336
'tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1'
320337
'tests/Integration/Commands/Test-SqlDscAgentAlertProperty.Integration.Tests.ps1'
321338
'tests/Integration/Commands/Test-SqlDscIsAgentAlert.Integration.Tests.ps1'
@@ -326,13 +343,18 @@ stages:
326343
'tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1'
327344
'tests/Integration/Commands/Enable-SqlDscAgentOperator.Integration.Tests.ps1'
328345
'tests/Integration/Commands/Disable-SqlDscAgentOperator.Integration.Tests.ps1'
346+
'tests/Integration/Commands/Disable-SqlDscAudit.Integration.Tests.ps1'
347+
'tests/Integration/Commands/Add-SqlDscTraceFlag.Integration.Tests.ps1'
329348
# Group 8
330349
'tests/Integration/Commands/Remove-SqlDscAgentAlert.Integration.Tests.ps1'
331350
'tests/Integration/Commands/Remove-SqlDscAgentOperator.Integration.Tests.ps1'
351+
'tests/Integration/Commands/Get-SqlDscAudit.Integration.Tests.ps1'
332352
'tests/Integration/Commands/Remove-SqlDscAudit.Integration.Tests.ps1'
353+
'tests/Integration/Commands/Set-SqlDscAudit.Integration.Tests.ps1'
333354
'tests/Integration/Commands/Remove-SqlDscDatabase.Integration.Tests.ps1'
334355
'tests/Integration/Commands/Remove-SqlDscRole.Integration.Tests.ps1'
335356
'tests/Integration/Commands/Remove-SqlDscLogin.Integration.Tests.ps1'
357+
'tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1'
336358
# Group 9
337359
'tests/Integration/Commands/Uninstall-SqlDscServer.Integration.Tests.ps1'
338360
)
@@ -397,6 +419,8 @@ stages:
397419
# Run the integration tests in a specific group order.
398420
# Group 0
399421
'tests/Integration/Commands/Prerequisites.Integration.Tests.ps1'
422+
'tests/Integration/Commands/Save-SqlDscSqlServerMediaFile.Integration.Tests.ps1'
423+
'tests/Integration/Commands/Import-SqlDscPreferredModule.Integration.Tests.ps1'
400424
# Group 1
401425
'tests/Integration/Commands/Install-SqlDscReportingService.Integration.Tests.ps1'
402426
# Group 2
@@ -460,6 +484,8 @@ stages:
460484
# Run the integration tests in a specific group order.
461485
# Group 0
462486
'tests/Integration/Commands/Prerequisites.Integration.Tests.ps1'
487+
'tests/Integration/Commands/Save-SqlDscSqlServerMediaFile.Integration.Tests.ps1'
488+
'tests/Integration/Commands/Import-SqlDscPreferredModule.Integration.Tests.ps1'
463489
# Group 1
464490
'tests/Integration/Commands/Install-SqlDscBIReportServer.Integration.Tests.ps1'
465491
# Group 2

source/Public/Add-SqlDscTraceFlag.ps1

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,10 @@ function Add-SqlDscTraceFlag
9696
}
9797

9898
# Copy $PSBoundParameters to keep it intact.
99-
$getSqlDscTraceFlagParameters = @{} + $PSBoundParameters
99+
$getSqlDscTraceFlagParameters = Remove-CommonParameter -Hashtable $PSBoundParameters
100100

101-
$commonParameters = [System.Management.Automation.PSCmdlet]::OptionalCommonParameters
102-
103-
# Remove parameters that Get-SqlDscTraceFLag does not have/support.
104-
$commonParameters + @('Force', 'TraceFlag') |
101+
# Remove parameters that Get-SqlDscTraceFlag does not have/support.
102+
@('Force', 'TraceFlag') |
105103
ForEach-Object -Process {
106104
$getSqlDscTraceFlagParameters.Remove($_)
107105
}
@@ -132,9 +130,9 @@ function Add-SqlDscTraceFlag
132130
if ($PSCmdlet.ShouldProcess($verboseDescriptionMessage, $verboseWarningMessage, $captionMessage))
133131
{
134132
# Copy $PSBoundParameters to keep it intact.
135-
$setSqlDscTraceFlagParameters = @{} + $PSBoundParameters
133+
$setSqlDscTraceFlagParameters = Remove-CommonParameter -Hashtable $PSBoundParameters
136134

137-
$setSqlDscTraceFlagParameters.TraceFLag = $desiredTraceFlags
135+
$setSqlDscTraceFlagParameters.TraceFlag = $desiredTraceFlags
138136

139137
$originalErrorActionPreference = $ErrorActionPreference
140138

source/Public/Remove-SqlDscTraceFlag.ps1

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,10 @@ function Remove-SqlDscTraceFlag
9696
}
9797

9898
# Copy $PSBoundParameters to keep it intact.
99-
$getSqlDscTraceFlagParameters = @{} + $PSBoundParameters
99+
$getSqlDscTraceFlagParameters = Remove-CommonParameter -Hashtable $PSBoundParameters
100100

101-
$commonParameters = [System.Management.Automation.PSCmdlet]::OptionalCommonParameters
102-
103-
# Remove parameters that Get-SqlDscTraceFLag does not have/support.
104-
$commonParameters + @('Force', 'TraceFlag') |
101+
# Remove parameters that Get-SqlDscTraceFlag does not have/support.
102+
@('Force', 'TraceFlag') |
105103
ForEach-Object -Process {
106104
$getSqlDscTraceFlagParameters.Remove($_)
107105
}
@@ -128,16 +126,23 @@ function Remove-SqlDscTraceFlag
128126
}
129127
)
130128

129+
# Short-circuit if removal results in no effective change
130+
if (-not (Compare-Object -ReferenceObject $currentTraceFlags -DifferenceObject $desiredTraceFlags))
131+
{
132+
Write-Debug -Message $script:localizedData.TraceFlag_Remove_NoChange
133+
return
134+
}
135+
131136
$verboseDescriptionMessage = $script:localizedData.TraceFlag_Remove_ShouldProcessVerboseDescription -f $InstanceName, ($TraceFlag -join ', ')
132137
$verboseWarningMessage = $script:localizedData.TraceFlag_Remove_ShouldProcessVerboseWarning -f $InstanceName
133138
$captionMessage = $script:localizedData.TraceFlag_Remove_ShouldProcessCaption
134139

135140
if ($PSCmdlet.ShouldProcess($verboseDescriptionMessage, $verboseWarningMessage, $captionMessage))
136141
{
137142
# Copy $PSBoundParameters to keep it intact.
138-
$setSqlDscTraceFlagParameters = @{} + $PSBoundParameters
143+
$setSqlDscTraceFlagParameters = Remove-CommonParameter -Hashtable $PSBoundParameters
139144

140-
$setSqlDscTraceFlagParameters.TraceFLag = $desiredTraceFlags
145+
$setSqlDscTraceFlagParameters.TraceFlag = $desiredTraceFlags
141146

142147
$originalErrorActionPreference = $ErrorActionPreference
143148

source/en-US/SqlServerDsc.strings.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ ConvertFrom-StringData @'
216216
# This string shall not end with full stop (.) since it is used as a title of ShouldProcess messages.
217217
TraceFlag_Remove_ShouldProcessCaption = Remove trace flag from instance
218218
TraceFlag_Remove_NoCurrentTraceFlags = There are no current trace flags on instance. Nothing to remove.
219+
TraceFlag_Remove_NoChange = The specified trace flags are not currently set on the instance. No changes needed.
219220
220221
## Get-SqlDscPreferredModule
221222
PreferredModule_ModuleVersionFound = Preferred module '{0}' with version '{1}' found.

0 commit comments

Comments
 (0)