Skip to content

Commit

Permalink
SqlServerDsc: Added SQL Server 2019 Integration Tests (#1676)
Browse files Browse the repository at this point in the history
- SqlServerDsc
  - Added unit tests and integration tests for SQL Server 2019 (issue #1310).
- SqlSetup
  - Added/corrected `InstallSharedDir`, property output when using SQL Server 2019.
  • Loading branch information
SphenicPaul authored Jan 24, 2021
1 parent c00e23a commit 8a040bf
Show file tree
Hide file tree
Showing 35 changed files with 267 additions and 96 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
68 changes: 68 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
{
Expand Down Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/DSC_SqlAgentAlert.Integration.Tests.ps1
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/DSC_SqlEndpoint.Integration.Tests.ps1
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/DSC_SqlLogin.Integration.Tests.ps1
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/DSC_SqlProtocol.Integration.Tests.ps1
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
9 changes: 5 additions & 4 deletions tests/Integration/DSC_SqlRS.Integration.Tests.ps1
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
42 changes: 24 additions & 18 deletions tests/Integration/DSC_SqlRS.config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -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'
{
Expand Down Expand Up @@ -257,7 +263,7 @@ Configuration DSC_SqlRS_StopReportingServicesInstance_Config
State = 'Stopped'
}
}
elseif($script:sqlVersion -eq '140')
elseif($script:sqlVersion -in @('150','140'))
{
Service 'StopReportingServicesInstance'
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/DSC_SqlRSSetup.Integration.Tests.ps1
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading

0 comments on commit 8a040bf

Please sign in to comment.