-
Notifications
You must be signed in to change notification settings - Fork 227
Add integration test stage for DSCv3 #2102
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
Conversation
|
It runs now, but fails with: |
|
This is the full trace log from the pipeline. Full trace log |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2102 +/- ##
=====================================
Coverage 94% 94%
=====================================
Files 226 226
Lines 11182 11182
=====================================
Hits 10545 10545
Misses 637 637
🚀 New features to boost your workflow:
|
|
With latest preview6 it goes further, but errors on Get it seems. The output from {
"type": "SqlServerDsc/SqlRSSetup",
"kind": "resource",
"version": "17.2.0",
"capabilities": ["get", "set", "test"],
"path": "D:\\a\\1\\s\\output\\builtModule\\SqlServerDsc\\17.2.0\\SqlServerDsc.psd1",
"description": "This module contains commands and DSC resources for deployment and configuration of Microsoft SQL Server, SQL Server Reporting Services and Power BI Report Server.",
"directory": "D:\\a\\1\\s\\output\\builtModule\\SqlServerDsc\\17.2.0",
"implementedAs": "ClassBased",
"author": "DSC Community",
"properties": [
"AcceptLicensingTerms",
"Action",
"InstanceName",
"MediaPath",
"DependsOn",
"Edition",
"EditionUpgrade",
"ForceRestart",
"InstallFolder",
"LogPath",
"ProductKey",
"PsDscRunAsCredential",
"SuppressRestart",
"Timeout",
"VersionUpgrade"
],
"requireAdapter": "Microsoft.Windows/WindowsPowerShell",
"manifest": null
}The content from the file `WindowsPSAdapterCache.json`: |
|
The tracelog from the test run: Full trace log |
|
I see two potential issues, first one: The SqlServerDsc module reports the following warning during module import when SqlServerDsc detects that module to handling SMO types is missing. This is expected, for example when a SQL Server instance is not yet installed. During module import it catches an error and outputs a warning to user if the dependent module is missing: SqlServerDsc/source/suffix.ps1 Line 24 in eb9caa2
The exception message comes from this command: SqlServerDsc/source/Public/Import-SqlDscPreferredModule.ps1 Lines 81 to 88 in eb9caa2
But it looks like DSC seems this warning as a result output from the resource that should be parsed. |
|
Another issue seems that is thinks the hidden variables
{
"result": [
{
"name": "SqlServerDsc/SqlRSSetup",
"type": "SqlServerDsc/SqlRSSetup",
"properties": {
"Timeout": 7200,
"InstanceName": "",
"Action": 0,
"AcceptLicensingTerms": false,
"MediaPath": null,
"ProductKey": null,
"EditionUpgrade": null,
"Edition": null,
"LogPath": null,
"InstallFolder": "",
"SuppressRestart": null,
"ForceRestart": null,
"VersionUpgrade": null,
"localizedData": {
"MediaPath_Invalid": "The media path \u0027{0}\u0027 does not exist. (SRSS0006)",
"Uninstalling_ReportingServices": "Uninstalling SQL Server Reporting Services. (SRSS0016)",
"TestDesiredState": "Determining the current state for resource \u0027{0}\u0027 using the key property \u0027{1}\u0027. (RB0002)",
"NotDesiredProductVersion": "The product version \u0027{0}\u0027 is not the desired for the instance \u0027{1}\u0027. Desired version in executable: \u0027{2}\u0027. (SRSS0018)",
"InDesiredState": "The current state is the desired state. (RB0005)",
"Instance_Installed": "Instance \u0027{0}\u0027 is installed. (SRSS0004)",
"Repairing_ReportingServices": "Repairing SQL Server Reporting Services. (SRSS0014)",
"EditionOrProductKeyMissing": "Neither the parameters Edition or ProductKey was specified. (SRSS0008)",
"Installing_ReportingServices": "Installing SQL Server Reporting Services. (SRSS0012)",
"Instance_NotInstalled": "Instance \u0027{0}\u0027 is not installed. (SRSS0003)",
"ModifyMethodNotImplemented": "An override for the method Modify() is not implemented in the resource. (RB0008)",
"Getting_Information_Instance": "Getting information about instance \u0027{0}\u0027. (SRSS0002)",
"MediaPath_DoesNotHaveRequiredExtension": "The media path \u0027{0}\u0027 does not reference an executable with the required extension .exe. (SRSS0007)",
"EditionUpgrade_RequiresKeyOrEdition": "EditionUpgrade requires either ProductKey or Edition to be specified. (SRSS0009)",
"CannotDetermineEdition": "Could not determine the edition for the installed instance \u0027{0}\u0027. Run the command `Get-SqlDscRSSetupConfiguration -InstanceName \u0027{0}\u0027` to get the configuration for the instance and verify that it returns a valid edition. (SRSS0021)",
"NoPropertiesToSet": "All properties are in desired state. (RB0007)",
"InstanceName_Invalid": "The instance name \u0027{0}\u0027 is invalid. Only one of the supported instance name can be used, either SSRS or PBIRS depending on what setup executable is used. (SRSS0019)",
"LogPath_ParentMissing": "The parent directory \u0027{0}\u0027 for LogPath does not exist. (SRSS0010)",
"NotInDesiredState": "The current state is not the desired state. (RB0004)",
"GetCurrentState": "Getting the current state for resource \u0027{0}\u0027 using the key property \u0027{1}\u0027. (RB0001)",
"CannotDetermineProductVersion": "Could not determine the product version for the installed instance \u0027{0}\u0027. Run the command `Get-SqlDscRSSetupConfiguration -InstanceName \u0027{0}\u0027` to get the configuration for the instance and verify that it returns a valid product version. (SRSS0020)",
"Installing_PowerBIReportServer": "Installing Power BI Report Server. (SRSS0013)",
"NotDesiredEdition": "The edition \u0027{0}\u0027 is not the desired for the instance \u0027{1}\u0027. Desired edition in executable: \u0027{2}\u0027. (SRSS0022)",
"SetProperty": "The property \u0027{0}\u0027 will be set to \u0027{1}\u0027. (RB0006)",
"AcceptLicensingTerms_Required": "AcceptLicensingTerms must be set for Install and Repair operations. (SRSS0005)",
"GetCurrentStateMethodNotImplemented": "An override for the method GetCurrentState() is not implemented in the resource. (RB0009)",
"SetDesiredState": "Setting the desired state for resource \u0027{0}\u0027 using the key property \u0027{1}\u0027. (RB0003)",
"Uninstalling_PowerBIReportServer": "Uninstalling Power BI Report Server. (SRSS0017)",
"Repairing_PowerBIReportServer": "Repairing Power BI Report Server. (SRSS0015)",
"InstallFolder_ParentMissing": "The parent directory \u0027{0}\u0027 for InstallFolder does not exist. (SRSS0011)"
},
"ExcludeDscProperties": [
"Action",
"AcceptLicensingTerms",
"MediaPath",
"ProductKey",
"EditionUpgrade",
"Edition",
"LogPath",
"InstallFolder",
"SuppressRestart",
"Timeout",
"ForceRestart",
"VersionUpgrade"
],
"FeatureOptionalEnums": false
}
}
]
} |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Now it actually returns a result, but the read-only property is not returned: |
|
It seems that first the first test that is run, read-only property is not returned in the output, but when the second test is run it does return the read-only property. Shifting the first and second test the test that first worked will fail and vice-verse. So there is something happen on the first time running the dsc executable with a class-based resource that does not do what it should. 🤔 Test 1 tracelog:Output from Pester 5:Test 2 tracelog:Output from Pester 5: |
|
The issue now that it fails seems that we have run this prior to running the tests: dsc resource list --adapter Microsoft.Windows/WindowsPowerShell |
|
Labeling this pull request (PR) as abandoned since it has gone 14 days or more since the last update. An abandoned PR can be continued by another contributor. The abandoned label will be removed if work on this PR is taken up again. |
65338be to
4f7c9a3
Compare
|
Labeling this pull request (PR) as abandoned since it has gone 14 days or more since the last update. An abandoned PR can be continued by another contributor. The abandoned label will be removed if work on this PR is taken up again. |
WalkthroughAdds DSCv3 integration testing: CI pipeline stages and matrices for DSCv3 resources, new Pester integration tests for SqlRSSetup and SqlDatabase, relaxed integration prerequisite checks, minor verbose-call cleanup in a common module, and editor/changelog updates. Changes
Sequence Diagram(s)sequenceDiagram
participant Pipeline as Azure Pipeline
participant Artifacts as Build Artifacts
participant Host as Test Host VM
participant DSCv3 as DSCv3 (PSDSC / dsc.exe)
participant Resource as DSC Resource
participant Results as Test Results Publisher
Pipeline->>Artifacts: download build artifacts
Pipeline->>Host: provision/prepare VM
Host->>DSCv3: install DSCv3 (Install-PSDSC / dsc.exe)
Host->>DSCv3: enumerate available resources
Host->>Resource: invoke dsc resource get/test/set (with params)
Resource-->>DSCv3: return resource state JSON
DSCv3-->>Host: exit code + JSON
Host->>Results: publish NUnit test results
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
🔭 Outside diff range comments (1)
source/en-US/DebugDscEngine.strings.psd1 (1)
1-16: LGTM! Well-structured localized strings file.The localized strings are well-organized and follow consistent naming conventions. The debug messages provide comprehensive tracing for the DebugDscEngine resource lifecycle methods.
Minor formatting suggestion for improved readability:
@{ - Getting_CurrentState = "Getting current state for DebugDscEngine resource with KeyProperty '{0}'." - Debug_GetCurrentState_Called = "GetCurrentState method called for KeyProperty '{0}' with properties: {1}." + Getting_CurrentState = "Getting current state for DebugDscEngine resource with KeyProperty '{0}'." + Debug_GetCurrentState_Called = "GetCurrentState method called for KeyProperty '{0}' with properties: {1}."
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (11)
.vscode/settings.json(1 hunks)CHANGELOG.md(1 hunks)azure-pipelines.yml(1 hunks)source/Classes/020.DebugDscEngine.ps1(1 hunks)source/en-US/DebugDscEngine.strings.psd1(1 hunks)source/suffix.ps1(1 hunks)tests/Integration/Commands/Prerequisites.Integration.Tests.ps1(1 hunks)tests/Integration/Resources/DSC_DebugDscEngine.Integration.Tests.ps1(1 hunks)tests/Integration/Resources/DSCv3_DebugDscEngine.Integration.Tests.ps1(1 hunks)tests/Integration/Resources/DSCv3_SqlRSSetup.Integration.Tests.ps1(1 hunks)tests/Unit/Classes/DebugDscEngine.Tests.ps1(1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
azure-pipelines.yml
[warning] 715-715: missing starting space in comment
(comments)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: dsccommunity.SqlServerDsc (Quality Test and Unit Test Publish Code Coverage)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test DSCv3 Resources - Power BI Report Server Integration PowerBI_WIN2025)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test DSCv3 Resources - Power BI Report Server Integration PowerBI_WIN2022)
- GitHub Check: dsccommunity.SqlServerDsc (Quality Test and Unit Test HQRM)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test DSCv3 Resources - Power BI Report Server Integration PowerBI_WIN2019)
- GitHub Check: dsccommunity.SqlServerDsc (Quality Test and Unit Test Unit)
- GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
🔇 Additional comments (13)
.vscode/settings.json (1)
81-81: LGTM! Good addition for DSC terminology.Adding "PSDSC" to the spell checker dictionary is appropriate for the DSCv3 integration work being introduced in this PR.
azure-pipelines.yml (3)
715-716: Clarify the dependency configuration.There's a commented line indicating this stage should depend on
Quality_Test_and_Unit_Test, but it currently depends onBuild. Please clarify if this is intentional or if the dependency should be updated.- #dependsOn: Quality_Test_and_Unit_Test - dependsOn: Build + dependsOn: Quality_Test_and_Unit_TestIf the current dependency on
Buildis intentional for faster feedback during DSCv3 development, consider adding a comment explaining the rationale.
754-778: Excellent DSCv3 setup and diagnostics.The DSCv3 installation and diagnostic steps are well-structured:
- Proper installation of PSDSC and DSC executable with pre-release versions
- Good PATH configuration for DSC executable
- Comprehensive resource listing and cache inspection for troubleshooting
780-795: Well-organized test execution for DSCv3 resources.The test execution configuration properly:
- Maintains PATH configuration for DSC executable
- Runs tests in logical order (prerequisites, then DSCv3-specific tests)
- Includes appropriate Pester configuration
The TODO comment on line 786 about moving prerequisites tests is noted and reasonable for future refactoring.
tests/Integration/Resources/DSC_DebugDscEngine.Integration.Tests.ps1 (2)
1-56: Excellent test structure and dependency management.The integration test follows DSC testing best practices:
- Proper dependency resolution with clear error messages
- Good use of Pester lifecycle blocks for setup and cleanup
- Comprehensive module import and environment initialization
57-234: Comprehensive test coverage for DSC resource lifecycle.The test scenarios effectively cover the complete DebugDscEngine resource lifecycle:
- Resource creation and state validation
- Property modification testing
- Property normalization verification
- Proper use of regex patterns for dynamic read-only properties
- Appropriate LCM idle waiting between tests
The property assertions are well-designed, especially the regex pattern
^ReadOnlyValue_\d{8}_\d{6}$for timestamp validation.tests/Integration/Resources/DSCv3_SqlRSSetup.Integration.Tests.ps1 (1)
56-80: Good DSCv3 executable integration pattern.The test demonstrates proper DSCv3 integration:
- Appropriate parameter setup for SqlRSSetup resource
- Correct use of DSC executable with trace logging
- Proper JSON input formatting and output handling
- Good exit code validation and error handling
tests/Unit/Classes/DebugDscEngine.Tests.ps1 (3)
1-48: Excellent test setup and environment management.The unit test suite demonstrates best practices:
- Proper dependency resolution with clear error handling
- Good module import and environment configuration
- Appropriate use of PSDefaultParameterValues for consistent test execution
- Thorough cleanup in AfterAll block
49-198: Comprehensive class method testing.The test coverage is excellent, validating:
- Class instantiation and inheritance from ResourceBase
- All major DSC methods (Get, Test, Set, GetCurrentState, Modify)
- Proper return types and values
- Both positive and negative scenarios
- Appropriate use of InModuleScope for internal class testing
200-292: Thorough property validation and normalization testing.The property testing is comprehensive:
- Validates both positive and negative validation scenarios
- Tests normalization logic (uppercase KeyProperty, trimmed WriteProperty)
- Includes appropriate error message validation
- Covers edge cases for null/empty properties
The normalization tests effectively verify the expected behavior (uppercase conversion and whitespace trimming).
source/Classes/020.DebugDscEngine.ps1 (2)
117-146: Well-implemented GetCurrentState method.The method correctly returns hardcoded values appropriate for a debug resource, includes useful timestamp generation for the read-only property, and has comprehensive verbose logging using localized strings.
183-255: Excellent implementation of validation and normalization methods.Both
AssertProperties()andNormalizeProperties()are well-implemented with proper error handling, appropriate transformations, and comprehensive logging. The use ofNew-ArgumentExceptionand localized strings follows best practices.tests/Integration/Resources/DSCv3_DebugDscEngine.Integration.Tests.ps1 (1)
47-114: Comprehensive test coverage for Get operations.The tests properly validate all scenarios including minimal properties, full properties, and normalization behavior. The timestamp validation using regex pattern and error handling for DSC executable failures are well-implemented.
tests/Integration/Resources/DSCv3_DebugDscEngine.Integration.Tests.ps1
Outdated
Show resolved
Hide resolved
tests/Integration/Resources/DSCv3_SqlRSSetup.Integration.Tests.ps1
Outdated
Show resolved
Hide resolved
tests/Integration/Resources/DSCv3_SqlRSSetup.Integration.Tests.ps1
Outdated
Show resolved
Hide resolved
|
Labeling this pull request (PR) as abandoned since it has gone 14 days or more since the last update. An abandoned PR can be continued by another contributor. The abandoned label will be removed if work on this PR is taken up again. |
|
Labeling this pull request (PR) as abandoned since it has gone 14 days or more since the last update. An abandoned PR can be continued by another contributor. The abandoned label will be removed if work on this PR is taken up again. |
|
Labeling this pull request (PR) as abandoned since it has gone 14 days or more since the last update. An abandoned PR can be continued by another contributor. The abandoned label will be removed if work on this PR is taken up again. |
…ved functionality
…qlDscServer tests
…rBI integration tests
…lDatabase and SqlRSSetup resources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@CHANGELOG.md`:
- Line 1209: The entry "Add integration tests for DSCv3." was added under the
released heading "## [17.1.0] - 2025-05-22" which mutates historical release
notes; either remove that line entirely from under "## [17.1.0] - 2025-05-22" or
move the text into the "## [Unreleased]" section instead, and when moving
include a proper issue/PR reference (e.g., "#1234") and brief context so
Unreleased tracks the change; do not alter any other content under "## [17.1.0]
- 2025-05-22".
…e and SqlRSSetup resources
johlju
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johlju reviewed 13 files and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @johlju).
tests/Integration/Commands/Prerequisites.Integration.Tests.ps1 line 198 at r3 (raw file):
$module.Count | Should -BeGreaterOrEqual 1 #$module.Version -ge '1.0.4.1' | Should -BeTrue
@coderabbitai[bot] track this in a new GitHub issue line that was changed from:
$module | Should -HaveCount 1
$module.Version -ge '1.0.4.1' | Should -BeTrueto:
$module.Count | Should -BeGreaterOrEqual 1
#$module.Version -ge '1.0.4.1' | Should -BeTrueThat change should not be needed it we create a separate Prerequisites integ test for the DSCv3 integration test stages
Code quote:
$module.Count | Should -BeGreaterOrEqual 1
#$module.Version -ge '1.0.4.1' | Should -BeTrueThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@CHANGELOG.md`:
- Around line 10-12: The changelog bullet under "SqlDatabase" also references
"SqlRSSetup" so update the heading/scope to match the content: either move this
bullet to the existing "SqlServerDsc" section (since it covers multiple
resources) or split it into two resource-specific bullets under "SqlDatabase"
and "SqlRSSetup" and make the wording plural ("resources"); modify the entry
text in CHANGELOG.md accordingly and ensure the headings "SqlDatabase",
"SqlRSSetup", or "SqlServerDsc" accurately reflect where the bullet now lives.
…tup resources to verify DSCv3 compatibility
johlju
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johlju reviewed 3 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @johlju).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@tests/Integration/Resources/DSCv3_SqlDatabase.Integration.Tests.ps1`:
- Around line 185-209: The failing test depends on the model DB’s initial
recovery model; update the tests so state is restored after modifying it: either
add an AfterAll block inside the "When setting the model database recovery model
to Simple" context to reset the model database RecoveryModel back to its
original value (capture original RecoveryModel before tests run) or change the
"When testing the model database with a different recovery model" spec to
explicitly set the model DB to a non-Simple recovery model before asserting
inDesiredState is $false; reference the Context names and the
$desiredParameters/RecoveryModel usage in the SqlDatabase tests to locate where
to capture/restore or explicitly set state.
In `@tests/Integration/Resources/DSCv3_SqlRSSetup.Integration.Tests.ps1`:
- Around line 51-76: The test's It block captures DSC output into $result but
performs no assertions; add Pester assertions after the dsc call to validate the
returned state matches expectations from $desiredParameters and that the DSC
call succeeded. Specifically, assert $result is not null/empty, assert resource
properties in $result (e.g. InstanceName, InstallFolder, Edition, Action/State)
equal the values from $desiredParameters, and assert the DSC run indicated
success (check any status/return code field in $result); use Pester Should
assertions to implement these checks immediately after the dsc --trace-level ...
command and before throwing on $dscExitCode.
🧹 Nitpick comments (5)
tests/Integration/Resources/DSCv3_SqlDatabase.Integration.Tests.ps1 (2)
50-53: Security concern: Plaintext password in test code.While this is an integration test with CI credentials, hardcoding passwords in source code is generally discouraged. Consider using environment variables or a secure configuration mechanism for CI credentials.
♻️ Suggested improvement
<# Credential object for DSCv3. Using lowercase 'username' and 'password' as required by DSCv3 psDscAdapter for PSCredential conversion. See PowerShell/DSC PR `#1308` for details on credential handling in DSCv3. #> $script:sqlAdminCredential = @{ username = "$env:COMPUTERNAME\SqlAdmin" - password = 'P@ssw0rd1' + password = $env:SqlAdminPassword ?? 'P@ssw0rd1' }
51-51: UseGet-ComputerNameinstead of$env:COMPUTERNAME.Per coding guidelines, integration tests should use
Get-ComputerNamefor computer names in CI environments to ensure cross-platform compatibility. Line 42 correctly usesGet-ComputerNamefor$script:serverName, but line 51 uses$env:COMPUTERNAMEdirectly.♻️ Suggested fix
$script:sqlAdminCredential = @{ - username = "$env:COMPUTERNAME\SqlAdmin" + username = "$(Get-ComputerName)\SqlAdmin" password = 'P@ssw0rd1' }tests/Integration/Resources/DSCv3_SqlRSSetup.Integration.Tests.ps1 (3)
1-30: Setup block follows required pattern with one inconsistency.The
BeforeDiscoveryblock correctly implements the module dependency handling. However, the error message on line 22 suggests running-Tasks buildwhile the other file (DSCv3_SqlDatabase.Integration.Tests.ps1) uses-Tasks noop. For consistency and per learnings,-Tasks noopis preferred for quicker setup.♻️ Suggested fix for consistency
- throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks build" first.' + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks noop" first.'
117-140: Set operation test lacks state verification assertions.The
Itblock for setting the resource state doesn't assert that the operation succeeded beyond checking the exit code. Consider verifying$result.afterStateor$result.changedPropertiesto confirm the expected changes.♻️ Suggested improvement
Write-Verbose -Message "Result:`n$($result | ConvertTo-Json | Out-String)" -Verbose + + # Verify the set operation returned expected state + $result.afterState | Should -Not -BeNullOrEmpty }
40-49: Consider consolidating repeated$tempFoldersetup.The
$tempFoldervariable is retrieved viaGet-TemporaryFolderin multipleBeforeAllblocks. This could be moved to theDescribe-levelBeforeAllto reduce duplication and ensure consistency.♻️ Suggested refactor
Describe "$($script:dscResourceFriendlyName)_Integration" -Tag @('Integration_PowerBI') { + BeforeAll { + # Get temporary folder for the test and make sure it exists + $script:tempFolder = Get-TemporaryFolder + Write-Verbose -Message "Temporary folder is $script:tempFolder" -Verbose + if (-not (Test-Path -Path $script:tempFolder)) + { + Write-Verbose -Message "Temporary folder did not exist, creating temporary folder $script:tempFolder" -Verbose + New-Item -Path $script:tempFolder -ItemType Directory -Force | Out-Null + } + } + Context 'When getting the current state of the resource' { - BeforeAll { - # Get temporary folder for the test and make sure it exists, if not create it - $tempFolder = Get-TemporaryFolder - ... - }Then use
$script:tempFolderin all test cases.Also applies to: 80-82, 113-115, 144-146
…SqlDatabase and SqlRSSetup resources
johlju
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johlju reviewed 2 files and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @johlju).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@tests/Integration/Resources/DSCv3_SqlDatabase.Integration.Tests.ps1`:
- Around line 32-35: The BeforeAll block sets $script:dscModuleName and
$script:dscResourceFriendlyName but never imports the module; update the
BeforeAll block (the BeforeAll function where $script:dscModuleName =
'SqlServerDsc' and $script:dscResourceFriendlyName = 'SqlDatabase') to call
Import-Module using that variable (e.g., Import-Module $script:dscModuleName) so
the SqlServerDsc module is loaded before tests run and module helpers can be
used.
- Around line 38-54: The tests set $script:serverName, $script:instanceName and
$script:sqlAdminCredential but never open/close a DB engine session; update the
Describe-level lifecycle to call Connect-SqlDscDatabaseEngine in BeforeAll
(using $script:serverName, $script:instanceName and $script:sqlAdminCredential
following the repo CI credential pattern) and call
Disconnect-SqlDscDatabaseEngine in AfterAll to tear the session down; ensure the
calls use the same credential object and instance variables so the integration
tests interact with a real DB engine session and are properly cleaned up.
♻️ Duplicate comments (1)
tests/Integration/Resources/DSCv3_SqlDatabase.Integration.Tests.ps1 (1)
185-235: Stabilize recovery-model tests by restoring initial state.Line 185-209 assumes the model DB is not
Simple, but Line 211-235 sets it toSimplewith no cleanup. Reruns or reordered contexts will flip the expectation. Capture the original recovery model and restore it inAfterAll, or explicitly set a non-Simplestate before assertinginDesiredStateis$false.
Pull Request (PR) description
This Pull Request (PR) fixes the following issues
Task list
file CHANGELOG.md. Entry should say what was changed and how that
affects users (if applicable), and reference the issue being resolved
(if applicable).
This change is