Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlServerDsc: Integration tests for SQL Server 2022 #1803

Merged
merged 14 commits into from
Nov 26, 2022
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- New GitHub issue templates for proposing new public commands, proposing
an enhancement to an existing command, or having a problem with an existing
command.
- Integration tests are now also run on SQL Server 2022.
- SqlDatabase
- Added compatibility levels for SQL Server 2022 (major version 16).
- SqlSetup
- Paths for SQL Server 2022 are correctly returned by Get.

### Changed

Expand Down
6 changes: 6 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ stages:
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
Expand Down
1 change: 1 addition & 0 deletions source/DSCResources/DSC_SqlDatabase/DSC_SqlDatabase.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ $script:supportedCompatibilityLevels = @{
13 = @('Version100', 'Version110', 'Version120', 'Version130')
14 = @('Version100', 'Version110', 'Version120', 'Version130', 'Version140')
15 = @('Version100', 'Version110', 'Version120', 'Version130', 'Version140', 'Version150')
16 = @('Version100', 'Version110', 'Version120', 'Version130', 'Version140', 'Version150', 'Version160')
}

<#
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 @@ -987,7 +987,7 @@ function Set-TargetResource

foreach ($feature in $featuresArray)
{
if (($sqlVersion -in ('13', '14', '15')) -and ($feature -in ('ADV_SSMS', 'SSMS')))
if (($sqlVersion -in ('13', '14', '15', '16')) -and ($feature -in ('ADV_SSMS', 'SSMS')))
{
$errorMessage = $script:localizedData.FeatureNotSupported -f $feature
New-InvalidOperationException -Message $errorMessage
Expand All @@ -1009,7 +1009,7 @@ function Set-TargetResource
# If SQL shared components already installed, clear InstallShared*Dir variables
switch ($sqlVersion)
{
{ $_ -in ('10', '11', '12', '13', '14', '15') }
{ $_ -in ('10', '11', '12', '13', '14', '15', '16') }
{
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 @@ -3211,7 +3211,7 @@ function Get-SqlSharedPaths

switch ($SqlServerMajorVersion)
{
{ $_ -in ('10', '11', '12', '13', '14', '15') }
{ $_ -in ('10', '11', '12', '13', '14', '15', '16') }
{
$registryKeySharedDir = 'FEE2E540D20152D4597229B6CFBC0A69'
$registryKeySharedWOWDir = 'A79497A344129F64CA7D69C56F5DD8B4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "<dscResourceFriendlyName>_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "<dscResourceFriendlyName>_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022', 'Integration_SQL2022') {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ AfterAll {

<#
TODO: This has temporarily been disabled as the test is not passing.
Tags should be changed to @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019')
Tags should be changed to @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022')
#>
Describe "$($script:dscResourceName)_Integration" -Tag 'Skip' {
BeforeAll {
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/DSC_SqlAudit.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
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
Expand Up @@ -36,7 +36,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
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
Expand Up @@ -36,7 +36,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
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
Expand Up @@ -40,7 +40,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
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
Expand Up @@ -36,7 +36,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019' <#, 'Integration_SQL2022' #>) {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019' <#, 'Integration_SQL2022' #>) {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019' <#, 'Integration_SQL2022' #>) {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/DSC_SqlRole.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/DSC_SqlScript.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ AfterAll {
Get-Module -Name 'CommonTestHelper' -All | Remove-Module -Force
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ AfterAll {
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019' <#, 'Integration_SQL2022' #>) {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
Expand Down
44 changes: 39 additions & 5 deletions tests/Integration/DSC_SqlSetup.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,15 @@ BeforeAll {
This is used in both the configuration file and in this script file
to run the correct tests depending of what version of SQL Server is
being tested in the current job.

The actual download URL can easiest be found in the browser download history.
#>
if (Test-ContinuousIntegrationTaskCategory -Category 'Integration_SQL2019')
if (Test-ContinuousIntegrationTaskCategory -Category 'Integration_SQL2022')
{
$script:sqlVersion = '160'
$script:mockSourceDownloadExeUrl = 'https://download.microsoft.com/download/c/c/9/cc9c6797-383c-4b24-8920-dc057c1de9d3/SQL2022-SSEI-Dev.exe'
}
elseif (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'
Expand Down Expand Up @@ -119,7 +126,6 @@ BeforeAll {
# 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
{
Expand Down Expand Up @@ -154,7 +160,7 @@ AfterAll {
Get-Module -Name 'CommonTestHelper' -All | Remove-Module -Force
}

Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019') {
Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}
Expand Down Expand Up @@ -636,7 +642,21 @@ Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016',
$resourceCurrentState.FailoverClusterGroupName | Should -BeNullOrEmpty
$resourceCurrentState.FailoverClusterIPAddress | Should -BeNullOrEmpty
$resourceCurrentState.FailoverClusterNetworkName | Should -BeNullOrEmpty
$resourceCurrentState.Features | Should -Be $ConfigurationData.AllNodes.AnalysisServicesMultiFeatures

if ($script:sqlVersion -in (160))
{
<#
The features CONN, BC, SDK is no longer supported after SQL Server 2019.
Thus they are not installed with the Database Engine instance DSCSQLTEST
in prior test, so this test do not find them already installed.
#>
$resourceCurrentState.Features | Should -Be 'AS'
}
else
{
$resourceCurrentState.Features | Should -Be 'AS,CONN,BC,SDK'
}

$resourceCurrentState.ForceReboot | Should -BeNullOrEmpty
$resourceCurrentState.FTSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.FTSvcAccountUsername | Should -BeNullOrEmpty
Expand Down Expand Up @@ -788,7 +808,21 @@ Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016',
$resourceCurrentState.FailoverClusterGroupName | Should -BeNullOrEmpty
$resourceCurrentState.FailoverClusterIPAddress | Should -BeNullOrEmpty
$resourceCurrentState.FailoverClusterNetworkName | Should -BeNullOrEmpty
$resourceCurrentState.Features | Should -Be $ConfigurationData.AllNodes.AnalysisServicesTabularFeatures

if ($script:sqlVersion -in (160))
{
<#
The features CONN, BC, SDK is no longer supported after SQL Server 2019.
Thus they are not installed with the Database Engine instance DSCSQLTEST
in prior test, so this test do not find them already installed.
#>
$resourceCurrentState.Features | Should -Be 'AS'
}
else
{
$resourceCurrentState.Features | Should -Be 'AS,CONN,BC,SDK'
}

$resourceCurrentState.ForceReboot | Should -BeNullOrEmpty
$resourceCurrentState.FTSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.FTSvcAccountUsername | Should -BeNullOrEmpty
Expand Down
Loading