From cacf5739d6d68baf75dd7ddb2501b0e60e6438a9 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 3 May 2023 19:40:45 +0200 Subject: [PATCH 01/33] Add integration tests for SQLPS --- azure-pipelines.yml | 90 +++++++++++++++++++ .../DSC_SqlSetup.Integration.Tests.ps1 | 2 +- tests/Integration/DSC_SqlSetup.config.ps1 | 14 ++- 3 files changed, 103 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ade6ce3e94..b30c97ecbe 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -329,6 +329,96 @@ stages: testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' testRunTitle: 'Integration (dbatools) ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' + - job: Test_Integration_SQLPS + displayName: 'Integration (SQLPS)' + dependsOn: Test_Integration + strategy: + matrix: + SQL2016_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2016' + SQL2017_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2017' + SQL2019_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2019' + SQL2022_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2022' + pool: + vmImage: $(JOB_VMIMAGE) + timeoutInMinutes: 0 + variables: + SkipInstallSMO: true + steps: + - task: DownloadPipelineArtifact@2 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + artifactName: $(buildArtifactName) + targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' + - task: PowerShell@2 + name: configureWinRM + displayName: 'Configure WinRM' + inputs: + targetType: 'inline' + script: 'winrm quickconfig -quiet' + pwsh: false + - powershell: | + Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 + # Make sure to keep SQLPS since that is what is being tested. + Remove-PowerShellModuleFromCI -Name @('SqlServer') + Remove-Module -Name CommonTestHelper + name: cleanCIWorker + displayName: 'Clean CI worker' + - powershell: | + ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @( + # Run the integration tests in a specific group order. + # Group 1 + 'tests/Integration/DSC_SqlSetup.Integration.Tests.ps1' + # Group 2 + 'tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlLogin.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlEndpoint.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabaseMail.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabaseDefaultLocation.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlAlwaysOnService.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlAgentOperator.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlServiceAccount.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlAgentFailsafe.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlTraceFlag.Integration.Tests.ps1' + # Group 3 + 'tests/Integration/DSC_SqlRole.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlRS_Default.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabaseUser.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlReplication.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlAudit.Integration.Tests.ps1' + # Group 4 + 'tests/Integration/DSC_SqlScript.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabasePermission.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlPermission.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlWindowsFirewall.Integration.Tests.ps1' + # Group 5 + 'tests/Integration/DSC_SqlSecureConnection.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlScriptQuery.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlProtocol.Integration.Tests.ps1' + # Group 6 (tests makes changes that could make SQL Server to loose connectivity) + 'tests/Integration/DSC_SqlProtocolTcpIp.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabaseObjectPermission.Integration.Tests.ps1' + ) + name: test + displayName: 'Run Integration Test' + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + condition: succeededOrFailed() + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' + testRunTitle: 'Integration (dbatools) ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' + - job: Test_Integration_RS displayName: 'Integration Reporting Services' strategy: diff --git a/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 b/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 index 5e27ad3a24..3b70b806db 100644 --- a/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 @@ -214,7 +214,7 @@ Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', } } - Context ('When using configuration <_>') -ForEach @( + Context ('When using configuration <_>') -Skip:($null -ne $env:SkipInstallSMO) -ForEach @( "$($script:dscResourceName)_InstallSMOModule_Config" ) { BeforeAll { diff --git a/tests/Integration/DSC_SqlSetup.config.ps1 b/tests/Integration/DSC_SqlSetup.config.ps1 index c746210c04..8f71fefcaf 100644 --- a/tests/Integration/DSC_SqlSetup.config.ps1 +++ b/tests/Integration/DSC_SqlSetup.config.ps1 @@ -198,6 +198,16 @@ else } } +# Do not use the feature flag AnalysisServicesConnection when running tests with SQLPS. +$featureFlag = if ((Get-Module -Name 'SqlServer', 'dbatools' -ListAvailable)) +{ + @('AnalysisServicesConnection') +} +else +{ + @() +} + <# Creating all the credential objects to save some repeating code. #> @@ -691,7 +701,7 @@ Configuration DSC_SqlSetup_InstallMultiDimensionalAnalysisServicesAsSystem_Confi { SqlSetup 'Integration_Test' { - FeatureFlag = @('AnalysisServicesConnection') + FeatureFlag = [System.String[]] $featureFlag InstanceName = $Node.AnalysisServicesMultiInstanceName Features = $Node.AnalysisServicesMultiFeatures @@ -745,7 +755,7 @@ Configuration DSC_SqlSetup_InstallTabularAnalysisServicesAsSystem_Config { SqlSetup 'Integration_Test' { - FeatureFlag = @('AnalysisServicesConnection') + FeatureFlag = [System.String[]] $featureFlag InstanceName = $Node.AnalysisServicesTabularInstanceName Features = $Node.AnalysisServicesTabularFeatures From 75632b7eb87f2799c1298f00a452f67e35cabb5d Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sat, 6 May 2023 11:28:13 +0200 Subject: [PATCH 02/33] Fix changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index defaf88d23..61b6ecb8e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- SqlServerDsc + - Integration tests now also run using SQLPS. + ### Changed - SqlServerDsc From 4947083521bbda0941ba4f10eddec3f9a9d4cd19 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sun, 7 May 2023 13:36:45 +0200 Subject: [PATCH 03/33] Clean CI from existing SQLPS modules --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b30c97ecbe..81fa52aa89 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -368,7 +368,7 @@ stages: - powershell: | Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 # Make sure to keep SQLPS since that is what is being tested. - Remove-PowerShellModuleFromCI -Name @('SqlServer') + Remove-PowerShellModuleFromCI -Name @('SqlServer', 'SQLPS') Remove-Module -Name CommonTestHelper name: cleanCIWorker displayName: 'Clean CI worker' From a21bf52d5b9379894b3ebd269cc54ad8f1891bfc Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sun, 7 May 2023 13:38:25 +0200 Subject: [PATCH 04/33] Update comment --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 81fa52aa89..2ba83ae9b2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -367,7 +367,7 @@ stages: pwsh: false - powershell: | Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 - # Make sure to keep SQLPS since that is what is being tested. + # Make sure to remove SQLPS so that a wrong version is not being imported prior to the SQL Server install. Remove-PowerShellModuleFromCI -Name @('SqlServer', 'SQLPS') Remove-Module -Name CommonTestHelper name: cleanCIWorker From 84e80e328fb788125bcb4d6c4a895599e2021f39 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 10 May 2023 17:17:22 +0200 Subject: [PATCH 05/33] DEBUG 1 --- source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 b/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 index 93c7416d3a..7ab8ea2236 100644 --- a/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 +++ b/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 @@ -1639,8 +1639,13 @@ function Set-TargetResource $forceReloadPowerShellModule = $true } + Write-Verbose -Message 'DEBUG1' -Verbose + Write-Verbose -Message ('Force Reload: {0}' -f ($forceReloadPowerShellModule | Out-String)) -Verbose + if ((-not $setupEndedInError) -and $forceReloadPowerShellModule) { + Write-Verbose -Message (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String) -Verbose + <# Force reload of SQLPS module in case a newer version of SQL Server was installed that contains a newer version @@ -1650,7 +1655,9 @@ function Set-TargetResource matches the latest assemblies in GAC, mitigating for example issue #1151. #> - Import-SqlDscPreferredModule -Force + Import-SqlDscPreferredModule -Force -Verbose + + Write-Verbose -Message (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String) -Verbose } if (-not (Test-TargetResource @PSBoundParameters)) From 0ee31d59770ce946ed39715b9c93991dfcb46e04 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 10 May 2023 17:19:44 +0200 Subject: [PATCH 06/33] DEBUG 2 --- azure-pipelines.yml | 870 ++++++++++++++++++++++---------------------- 1 file changed, 435 insertions(+), 435 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2ba83ae9b2..b0fd68b0be 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -57,281 +57,281 @@ stages: - stage: Test dependsOn: Build jobs: - - job: Test_HQRM - displayName: 'HQRM' - pool: - vmImage: 'windows-2022' - timeoutInMinutes: 0 - variables: - # This sets environment variable $env:SqlServerDscCI. - SqlServerDscCI: true - steps: - - task: DownloadPipelineArtifact@2 - displayName: 'Download Build Artifact' - inputs: - buildType: 'current' - artifactName: $(buildArtifactName) - targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' - # This task need to use Windows PowerShell due to a bug in PS7 that cannot - # find/use class-based DSC resources that uses inheritance, which result in - # the examples cannot compile. See the following issue for more information: - # https://github.com/dsccommunity/DnsServerDsc/issues/268#issuecomment-918505230 - - powershell: | - # Workaround for issue https://github.com/dsccommunity/DscResource.Test/issues/100 - ./build.ps1 -Task noop + # - job: Test_HQRM + # displayName: 'HQRM' + # pool: + # vmImage: 'windows-2022' + # timeoutInMinutes: 0 + # variables: + # # This sets environment variable $env:SqlServerDscCI. + # SqlServerDscCI: true + # steps: + # - task: DownloadPipelineArtifact@2 + # displayName: 'Download Build Artifact' + # inputs: + # buildType: 'current' + # artifactName: $(buildArtifactName) + # targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' + # # This task need to use Windows PowerShell due to a bug in PS7 that cannot + # # find/use class-based DSC resources that uses inheritance, which result in + # # the examples cannot compile. See the following issue for more information: + # # https://github.com/dsccommunity/DnsServerDsc/issues/268#issuecomment-918505230 + # - powershell: | + # # Workaround for issue https://github.com/dsccommunity/DscResource.Test/issues/100 + # ./build.ps1 -Task noop - $pesterConfig = New-PesterConfiguration - $pesterConfig.Run.Path = '.\tests\QA' - $pesterConfig.Run.Throw = $true - $pesterConfig.Output.Verbosity = 'Detailed' + # $pesterConfig = New-PesterConfiguration + # $pesterConfig.Run.Path = '.\tests\QA' + # $pesterConfig.Run.Throw = $true + # $pesterConfig.Output.Verbosity = 'Detailed' - Invoke-Pester -Configuration $pesterConfig - name: qualityTest - displayName: 'Run SqlServerDsc QA Test' - - task: PowerShell@2 - name: test - displayName: 'Run HQRM Test' - condition: succeededOrFailed() - inputs: - filePath: './build.ps1' - arguments: '-Tasks hqrmtest' - pwsh: false - - task: PublishTestResults@2 - displayName: 'Publish Test Results' - condition: succeededOrFailed() - inputs: - testResultsFormat: 'NUnit' - testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' - testRunTitle: 'HQRM' + # Invoke-Pester -Configuration $pesterConfig + # name: qualityTest + # displayName: 'Run SqlServerDsc QA Test' + # - task: PowerShell@2 + # name: test + # displayName: 'Run HQRM Test' + # condition: succeededOrFailed() + # inputs: + # filePath: './build.ps1' + # arguments: '-Tasks hqrmtest' + # pwsh: false + # - task: PublishTestResults@2 + # displayName: 'Publish Test Results' + # condition: succeededOrFailed() + # inputs: + # testResultsFormat: 'NUnit' + # testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' + # testRunTitle: 'HQRM' - - job: Test_Unit - displayName: 'Unit' - pool: - vmImage: 'windows-2019' - timeoutInMinutes: 0 - variables: - # This sets environment variable $env:SqlServerDscCI. - SqlServerDscCI: true - steps: - - task: DownloadPipelineArtifact@2 - displayName: 'Download Build Artifact' - inputs: - buildType: 'current' - artifactName: $(buildArtifactName) - targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' - - task: PowerShell@2 - name: test - displayName: 'Run Unit Test' - inputs: - filePath: './build.ps1' - arguments: "-Tasks test -PesterPath 'tests/Unit'" - pwsh: true - - task: PublishTestResults@2 - displayName: 'Publish Test Results' - condition: succeededOrFailed() - inputs: - testResultsFormat: 'NUnit' - testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' - testRunTitle: 'Unit (Windows Server 2019)' - - task: PublishPipelineArtifact@1 - displayName: 'Publish Test Artifact' - condition: succeededOrFailed() - inputs: - targetPath: '$(buildFolderName)/$(testResultFolderName)/' - artifactName: $(testArtifactName) - parallel: true + # - job: Test_Unit + # displayName: 'Unit' + # pool: + # vmImage: 'windows-2019' + # timeoutInMinutes: 0 + # variables: + # # This sets environment variable $env:SqlServerDscCI. + # SqlServerDscCI: true + # steps: + # - task: DownloadPipelineArtifact@2 + # displayName: 'Download Build Artifact' + # inputs: + # buildType: 'current' + # artifactName: $(buildArtifactName) + # targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' + # - task: PowerShell@2 + # name: test + # displayName: 'Run Unit Test' + # inputs: + # filePath: './build.ps1' + # arguments: "-Tasks test -PesterPath 'tests/Unit'" + # pwsh: true + # - task: PublishTestResults@2 + # displayName: 'Publish Test Results' + # condition: succeededOrFailed() + # inputs: + # testResultsFormat: 'NUnit' + # testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' + # testRunTitle: 'Unit (Windows Server 2019)' + # - task: PublishPipelineArtifact@1 + # displayName: 'Publish Test Artifact' + # condition: succeededOrFailed() + # inputs: + # targetPath: '$(buildFolderName)/$(testResultFolderName)/' + # artifactName: $(testArtifactName) + # parallel: true - - job: Test_Integration - displayName: 'Integration' - strategy: - matrix: - SQL2016_WIN2019: - JOB_VMIMAGE: 'windows-2019' - TEST_CONFIGURATION: 'Integration_SQL2016' - SQL2016_WIN2022: - JOB_VMIMAGE: 'windows-2022' - TEST_CONFIGURATION: 'Integration_SQL2016' - SQL2017_WIN2019: - JOB_VMIMAGE: 'windows-2019' - TEST_CONFIGURATION: 'Integration_SQL2017' - SQL2017_WIN2022: - JOB_VMIMAGE: 'windows-2022' - TEST_CONFIGURATION: 'Integration_SQL2017' - SQL2019_WIN2019: - JOB_VMIMAGE: 'windows-2019' - TEST_CONFIGURATION: 'Integration_SQL2019' - SQL2019_WIN2022: - JOB_VMIMAGE: 'windows-2022' - TEST_CONFIGURATION: 'Integration_SQL2019' - SQL2022_WIN2019: - JOB_VMIMAGE: 'windows-2019' - TEST_CONFIGURATION: 'Integration_SQL2022' - SQL2022_WIN2022: - JOB_VMIMAGE: 'windows-2022' - TEST_CONFIGURATION: 'Integration_SQL2022' - pool: - vmImage: $(JOB_VMIMAGE) - timeoutInMinutes: 0 - steps: - - task: DownloadPipelineArtifact@2 - displayName: 'Download Build Artifact' - inputs: - buildType: 'current' - artifactName: $(buildArtifactName) - targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' - - task: PowerShell@2 - name: configureWinRM - displayName: 'Configure WinRM' - inputs: - targetType: 'inline' - script: 'winrm quickconfig -quiet' - pwsh: false - - powershell: | - Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 - Remove-PowerShellModuleFromCI -Name @('SqlServer', 'SQLPS') - Remove-Module -Name CommonTestHelper - name: cleanCIWorker - displayName: 'Clean CI worker' - - powershell: | - ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @( - # Run the integration tests in a specific group order. - # Group 1 - 'tests/Integration/DSC_SqlSetup.Integration.Tests.ps1' - # Group 2 - 'tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlLogin.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlEndpoint.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlDatabaseMail.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlDatabaseDefaultLocation.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlAlwaysOnService.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlAgentOperator.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlServiceAccount.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlAgentFailsafe.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlTraceFlag.Integration.Tests.ps1' - # Group 3 - 'tests/Integration/DSC_SqlRole.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlRS_Default.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlDatabaseUser.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlReplication.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlAudit.Integration.Tests.ps1' - # Group 4 - 'tests/Integration/DSC_SqlScript.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlDatabasePermission.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlPermission.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlWindowsFirewall.Integration.Tests.ps1' - # Group 5 - 'tests/Integration/DSC_SqlSecureConnection.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlScriptQuery.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlProtocol.Integration.Tests.ps1' - # Group 6 (tests makes changes that could make SQL Server to loose connectivity) - 'tests/Integration/DSC_SqlProtocolTcpIp.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlDatabaseObjectPermission.Integration.Tests.ps1' - ) - name: test - displayName: 'Run Integration Test' - - task: PublishTestResults@2 - displayName: 'Publish Test Results' - condition: succeededOrFailed() - inputs: - testResultsFormat: 'NUnit' - testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' - testRunTitle: 'Integration ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' + # - job: Test_Integration + # displayName: 'Integration' + # strategy: + # matrix: + # SQL2016_WIN2019: + # JOB_VMIMAGE: 'windows-2019' + # TEST_CONFIGURATION: 'Integration_SQL2016' + # SQL2016_WIN2022: + # JOB_VMIMAGE: 'windows-2022' + # TEST_CONFIGURATION: 'Integration_SQL2016' + # SQL2017_WIN2019: + # JOB_VMIMAGE: 'windows-2019' + # TEST_CONFIGURATION: 'Integration_SQL2017' + # SQL2017_WIN2022: + # JOB_VMIMAGE: 'windows-2022' + # TEST_CONFIGURATION: 'Integration_SQL2017' + # SQL2019_WIN2019: + # JOB_VMIMAGE: 'windows-2019' + # TEST_CONFIGURATION: 'Integration_SQL2019' + # SQL2019_WIN2022: + # JOB_VMIMAGE: 'windows-2022' + # TEST_CONFIGURATION: 'Integration_SQL2019' + # SQL2022_WIN2019: + # JOB_VMIMAGE: 'windows-2019' + # TEST_CONFIGURATION: 'Integration_SQL2022' + # SQL2022_WIN2022: + # JOB_VMIMAGE: 'windows-2022' + # TEST_CONFIGURATION: 'Integration_SQL2022' + # pool: + # vmImage: $(JOB_VMIMAGE) + # timeoutInMinutes: 0 + # steps: + # - task: DownloadPipelineArtifact@2 + # displayName: 'Download Build Artifact' + # inputs: + # buildType: 'current' + # artifactName: $(buildArtifactName) + # targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' + # - task: PowerShell@2 + # name: configureWinRM + # displayName: 'Configure WinRM' + # inputs: + # targetType: 'inline' + # script: 'winrm quickconfig -quiet' + # pwsh: false + # - powershell: | + # Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 + # Remove-PowerShellModuleFromCI -Name @('SqlServer', 'SQLPS') + # Remove-Module -Name CommonTestHelper + # name: cleanCIWorker + # displayName: 'Clean CI worker' + # - powershell: | + # ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @( + # # Run the integration tests in a specific group order. + # # Group 1 + # 'tests/Integration/DSC_SqlSetup.Integration.Tests.ps1' + # # Group 2 + # 'tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlLogin.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlEndpoint.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlDatabaseMail.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlDatabaseDefaultLocation.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlAlwaysOnService.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlAgentOperator.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlServiceAccount.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlAgentFailsafe.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlTraceFlag.Integration.Tests.ps1' + # # Group 3 + # 'tests/Integration/DSC_SqlRole.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlRS_Default.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlDatabaseUser.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlReplication.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlAudit.Integration.Tests.ps1' + # # Group 4 + # 'tests/Integration/DSC_SqlScript.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlDatabasePermission.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlPermission.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlWindowsFirewall.Integration.Tests.ps1' + # # Group 5 + # 'tests/Integration/DSC_SqlSecureConnection.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlScriptQuery.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlProtocol.Integration.Tests.ps1' + # # Group 6 (tests makes changes that could make SQL Server to loose connectivity) + # 'tests/Integration/DSC_SqlProtocolTcpIp.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlDatabaseObjectPermission.Integration.Tests.ps1' + # ) + # name: test + # displayName: 'Run Integration Test' + # - task: PublishTestResults@2 + # displayName: 'Publish Test Results' + # condition: succeededOrFailed() + # inputs: + # testResultsFormat: 'NUnit' + # testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' + # testRunTitle: 'Integration ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' - - job: Test_Integration_dbatools - displayName: 'Integration (dbatools)' - dependsOn: Test_Integration - strategy: - matrix: - SQL2016_WIN2022: - JOB_VMIMAGE: 'windows-2022' - TEST_CONFIGURATION: 'Integration_SQL2016' - SQL2017_WIN2022: - JOB_VMIMAGE: 'windows-2022' - TEST_CONFIGURATION: 'Integration_SQL2017' - SQL2019_WIN2022: - JOB_VMIMAGE: 'windows-2022' - TEST_CONFIGURATION: 'Integration_SQL2019' - SQL2022_WIN2022: - JOB_VMIMAGE: 'windows-2022' - TEST_CONFIGURATION: 'Integration_SQL2022' - pool: - vmImage: $(JOB_VMIMAGE) - timeoutInMinutes: 0 - variables: - SMODefaultModuleName: 'dbatools' - steps: - - task: DownloadPipelineArtifact@2 - displayName: 'Download Build Artifact' - inputs: - buildType: 'current' - artifactName: $(buildArtifactName) - targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' - - task: PowerShell@2 - name: configureWinRM - displayName: 'Configure WinRM' - inputs: - targetType: 'inline' - script: 'winrm quickconfig -quiet' - pwsh: false - - powershell: | - Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 - # Make sure to keep SQLPS so that Invoke-SqlCmd is available. - Remove-PowerShellModuleFromCI -Name @('SqlServer') - Remove-Module -Name CommonTestHelper - name: cleanCIWorker - displayName: 'Clean CI worker' - - powershell: | - ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @( - # Run the integration tests in a specific group order. - # Group 1 - 'tests/Integration/DSC_SqlSetup.Integration.Tests.ps1' - # Group 2 - 'tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlLogin.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlEndpoint.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlDatabaseMail.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlDatabaseDefaultLocation.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlAlwaysOnService.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlAgentOperator.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlServiceAccount.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlAgentFailsafe.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlTraceFlag.Integration.Tests.ps1' - # Group 3 - 'tests/Integration/DSC_SqlRole.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlRS_Default.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlDatabaseUser.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlReplication.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlAudit.Integration.Tests.ps1' - # Group 4 - 'tests/Integration/DSC_SqlScript.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlDatabasePermission.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlPermission.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlWindowsFirewall.Integration.Tests.ps1' - # Group 5 - 'tests/Integration/DSC_SqlSecureConnection.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlScriptQuery.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlProtocol.Integration.Tests.ps1' - # Group 6 (tests makes changes that could make SQL Server to loose connectivity) - 'tests/Integration/DSC_SqlProtocolTcpIp.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlDatabaseObjectPermission.Integration.Tests.ps1' - ) - name: test - displayName: 'Run Integration Test' - - task: PublishTestResults@2 - displayName: 'Publish Test Results' - condition: succeededOrFailed() - inputs: - testResultsFormat: 'NUnit' - testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' - testRunTitle: 'Integration (dbatools) ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' + # - job: Test_Integration_dbatools + # displayName: 'Integration (dbatools)' + # dependsOn: Test_Integration + # strategy: + # matrix: + # SQL2016_WIN2022: + # JOB_VMIMAGE: 'windows-2022' + # TEST_CONFIGURATION: 'Integration_SQL2016' + # SQL2017_WIN2022: + # JOB_VMIMAGE: 'windows-2022' + # TEST_CONFIGURATION: 'Integration_SQL2017' + # SQL2019_WIN2022: + # JOB_VMIMAGE: 'windows-2022' + # TEST_CONFIGURATION: 'Integration_SQL2019' + # SQL2022_WIN2022: + # JOB_VMIMAGE: 'windows-2022' + # TEST_CONFIGURATION: 'Integration_SQL2022' + # pool: + # vmImage: $(JOB_VMIMAGE) + # timeoutInMinutes: 0 + # variables: + # SMODefaultModuleName: 'dbatools' + # steps: + # - task: DownloadPipelineArtifact@2 + # displayName: 'Download Build Artifact' + # inputs: + # buildType: 'current' + # artifactName: $(buildArtifactName) + # targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' + # - task: PowerShell@2 + # name: configureWinRM + # displayName: 'Configure WinRM' + # inputs: + # targetType: 'inline' + # script: 'winrm quickconfig -quiet' + # pwsh: false + # - powershell: | + # Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 + # # Make sure to keep SQLPS so that Invoke-SqlCmd is available. + # Remove-PowerShellModuleFromCI -Name @('SqlServer') + # Remove-Module -Name CommonTestHelper + # name: cleanCIWorker + # displayName: 'Clean CI worker' + # - powershell: | + # ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @( + # # Run the integration tests in a specific group order. + # # Group 1 + # 'tests/Integration/DSC_SqlSetup.Integration.Tests.ps1' + # # Group 2 + # 'tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlLogin.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlEndpoint.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlDatabaseMail.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlDatabaseDefaultLocation.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlAlwaysOnService.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlAgentOperator.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlServiceAccount.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlAgentFailsafe.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlTraceFlag.Integration.Tests.ps1' + # # Group 3 + # 'tests/Integration/DSC_SqlRole.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlRS_Default.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlDatabaseUser.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlReplication.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlAudit.Integration.Tests.ps1' + # # Group 4 + # 'tests/Integration/DSC_SqlScript.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlDatabasePermission.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlPermission.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlWindowsFirewall.Integration.Tests.ps1' + # # Group 5 + # 'tests/Integration/DSC_SqlSecureConnection.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlScriptQuery.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlProtocol.Integration.Tests.ps1' + # # Group 6 (tests makes changes that could make SQL Server to loose connectivity) + # 'tests/Integration/DSC_SqlProtocolTcpIp.Integration.Tests.ps1' + # 'tests/Integration/DSC_SqlDatabaseObjectPermission.Integration.Tests.ps1' + # ) + # name: test + # displayName: 'Run Integration Test' + # - task: PublishTestResults@2 + # displayName: 'Publish Test Results' + # condition: succeededOrFailed() + # inputs: + # testResultsFormat: 'NUnit' + # testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' + # testRunTitle: 'Integration (dbatools) ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' - job: Test_Integration_SQLPS displayName: 'Integration (SQLPS)' - dependsOn: Test_Integration + #dependsOn: Test_Integration strategy: matrix: SQL2016_WIN2022: @@ -419,176 +419,176 @@ stages: testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' testRunTitle: 'Integration (dbatools) ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' - - job: Test_Integration_RS - displayName: 'Integration Reporting Services' - strategy: - matrix: - SQL2016_WIN2019: - JOB_VMIMAGE: 'windows-2019' - TEST_CONFIGURATION: 'Integration_SQL2016' - SQL2016_WIN2022: - JOB_VMIMAGE: 'windows-2022' - TEST_CONFIGURATION: 'Integration_SQL2016' - SQL2017_WIN2019: - JOB_VMIMAGE: 'windows-2019' - TEST_CONFIGURATION: 'Integration_SQL2017' - SQL2017_WIN2022: - JOB_VMIMAGE: 'windows-2022' - TEST_CONFIGURATION: 'Integration_SQL2017' - SQL2019_WIN2019: - JOB_VMIMAGE: 'windows-2019' - TEST_CONFIGURATION: 'Integration_SQL2019' - SQL2019_WIN2022: - JOB_VMIMAGE: 'windows-2022' - TEST_CONFIGURATION: 'Integration_SQL2019' - SQL2022_WIN2019: - JOB_VMIMAGE: 'windows-2019' - TEST_CONFIGURATION: 'Integration_SQL2022' - SQL2022_WIN2022: - JOB_VMIMAGE: 'windows-2022' - TEST_CONFIGURATION: 'Integration_SQL2022' - variables: - SKIP_DATABASE_ENGINE_DEFAULT_INSTANCE: true - SKIP_ANALYSIS_MULTI_INSTANCE: true - SKIP_ANALYSIS_TABULAR_INSTANCE: true - SMODefaultModuleName: 'SqlServer' - pool: - vmImage: $(JOB_VMIMAGE) - timeoutInMinutes: 0 - steps: - - task: DownloadPipelineArtifact@2 - displayName: 'Download Build Artifact' - inputs: - buildType: 'current' - artifactName: $(buildArtifactName) - targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' - - task: PowerShell@2 - name: configureWinRM - displayName: 'Configure WinRM' - inputs: - targetType: 'inline' - script: 'winrm quickconfig -quiet' - pwsh: false - - powershell: | - Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 - Remove-PowerShellModuleFromCI -Name @('SqlServer', 'SQLPS') - Remove-Module -Name CommonTestHelper - name: cleanCIWorker - displayName: 'Clean CI worker' - - powershell: | - ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @( - # Run the integration tests in a specific group order. - # Group 1 - 'tests/Integration/DSC_SqlSetup.Integration.Tests.ps1' - # Group 2 - 'tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1' - # Group 3 - 'tests/Integration/DSC_SqlRS.Integration.Tests.ps1' - ) - name: test - displayName: 'Run Reporting Services Integration Test' - - task: PublishTestResults@2 - displayName: 'Publish Test Results' - condition: succeededOrFailed() - inputs: - testResultsFormat: 'NUnit' - testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' - testRunTitle: 'Integration RS ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' + # - job: Test_Integration_RS + # displayName: 'Integration Reporting Services' + # strategy: + # matrix: + # SQL2016_WIN2019: + # JOB_VMIMAGE: 'windows-2019' + # TEST_CONFIGURATION: 'Integration_SQL2016' + # SQL2016_WIN2022: + # JOB_VMIMAGE: 'windows-2022' + # TEST_CONFIGURATION: 'Integration_SQL2016' + # SQL2017_WIN2019: + # JOB_VMIMAGE: 'windows-2019' + # TEST_CONFIGURATION: 'Integration_SQL2017' + # SQL2017_WIN2022: + # JOB_VMIMAGE: 'windows-2022' + # TEST_CONFIGURATION: 'Integration_SQL2017' + # SQL2019_WIN2019: + # JOB_VMIMAGE: 'windows-2019' + # TEST_CONFIGURATION: 'Integration_SQL2019' + # SQL2019_WIN2022: + # JOB_VMIMAGE: 'windows-2022' + # TEST_CONFIGURATION: 'Integration_SQL2019' + # SQL2022_WIN2019: + # JOB_VMIMAGE: 'windows-2019' + # TEST_CONFIGURATION: 'Integration_SQL2022' + # SQL2022_WIN2022: + # JOB_VMIMAGE: 'windows-2022' + # TEST_CONFIGURATION: 'Integration_SQL2022' + # variables: + # SKIP_DATABASE_ENGINE_DEFAULT_INSTANCE: true + # SKIP_ANALYSIS_MULTI_INSTANCE: true + # SKIP_ANALYSIS_TABULAR_INSTANCE: true + # SMODefaultModuleName: 'SqlServer' + # pool: + # vmImage: $(JOB_VMIMAGE) + # timeoutInMinutes: 0 + # steps: + # - task: DownloadPipelineArtifact@2 + # displayName: 'Download Build Artifact' + # inputs: + # buildType: 'current' + # artifactName: $(buildArtifactName) + # targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' + # - task: PowerShell@2 + # name: configureWinRM + # displayName: 'Configure WinRM' + # inputs: + # targetType: 'inline' + # script: 'winrm quickconfig -quiet' + # pwsh: false + # - powershell: | + # Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 + # Remove-PowerShellModuleFromCI -Name @('SqlServer', 'SQLPS') + # Remove-Module -Name CommonTestHelper + # name: cleanCIWorker + # displayName: 'Clean CI worker' + # - powershell: | + # ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @( + # # Run the integration tests in a specific group order. + # # Group 1 + # 'tests/Integration/DSC_SqlSetup.Integration.Tests.ps1' + # # Group 2 + # 'tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1' + # # Group 3 + # 'tests/Integration/DSC_SqlRS.Integration.Tests.ps1' + # ) + # name: test + # displayName: 'Run Reporting Services Integration Test' + # - task: PublishTestResults@2 + # displayName: 'Publish Test Results' + # condition: succeededOrFailed() + # inputs: + # testResultsFormat: 'NUnit' + # testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' + # testRunTitle: 'Integration RS ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' - - job: Test_Integration_RS_dbatools - displayName: 'Integration Reporting Services (dbatools)' - dependsOn: Test_Integration_RS - strategy: - matrix: - SQL2016_WIN2022: - JOB_VMIMAGE: 'windows-2022' - TEST_CONFIGURATION: 'Integration_SQL2016' - SQL2017_WIN2022: - JOB_VMIMAGE: 'windows-2022' - TEST_CONFIGURATION: 'Integration_SQL2017' - SQL2019_WIN2022: - JOB_VMIMAGE: 'windows-2022' - TEST_CONFIGURATION: 'Integration_SQL2019' - SQL2022_WIN2022: - JOB_VMIMAGE: 'windows-2022' - TEST_CONFIGURATION: 'Integration_SQL2022' - variables: - SKIP_DATABASE_ENGINE_DEFAULT_INSTANCE: true - SKIP_ANALYSIS_MULTI_INSTANCE: true - SKIP_ANALYSIS_TABULAR_INSTANCE: true - SMODefaultModuleName: 'dbatools' - pool: - vmImage: $(JOB_VMIMAGE) - timeoutInMinutes: 0 - steps: - - task: DownloadPipelineArtifact@2 - displayName: 'Download Build Artifact' - inputs: - buildType: 'current' - artifactName: $(buildArtifactName) - targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' - - task: PowerShell@2 - name: configureWinRM - displayName: 'Configure WinRM' - inputs: - targetType: 'inline' - script: 'winrm quickconfig -quiet' - pwsh: false - - powershell: | - ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @( - # Run the integration tests in a specific group order. - # Group 1 - 'tests/Integration/DSC_SqlSetup.Integration.Tests.ps1' - # Group 2 - 'tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1' - # Group 3 - 'tests/Integration/DSC_SqlRS.Integration.Tests.ps1' - ) - name: test - displayName: 'Run Reporting Services Integration Test' - - task: PublishTestResults@2 - displayName: 'Publish Test Results' - condition: succeededOrFailed() - inputs: - testResultsFormat: 'NUnit' - testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' - testRunTitle: 'Integration RS (dbatools) ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' + # - job: Test_Integration_RS_dbatools + # displayName: 'Integration Reporting Services (dbatools)' + # dependsOn: Test_Integration_RS + # strategy: + # matrix: + # SQL2016_WIN2022: + # JOB_VMIMAGE: 'windows-2022' + # TEST_CONFIGURATION: 'Integration_SQL2016' + # SQL2017_WIN2022: + # JOB_VMIMAGE: 'windows-2022' + # TEST_CONFIGURATION: 'Integration_SQL2017' + # SQL2019_WIN2022: + # JOB_VMIMAGE: 'windows-2022' + # TEST_CONFIGURATION: 'Integration_SQL2019' + # SQL2022_WIN2022: + # JOB_VMIMAGE: 'windows-2022' + # TEST_CONFIGURATION: 'Integration_SQL2022' + # variables: + # SKIP_DATABASE_ENGINE_DEFAULT_INSTANCE: true + # SKIP_ANALYSIS_MULTI_INSTANCE: true + # SKIP_ANALYSIS_TABULAR_INSTANCE: true + # SMODefaultModuleName: 'dbatools' + # pool: + # vmImage: $(JOB_VMIMAGE) + # timeoutInMinutes: 0 + # steps: + # - task: DownloadPipelineArtifact@2 + # displayName: 'Download Build Artifact' + # inputs: + # buildType: 'current' + # artifactName: $(buildArtifactName) + # targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' + # - task: PowerShell@2 + # name: configureWinRM + # displayName: 'Configure WinRM' + # inputs: + # targetType: 'inline' + # script: 'winrm quickconfig -quiet' + # pwsh: false + # - powershell: | + # ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @( + # # Run the integration tests in a specific group order. + # # Group 1 + # 'tests/Integration/DSC_SqlSetup.Integration.Tests.ps1' + # # Group 2 + # 'tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1' + # # Group 3 + # 'tests/Integration/DSC_SqlRS.Integration.Tests.ps1' + # ) + # name: test + # displayName: 'Run Reporting Services Integration Test' + # - task: PublishTestResults@2 + # displayName: 'Publish Test Results' + # condition: succeededOrFailed() + # inputs: + # testResultsFormat: 'NUnit' + # testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' + # testRunTitle: 'Integration RS (dbatools) ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' - - job: Code_Coverage - displayName: 'Publish Code Coverage' - dependsOn: Test_Unit - condition: succeededOrFailed() - pool: - vmImage: 'ubuntu-latest' - timeoutInMinutes: 0 - steps: - - pwsh: | - $repositoryOwner,$repositoryName = $env:BUILD_REPOSITORY_NAME -split '/' - echo "##vso[task.setvariable variable=RepositoryOwner;isOutput=true]$repositoryOwner" - echo "##vso[task.setvariable variable=RepositoryName;isOutput=true]$repositoryName" - name: dscBuildVariable - displayName: 'Set Environment Variables' - - task: DownloadPipelineArtifact@2 - displayName: 'Download Build Artifact' - inputs: - buildType: 'current' - artifactName: $(buildArtifactName) - targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' - - task: DownloadPipelineArtifact@2 - displayName: 'Download Test Artifact' - inputs: - buildType: 'current' - artifactName: $(testArtifactName) - targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)' - - task: PublishCodeCoverageResults@1 - displayName: 'Publish Code Coverage to Azure DevOps' - inputs: - codeCoverageTool: 'JaCoCo' - summaryFileLocation: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml' - pathToSources: '$(Build.SourcesDirectory)/$(sourceFolderName)/' - - script: | - bash <(curl -s https://codecov.io/bash) -f "./$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml" -F unit - displayName: 'Publish Code Coverage to Codecov.io' + # - job: Code_Coverage + # displayName: 'Publish Code Coverage' + # dependsOn: Test_Unit + # condition: succeededOrFailed() + # pool: + # vmImage: 'ubuntu-latest' + # timeoutInMinutes: 0 + # steps: + # - pwsh: | + # $repositoryOwner,$repositoryName = $env:BUILD_REPOSITORY_NAME -split '/' + # echo "##vso[task.setvariable variable=RepositoryOwner;isOutput=true]$repositoryOwner" + # echo "##vso[task.setvariable variable=RepositoryName;isOutput=true]$repositoryName" + # name: dscBuildVariable + # displayName: 'Set Environment Variables' + # - task: DownloadPipelineArtifact@2 + # displayName: 'Download Build Artifact' + # inputs: + # buildType: 'current' + # artifactName: $(buildArtifactName) + # targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' + # - task: DownloadPipelineArtifact@2 + # displayName: 'Download Test Artifact' + # inputs: + # buildType: 'current' + # artifactName: $(testArtifactName) + # targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)' + # - task: PublishCodeCoverageResults@1 + # displayName: 'Publish Code Coverage to Azure DevOps' + # inputs: + # codeCoverageTool: 'JaCoCo' + # summaryFileLocation: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml' + # pathToSources: '$(Build.SourcesDirectory)/$(sourceFolderName)/' + # - script: | + # bash <(curl -s https://codecov.io/bash) -f "./$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml" -F unit + # displayName: 'Publish Code Coverage to Codecov.io' - stage: Deploy dependsOn: Test From cb11f520995620cbd07937ebecc0ba30699a3841 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 11 May 2023 13:09:35 +0200 Subject: [PATCH 07/33] DEBUG 3 --- .../Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 index 9201acd1c7..4850c935a0 100644 --- a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 +++ b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 @@ -503,7 +503,12 @@ function Connect-SQL $Encrypt ) - Import-SqlDscPreferredModule + Write-Verbose -Message 'DEBUG2' -Verbose + Write-Verbose -Message (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String) -Verbose + + Import-SqlDscPreferredModule -Force + + Write-Verbose -Message (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String) -Verbose if ($InstanceName -eq 'MSSQLSERVER') { From 5fb9906c8e01463229585d6e1adac33ddd2e491c Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 11 May 2023 13:40:22 +0200 Subject: [PATCH 08/33] DEBUG 4 --- source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 | 5 +++++ source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 | 2 ++ 2 files changed, 7 insertions(+) diff --git a/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 b/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 index 7ab8ea2236..c2a91b1df9 100644 --- a/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 +++ b/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 @@ -1644,7 +1644,10 @@ function Set-TargetResource if ((-not $setupEndedInError) -and $forceReloadPowerShellModule) { + Write-Verbose -Message (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String) -Verbose + Write-Verbose -Message $env:PSModulePath -Verbose + Write-Verbose -Message (Get-PSModulePath -FromTarget 'Session', 'User', 'Machine') -Verbose <# Force reload of SQLPS module in case a newer version of @@ -1658,6 +1661,8 @@ function Set-TargetResource Import-SqlDscPreferredModule -Force -Verbose Write-Verbose -Message (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String) -Verbose + Write-Verbose -Message $env:PSModulePath -Verbose + Write-Verbose -Message (Get-PSModulePath -FromTarget 'Session', 'User', 'Machine') -Verbose } if (-not (Test-TargetResource @PSBoundParameters)) diff --git a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 index 4850c935a0..eebec1592a 100644 --- a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 +++ b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 @@ -504,7 +504,9 @@ function Connect-SQL ) Write-Verbose -Message 'DEBUG2' -Verbose + Write-Verbose -Message $env:PSModulePath -Verbose Write-Verbose -Message (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String) -Verbose + Write-Verbose -Message (Get-PSModulePath -FromTarget 'Session', 'User', 'Machine') -Verbose Import-SqlDscPreferredModule -Force From 0de24cdcd640b7d61a0383a712ff89c127232192 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 11 May 2023 15:47:40 +0200 Subject: [PATCH 09/33] DEBUG 5 --- source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 | 9 ++++----- .../Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 | 8 ++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 b/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 index c2a91b1df9..7faddbeca6 100644 --- a/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 +++ b/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 @@ -1644,10 +1644,9 @@ function Set-TargetResource if ((-not $setupEndedInError) -and $forceReloadPowerShellModule) { - Write-Verbose -Message (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String) -Verbose - Write-Verbose -Message $env:PSModulePath -Verbose - Write-Verbose -Message (Get-PSModulePath -FromTarget 'Session', 'User', 'Machine') -Verbose + Write-Verbose -Message ('Session PSModulePath: {0}' -f $env:PSModulePath) -Verbose + Write-Verbose -Message ('All PSModulePath: {0}' -f (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String)) -Verbose <# Force reload of SQLPS module in case a newer version of @@ -1661,8 +1660,8 @@ function Set-TargetResource Import-SqlDscPreferredModule -Force -Verbose Write-Verbose -Message (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String) -Verbose - Write-Verbose -Message $env:PSModulePath -Verbose - Write-Verbose -Message (Get-PSModulePath -FromTarget 'Session', 'User', 'Machine') -Verbose + Write-Verbose -Message ('Session PSModulePath: {0}' -f $env:PSModulePath) -Verbose + Write-Verbose -Message ('All PSModulePath: {0}' -f (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String)) -Verbose } if (-not (Test-TargetResource @PSBoundParameters)) diff --git a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 index eebec1592a..86bdf0c00f 100644 --- a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 +++ b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 @@ -504,10 +504,14 @@ function Connect-SQL ) Write-Verbose -Message 'DEBUG2' -Verbose - Write-Verbose -Message $env:PSModulePath -Verbose - Write-Verbose -Message (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String) -Verbose + Write-Verbose -Message ('Session PSModulePath: {0}' -f $env:PSModulePath) -Verbose + Write-Verbose -Message ('All PSModulePath: {0}' -f (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String)) -Verbose Write-Verbose -Message (Get-PSModulePath -FromTarget 'Session', 'User', 'Machine') -Verbose + Write-Verbose -Message 'DEBUG3' -Verbose + Write-Verbose -Message ('Found module: {0}' -f (Get-SqlDscPreferredModule -ErrorAction 'Continue')) -Verbose + Write-Verbose -Message ('Found module (refresh): {0}' -f (Get-SqlDscPreferredModule -Refresh -ErrorAction 'Stop')) -Verbose + Import-SqlDscPreferredModule -Force Write-Verbose -Message (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String) -Verbose From 9116a00134df4816c3fd20fc83149ddf12763044 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 11 May 2023 17:24:40 +0200 Subject: [PATCH 10/33] DEBUG 6 --- source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 | 8 ++++---- .../Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 | 4 ++-- source/Public/Get-SqlDscPreferredModule.ps1 | 5 +++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 b/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 index 7faddbeca6..aaec6ed7fc 100644 --- a/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 +++ b/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 @@ -1644,9 +1644,9 @@ function Set-TargetResource if ((-not $setupEndedInError) -and $forceReloadPowerShellModule) { - Write-Verbose -Message (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String) -Verbose Write-Verbose -Message ('Session PSModulePath: {0}' -f $env:PSModulePath) -Verbose - Write-Verbose -Message ('All PSModulePath: {0}' -f (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String)) -Verbose + Write-Verbose -Message ('Available modules: {0}' -f (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String)) -Verbose + Write-Verbose -Message ('All PSModulePath: {0}' -f (Get-PSModulePath -FromTarget 'Session', 'User', 'Machine')) -Verbose <# Force reload of SQLPS module in case a newer version of @@ -1659,9 +1659,9 @@ function Set-TargetResource #> Import-SqlDscPreferredModule -Force -Verbose - Write-Verbose -Message (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String) -Verbose Write-Verbose -Message ('Session PSModulePath: {0}' -f $env:PSModulePath) -Verbose - Write-Verbose -Message ('All PSModulePath: {0}' -f (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String)) -Verbose + Write-Verbose -Message ('Available modules: {0}' -f (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String)) -Verbose + Write-Verbose -Message ('All PSModulePath: {0}' -f (Get-PSModulePath -FromTarget 'Session', 'User', 'Machine')) -Verbose } if (-not (Test-TargetResource @PSBoundParameters)) diff --git a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 index 86bdf0c00f..633ddf4337 100644 --- a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 +++ b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 @@ -505,8 +505,8 @@ function Connect-SQL Write-Verbose -Message 'DEBUG2' -Verbose Write-Verbose -Message ('Session PSModulePath: {0}' -f $env:PSModulePath) -Verbose - Write-Verbose -Message ('All PSModulePath: {0}' -f (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String)) -Verbose - Write-Verbose -Message (Get-PSModulePath -FromTarget 'Session', 'User', 'Machine') -Verbose + Write-Verbose -Message ('Available modules: {0}' -f (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String)) -Verbose + Write-Verbose -Message ('All PSModulePath: {0}' -f (Get-PSModulePath -FromTarget 'Session', 'User', 'Machine')) -Verbose Write-Verbose -Message 'DEBUG3' -Verbose Write-Verbose -Message ('Found module: {0}' -f (Get-SqlDscPreferredModule -ErrorAction 'Continue')) -Verbose diff --git a/source/Public/Get-SqlDscPreferredModule.ps1 b/source/Public/Get-SqlDscPreferredModule.ps1 index 446232927d..4df07a42a6 100644 --- a/source/Public/Get-SqlDscPreferredModule.ps1 +++ b/source/Public/Get-SqlDscPreferredModule.ps1 @@ -127,11 +127,16 @@ function Get-SqlDscPreferredModule } ) + Write-Verbose -Message ('Get-SqlDscPreferredModule Available Modules: {0}' -f ($availableModule | Out-String)) -Verbose + foreach ($preferredModuleName in $Name) { $preferredModule = $availableModule | Where-Object -Property 'Name' -EQ -Value $preferredModuleName + Write-Verbose -Message ('PreferredModuleName: {0}' -f $preferredModuleName) -Verbose + Write-Verbose -Message ('Found PreferredModule: {0}' -f ($preferredModule | Out-String)) -Verbose + if ($preferredModule) { if ($preferredModule.Name -eq 'SQLPS') From 8efa957f611b142d78591d2043d8a0a1e6dadd0b Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 16 May 2023 20:16:35 +0200 Subject: [PATCH 11/33] DEBUG 7 --- source/Public/Get-SqlDscPreferredModule.ps1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/Public/Get-SqlDscPreferredModule.ps1 b/source/Public/Get-SqlDscPreferredModule.ps1 index 4df07a42a6..a79ff54ae3 100644 --- a/source/Public/Get-SqlDscPreferredModule.ps1 +++ b/source/Public/Get-SqlDscPreferredModule.ps1 @@ -74,7 +74,13 @@ function Get-SqlDscPreferredModule } } - if ($Refresh.IsPresent) + Write-Verbose -Message ('DEBUG Session: {0}' -f (Get-PSModulePath -FromTarget 'Session')) -Verbose + Write-Verbose -Message ('DEBUG User: {0}' -f (Get-PSModulePath -FromTarget 'User')) -Verbose + Write-Verbose -Message ('DEBUG Machine: {0}' -f (Get-PSModulePath -FromTarget 'Machine')) -Verbose + Write-Verbose -Message ('DEBUG $env: {0}' -f $env:PSModulePath) -Verbose + + #if ($Refresh.IsPresent) + if ($true) { # Only run on Windows that has Machine state. if (-not ($IsLinux -or $IsMacOS)) From f0f7fb62e942023eec9b1fbba527326c162c981b Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 16 May 2023 20:59:55 +0200 Subject: [PATCH 12/33] DEBUG 8 --- source/Public/Get-SqlDscPreferredModule.ps1 | 14 ++++++------- .../DSC_SqlAgentAlert.Integration.Tests.ps1 | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/source/Public/Get-SqlDscPreferredModule.ps1 b/source/Public/Get-SqlDscPreferredModule.ps1 index a79ff54ae3..dd718c479f 100644 --- a/source/Public/Get-SqlDscPreferredModule.ps1 +++ b/source/Public/Get-SqlDscPreferredModule.ps1 @@ -74,10 +74,10 @@ function Get-SqlDscPreferredModule } } - Write-Verbose -Message ('DEBUG Session: {0}' -f (Get-PSModulePath -FromTarget 'Session')) -Verbose - Write-Verbose -Message ('DEBUG User: {0}' -f (Get-PSModulePath -FromTarget 'User')) -Verbose - Write-Verbose -Message ('DEBUG Machine: {0}' -f (Get-PSModulePath -FromTarget 'Machine')) -Verbose - Write-Verbose -Message ('DEBUG $env: {0}' -f $env:PSModulePath) -Verbose + Write-Verbose -Message ('Get-SqlDscPreferredModule: DEBUG Session: {0}' -f (Get-PSModulePath -FromTarget 'Session')) -Verbose + Write-Verbose -Message ('Get-SqlDscPreferredModule: DEBUG User: {0}' -f (Get-PSModulePath -FromTarget 'User')) -Verbose + Write-Verbose -Message ('Get-SqlDscPreferredModule: DEBUG Machine: {0}' -f (Get-PSModulePath -FromTarget 'Machine')) -Verbose + Write-Verbose -Message ('Get-SqlDscPreferredModule: DEBUG $env: {0}' -f $env:PSModulePath) -Verbose #if ($Refresh.IsPresent) if ($true) @@ -133,15 +133,15 @@ function Get-SqlDscPreferredModule } ) - Write-Verbose -Message ('Get-SqlDscPreferredModule Available Modules: {0}' -f ($availableModule | Out-String)) -Verbose + Write-Verbose -Message ('Get-SqlDscPreferredModule: Available Modules: {0}' -f ($availableModule | Out-String)) -Verbose foreach ($preferredModuleName in $Name) { $preferredModule = $availableModule | Where-Object -Property 'Name' -EQ -Value $preferredModuleName - Write-Verbose -Message ('PreferredModuleName: {0}' -f $preferredModuleName) -Verbose - Write-Verbose -Message ('Found PreferredModule: {0}' -f ($preferredModule | Out-String)) -Verbose + Write-Verbose -Message ('Get-SqlDscPreferredModule: PreferredModuleName: {0}' -f $preferredModuleName) -Verbose + Write-Verbose -Message ('Get-SqlDscPreferredModule: Found PreferredModule: {0}' -f ($preferredModule | Out-String)) -Verbose if ($preferredModule) { diff --git a/tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1 b/tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1 index 2432c6dda7..dd5a7cd1f5 100644 --- a/tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1 @@ -2,6 +2,11 @@ param () BeforeDiscovery { + Write-Verbose -Message ('SqlAgentAlert: DEBUG1 Session: {0}' -f (Get-PSModulePath -FromTarget 'Session')) -Verbose + Write-Verbose -Message ('SqlAgentAlert: DEBUG1 User: {0}' -f (Get-PSModulePath -FromTarget 'User')) -Verbose + Write-Verbose -Message ('SqlAgentAlert: DEBUG1 Machine: {0}' -f (Get-PSModulePath -FromTarget 'Machine')) -Verbose + Write-Verbose -Message ('SqlAgentAlert: DEBUG1 $env: {0}' -f $env:PSModulePath) -Verbose + try { if (-not (Get-Module -Name 'DscResource.Test')) @@ -31,6 +36,11 @@ BeforeDiscovery { } BeforeAll { + Write-Verbose -Message ('SqlAgentAlert: DEBUG2 Session: {0}' -f (Get-PSModulePath -FromTarget 'Session')) -Verbose + Write-Verbose -Message ('SqlAgentAlert: DEBUG2 User: {0}' -f (Get-PSModulePath -FromTarget 'User')) -Verbose + Write-Verbose -Message ('SqlAgentAlert: DEBUG2 Machine: {0}' -f (Get-PSModulePath -FromTarget 'Machine')) -Verbose + Write-Verbose -Message ('SqlAgentAlert: DEBUG2 $env: {0}' -f $env:PSModulePath) -Verbose + # Need to define the variables here which will be used in Pester Run. $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlAgentAlert' @@ -42,8 +52,18 @@ BeforeAll { -ResourceType 'Mof' ` -TestType 'Integration' + Write-Verbose -Message ('SqlAgentAlert: DEBUG3 Session: {0}' -f (Get-PSModulePath -FromTarget 'Session')) -Verbose + Write-Verbose -Message ('SqlAgentAlert: DEBUG3 User: {0}' -f (Get-PSModulePath -FromTarget 'User')) -Verbose + Write-Verbose -Message ('SqlAgentAlert: DEBUG3 Machine: {0}' -f (Get-PSModulePath -FromTarget 'Machine')) -Verbose + Write-Verbose -Message ('SqlAgentAlert: DEBUG3 $env: {0}' -f $env:PSModulePath) -Verbose + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $configFile + + Write-Verbose -Message ('SqlAgentAlert: DEBUG4 Session: {0}' -f (Get-PSModulePath -FromTarget 'Session')) -Verbose + Write-Verbose -Message ('SqlAgentAlert: DEBUG4 User: {0}' -f (Get-PSModulePath -FromTarget 'User')) -Verbose + Write-Verbose -Message ('SqlAgentAlert: DEBUG4 Machine: {0}' -f (Get-PSModulePath -FromTarget 'Machine')) -Verbose + Write-Verbose -Message ('SqlAgentAlert: DEBUG4 $env: {0}' -f $env:PSModulePath) -Verbose } AfterAll { From 683806579e61c2d8d9eef7c0f318e9857f11c271 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 16 May 2023 21:32:35 +0200 Subject: [PATCH 13/33] DEBUG 9 --- .../DSC_SqlAgentAlert.Integration.Tests.ps1 | 5 ----- tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 | 10 ++++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1 b/tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1 index dd5a7cd1f5..49c1e715aa 100644 --- a/tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1 @@ -2,11 +2,6 @@ param () BeforeDiscovery { - Write-Verbose -Message ('SqlAgentAlert: DEBUG1 Session: {0}' -f (Get-PSModulePath -FromTarget 'Session')) -Verbose - Write-Verbose -Message ('SqlAgentAlert: DEBUG1 User: {0}' -f (Get-PSModulePath -FromTarget 'User')) -Verbose - Write-Verbose -Message ('SqlAgentAlert: DEBUG1 Machine: {0}' -f (Get-PSModulePath -FromTarget 'Machine')) -Verbose - Write-Verbose -Message ('SqlAgentAlert: DEBUG1 $env: {0}' -f $env:PSModulePath) -Verbose - try { if (-not (Get-Module -Name 'DscResource.Test')) diff --git a/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 b/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 index 3b70b806db..bd8c94e38c 100644 --- a/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 @@ -169,8 +169,18 @@ BeforeAll { } AfterAll { + Write-Verbose -Message ('SqlSetup: DEBUG1 Session: {0}' -f (Get-PSModulePath -FromTarget 'Session')) -Verbose + Write-Verbose -Message ('SqlSetup: DEBUG1 User: {0}' -f (Get-PSModulePath -FromTarget 'User')) -Verbose + Write-Verbose -Message ('SqlSetup: DEBUG1 Machine: {0}' -f (Get-PSModulePath -FromTarget 'Machine')) -Verbose + Write-Verbose -Message ('SqlSetup: DEBUG1 $env: {0}' -f $env:PSModulePath) -Verbose + Restore-TestEnvironment -TestEnvironment $script:testEnvironment + Write-Verbose -Message ('SqlSetup: DEBUG2 Session: {0}' -f (Get-PSModulePath -FromTarget 'Session')) -Verbose + Write-Verbose -Message ('SqlSetup: DEBUG2 User: {0}' -f (Get-PSModulePath -FromTarget 'User')) -Verbose + Write-Verbose -Message ('SqlSetup: DEBUG2 Machine: {0}' -f (Get-PSModulePath -FromTarget 'Machine')) -Verbose + Write-Verbose -Message ('SqlSetup: DEBUG2 $env: {0}' -f $env:PSModulePath) -Verbose + Get-Module -Name 'CommonTestHelper' -All | Remove-Module -Force } From 7a6b35a09149b863f231b21b5b6cbc58fa4c6c64 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 17 May 2023 18:00:21 +0200 Subject: [PATCH 14/33] DEBUG 10 --- RequiredModules.psd1 | 9 ++++++++- tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/RequiredModules.psd1 b/RequiredModules.psd1 index 46c4c4d298..bf8e6dafd4 100644 --- a/RequiredModules.psd1 +++ b/RequiredModules.psd1 @@ -28,7 +28,14 @@ Sampler = 'latest' 'Sampler.GitHubTasks' = 'latest' MarkdownLinkCheck = 'latest' - 'DscResource.Test' = 'latest' + + 'DscResource.Test' = @{ + Version = 'latest' + Parameters = @{ + AllowPrerelease = $true + } + } + xDscResourceDesigner = 'latest' 'DscResource.DocGenerator' = 'latest' diff --git a/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 b/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 index bd8c94e38c..0a6f51e262 100644 --- a/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 @@ -174,7 +174,7 @@ AfterAll { Write-Verbose -Message ('SqlSetup: DEBUG1 Machine: {0}' -f (Get-PSModulePath -FromTarget 'Machine')) -Verbose Write-Verbose -Message ('SqlSetup: DEBUG1 $env: {0}' -f $env:PSModulePath) -Verbose - Restore-TestEnvironment -TestEnvironment $script:testEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment -KeepNewMachinePSModulePath Write-Verbose -Message ('SqlSetup: DEBUG2 Session: {0}' -f (Get-PSModulePath -FromTarget 'Session')) -Verbose Write-Verbose -Message ('SqlSetup: DEBUG2 User: {0}' -f (Get-PSModulePath -FromTarget 'User')) -Verbose From 5018b867cd62a4b8de0fb1a4c1f72aa557a55fc7 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 17 May 2023 21:35:08 +0200 Subject: [PATCH 15/33] DEBUG 11 --- tests/Integration/DSC_SqlSetup.config.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Integration/DSC_SqlSetup.config.ps1 b/tests/Integration/DSC_SqlSetup.config.ps1 index 8f71fefcaf..5fef3eb28b 100644 --- a/tests/Integration/DSC_SqlSetup.config.ps1 +++ b/tests/Integration/DSC_SqlSetup.config.ps1 @@ -205,7 +205,8 @@ $featureFlag = if ((Get-Module -Name 'SqlServer', 'dbatools' -ListAvailable)) } else { - @() + #@() + @('AnalysisServicesConnection') } <# From baa0f1bf1f2be88a9d94f53fc6dbf055d6a73305 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 18 May 2023 07:28:28 +0200 Subject: [PATCH 16/33] DEBUG 12 --- tests/Integration/DSC_SqlSetup.config.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/Integration/DSC_SqlSetup.config.ps1 b/tests/Integration/DSC_SqlSetup.config.ps1 index 5fef3eb28b..8f71fefcaf 100644 --- a/tests/Integration/DSC_SqlSetup.config.ps1 +++ b/tests/Integration/DSC_SqlSetup.config.ps1 @@ -205,8 +205,7 @@ $featureFlag = if ((Get-Module -Name 'SqlServer', 'dbatools' -ListAvailable)) } else { - #@() - @('AnalysisServicesConnection') + @() } <# From b77d7545e77d69544ad6ec3284561f99167de16e Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 18 May 2023 07:49:51 +0200 Subject: [PATCH 17/33] DEBUG 13 --- .../DSC_SqlReplication/DSC_SqlReplication.psm1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 b/source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 index 45a92e6d0b..29b65341b9 100644 --- a/source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 +++ b/source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 @@ -93,8 +93,16 @@ function Get-TargetResource $script:localizedData.GetCurrentState -f $InstanceName ) + Write-Verbose -Message ('All assemblies: {0}' -f ([System.AppDomain]::CurrentDomain.GetAssemblies() | Out-String)) -Verbose + Write-Verbose -Message ('All SQL assemblies: {0}' -f ([System.AppDomain]::CurrentDomain.GetAssemblies() | ? Location -like '*SQL*' | Out-String)) -Verbose + Write-Verbose -Message ('ConnectionInfo assembly: {0}' -f ([System.AppDomain]::CurrentDomain.GetAssemblies() | ? Location -like '*ConnectionInfo*' | fl * | Out-String)) -Verbose + Import-SqlDscPreferredModule + Write-Verbose -Message ('All assemblies: {0}' -f ([System.AppDomain]::CurrentDomain.GetAssemblies() | Out-String)) -Verbose + Write-Verbose -Message ('All SQL assemblies: {0}' -f ([System.AppDomain]::CurrentDomain.GetAssemblies() | ? Location -like '*SQL*' | Out-String)) -Verbose + Write-Verbose -Message ('ConnectionInfo assembly: {0}' -f ([System.AppDomain]::CurrentDomain.GetAssemblies() | ? Location -like '*ConnectionInfo*' | fl * | Out-String)) -Verbose + $sqlMajorVersion = Get-SqlInstanceMajorVersion -InstanceName $InstanceName $localSqlName = Get-SqlLocalServerName -InstanceName $InstanceName @@ -439,6 +447,7 @@ function New-ServerConnection if ($SqlMajorVersion -eq 16) { + Write-Verbose -Message 'DEBUG100' -Verbose <# For SQL Server 2022 the object must be created with New-Object and also requires the module SqlServer v22 (minimum v22.0.49-preview). @@ -447,6 +456,7 @@ function New-ServerConnection } else { + Write-Verbose -Message 'DEBUG101' -Verbose <# SQL Server 2016, 2017, and 2019 must use the assembly in the GAC. If the method for SQL Server 2022 is used it throws the error: From c20f752a2fdd7fe332f501578559bf9dc65e1ebc Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 18 May 2023 10:13:31 +0200 Subject: [PATCH 18/33] DEBUG 14 --- source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 b/source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 index 29b65341b9..88a9b95b64 100644 --- a/source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 +++ b/source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 @@ -445,7 +445,7 @@ function New-ServerConnection $SqlServerName ) - if ($SqlMajorVersion -eq 16) + if ($SqlMajorVersion -eq 99) { Write-Verbose -Message 'DEBUG100' -Verbose <# From 3057ae73d3b4d64c99896525432e2b4338216eea Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 18 May 2023 12:06:24 +0200 Subject: [PATCH 19/33] DEBUG 15 --- azure-pipelines.yml | 3 ++- .../DSC_SqlReplication/DSC_SqlReplication.psm1 | 12 +----------- .../SqlServerDsc.Common/SqlServerDsc.Common.psm1 | 11 ----------- source/Public/Get-SqlDscPreferredModule.ps1 | 10 ---------- .../DSC_SqlAgentAlert.Integration.Tests.ps1 | 15 --------------- .../DSC_SqlSetup.Integration.Tests.ps1 | 10 ---------- 6 files changed, 3 insertions(+), 58 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b0fd68b0be..18a02ebc0e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -394,7 +394,8 @@ stages: 'tests/Integration/DSC_SqlRole.Integration.Tests.ps1' 'tests/Integration/DSC_SqlRS_Default.Integration.Tests.ps1' 'tests/Integration/DSC_SqlDatabaseUser.Integration.Tests.ps1' - 'tests/Integration/DSC_SqlReplication.Integration.Tests.ps1' + ## Replication does not work with SQLPS and SQL Server 2022. + (if ($(TEST_CONFIGURATION) -ne 'Integration_SQL2022') { 'tests/Integration/DSC_SqlReplication.Integration.Tests.ps1' }) 'tests/Integration/DSC_SqlAudit.Integration.Tests.ps1' # Group 4 'tests/Integration/DSC_SqlScript.Integration.Tests.ps1' diff --git a/source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 b/source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 index 88a9b95b64..45a92e6d0b 100644 --- a/source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 +++ b/source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 @@ -93,16 +93,8 @@ function Get-TargetResource $script:localizedData.GetCurrentState -f $InstanceName ) - Write-Verbose -Message ('All assemblies: {0}' -f ([System.AppDomain]::CurrentDomain.GetAssemblies() | Out-String)) -Verbose - Write-Verbose -Message ('All SQL assemblies: {0}' -f ([System.AppDomain]::CurrentDomain.GetAssemblies() | ? Location -like '*SQL*' | Out-String)) -Verbose - Write-Verbose -Message ('ConnectionInfo assembly: {0}' -f ([System.AppDomain]::CurrentDomain.GetAssemblies() | ? Location -like '*ConnectionInfo*' | fl * | Out-String)) -Verbose - Import-SqlDscPreferredModule - Write-Verbose -Message ('All assemblies: {0}' -f ([System.AppDomain]::CurrentDomain.GetAssemblies() | Out-String)) -Verbose - Write-Verbose -Message ('All SQL assemblies: {0}' -f ([System.AppDomain]::CurrentDomain.GetAssemblies() | ? Location -like '*SQL*' | Out-String)) -Verbose - Write-Verbose -Message ('ConnectionInfo assembly: {0}' -f ([System.AppDomain]::CurrentDomain.GetAssemblies() | ? Location -like '*ConnectionInfo*' | fl * | Out-String)) -Verbose - $sqlMajorVersion = Get-SqlInstanceMajorVersion -InstanceName $InstanceName $localSqlName = Get-SqlLocalServerName -InstanceName $InstanceName @@ -445,9 +437,8 @@ function New-ServerConnection $SqlServerName ) - if ($SqlMajorVersion -eq 99) + if ($SqlMajorVersion -eq 16) { - Write-Verbose -Message 'DEBUG100' -Verbose <# For SQL Server 2022 the object must be created with New-Object and also requires the module SqlServer v22 (minimum v22.0.49-preview). @@ -456,7 +447,6 @@ function New-ServerConnection } else { - Write-Verbose -Message 'DEBUG101' -Verbose <# SQL Server 2016, 2017, and 2019 must use the assembly in the GAC. If the method for SQL Server 2022 is used it throws the error: diff --git a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 index 633ddf4337..e3b799cb1f 100644 --- a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 +++ b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 @@ -503,19 +503,8 @@ function Connect-SQL $Encrypt ) - Write-Verbose -Message 'DEBUG2' -Verbose - Write-Verbose -Message ('Session PSModulePath: {0}' -f $env:PSModulePath) -Verbose - Write-Verbose -Message ('Available modules: {0}' -f (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String)) -Verbose - Write-Verbose -Message ('All PSModulePath: {0}' -f (Get-PSModulePath -FromTarget 'Session', 'User', 'Machine')) -Verbose - - Write-Verbose -Message 'DEBUG3' -Verbose - Write-Verbose -Message ('Found module: {0}' -f (Get-SqlDscPreferredModule -ErrorAction 'Continue')) -Verbose - Write-Verbose -Message ('Found module (refresh): {0}' -f (Get-SqlDscPreferredModule -Refresh -ErrorAction 'Stop')) -Verbose - Import-SqlDscPreferredModule -Force - Write-Verbose -Message (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String) -Verbose - if ($InstanceName -eq 'MSSQLSERVER') { $databaseEngineInstance = $ServerName diff --git a/source/Public/Get-SqlDscPreferredModule.ps1 b/source/Public/Get-SqlDscPreferredModule.ps1 index dd718c479f..57ea311034 100644 --- a/source/Public/Get-SqlDscPreferredModule.ps1 +++ b/source/Public/Get-SqlDscPreferredModule.ps1 @@ -74,11 +74,6 @@ function Get-SqlDscPreferredModule } } - Write-Verbose -Message ('Get-SqlDscPreferredModule: DEBUG Session: {0}' -f (Get-PSModulePath -FromTarget 'Session')) -Verbose - Write-Verbose -Message ('Get-SqlDscPreferredModule: DEBUG User: {0}' -f (Get-PSModulePath -FromTarget 'User')) -Verbose - Write-Verbose -Message ('Get-SqlDscPreferredModule: DEBUG Machine: {0}' -f (Get-PSModulePath -FromTarget 'Machine')) -Verbose - Write-Verbose -Message ('Get-SqlDscPreferredModule: DEBUG $env: {0}' -f $env:PSModulePath) -Verbose - #if ($Refresh.IsPresent) if ($true) { @@ -133,16 +128,11 @@ function Get-SqlDscPreferredModule } ) - Write-Verbose -Message ('Get-SqlDscPreferredModule: Available Modules: {0}' -f ($availableModule | Out-String)) -Verbose - foreach ($preferredModuleName in $Name) { $preferredModule = $availableModule | Where-Object -Property 'Name' -EQ -Value $preferredModuleName - Write-Verbose -Message ('Get-SqlDscPreferredModule: PreferredModuleName: {0}' -f $preferredModuleName) -Verbose - Write-Verbose -Message ('Get-SqlDscPreferredModule: Found PreferredModule: {0}' -f ($preferredModule | Out-String)) -Verbose - if ($preferredModule) { if ($preferredModule.Name -eq 'SQLPS') diff --git a/tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1 b/tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1 index 49c1e715aa..2432c6dda7 100644 --- a/tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1 @@ -31,11 +31,6 @@ BeforeDiscovery { } BeforeAll { - Write-Verbose -Message ('SqlAgentAlert: DEBUG2 Session: {0}' -f (Get-PSModulePath -FromTarget 'Session')) -Verbose - Write-Verbose -Message ('SqlAgentAlert: DEBUG2 User: {0}' -f (Get-PSModulePath -FromTarget 'User')) -Verbose - Write-Verbose -Message ('SqlAgentAlert: DEBUG2 Machine: {0}' -f (Get-PSModulePath -FromTarget 'Machine')) -Verbose - Write-Verbose -Message ('SqlAgentAlert: DEBUG2 $env: {0}' -f $env:PSModulePath) -Verbose - # Need to define the variables here which will be used in Pester Run. $script:dscModuleName = 'SqlServerDsc' $script:dscResourceFriendlyName = 'SqlAgentAlert' @@ -47,18 +42,8 @@ BeforeAll { -ResourceType 'Mof' ` -TestType 'Integration' - Write-Verbose -Message ('SqlAgentAlert: DEBUG3 Session: {0}' -f (Get-PSModulePath -FromTarget 'Session')) -Verbose - Write-Verbose -Message ('SqlAgentAlert: DEBUG3 User: {0}' -f (Get-PSModulePath -FromTarget 'User')) -Verbose - Write-Verbose -Message ('SqlAgentAlert: DEBUG3 Machine: {0}' -f (Get-PSModulePath -FromTarget 'Machine')) -Verbose - Write-Verbose -Message ('SqlAgentAlert: DEBUG3 $env: {0}' -f $env:PSModulePath) -Verbose - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $configFile - - Write-Verbose -Message ('SqlAgentAlert: DEBUG4 Session: {0}' -f (Get-PSModulePath -FromTarget 'Session')) -Verbose - Write-Verbose -Message ('SqlAgentAlert: DEBUG4 User: {0}' -f (Get-PSModulePath -FromTarget 'User')) -Verbose - Write-Verbose -Message ('SqlAgentAlert: DEBUG4 Machine: {0}' -f (Get-PSModulePath -FromTarget 'Machine')) -Verbose - Write-Verbose -Message ('SqlAgentAlert: DEBUG4 $env: {0}' -f $env:PSModulePath) -Verbose } AfterAll { diff --git a/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 b/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 index 0a6f51e262..8fcb1e5804 100644 --- a/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 @@ -169,18 +169,8 @@ BeforeAll { } AfterAll { - Write-Verbose -Message ('SqlSetup: DEBUG1 Session: {0}' -f (Get-PSModulePath -FromTarget 'Session')) -Verbose - Write-Verbose -Message ('SqlSetup: DEBUG1 User: {0}' -f (Get-PSModulePath -FromTarget 'User')) -Verbose - Write-Verbose -Message ('SqlSetup: DEBUG1 Machine: {0}' -f (Get-PSModulePath -FromTarget 'Machine')) -Verbose - Write-Verbose -Message ('SqlSetup: DEBUG1 $env: {0}' -f $env:PSModulePath) -Verbose - Restore-TestEnvironment -TestEnvironment $script:testEnvironment -KeepNewMachinePSModulePath - Write-Verbose -Message ('SqlSetup: DEBUG2 Session: {0}' -f (Get-PSModulePath -FromTarget 'Session')) -Verbose - Write-Verbose -Message ('SqlSetup: DEBUG2 User: {0}' -f (Get-PSModulePath -FromTarget 'User')) -Verbose - Write-Verbose -Message ('SqlSetup: DEBUG2 Machine: {0}' -f (Get-PSModulePath -FromTarget 'Machine')) -Verbose - Write-Verbose -Message ('SqlSetup: DEBUG2 $env: {0}' -f $env:PSModulePath) -Verbose - Get-Module -Name 'CommonTestHelper' -All | Remove-Module -Force } From 0d8a109327372e5efa3347c71b7b21fb6e21a3fc Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 18 May 2023 12:09:55 +0200 Subject: [PATCH 20/33] DEBUG 16 --- source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 | 13 +------------ source/Public/Get-SqlDscPreferredModule.ps1 | 3 +-- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 b/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 index aaec6ed7fc..93c7416d3a 100644 --- a/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 +++ b/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 @@ -1639,15 +1639,8 @@ function Set-TargetResource $forceReloadPowerShellModule = $true } - Write-Verbose -Message 'DEBUG1' -Verbose - Write-Verbose -Message ('Force Reload: {0}' -f ($forceReloadPowerShellModule | Out-String)) -Verbose - if ((-not $setupEndedInError) -and $forceReloadPowerShellModule) { - Write-Verbose -Message ('Session PSModulePath: {0}' -f $env:PSModulePath) -Verbose - Write-Verbose -Message ('Available modules: {0}' -f (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String)) -Verbose - Write-Verbose -Message ('All PSModulePath: {0}' -f (Get-PSModulePath -FromTarget 'Session', 'User', 'Machine')) -Verbose - <# Force reload of SQLPS module in case a newer version of SQL Server was installed that contains a newer version @@ -1657,11 +1650,7 @@ function Set-TargetResource matches the latest assemblies in GAC, mitigating for example issue #1151. #> - Import-SqlDscPreferredModule -Force -Verbose - - Write-Verbose -Message ('Session PSModulePath: {0}' -f $env:PSModulePath) -Verbose - Write-Verbose -Message ('Available modules: {0}' -f (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String)) -Verbose - Write-Verbose -Message ('All PSModulePath: {0}' -f (Get-PSModulePath -FromTarget 'Session', 'User', 'Machine')) -Verbose + Import-SqlDscPreferredModule -Force } if (-not (Test-TargetResource @PSBoundParameters)) diff --git a/source/Public/Get-SqlDscPreferredModule.ps1 b/source/Public/Get-SqlDscPreferredModule.ps1 index 57ea311034..446232927d 100644 --- a/source/Public/Get-SqlDscPreferredModule.ps1 +++ b/source/Public/Get-SqlDscPreferredModule.ps1 @@ -74,8 +74,7 @@ function Get-SqlDscPreferredModule } } - #if ($Refresh.IsPresent) - if ($true) + if ($Refresh.IsPresent) { # Only run on Windows that has Machine state. if (-not ($IsLinux -or $IsMacOS)) From 8d61fb4b7dae2a9004cffdc2927278bb671ac7fd Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 18 May 2023 12:10:57 +0200 Subject: [PATCH 21/33] DEBUG 17 --- source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 index e3b799cb1f..9201acd1c7 100644 --- a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 +++ b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 @@ -503,7 +503,7 @@ function Connect-SQL $Encrypt ) - Import-SqlDscPreferredModule -Force + Import-SqlDscPreferredModule if ($InstanceName -eq 'MSSQLSERVER') { From 0cf8ac7c45f2ea7299603d9679d0f19b53be2394 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 18 May 2023 12:23:47 +0200 Subject: [PATCH 22/33] DEBUG 18 --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 18a02ebc0e..46ea091b0b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -395,7 +395,7 @@ stages: 'tests/Integration/DSC_SqlRS_Default.Integration.Tests.ps1' 'tests/Integration/DSC_SqlDatabaseUser.Integration.Tests.ps1' ## Replication does not work with SQLPS and SQL Server 2022. - (if ($(TEST_CONFIGURATION) -ne 'Integration_SQL2022') { 'tests/Integration/DSC_SqlReplication.Integration.Tests.ps1' }) + (if ('$(TEST_CONFIGURATION)' -ne 'Integration_SQL2022') { 'tests/Integration/DSC_SqlReplication.Integration.Tests.ps1' }) 'tests/Integration/DSC_SqlAudit.Integration.Tests.ps1' # Group 4 'tests/Integration/DSC_SqlScript.Integration.Tests.ps1' From 1e5616aaba6d6d9d53a2f0186f291df7ed3de5f3 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 18 May 2023 12:33:11 +0200 Subject: [PATCH 23/33] DEBUG 19 --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 46ea091b0b..35c7a1e387 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -395,7 +395,7 @@ stages: 'tests/Integration/DSC_SqlRS_Default.Integration.Tests.ps1' 'tests/Integration/DSC_SqlDatabaseUser.Integration.Tests.ps1' ## Replication does not work with SQLPS and SQL Server 2022. - (if ('$(TEST_CONFIGURATION)' -ne 'Integration_SQL2022') { 'tests/Integration/DSC_SqlReplication.Integration.Tests.ps1' }) + $(if ('$(TEST_CONFIGURATION)' -ne 'Integration_SQL2022') { 'tests/Integration/DSC_SqlReplication.Integration.Tests.ps1' }) 'tests/Integration/DSC_SqlAudit.Integration.Tests.ps1' # Group 4 'tests/Integration/DSC_SqlScript.Integration.Tests.ps1' From 485fd2bc79d66e7d09e782d6abbeea942b4d8ae2 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 18 May 2023 14:17:47 +0200 Subject: [PATCH 24/33] Fix wrong names --- tests/Integration/DSC_SqlReplication.config.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Integration/DSC_SqlReplication.config.ps1 b/tests/Integration/DSC_SqlReplication.config.ps1 index 80d10f87f1..28f421ca41 100644 --- a/tests/Integration/DSC_SqlReplication.config.ps1 +++ b/tests/Integration/DSC_SqlReplication.config.ps1 @@ -40,13 +40,13 @@ Configuration DSC_SqlReplication_Prerequisites_Config node $AllNodes.NodeName { - Service ('StopSqlServerInstance{0}' -f $Node.DefaultInstanceName) + Service ('StartSqlServerInstance{0}' -f $Node.DefaultInstanceName) { Name = $Node.DefaultInstanceName State = 'Running' } - Service ('StopSqlServerAgentForInstance{0}' -f $Node.DefaultInstanceName) + Service ('StartSqlServerAgentForInstance{0}' -f $Node.DefaultInstanceName) { Name = 'SQLSERVERAGENT' State = 'Running' From fe8b06ebc45aa4ae5937c452d2698a9ab5643e57 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 18 May 2023 14:18:05 +0200 Subject: [PATCH 25/33] Revert pipeline jobs --- azure-pipelines.yml | 868 ++++++++++++++++++++++---------------------- 1 file changed, 434 insertions(+), 434 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 35c7a1e387..5a696f77ba 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -57,277 +57,277 @@ stages: - stage: Test dependsOn: Build jobs: - # - job: Test_HQRM - # displayName: 'HQRM' - # pool: - # vmImage: 'windows-2022' - # timeoutInMinutes: 0 - # variables: - # # This sets environment variable $env:SqlServerDscCI. - # SqlServerDscCI: true - # steps: - # - task: DownloadPipelineArtifact@2 - # displayName: 'Download Build Artifact' - # inputs: - # buildType: 'current' - # artifactName: $(buildArtifactName) - # targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' - # # This task need to use Windows PowerShell due to a bug in PS7 that cannot - # # find/use class-based DSC resources that uses inheritance, which result in - # # the examples cannot compile. See the following issue for more information: - # # https://github.com/dsccommunity/DnsServerDsc/issues/268#issuecomment-918505230 - # - powershell: | - # # Workaround for issue https://github.com/dsccommunity/DscResource.Test/issues/100 - # ./build.ps1 -Task noop + - job: Test_HQRM + displayName: 'HQRM' + pool: + vmImage: 'windows-2022' + timeoutInMinutes: 0 + variables: + # This sets environment variable $env:SqlServerDscCI. + SqlServerDscCI: true + steps: + - task: DownloadPipelineArtifact@2 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + artifactName: $(buildArtifactName) + targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' + # This task need to use Windows PowerShell due to a bug in PS7 that cannot + # find/use class-based DSC resources that uses inheritance, which result in + # the examples cannot compile. See the following issue for more information: + # https://github.com/dsccommunity/DnsServerDsc/issues/268#issuecomment-918505230 + - powershell: | + # Workaround for issue https://github.com/dsccommunity/DscResource.Test/issues/100 + ./build.ps1 -Task noop - # $pesterConfig = New-PesterConfiguration - # $pesterConfig.Run.Path = '.\tests\QA' - # $pesterConfig.Run.Throw = $true - # $pesterConfig.Output.Verbosity = 'Detailed' + $pesterConfig = New-PesterConfiguration + $pesterConfig.Run.Path = '.\tests\QA' + $pesterConfig.Run.Throw = $true + $pesterConfig.Output.Verbosity = 'Detailed' - # Invoke-Pester -Configuration $pesterConfig - # name: qualityTest - # displayName: 'Run SqlServerDsc QA Test' - # - task: PowerShell@2 - # name: test - # displayName: 'Run HQRM Test' - # condition: succeededOrFailed() - # inputs: - # filePath: './build.ps1' - # arguments: '-Tasks hqrmtest' - # pwsh: false - # - task: PublishTestResults@2 - # displayName: 'Publish Test Results' - # condition: succeededOrFailed() - # inputs: - # testResultsFormat: 'NUnit' - # testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' - # testRunTitle: 'HQRM' + Invoke-Pester -Configuration $pesterConfig + name: qualityTest + displayName: 'Run SqlServerDsc QA Test' + - task: PowerShell@2 + name: test + displayName: 'Run HQRM Test' + condition: succeededOrFailed() + inputs: + filePath: './build.ps1' + arguments: '-Tasks hqrmtest' + pwsh: false + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + condition: succeededOrFailed() + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' + testRunTitle: 'HQRM' - # - job: Test_Unit - # displayName: 'Unit' - # pool: - # vmImage: 'windows-2019' - # timeoutInMinutes: 0 - # variables: - # # This sets environment variable $env:SqlServerDscCI. - # SqlServerDscCI: true - # steps: - # - task: DownloadPipelineArtifact@2 - # displayName: 'Download Build Artifact' - # inputs: - # buildType: 'current' - # artifactName: $(buildArtifactName) - # targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' - # - task: PowerShell@2 - # name: test - # displayName: 'Run Unit Test' - # inputs: - # filePath: './build.ps1' - # arguments: "-Tasks test -PesterPath 'tests/Unit'" - # pwsh: true - # - task: PublishTestResults@2 - # displayName: 'Publish Test Results' - # condition: succeededOrFailed() - # inputs: - # testResultsFormat: 'NUnit' - # testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' - # testRunTitle: 'Unit (Windows Server 2019)' - # - task: PublishPipelineArtifact@1 - # displayName: 'Publish Test Artifact' - # condition: succeededOrFailed() - # inputs: - # targetPath: '$(buildFolderName)/$(testResultFolderName)/' - # artifactName: $(testArtifactName) - # parallel: true + - job: Test_Unit + displayName: 'Unit' + pool: + vmImage: 'windows-2019' + timeoutInMinutes: 0 + variables: + # This sets environment variable $env:SqlServerDscCI. + SqlServerDscCI: true + steps: + - task: DownloadPipelineArtifact@2 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + artifactName: $(buildArtifactName) + targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' + - task: PowerShell@2 + name: test + displayName: 'Run Unit Test' + inputs: + filePath: './build.ps1' + arguments: "-Tasks test -PesterPath 'tests/Unit'" + pwsh: true + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + condition: succeededOrFailed() + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' + testRunTitle: 'Unit (Windows Server 2019)' + - task: PublishPipelineArtifact@1 + displayName: 'Publish Test Artifact' + condition: succeededOrFailed() + inputs: + targetPath: '$(buildFolderName)/$(testResultFolderName)/' + artifactName: $(testArtifactName) + parallel: true - # - job: Test_Integration - # displayName: 'Integration' - # strategy: - # matrix: - # SQL2016_WIN2019: - # JOB_VMIMAGE: 'windows-2019' - # TEST_CONFIGURATION: 'Integration_SQL2016' - # SQL2016_WIN2022: - # JOB_VMIMAGE: 'windows-2022' - # TEST_CONFIGURATION: 'Integration_SQL2016' - # SQL2017_WIN2019: - # JOB_VMIMAGE: 'windows-2019' - # TEST_CONFIGURATION: 'Integration_SQL2017' - # SQL2017_WIN2022: - # JOB_VMIMAGE: 'windows-2022' - # TEST_CONFIGURATION: 'Integration_SQL2017' - # SQL2019_WIN2019: - # JOB_VMIMAGE: 'windows-2019' - # TEST_CONFIGURATION: 'Integration_SQL2019' - # SQL2019_WIN2022: - # JOB_VMIMAGE: 'windows-2022' - # TEST_CONFIGURATION: 'Integration_SQL2019' - # SQL2022_WIN2019: - # JOB_VMIMAGE: 'windows-2019' - # TEST_CONFIGURATION: 'Integration_SQL2022' - # SQL2022_WIN2022: - # JOB_VMIMAGE: 'windows-2022' - # TEST_CONFIGURATION: 'Integration_SQL2022' - # pool: - # vmImage: $(JOB_VMIMAGE) - # timeoutInMinutes: 0 - # steps: - # - task: DownloadPipelineArtifact@2 - # displayName: 'Download Build Artifact' - # inputs: - # buildType: 'current' - # artifactName: $(buildArtifactName) - # targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' - # - task: PowerShell@2 - # name: configureWinRM - # displayName: 'Configure WinRM' - # inputs: - # targetType: 'inline' - # script: 'winrm quickconfig -quiet' - # pwsh: false - # - powershell: | - # Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 - # Remove-PowerShellModuleFromCI -Name @('SqlServer', 'SQLPS') - # Remove-Module -Name CommonTestHelper - # name: cleanCIWorker - # displayName: 'Clean CI worker' - # - powershell: | - # ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @( - # # Run the integration tests in a specific group order. - # # Group 1 - # 'tests/Integration/DSC_SqlSetup.Integration.Tests.ps1' - # # Group 2 - # 'tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlLogin.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlEndpoint.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlDatabaseMail.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlDatabaseDefaultLocation.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlAlwaysOnService.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlAgentOperator.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlServiceAccount.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlAgentFailsafe.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlTraceFlag.Integration.Tests.ps1' - # # Group 3 - # 'tests/Integration/DSC_SqlRole.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlRS_Default.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlDatabaseUser.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlReplication.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlAudit.Integration.Tests.ps1' - # # Group 4 - # 'tests/Integration/DSC_SqlScript.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlDatabasePermission.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlPermission.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlWindowsFirewall.Integration.Tests.ps1' - # # Group 5 - # 'tests/Integration/DSC_SqlSecureConnection.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlScriptQuery.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlProtocol.Integration.Tests.ps1' - # # Group 6 (tests makes changes that could make SQL Server to loose connectivity) - # 'tests/Integration/DSC_SqlProtocolTcpIp.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlDatabaseObjectPermission.Integration.Tests.ps1' - # ) - # name: test - # displayName: 'Run Integration Test' - # - task: PublishTestResults@2 - # displayName: 'Publish Test Results' - # condition: succeededOrFailed() - # inputs: - # testResultsFormat: 'NUnit' - # testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' - # testRunTitle: 'Integration ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' + - job: Test_Integration + displayName: 'Integration' + strategy: + matrix: + SQL2016_WIN2019: + JOB_VMIMAGE: 'windows-2019' + TEST_CONFIGURATION: 'Integration_SQL2016' + SQL2016_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2016' + SQL2017_WIN2019: + JOB_VMIMAGE: 'windows-2019' + TEST_CONFIGURATION: 'Integration_SQL2017' + SQL2017_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2017' + SQL2019_WIN2019: + JOB_VMIMAGE: 'windows-2019' + TEST_CONFIGURATION: 'Integration_SQL2019' + SQL2019_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2019' + SQL2022_WIN2019: + JOB_VMIMAGE: 'windows-2019' + TEST_CONFIGURATION: 'Integration_SQL2022' + SQL2022_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2022' + pool: + vmImage: $(JOB_VMIMAGE) + timeoutInMinutes: 0 + steps: + - task: DownloadPipelineArtifact@2 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + artifactName: $(buildArtifactName) + targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' + - task: PowerShell@2 + name: configureWinRM + displayName: 'Configure WinRM' + inputs: + targetType: 'inline' + script: 'winrm quickconfig -quiet' + pwsh: false + - powershell: | + Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 + Remove-PowerShellModuleFromCI -Name @('SqlServer', 'SQLPS') + Remove-Module -Name CommonTestHelper + name: cleanCIWorker + displayName: 'Clean CI worker' + - powershell: | + ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @( + # Run the integration tests in a specific group order. + # Group 1 + 'tests/Integration/DSC_SqlSetup.Integration.Tests.ps1' + # Group 2 + 'tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlLogin.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlEndpoint.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabaseMail.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabaseDefaultLocation.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlAlwaysOnService.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlAgentOperator.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlServiceAccount.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlAgentFailsafe.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlTraceFlag.Integration.Tests.ps1' + # Group 3 + 'tests/Integration/DSC_SqlRole.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlRS_Default.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabaseUser.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlReplication.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlAudit.Integration.Tests.ps1' + # Group 4 + 'tests/Integration/DSC_SqlScript.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabasePermission.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlPermission.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlWindowsFirewall.Integration.Tests.ps1' + # Group 5 + 'tests/Integration/DSC_SqlSecureConnection.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlScriptQuery.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlProtocol.Integration.Tests.ps1' + # Group 6 (tests makes changes that could make SQL Server to loose connectivity) + 'tests/Integration/DSC_SqlProtocolTcpIp.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabaseObjectPermission.Integration.Tests.ps1' + ) + name: test + displayName: 'Run Integration Test' + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + condition: succeededOrFailed() + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' + testRunTitle: 'Integration ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' - # - job: Test_Integration_dbatools - # displayName: 'Integration (dbatools)' - # dependsOn: Test_Integration - # strategy: - # matrix: - # SQL2016_WIN2022: - # JOB_VMIMAGE: 'windows-2022' - # TEST_CONFIGURATION: 'Integration_SQL2016' - # SQL2017_WIN2022: - # JOB_VMIMAGE: 'windows-2022' - # TEST_CONFIGURATION: 'Integration_SQL2017' - # SQL2019_WIN2022: - # JOB_VMIMAGE: 'windows-2022' - # TEST_CONFIGURATION: 'Integration_SQL2019' - # SQL2022_WIN2022: - # JOB_VMIMAGE: 'windows-2022' - # TEST_CONFIGURATION: 'Integration_SQL2022' - # pool: - # vmImage: $(JOB_VMIMAGE) - # timeoutInMinutes: 0 - # variables: - # SMODefaultModuleName: 'dbatools' - # steps: - # - task: DownloadPipelineArtifact@2 - # displayName: 'Download Build Artifact' - # inputs: - # buildType: 'current' - # artifactName: $(buildArtifactName) - # targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' - # - task: PowerShell@2 - # name: configureWinRM - # displayName: 'Configure WinRM' - # inputs: - # targetType: 'inline' - # script: 'winrm quickconfig -quiet' - # pwsh: false - # - powershell: | - # Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 - # # Make sure to keep SQLPS so that Invoke-SqlCmd is available. - # Remove-PowerShellModuleFromCI -Name @('SqlServer') - # Remove-Module -Name CommonTestHelper - # name: cleanCIWorker - # displayName: 'Clean CI worker' - # - powershell: | - # ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @( - # # Run the integration tests in a specific group order. - # # Group 1 - # 'tests/Integration/DSC_SqlSetup.Integration.Tests.ps1' - # # Group 2 - # 'tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlLogin.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlEndpoint.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlDatabaseMail.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlDatabaseDefaultLocation.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlAlwaysOnService.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlAgentOperator.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlServiceAccount.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlAgentFailsafe.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlTraceFlag.Integration.Tests.ps1' - # # Group 3 - # 'tests/Integration/DSC_SqlRole.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlRS_Default.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlDatabaseUser.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlReplication.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlAudit.Integration.Tests.ps1' - # # Group 4 - # 'tests/Integration/DSC_SqlScript.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlDatabasePermission.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlPermission.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlWindowsFirewall.Integration.Tests.ps1' - # # Group 5 - # 'tests/Integration/DSC_SqlSecureConnection.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlScriptQuery.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlProtocol.Integration.Tests.ps1' - # # Group 6 (tests makes changes that could make SQL Server to loose connectivity) - # 'tests/Integration/DSC_SqlProtocolTcpIp.Integration.Tests.ps1' - # 'tests/Integration/DSC_SqlDatabaseObjectPermission.Integration.Tests.ps1' - # ) - # name: test - # displayName: 'Run Integration Test' - # - task: PublishTestResults@2 - # displayName: 'Publish Test Results' - # condition: succeededOrFailed() - # inputs: - # testResultsFormat: 'NUnit' - # testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' - # testRunTitle: 'Integration (dbatools) ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' + - job: Test_Integration_dbatools + displayName: 'Integration (dbatools)' + dependsOn: Test_Integration + strategy: + matrix: + SQL2016_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2016' + SQL2017_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2017' + SQL2019_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2019' + SQL2022_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2022' + pool: + vmImage: $(JOB_VMIMAGE) + timeoutInMinutes: 0 + variables: + SMODefaultModuleName: 'dbatools' + steps: + - task: DownloadPipelineArtifact@2 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + artifactName: $(buildArtifactName) + targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' + - task: PowerShell@2 + name: configureWinRM + displayName: 'Configure WinRM' + inputs: + targetType: 'inline' + script: 'winrm quickconfig -quiet' + pwsh: false + - powershell: | + Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 + # Make sure to keep SQLPS so that Invoke-SqlCmd is available. + Remove-PowerShellModuleFromCI -Name @('SqlServer') + Remove-Module -Name CommonTestHelper + name: cleanCIWorker + displayName: 'Clean CI worker' + - powershell: | + ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @( + # Run the integration tests in a specific group order. + # Group 1 + 'tests/Integration/DSC_SqlSetup.Integration.Tests.ps1' + # Group 2 + 'tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlLogin.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlEndpoint.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabaseMail.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabaseDefaultLocation.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlAlwaysOnService.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlAgentOperator.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlServiceAccount.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlAgentFailsafe.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlTraceFlag.Integration.Tests.ps1' + # Group 3 + 'tests/Integration/DSC_SqlRole.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlRS_Default.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabaseUser.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlReplication.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlAudit.Integration.Tests.ps1' + # Group 4 + 'tests/Integration/DSC_SqlScript.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabasePermission.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlPermission.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlWindowsFirewall.Integration.Tests.ps1' + # Group 5 + 'tests/Integration/DSC_SqlSecureConnection.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlScriptQuery.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlProtocol.Integration.Tests.ps1' + # Group 6 (tests makes changes that could make SQL Server to loose connectivity) + 'tests/Integration/DSC_SqlProtocolTcpIp.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabaseObjectPermission.Integration.Tests.ps1' + ) + name: test + displayName: 'Run Integration Test' + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + condition: succeededOrFailed() + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' + testRunTitle: 'Integration (dbatools) ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' - job: Test_Integration_SQLPS displayName: 'Integration (SQLPS)' @@ -420,176 +420,176 @@ stages: testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' testRunTitle: 'Integration (dbatools) ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' - # - job: Test_Integration_RS - # displayName: 'Integration Reporting Services' - # strategy: - # matrix: - # SQL2016_WIN2019: - # JOB_VMIMAGE: 'windows-2019' - # TEST_CONFIGURATION: 'Integration_SQL2016' - # SQL2016_WIN2022: - # JOB_VMIMAGE: 'windows-2022' - # TEST_CONFIGURATION: 'Integration_SQL2016' - # SQL2017_WIN2019: - # JOB_VMIMAGE: 'windows-2019' - # TEST_CONFIGURATION: 'Integration_SQL2017' - # SQL2017_WIN2022: - # JOB_VMIMAGE: 'windows-2022' - # TEST_CONFIGURATION: 'Integration_SQL2017' - # SQL2019_WIN2019: - # JOB_VMIMAGE: 'windows-2019' - # TEST_CONFIGURATION: 'Integration_SQL2019' - # SQL2019_WIN2022: - # JOB_VMIMAGE: 'windows-2022' - # TEST_CONFIGURATION: 'Integration_SQL2019' - # SQL2022_WIN2019: - # JOB_VMIMAGE: 'windows-2019' - # TEST_CONFIGURATION: 'Integration_SQL2022' - # SQL2022_WIN2022: - # JOB_VMIMAGE: 'windows-2022' - # TEST_CONFIGURATION: 'Integration_SQL2022' - # variables: - # SKIP_DATABASE_ENGINE_DEFAULT_INSTANCE: true - # SKIP_ANALYSIS_MULTI_INSTANCE: true - # SKIP_ANALYSIS_TABULAR_INSTANCE: true - # SMODefaultModuleName: 'SqlServer' - # pool: - # vmImage: $(JOB_VMIMAGE) - # timeoutInMinutes: 0 - # steps: - # - task: DownloadPipelineArtifact@2 - # displayName: 'Download Build Artifact' - # inputs: - # buildType: 'current' - # artifactName: $(buildArtifactName) - # targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' - # - task: PowerShell@2 - # name: configureWinRM - # displayName: 'Configure WinRM' - # inputs: - # targetType: 'inline' - # script: 'winrm quickconfig -quiet' - # pwsh: false - # - powershell: | - # Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 - # Remove-PowerShellModuleFromCI -Name @('SqlServer', 'SQLPS') - # Remove-Module -Name CommonTestHelper - # name: cleanCIWorker - # displayName: 'Clean CI worker' - # - powershell: | - # ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @( - # # Run the integration tests in a specific group order. - # # Group 1 - # 'tests/Integration/DSC_SqlSetup.Integration.Tests.ps1' - # # Group 2 - # 'tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1' - # # Group 3 - # 'tests/Integration/DSC_SqlRS.Integration.Tests.ps1' - # ) - # name: test - # displayName: 'Run Reporting Services Integration Test' - # - task: PublishTestResults@2 - # displayName: 'Publish Test Results' - # condition: succeededOrFailed() - # inputs: - # testResultsFormat: 'NUnit' - # testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' - # testRunTitle: 'Integration RS ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' + - job: Test_Integration_RS + displayName: 'Integration Reporting Services' + strategy: + matrix: + SQL2016_WIN2019: + JOB_VMIMAGE: 'windows-2019' + TEST_CONFIGURATION: 'Integration_SQL2016' + SQL2016_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2016' + SQL2017_WIN2019: + JOB_VMIMAGE: 'windows-2019' + TEST_CONFIGURATION: 'Integration_SQL2017' + SQL2017_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2017' + SQL2019_WIN2019: + JOB_VMIMAGE: 'windows-2019' + TEST_CONFIGURATION: 'Integration_SQL2019' + SQL2019_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2019' + SQL2022_WIN2019: + JOB_VMIMAGE: 'windows-2019' + TEST_CONFIGURATION: 'Integration_SQL2022' + SQL2022_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2022' + variables: + SKIP_DATABASE_ENGINE_DEFAULT_INSTANCE: true + SKIP_ANALYSIS_MULTI_INSTANCE: true + SKIP_ANALYSIS_TABULAR_INSTANCE: true + SMODefaultModuleName: 'SqlServer' + pool: + vmImage: $(JOB_VMIMAGE) + timeoutInMinutes: 0 + steps: + - task: DownloadPipelineArtifact@2 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + artifactName: $(buildArtifactName) + targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' + - task: PowerShell@2 + name: configureWinRM + displayName: 'Configure WinRM' + inputs: + targetType: 'inline' + script: 'winrm quickconfig -quiet' + pwsh: false + - powershell: | + Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 + Remove-PowerShellModuleFromCI -Name @('SqlServer', 'SQLPS') + Remove-Module -Name CommonTestHelper + name: cleanCIWorker + displayName: 'Clean CI worker' + - powershell: | + ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @( + # Run the integration tests in a specific group order. + # Group 1 + 'tests/Integration/DSC_SqlSetup.Integration.Tests.ps1' + # Group 2 + 'tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1' + # Group 3 + 'tests/Integration/DSC_SqlRS.Integration.Tests.ps1' + ) + name: test + displayName: 'Run Reporting Services Integration Test' + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + condition: succeededOrFailed() + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' + testRunTitle: 'Integration RS ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' - # - job: Test_Integration_RS_dbatools - # displayName: 'Integration Reporting Services (dbatools)' - # dependsOn: Test_Integration_RS - # strategy: - # matrix: - # SQL2016_WIN2022: - # JOB_VMIMAGE: 'windows-2022' - # TEST_CONFIGURATION: 'Integration_SQL2016' - # SQL2017_WIN2022: - # JOB_VMIMAGE: 'windows-2022' - # TEST_CONFIGURATION: 'Integration_SQL2017' - # SQL2019_WIN2022: - # JOB_VMIMAGE: 'windows-2022' - # TEST_CONFIGURATION: 'Integration_SQL2019' - # SQL2022_WIN2022: - # JOB_VMIMAGE: 'windows-2022' - # TEST_CONFIGURATION: 'Integration_SQL2022' - # variables: - # SKIP_DATABASE_ENGINE_DEFAULT_INSTANCE: true - # SKIP_ANALYSIS_MULTI_INSTANCE: true - # SKIP_ANALYSIS_TABULAR_INSTANCE: true - # SMODefaultModuleName: 'dbatools' - # pool: - # vmImage: $(JOB_VMIMAGE) - # timeoutInMinutes: 0 - # steps: - # - task: DownloadPipelineArtifact@2 - # displayName: 'Download Build Artifact' - # inputs: - # buildType: 'current' - # artifactName: $(buildArtifactName) - # targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' - # - task: PowerShell@2 - # name: configureWinRM - # displayName: 'Configure WinRM' - # inputs: - # targetType: 'inline' - # script: 'winrm quickconfig -quiet' - # pwsh: false - # - powershell: | - # ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @( - # # Run the integration tests in a specific group order. - # # Group 1 - # 'tests/Integration/DSC_SqlSetup.Integration.Tests.ps1' - # # Group 2 - # 'tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1' - # # Group 3 - # 'tests/Integration/DSC_SqlRS.Integration.Tests.ps1' - # ) - # name: test - # displayName: 'Run Reporting Services Integration Test' - # - task: PublishTestResults@2 - # displayName: 'Publish Test Results' - # condition: succeededOrFailed() - # inputs: - # testResultsFormat: 'NUnit' - # testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' - # testRunTitle: 'Integration RS (dbatools) ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' + - job: Test_Integration_RS_dbatools + displayName: 'Integration Reporting Services (dbatools)' + dependsOn: Test_Integration_RS + strategy: + matrix: + SQL2016_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2016' + SQL2017_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2017' + SQL2019_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2019' + SQL2022_WIN2022: + JOB_VMIMAGE: 'windows-2022' + TEST_CONFIGURATION: 'Integration_SQL2022' + variables: + SKIP_DATABASE_ENGINE_DEFAULT_INSTANCE: true + SKIP_ANALYSIS_MULTI_INSTANCE: true + SKIP_ANALYSIS_TABULAR_INSTANCE: true + SMODefaultModuleName: 'dbatools' + pool: + vmImage: $(JOB_VMIMAGE) + timeoutInMinutes: 0 + steps: + - task: DownloadPipelineArtifact@2 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + artifactName: $(buildArtifactName) + targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' + - task: PowerShell@2 + name: configureWinRM + displayName: 'Configure WinRM' + inputs: + targetType: 'inline' + script: 'winrm quickconfig -quiet' + pwsh: false + - powershell: | + ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterTag $(TEST_CONFIGURATION) -PesterPath @( + # Run the integration tests in a specific group order. + # Group 1 + 'tests/Integration/DSC_SqlSetup.Integration.Tests.ps1' + # Group 2 + 'tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1' + # Group 3 + 'tests/Integration/DSC_SqlRS.Integration.Tests.ps1' + ) + name: test + displayName: 'Run Reporting Services Integration Test' + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + condition: succeededOrFailed() + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' + testRunTitle: 'Integration RS (dbatools) ($(TEST_CONFIGURATION) / $(JOB_VMIMAGE))' - # - job: Code_Coverage - # displayName: 'Publish Code Coverage' - # dependsOn: Test_Unit - # condition: succeededOrFailed() - # pool: - # vmImage: 'ubuntu-latest' - # timeoutInMinutes: 0 - # steps: - # - pwsh: | - # $repositoryOwner,$repositoryName = $env:BUILD_REPOSITORY_NAME -split '/' - # echo "##vso[task.setvariable variable=RepositoryOwner;isOutput=true]$repositoryOwner" - # echo "##vso[task.setvariable variable=RepositoryName;isOutput=true]$repositoryName" - # name: dscBuildVariable - # displayName: 'Set Environment Variables' - # - task: DownloadPipelineArtifact@2 - # displayName: 'Download Build Artifact' - # inputs: - # buildType: 'current' - # artifactName: $(buildArtifactName) - # targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' - # - task: DownloadPipelineArtifact@2 - # displayName: 'Download Test Artifact' - # inputs: - # buildType: 'current' - # artifactName: $(testArtifactName) - # targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)' - # - task: PublishCodeCoverageResults@1 - # displayName: 'Publish Code Coverage to Azure DevOps' - # inputs: - # codeCoverageTool: 'JaCoCo' - # summaryFileLocation: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml' - # pathToSources: '$(Build.SourcesDirectory)/$(sourceFolderName)/' - # - script: | - # bash <(curl -s https://codecov.io/bash) -f "./$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml" -F unit - # displayName: 'Publish Code Coverage to Codecov.io' + - job: Code_Coverage + displayName: 'Publish Code Coverage' + dependsOn: Test_Unit + condition: succeededOrFailed() + pool: + vmImage: 'ubuntu-latest' + timeoutInMinutes: 0 + steps: + - pwsh: | + $repositoryOwner,$repositoryName = $env:BUILD_REPOSITORY_NAME -split '/' + echo "##vso[task.setvariable variable=RepositoryOwner;isOutput=true]$repositoryOwner" + echo "##vso[task.setvariable variable=RepositoryName;isOutput=true]$repositoryName" + name: dscBuildVariable + displayName: 'Set Environment Variables' + - task: DownloadPipelineArtifact@2 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + artifactName: $(buildArtifactName) + targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)' + - task: DownloadPipelineArtifact@2 + displayName: 'Download Test Artifact' + inputs: + buildType: 'current' + artifactName: $(testArtifactName) + targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)' + - task: PublishCodeCoverageResults@1 + displayName: 'Publish Code Coverage to Azure DevOps' + inputs: + codeCoverageTool: 'JaCoCo' + summaryFileLocation: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml' + pathToSources: '$(Build.SourcesDirectory)/$(sourceFolderName)/' + - script: | + bash <(curl -s https://codecov.io/bash) -f "./$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml" -F unit + displayName: 'Publish Code Coverage to Codecov.io' - stage: Deploy dependsOn: Test From ae5ae2ba0ffe9cf2129093c75e87486fb95c5cf3 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 18 May 2023 19:03:28 +0200 Subject: [PATCH 26/33] Fix depends --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5a696f77ba..a735944af7 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -331,7 +331,7 @@ stages: - job: Test_Integration_SQLPS displayName: 'Integration (SQLPS)' - #dependsOn: Test_Integration + dependsOn: Test_Integration strategy: matrix: SQL2016_WIN2022: From 266695269c4d013e848cb7ff6f07abd6a7df7c82 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 18 May 2023 19:23:17 +0200 Subject: [PATCH 27/33] Fix review comment --- RequiredModules.psd1 | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/RequiredModules.psd1 b/RequiredModules.psd1 index bf8e6dafd4..46c4c4d298 100644 --- a/RequiredModules.psd1 +++ b/RequiredModules.psd1 @@ -28,14 +28,7 @@ Sampler = 'latest' 'Sampler.GitHubTasks' = 'latest' MarkdownLinkCheck = 'latest' - - 'DscResource.Test' = @{ - Version = 'latest' - Parameters = @{ - AllowPrerelease = $true - } - } - + 'DscResource.Test' = 'latest' xDscResourceDesigner = 'latest' 'DscResource.DocGenerator' = 'latest' From ec9a5fc5c1a3e8b1202bc34d29a0dfc5a331b898 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sun, 21 May 2023 10:39:29 +0200 Subject: [PATCH 28/33] DEBUG 1 --- azure-pipelines.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a735944af7..ba471b41bf 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -277,8 +277,7 @@ stages: pwsh: false - powershell: | Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 - # Make sure to keep SQLPS so that Invoke-SqlCmd is available. - Remove-PowerShellModuleFromCI -Name @('SqlServer') + Remove-PowerShellModuleFromCI -Name @('SqlServer', 'SQLPS') Remove-Module -Name CommonTestHelper name: cleanCIWorker displayName: 'Clean CI worker' From 908acb7314fc2885e45886c9ca606b2113cd3c38 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sun, 21 May 2023 14:29:36 +0200 Subject: [PATCH 29/33] Revert "DEBUG 1" This reverts commit ec9a5fc5c1a3e8b1202bc34d29a0dfc5a331b898. --- azure-pipelines.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ba471b41bf..a735944af7 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -277,7 +277,8 @@ stages: pwsh: false - powershell: | Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 - Remove-PowerShellModuleFromCI -Name @('SqlServer', 'SQLPS') + # Make sure to keep SQLPS so that Invoke-SqlCmd is available. + Remove-PowerShellModuleFromCI -Name @('SqlServer') Remove-Module -Name CommonTestHelper name: cleanCIWorker displayName: 'Clean CI worker' From 707703d652a898ea477da18fa288233128696a4f Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sun, 21 May 2023 14:43:04 +0200 Subject: [PATCH 30/33] DEBUG 2 --- azure-pipelines.yml | 3 +-- source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a735944af7..ba471b41bf 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -277,8 +277,7 @@ stages: pwsh: false - powershell: | Import-Module -Name ./tests/TestHelpers/CommonTestHelper.psm1 - # Make sure to keep SQLPS so that Invoke-SqlCmd is available. - Remove-PowerShellModuleFromCI -Name @('SqlServer') + Remove-PowerShellModuleFromCI -Name @('SqlServer', 'SQLPS') Remove-Module -Name CommonTestHelper name: cleanCIWorker displayName: 'Clean CI worker' diff --git a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 index 9201acd1c7..217a5a441e 100644 --- a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 +++ b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 @@ -1949,7 +1949,7 @@ function Invoke-SqlScript $Encrypt ) - Import-SqlDscPreferredModule + Import-SqlDscPreferredModule -Force if ($PSCmdlet.ParameterSetName -eq 'File') { From 9e038556c6158f97af605af80e8e2c672304ee45 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sun, 21 May 2023 20:19:21 +0200 Subject: [PATCH 31/33] DEBUG 3 --- .../SqlServerDsc.Common/SqlServerDsc.Common.psm1 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 index 217a5a441e..5248bf8bcf 100644 --- a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 +++ b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 @@ -1949,7 +1949,17 @@ function Invoke-SqlScript $Encrypt ) - Import-SqlDscPreferredModule -Force + Write-Verbose -Message ('Session PSModulePath: {0}' -f $env:PSModulePath) -Verbose + Write-Verbose -Message ('Available modules: {0}' -f (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String)) -Verbose + Write-Verbose -Message ('All PSModulePath: {0}' -f (Get-PSModulePath -FromTarget 'Session', 'User', 'Machine')) -Verbose + + Write-Verbose -Message ('Found module: {0}' -f (Get-SqlDscPreferredModule -ErrorAction 'Continue')) -Verbose + Write-Verbose -Message ('Found module (refresh): {0}' -f (Get-SqlDscPreferredModule -Refresh -ErrorAction 'Continue')) -Verbose + + Import-SqlDscPreferredModule -Force -Verbose + + Write-Verbose -Message ('Imported modules: {0}' -f (Get-Module | Out-String)) -Verbose + Write-Verbose -Message ('All SQLPS commands: {0}' -f (Get-Command -Module 'SQLPS' -ErrorAction 'SilentlyContinue' | Out-String)) -Verbose if ($PSCmdlet.ParameterSetName -eq 'File') { From 22764cf4806931d1c8b8e9f264073ee7e308618b Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Mon, 22 May 2023 12:59:29 +0200 Subject: [PATCH 32/33] DEBUG 4 --- .../Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 index 5248bf8bcf..3cfe8bcdde 100644 --- a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 +++ b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 @@ -1959,7 +1959,14 @@ function Invoke-SqlScript Import-SqlDscPreferredModule -Force -Verbose Write-Verbose -Message ('Imported modules: {0}' -f (Get-Module | Out-String)) -Verbose - Write-Verbose -Message ('All SQLPS commands: {0}' -f (Get-Command -Module 'SQLPS' -ErrorAction 'SilentlyContinue' | Out-String)) -Verbose + if ((Get-Module -Name 'SQLPS')) + { + Write-Verbose -Message ('DEBUG: All SQLPS commands: {0}' -f (Get-Command -Module 'SQLPS' -ErrorAction 'SilentlyContinue' | Out-String)) -Verbose + } + else + { + Write-Verbose -Message 'DEBUG: NO SQLPS IS LOADED' -Verbose + } if ($PSCmdlet.ParameterSetName -eq 'File') { From 35939c58dc0af7c8e2a3648d51dbbf0e1c733363 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Mon, 22 May 2023 17:12:45 +0200 Subject: [PATCH 33/33] DEBUG 5 --- .../SqlServerDsc.Common.psm1 | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 index 3cfe8bcdde..eee3acd4d7 100644 --- a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 +++ b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 @@ -1949,14 +1949,30 @@ function Invoke-SqlScript $Encrypt ) - Write-Verbose -Message ('Session PSModulePath: {0}' -f $env:PSModulePath) -Verbose - Write-Verbose -Message ('Available modules: {0}' -f (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String)) -Verbose - Write-Verbose -Message ('All PSModulePath: {0}' -f (Get-PSModulePath -FromTarget 'Session', 'User', 'Machine')) -Verbose + # Write-Verbose -Message ('Session PSModulePath: {0}' -f $env:PSModulePath) -Verbose + # Write-Verbose -Message ('Available modules: {0}' -f (Get-Module -Name @('SqlServer', 'SqlServerDsc', 'SQLPS') -ListAvailable | Out-String)) -Verbose + # Write-Verbose -Message ('All PSModulePath: {0}' -f (Get-PSModulePath -FromTarget 'Session', 'User', 'Machine')) -Verbose - Write-Verbose -Message ('Found module: {0}' -f (Get-SqlDscPreferredModule -ErrorAction 'Continue')) -Verbose - Write-Verbose -Message ('Found module (refresh): {0}' -f (Get-SqlDscPreferredModule -Refresh -ErrorAction 'Continue')) -Verbose + # Write-Verbose -Message ('Found module: {0}' -f (Get-SqlDscPreferredModule -ErrorAction 'Continue')) -Verbose + # Write-Verbose -Message ('Found module (refresh): {0}' -f (Get-SqlDscPreferredModule -Refresh -ErrorAction 'Continue')) -Verbose - Import-SqlDscPreferredModule -Force -Verbose + # Import the preferred module. + Import-SqlDscPreferredModule + + <# + If dbatools was imported as the preferred module and SqlServer is not available + then we need to import SQLPS because it will not always be dynamically imported + when Invoke-SqlCmd is called. + + Import-SqlDscPreferredModule must be called before Get-SqlDscPreferredModule + so that any module set using environment variable SMODefaultModuleName is + always imported first. + #> + if ((Get-SqlDscPreferredModule -Name @('SqlServer', 'dbatools')) -eq 'dbatools') + { + # Call Get-SqlDscPreferredModule to make sure we get the latest installed version of SQLPS. + Import-Module -Name (Get-SqlDscPreferredModule -Name 'SQLPS') + } Write-Verbose -Message ('Imported modules: {0}' -f (Get-Module | Out-String)) -Verbose if ((Get-Module -Name 'SQLPS'))