diff --git a/CHANGELOG.md b/CHANGELOG.md index 481376fc4..7dc600906 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,13 +25,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 where `PasswordExpirationEnabled` is `$true` but `PasswordPolicyEnforced` is `$false`). +- SqlServerDsc + - Added unit tests and integration tests for SQL Server 2019 + ([issue #1310](https://github.com/dsccommunity/SqlServerDsc/issues/1310)). + ### Fixed - SqlServerDsc - The component `gitversion` that is used in the pipeline was wrongly configured when the repository moved to the new default branch `main`. It no longer throws an error when using newer versions of GitVersion - ([issue #1674](https://github.com/dsccommunity/SqlServerDsc/issues/1674), + ([issue #1674](https://github.com/dsccommunity/SqlServerDsc/issues/1674)). - SqlLogin - Added integration tests to assert `LoginPasswordExpirationEnabled`, `LoginPasswordPolicyEnforced` and `LoginMustChangePassword` properties/parameters @@ -46,6 +50,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - SqlRSSetup - If parameter `SuppressRestart` is set to `$false` the `/norestart` argument is no longer wrongly added ([issue #1401](https://github.com/dsccommunity/SqlServerDsc/issues/1401)). +- SqlSetup + - Added/corrected `InstallSharedDir`, property output when using SQL Server 2019. ## [15.0.1] - 2021-01-09 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9e6fe3721..0dbb6f9d5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -240,8 +240,8 @@ To make sure a integration tests is run in the correct order the integration tests are grouped in the file `azure-pipelines.yml` in the integration tests jobs. -There are two integration tests jobs that each test SQL Server 2016 and -SQL Server 2017. +There are three, separate, integration tests jobs that each, independently, test +SQL Server 2016, SQL Server 2017 and SQL Server 2019. ### Testing of examples files diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 27409737d..d7417fd11 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -248,6 +248,74 @@ stages: testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' testRunTitle: 'Integration (Windows Server Core)' + - job: Test_Integration_SQL2019 + displayName: 'Integration (SQL2019)' + pool: + vmImage: 'windows-2019' + timeoutInMinutes: 0 + variables: + # This sets environment variable $env:CI. + CI: true + # This sets environment variable $env:CONFIGURATION. + configuration: Integration_SQL2019 + steps: + - task: DownloadBuildArtifacts@0 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: $(buildArtifactName) + downloadPath: '$(Build.SourcesDirectory)' + - task: PowerShell@2 + name: configureWinRM + displayName: 'Configure WinRM' + inputs: + targetType: 'inline' + script: 'winrm quickconfig -quiet' + pwsh: false + - powershell: | + ./build.ps1 -Tasks test -CodeCoverageThreshold 0 -PesterScript @( + # 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' + # Group 3 + 'tests/Integration/DSC_SqlRole.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlRS.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabaseUser.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlReplication.Integration.Tests.ps1' + # Group 4 + 'tests/Integration/DSC_SqlScript.Integration.Tests.ps1' + 'tests/Integration/DSC_SqlDatabasePermission.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 (Windows Server Core)' + - job: Code_Coverage displayName: 'Publish Code Coverage' dependsOn: Test_Unit diff --git a/source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1 b/source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1 index edd3b9a74..0973e55d0 100644 --- a/source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1 +++ b/source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1 @@ -903,7 +903,7 @@ function Get-ReportingServicesData if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$instanceId\MSSQLServer\CurrentVersion") { - # SQL Server 2017 SSRS stores current SQL Server version to a different Registry path. + # SQL Server 2017 and 2019 SSRS stores current SQL Server version to a different Registry path. $sqlVersion = [int]((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$InstanceId\MSSQLServer\CurrentVersion" -Name 'CurrentVersion').CurrentVersion).Split('.')[0] } else diff --git a/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 b/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 index 12c0deac6..e4e9237bb 100644 --- a/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 +++ b/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 @@ -993,7 +993,7 @@ function Set-TargetResource foreach ($feature in $featuresArray) { - if (($sqlVersion -in ('13', '14')) -and ($feature -in ('ADV_SSMS', 'SSMS'))) + if (($sqlVersion -in ('13', '14', '15')) -and ($feature -in ('ADV_SSMS', 'SSMS'))) { $errorMessage = $script:localizedData.FeatureNotSupported -f $feature New-InvalidOperationException -Message $errorMessage @@ -1017,7 +1017,7 @@ function Set-TargetResource # If SQL shared components already installed, clear InstallShared*Dir variables switch ($sqlVersion) { - { $_ -in ('10', '11', '12', '13', '14') } + { $_ -in ('10', '11', '12', '13', '14', '15') } { if ((Get-Variable -Name 'InstallSharedDir' -ErrorAction SilentlyContinue) -and (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\FEE2E540D20152D4597229B6CFBC0A69' -ErrorAction SilentlyContinue)) { @@ -3247,7 +3247,7 @@ function Get-SqlSharedPaths switch ($SqlServerMajorVersion) { - { $_ -in ('10', '11', '12', '13', '14') } + { $_ -in ('10', '11', '12', '13', '14', '15') } { $registryKeySharedDir = 'FEE2E540D20152D4597229B6CFBC0A69' $registryKeySharedWOWDir = 'A79497A344129F64CA7D69C56F5DD8B4' diff --git a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 index 8783e8f2b..b3e03de12 100644 --- a/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 +++ b/source/Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1 @@ -1247,7 +1247,7 @@ function Restart-ReportingServicesService if ($InstanceName -eq 'SSRS') { - # Check if we're dealing with SSRS 2017 + # Check if we're dealing with SSRS 2017 or SQL2019 $ServiceName = 'SQLServerReportingServices' Write-Verbose -Message ($script:localizedData.GetServiceInformation -f $ServiceName) -Verbose diff --git a/tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1 b/tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1 index 39883bbf3..e615c8c07 100644 --- a/tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlAgentFailsafe.Integration.Tests.ps1 b/tests/Integration/DSC_SqlAgentFailsafe.Integration.Tests.ps1 index 46ecf8257..39f9700a9 100644 --- a/tests/Integration/DSC_SqlAgentFailsafe.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlAgentFailsafe.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlAgentOperator.Integration.Tests.ps1 b/tests/Integration/DSC_SqlAgentOperator.Integration.Tests.ps1 index f801a396e..f08cbed02 100644 --- a/tests/Integration/DSC_SqlAgentOperator.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlAgentOperator.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1 b/tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1 index a606a5f91..406e0345d 100644 --- a/tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlDatabaseDefaultLocation.Integration.Tests.ps1 b/tests/Integration/DSC_SqlDatabaseDefaultLocation.Integration.Tests.ps1 index 23d2e1383..500bc7711 100644 --- a/tests/Integration/DSC_SqlDatabaseDefaultLocation.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlDatabaseDefaultLocation.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlDatabaseMail.Integration.Tests.ps1 b/tests/Integration/DSC_SqlDatabaseMail.Integration.Tests.ps1 index fa202c200..fc9037d28 100644 --- a/tests/Integration/DSC_SqlDatabaseMail.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlDatabaseMail.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlDatabaseObjectPermission.Integration.Tests.ps1 b/tests/Integration/DSC_SqlDatabaseObjectPermission.Integration.Tests.ps1 index c03ed05e8..a5a1b805b 100644 --- a/tests/Integration/DSC_SqlDatabaseObjectPermission.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlDatabaseObjectPermission.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlDatabasePermission.Integration.Tests.ps1 b/tests/Integration/DSC_SqlDatabasePermission.Integration.Tests.ps1 index a67953180..00caa14da 100644 --- a/tests/Integration/DSC_SqlDatabasePermission.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlDatabasePermission.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlDatabaseUser.Integration.Tests.ps1 b/tests/Integration/DSC_SqlDatabaseUser.Integration.Tests.ps1 index 518998e53..09d9d41c9 100644 --- a/tests/Integration/DSC_SqlDatabaseUser.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlDatabaseUser.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlEndpoint.Integration.Tests.ps1 b/tests/Integration/DSC_SqlEndpoint.Integration.Tests.ps1 index 750d5d609..261124cf2 100644 --- a/tests/Integration/DSC_SqlEndpoint.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlEndpoint.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016', 'Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016', 'Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlLogin.Integration.Tests.ps1 b/tests/Integration/DSC_SqlLogin.Integration.Tests.ps1 index cd5ea7c68..05b5a6ca9 100644 --- a/tests/Integration/DSC_SqlLogin.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlLogin.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlProtocol.Integration.Tests.ps1 b/tests/Integration/DSC_SqlProtocol.Integration.Tests.ps1 index e3c7fe919..cefb5f82f 100644 --- a/tests/Integration/DSC_SqlProtocol.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlProtocol.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlProtocolTcpIp.Integration.Tests.ps1 b/tests/Integration/DSC_SqlProtocolTcpIp.Integration.Tests.ps1 index 69407af11..c3a8faf27 100644 --- a/tests/Integration/DSC_SqlProtocolTcpIp.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlProtocolTcpIp.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlRS.Integration.Tests.ps1 b/tests/Integration/DSC_SqlRS.Integration.Tests.ps1 index d8eef332c..2c3796ecf 100644 --- a/tests/Integration/DSC_SqlRS.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlRS.Integration.Tests.ps1 @@ -1,5 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') +# Not currently run for SQL Server 2019 if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) { return @@ -129,7 +130,7 @@ try It 'Should be able to access the ReportServer site without any error' { if($script:sqlVersion -eq '140') { - # SSRS 2017 does not support multiple instances + # SSRS 2017 and 2019 do not support multiple instances $reportServerUri = 'http://{0}/ReportServer' -f $env:COMPUTERNAME } else @@ -159,7 +160,7 @@ try It 'Should be able to access the Reports site without any error' { if($script:sqlVersion -eq '140') { - # SSRS 2017 does not support multiple instances + # SSRS 2017 and 2019 do not support multiple instances $reportsUri = 'http://{0}/Reports' -f $env:COMPUTERNAME } else @@ -241,7 +242,7 @@ try It 'Should not be able to access the ReportServer site and throw an error message' { if($script:sqlVersion -eq '140') { - # SSRS 2017 does not support multiple instances + # SSRS 2017 and 2019 do not support multiple instances $reportServerUri = 'http://{0}/ReportServer' -f $env:COMPUTERNAME } else @@ -301,7 +302,7 @@ try It 'Should be able to access the ReportServer site without any error' { if($script:sqlVersion -eq '140') { - # SSRS 2017 does not support multiple instances + # SSRS 2017 and 2019 do not support multiple instances $reportServerUri = 'http://{0}/ReportServer' -f $env:COMPUTERNAME } else diff --git a/tests/Integration/DSC_SqlRS.config.ps1 b/tests/Integration/DSC_SqlRS.config.ps1 index 9a141cadb..be21d9486 100644 --- a/tests/Integration/DSC_SqlRS.config.ps1 +++ b/tests/Integration/DSC_SqlRS.config.ps1 @@ -17,7 +17,13 @@ else $mockLastDrive = ((Get-Volume).DriveLetter | Sort-Object | Select-Object -Last 1) $mockIsoMediaDriveLetter = [char](([int][char]$mockLastDrive) + 1) - if($script:sqlVersion -eq '140') + if($script:sqlVersion -eq '150') + { + # SQL2019 + $instanceName = 'SSRS' + $isoImageName = 'SQL2019.iso' + } + elseif($script:sqlVersion -eq '140') { # SQL2017 $instanceName = 'SSRS' @@ -74,20 +80,6 @@ Configuration DSC_SqlRS_CreateDependencies_Config node $AllNodes.NodeName { - MountImage 'MountIsoMedia' - { - ImagePath = $Node.ImagePath - DriveLetter = $Node.DriveLetter - Ensure = 'Present' - } - - WaitForVolume 'WaitForMountOfIsoMedia' - { - DriveLetter = $Node.DriveLetter - RetryIntervalSec = 5 - RetryCount = 10 - } - User 'CreateReportingServicesServiceAccount' { Ensure = 'Present' @@ -105,6 +97,20 @@ Configuration DSC_SqlRS_CreateDependencies_Config if($script:sqlVersion -eq '130') { + MountImage 'MountIsoMedia' + { + ImagePath = $Node.ImagePath + DriveLetter = $Node.DriveLetter + Ensure = 'Present' + } + + WaitForVolume 'WaitForMountOfIsoMedia' + { + DriveLetter = $Node.DriveLetter + RetryIntervalSec = 5 + RetryCount = 10 + } + SqlSetup 'InstallReportingServicesInstance' { InstanceName = $Node.InstanceName @@ -133,10 +139,10 @@ Configuration DSC_SqlRS_CreateDependencies_Config } } <# - DSC_SqlRSSetup.Integration.Tests.ps1 will have installed SSRS 2017. + DSC_SqlRSSetup.Integration.Tests.ps1 will have installed SSRS 2017 or 2019. We just need to start SSRS. #> - elseif($script:sqlVersion -eq '140') + elseif($script:sqlVersion -in @('150','140')) { Service 'StartReportingServicesInstance' { @@ -257,7 +263,7 @@ Configuration DSC_SqlRS_StopReportingServicesInstance_Config State = 'Stopped' } } - elseif($script:sqlVersion -eq '140') + elseif($script:sqlVersion -in @('150','140')) { Service 'StopReportingServicesInstance' { diff --git a/tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1 b/tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1 index 422a07ae0..a4dadda52 100644 --- a/tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -# Run only for SQL 2017 integration testing. +# Run only for SQL Server 2017, integration testing at present (not SQL Server 2019) if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2017'))) { return diff --git a/tests/Integration/DSC_SqlRSSetup.config.ps1 b/tests/Integration/DSC_SqlRSSetup.config.ps1 index 1b66ec920..6c16b35e7 100644 --- a/tests/Integration/DSC_SqlRSSetup.config.ps1 +++ b/tests/Integration/DSC_SqlRSSetup.config.ps1 @@ -41,8 +41,8 @@ else If it exist, it will be upgraded. Uninstall is not tested, because when upgrading the existing Microsoft - SQL Server 2017 Reporting Services instance it requires a restart which - prevents uninstall until the node is rebooted. + SQL Server 2017 or SQL Server 2019 Reporting Services instance it requires + a restart which prevents uninstall until the node is rebooted. #> Configuration DSC_SqlRSSetup_InstallReportingServicesAsUser_Config { diff --git a/tests/Integration/DSC_SqlReplication.Integration.Tests.ps1 b/tests/Integration/DSC_SqlReplication.Integration.Tests.ps1 index fb195ab86..c441e10e5 100644 --- a/tests/Integration/DSC_SqlReplication.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlReplication.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlRole.Integration.Tests.ps1 b/tests/Integration/DSC_SqlRole.Integration.Tests.ps1 index 5e20d4da2..ed48847e1 100644 --- a/tests/Integration/DSC_SqlRole.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlRole.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlScript.Integration.Tests.ps1 b/tests/Integration/DSC_SqlScript.Integration.Tests.ps1 index 348b9e537..564f12b00 100644 --- a/tests/Integration/DSC_SqlScript.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlScript.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlScriptQuery.Integration.Tests.ps1 b/tests/Integration/DSC_SqlScriptQuery.Integration.Tests.ps1 index 61fbd3993..9b5064f7e 100644 --- a/tests/Integration/DSC_SqlScriptQuery.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlScriptQuery.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlSecureConnection.Integration.Tests.ps1 b/tests/Integration/DSC_SqlSecureConnection.Integration.Tests.ps1 index d48b4b032..7caaff153 100644 --- a/tests/Integration/DSC_SqlSecureConnection.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlSecureConnection.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlServiceAccount.Integration.Tests.ps1 b/tests/Integration/DSC_SqlServiceAccount.Integration.Tests.ps1 index 8a5c2df4e..54b6fecd1 100644 --- a/tests/Integration/DSC_SqlServiceAccount.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlServiceAccount.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } diff --git a/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 b/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 index 7f47f61f6..615927bb9 100644 --- a/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SqlSetup.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))) +if (-not (Test-BuildCategory -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017','Integration_SQL2019'))) { return } @@ -66,7 +66,12 @@ function Show-SqlBootstrapLog to run the correct tests depending of what version of SQL Server is being tested in the current job. #> -if (Test-ContinuousIntegrationTaskCategory -Category 'Integration_SQL2017') +if (Test-ContinuousIntegrationTaskCategory -Category 'Integration_SQL2019') +{ + $script:sqlVersion = '150' + $script:mockSourceDownloadExeUrl = 'https://download.microsoft.com/download/d/a/2/da259851-b941-459d-989c-54a18a5d44dd/SQL2019-SSEI-Dev.exe' +} +elseif (Test-ContinuousIntegrationTaskCategory -Category 'Integration_SQL2017') { $script:sqlVersion = '140' $script:mockSourceMediaUrl = 'https://download.microsoft.com/download/E/F/2/EF23C21D-7860-4F05-88CE-39AA114B014B/SQLServer2017-x64-ENU.iso' @@ -93,7 +98,28 @@ try Write-Verbose -Message "Start downloading the SQL Server media at $(Get-Date -Format 'yyyy-MM-dd hh:mm:ss')" -Verbose - Invoke-WebRequest -Uri $script:mockSourceMediaUrl -OutFile $ConfigurationData.AllNodes.ImagePath + if($script:mockSourceDownloadExeUrl) + { + # Download the EXE used to download the ISO + Invoke-WebRequest -Uri $script:mockSourceDownloadExeUrl -OutFile $ConfigurationData.AllNodes.DownloadExePath | Out-Null + + # Download ISO using the EXE + $imageDirectoryPath = Split-Path -Path $ConfigurationData.AllNodes.ImagePath -Parent + $downloadExeArgumentList = '/ENU /Quiet /HideProgressBar /Action=Download /Language=en-US /MediaType=ISO /MediaPath={0}' -f $imageDirectoryPath + Start-Process -FilePath $ConfigurationData.AllNodes.DownloadExePath ` + -ArgumentList $downloadExeArgumentList ` + -Wait + + # Rename the ISO to maintain consistency of names within integration tests + Rename-Item -Path $ConfigurationData.AllNodes.DownloadIsoPath ` + -NewName $(Split-Path -Path $ConfigurationData.AllNodes.ImagePath -Leaf) | Out-Null + + } + else + { + # Direct ISO download + Invoke-WebRequest -Uri $script:mockSourceMediaUrl -OutFile $ConfigurationData.AllNodes.ImagePath + } Write-Verbose -Message ('SQL Server media file has SHA1 hash ''{0}''' -f (Get-FileHash -Path $ConfigurationData.AllNodes.ImagePath -Algorithm 'SHA1').Hash) -Verbose diff --git a/tests/Integration/DSC_SqlSetup.config.ps1 b/tests/Integration/DSC_SqlSetup.config.ps1 index f2250b0f4..674c2aef9 100644 --- a/tests/Integration/DSC_SqlSetup.config.ps1 +++ b/tests/Integration/DSC_SqlSetup.config.ps1 @@ -23,6 +23,19 @@ else #> switch ($script:sqlVersion) { + '150' + { + $versionSpecificData = @{ + SqlServerInstanceIdPrefix = 'MSSQL15' + AnalysisServiceInstanceIdPrefix = 'MSAS15' + IsoImageName = 'SQL2019.iso' + + # Additional variables required as ISO is downloaded via additional EXE + DownloadExeName = 'SQL2019_Download.exe' + DownloadIsoName = 'SQLServer2019-x64-ENU-Dev.iso' + } + } + '140' { $versionSpecificData = @{ @@ -89,6 +102,10 @@ else SuppressReboot = $true # Make sure we don't reboot during testing. ForceReboot = $false + # Properties for downloading media + DownloadExePath = $(if($versionSpecificData.DownloadExeName){Join-Path -Path $env:TEMP -ChildPath $versionSpecificData.DownloadExeName}) + DownloadIsoPath = $(if($versionSpecificData.DownloadIsoName){Join-Path -Path $env:TEMP -ChildPath $versionSpecificData.DownloadIsoName}) + # Properties for mounting media ImagePath = Join-Path -Path $env:TEMP -ChildPath $versionSpecificData.IsoImageName DriveLetter = $mockIsoMediaDriveLetter diff --git a/tests/Integration/README.md b/tests/Integration/README.md index 228026eea..9d4daf6ac 100644 --- a/tests/Integration/README.md +++ b/tests/Integration/README.md @@ -16,11 +16,11 @@ to each other. Dependencies are made to speed up the testing.** ## SqlSetup -Installs the Database Engine, Analysis Service for both SQL Server 2016 -and SQL Server 2017 in two different Azure Pipelines jobs with the configuration -names `'Integration_SQL2016'` and `'Integration_SQL2017'`. It will also -install the Reporting Services 2016 in the Azure Pipelines job with the configuration -name `'Integration_SQL2016'`. +Installs the Database Engine, Analysis Service for SQL Server 2016, SQL Server 2017 +and SQL Server 2019 in three different Azure Pipelines jobs with the configuration +names `'Integration_SQL2016'`, `'Integration_SQL2017'` and `'Integration_SQL2019'`, +respectively. It will also install the Reporting Services 2016 in the Azure Pipelines +job with the configuration name `'Integration_SQL2016'`. **Run order:** 1 @@ -81,14 +81,13 @@ configuration name `'Integration_SQL2017'`. **Depends on:** SqlSetup (for the local installation account) -The integration tests will install (or upgrade) a Microsoft SQL Server -2017 Reporting Services instance and leave it on the AppVeyor build worker +The integration tests will install (or upgrade) separate, Microsoft SQL Server +2017 and 2019, Reporting Services instances and leave them on the build server for other integration tests to use. >**NOTE:** Uninstall is not tested, because when upgrading the existing >Microsoft SQL Server Reporting Services instance it requires a restart, ->that prevents uninstall until the node is restarted. AppVeyor build ->workers are not allowed to be restarted during testing phase. +>that prevents uninstall until the node is restarted. Instance | State --- | --- @@ -257,18 +256,19 @@ worker.* ## SqlRS -Configures _SQL Server Reporting Services 2016_ and _SQL Server Reporting_ -_Services 2017_ in two different Azure Pipelines jobs with the configuration -names `'Integration_SQL2016'` and `'Integration_SQL2017'`. +Configures _SQL Server Reporting Services 2016_, _SQL Server Reporting_ +_Services 2017_ and _SQL Server Reporting_ +_Services 2019_ in three different Azure Pipelines jobs with the configuration +names `'Integration_SQL2016'`, `'Integration_SQL2017'` and `'Integration_SQL2019'`. **Run order:** 3 **Depends on:** SqlSetup, SqlRSSetup When running integration tests for SQL Server 2016 the integration tests -will install the following instances and leave it on the AppVeyor build -worker for other integration tests to use. -When running integration tests for SQL Server 2017 the Reporting Services +will install the following instances and leave it on the build server for other +integration tests to use. +When running integration tests for SQL Server 2017 and 2019, the Reporting Services instance installed by the resource SqlRSSetup is started, and then stopped again after the integration tests has run. diff --git a/tests/Unit/DSC_SqlRS.Tests.ps1 b/tests/Unit/DSC_SqlRS.Tests.ps1 index 5710e7a82..f31ac4bcf 100644 --- a/tests/Unit/DSC_SqlRS.Tests.ps1 +++ b/tests/Unit/DSC_SqlRS.Tests.ps1 @@ -328,6 +328,10 @@ try VersionName = "SQL Server Reporting Services 2017" Version = 14 } + @{ + VersionName = "SQL Server Reporting Services 2019" + Version = 15 + } ) foreach($sqlVersion in $sqlVersions) { @@ -1004,11 +1008,18 @@ try } } + $mockSql2019Version = '15.0.2000.5' + $mockGetItemProperty_Sql2019 = { + return @{ + CurrentVersion = $mockSql2019Version + } + } + $mockGetItemProperty_Sql2014AndSql2016_ParameterFilter = { $Path -eq ('HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\{0}\Setup' -f $mockInstanceId) } - $mockGetItemProperty_Sql2017_ParameterFilter = { + $mockGetItemProperty_Sql2017AndSql2019_ParameterFilter = { $Path -eq ('HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\{0}\MSSQLServer\CurrentVersion' -f $mockInstanceId) } @@ -1105,7 +1116,7 @@ try Mock -CommandName Get-ItemProperty ` -MockWith $mockGetItemProperty_Sql2017 ` - -ParameterFilter $mockGetItemProperty_Sql2017_ParameterFilter + -ParameterFilter $mockGetItemProperty_Sql2017AndSql2019_ParameterFilter } It 'Should return the correct information' { @@ -1125,7 +1136,42 @@ try -Exactly -Times 2 -Scope 'It' Assert-MockCalled -CommandName Get-ItemProperty ` - -ParameterFilter $mockGetItemProperty_Sql2017_ParameterFilter ` + -ParameterFilter $mockGetItemProperty_Sql2017AndSql2019_ParameterFilter ` + -Exactly -Times 1 -Scope 'It' + + Assert-MockCalled -CommandName Get-CimInstance -Exactly -Times 1 -Scope 'It' + } + } + + Context 'When the instance is SQL Server Reporting Services 2019' { + BeforeEach { + Mock -CommandName Test-Path -MockWith { + return $true + } + + Mock -CommandName Get-ItemProperty ` + -MockWith $mockGetItemProperty_Sql2019 ` + -ParameterFilter $mockGetItemProperty_Sql2017AndSql2019_ParameterFilter + } + + It 'Should return the correct information' { + $getReportingServicesDataResult = Get-ReportingServicesData -InstanceName $mockNamedInstanceName + $getReportingServicesDataResult.Configuration | Should -BeOfType [Microsoft.Management.Infrastructure.CimInstance] + $getReportingServicesDataResult.Configuration.InstanceName | Should -Be $mockNamedInstanceName + $getReportingServicesDataResult.Configuration.DatabaseServerName | Should -Be "$mockReportingServicesDatabaseServerName\$mockReportingServicesDatabaseNamedInstanceName" + $getReportingServicesDataResult.Configuration.IsInitialized | Should -Be $false + $getReportingServicesDataResult.Configuration.VirtualDirectoryReportServer | Should -Be $mockVirtualDirectoryReportServerName + $getReportingServicesDataResult.Configuration.VirtualDirectoryReportManager | Should -Be $mockVirtualDirectoryReportManagerName + $getReportingServicesDataResult.Configuration.SecureConnectionLevel | Should -Be 0 + $getReportingServicesDataResult.ReportsApplicationName | Should -Be 'ReportServerWebApp' + $getReportingServicesDataResult.SqlVersion | Should -Be $mockSql2019Version.Split('.')[0] + + Assert-MockCalled -CommandName Get-ItemProperty ` + -ParameterFilter $mockGetItemProperty_InstanceNames_ParameterFilter ` + -Exactly -Times 2 -Scope 'It' + + Assert-MockCalled -CommandName Get-ItemProperty ` + -ParameterFilter $mockGetItemProperty_Sql2017AndSql2019_ParameterFilter ` -Exactly -Times 1 -Scope 'It' Assert-MockCalled -CommandName Get-CimInstance -Exactly -Times 1 -Scope 'It' diff --git a/tests/Unit/DSC_SqlSetup.Tests.ps1 b/tests/Unit/DSC_SqlSetup.Tests.ps1 index 057fc7733..845a7e3c2 100644 --- a/tests/Unit/DSC_SqlSetup.Tests.ps1 +++ b/tests/Unit/DSC_SqlSetup.Tests.ps1 @@ -48,6 +48,7 @@ try InModuleScope $script:dscResourceName { # Testing each supported SQL Server version $testProductVersion = @( + 15 # SQL Server 2019 14 # SQL Server 2017 13 # SQL Server 2016 12 # SQL Server 2014 @@ -199,7 +200,7 @@ try $Name -eq 'ImagePath' } -MockWith { <# - Example for a named instance for SQL Server 2017: + Example for a named instance for SQL Server 2017 and 2019: '"C:\Program Files\Microsoft SQL Server\MSAS14.INSTANCE\OLAP\bin\msmdsrv.exe" -s "C:\Program Files\Microsoft SQL Server\MSAS14.INSTANCE\OLAP\Config"' #> return '"C:\Program Files\Microsoft SQL Server\OLAP\bin\msmdsrv.exe" -s "{0}"' -f $mockSqlAnalysisConfigDirectory @@ -689,7 +690,7 @@ try It 'Should return correct names of installed features' { $result = Get-TargetResource @testParameters - if ($mockSqlMajorVersion -in (13,14)) + if ($mockSqlMajorVersion -in ('13', '14', '15')) { $result.Features | Should -Match 'SQLENGINE\b' $result.Features | Should -Match 'REPLICATION\b' @@ -821,7 +822,7 @@ try It 'Should return correct names of installed features' { $result = Get-TargetResource @testParameters - if ($mockSqlMajorVersion -in (13,14)) + if ($mockSqlMajorVersion -in ('13', '14', '15')) { $result.Features | Should -Match 'SQLENGINE\b' $result.Features | Should -Match 'REPLICATION\b' @@ -1023,7 +1024,7 @@ try It 'Should return correct names of installed features' { $result = Get-TargetResource @testParameters - if ($mockSqlMajorVersion -in (13,14)) + if ($mockSqlMajorVersion -in ('13', '14', '15')) { $result.Features | Should -Match 'SQLENGINE\b' $result.Features | Should -Match 'REPLICATION\b' @@ -1318,7 +1319,7 @@ try It 'Should return correct names of installed features' { $result = Get-TargetResource @testParameters - if ($mockSqlMajorVersion -in (13,14)) + if ($mockSqlMajorVersion -in ('13', '14', '15')) { $result.Features | Should -Match 'SQLENGINE\b' $result.Features | Should -Match 'REPLICATION\b' @@ -2148,7 +2149,7 @@ try BrowserSvcStartupType = 'Automatic' } - if ( $mockSqlMajorVersion -in (13,14) ) + if ( $mockSqlMajorVersion -in ('13', '14', '15') ) { $testParameters.Features = $testParameters.Features -replace ',SSMS,ADV_SSMS','' } @@ -2543,7 +2544,7 @@ try SqlTempDbLogFileGrowth = 128 } - if ( $mockSqlMajorVersion -in (13,14) ) + if ( $mockSqlMajorVersion -in ('13', '14', '15') ) { $testParameters.Features = $testParameters.Features -replace ',SSMS,ADV_SSMS','' } @@ -2586,9 +2587,9 @@ try Assert-MockCalled -CommandName Import-SQLPSModule -Exactly -Times 1 -Scope It } - if ($mockSqlMajorVersion -in (13,14)) + if ($mockSqlMajorVersion -in ('13', '14', '15')) { - It 'Should throw when feature parameter contains ''SSMS'' when installing SQL Server 2016 and 2017' { + It 'Should throw when feature parameter contains ''SSMS'' when installing SQL Server 2016, 2017 or 2019' { $testParameters += @{ InstanceName = $mockDefaultInstance_InstanceName SourceCredential = $null @@ -2601,7 +2602,7 @@ try { Set-TargetResource @testParameters } | Should -Throw "'SSMS' is not a valid value for setting 'FEATURES'. Refer to SQL Help for more information." } - It 'Should throw when feature parameter contains ''ADV_SSMS'' when installing SQL Server 2016 and 2017' { + It 'Should throw when feature parameter contains ''ADV_SSMS'' when installing SQL Server 2016, 2017 or 2019' { $testParameters += @{ InstanceName = $mockDefaultInstance_InstanceName SourceCredential = $null @@ -2684,7 +2685,7 @@ try SourcePath = $mockSourcePathUNC } - if ( $mockSqlMajorVersion -in (13,14) ) + if ( $mockSqlMajorVersion -in ('13', '14', '15') ) { $testParameters.Features = $testParameters.Features -replace ',SSMS,ADV_SSMS','' } @@ -2709,16 +2710,16 @@ try Assert-MockCalled -CommandName Test-TargetResource -Exactly -Times 1 -Scope It } - if ($mockSqlMajorVersion -in (13,14)) + if ($mockSqlMajorVersion -in ('13', '14', '15')) { - It 'Should throw when feature parameter contains ''SSMS'' when installing SQL Server 2016 and 2017' { + It 'Should throw when feature parameter contains ''SSMS'' when installing SQL Server 2016, 2017 or 2019' { $testParameters.Features = 'SSMS' $mockStartSqlSetupProcessExpectedArgument = '' { Set-TargetResource @testParameters } | Should -Throw "'SSMS' is not a valid value for setting 'FEATURES'. Refer to SQL Help for more information." } - It 'Should throw when feature parameter contains ''ADV_SSMS'' when installing SQL Server 2016 and 2017' { + It 'Should throw when feature parameter contains ''ADV_SSMS'' when installing SQL Server 2016, 2017 or 2019' { $testParameters.Features = 'ADV_SSMS' $mockStartSqlSetupProcessExpectedArgument = '' @@ -2785,7 +2786,7 @@ try SuppressReboot = $true } - if ( $mockSqlMajorVersion -in (13,14) ) + if ( $mockSqlMajorVersion -in ('13', '14', '15') ) { $testParameters.Features = $testParameters.Features -replace ',SSMS,ADV_SSMS','' } @@ -2811,16 +2812,16 @@ try Assert-MockCalled -CommandName Import-SQLPSModule -Exactly -Times 1 -Scope It } - if( $mockSqlMajorVersion -in (13,14) ) + if( $mockSqlMajorVersion -in ('13', '14', '15') ) { - It 'Should throw when feature parameter contains ''SSMS'' when installing SQL Server 2016 and 2017' { + It 'Should throw when feature parameter contains ''SSMS'' when installing SQL Server 2016, 2017 or 2019' { $testParameters.Features = 'SSMS' $mockStartSqlSetupProcessExpectedArgument = @{} { Set-TargetResource @testParameters } | Should -Throw "'SSMS' is not a valid value for setting 'FEATURES'. Refer to SQL Help for more information." } - It 'Should throw when feature parameter contains ''ADV_SSMS'' when installing SQL Server 2016 and 2017' { + It 'Should throw when feature parameter contains ''ADV_SSMS'' when installing SQL Server 2016, 2017 or 2019' { $testParameters.Features = 'ADV_SSMS' $mockStartSqlSetupProcessExpectedArgument = @{} @@ -2893,7 +2894,7 @@ try ForceReboot = $true } - if ( $mockSqlMajorVersion -in (13,14) ) + if ( $mockSqlMajorVersion -in ('13', '14', '15') ) { $testParameters.Features = $testParameters.Features -replace ',SSMS,ADV_SSMS','' } @@ -2917,16 +2918,16 @@ try Assert-MockCalled -CommandName Test-TargetResource -Exactly -Times 1 -Scope It } - if( $mockSqlMajorVersion -in (13,14) ) + if( $mockSqlMajorVersion -in ('13', '14', '15') ) { - It 'Should throw when feature parameter contains ''SSMS'' when installing SQL Server 2016 and 2017' { + It 'Should throw when feature parameter contains ''SSMS'' when installing SQL Server 2016, 2017 or 2019' { $testParameters.Features = $($testParameters.Features), 'SSMS' -join ',' $mockStartSqlSetupProcessExpectedArgument = @{} { Set-TargetResource @testParameters } | Should -Throw "'SSMS' is not a valid value for setting 'FEATURES'. Refer to SQL Help for more information." } - It 'Should throw when feature parameter contains ''ADV_SSMS'' when installing SQL Server 2016 and 2017' { + It 'Should throw when feature parameter contains ''ADV_SSMS'' when installing SQL Server 2016, 2017 or 2019' { $testParameters.Features = $($testParameters.Features), 'ADV_SSMS' -join ',' $mockStartSqlSetupProcessExpectedArgument = @{} diff --git a/tests/Unit/SqlServerDsc.Common.Tests.ps1 b/tests/Unit/SqlServerDsc.Common.Tests.ps1 index f17644fe0..4a9418d3a 100644 --- a/tests/Unit/SqlServerDsc.Common.Tests.ps1 +++ b/tests/Unit/SqlServerDsc.Common.Tests.ps1 @@ -3086,7 +3086,7 @@ InModuleScope $script:subModuleName { } } - Context 'When restarting an SQL Server 2017 Report Services' { + Context 'When restarting a SQL Server 2017 (or newer) Report Services' { BeforeAll { $mockServiceName = 'SQLServerReportingServices' $mockDependedServiceName = 'DependentService'