Skip to content

Commit

Permalink
SqlSetup: Join integration tests into the same script (#1296)
Browse files Browse the repository at this point in the history
  • Loading branch information
johlju authored Mar 5, 2019
1 parent 9801548 commit 40e746c
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 1,088 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ param()

Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1')

if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2017'))
if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016','Integration_SQL2017'))
{
return
}
Expand Down Expand Up @@ -64,6 +64,25 @@ function Show-SqlBootstrapLog
Write-Verbose -Message $('-' * 80) -Verbose
}


<#
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.
#>
if (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'
}
else
{
$script:sqlVersion = '130'
$script:mockSourceMediaUrl = 'https://download.microsoft.com/download/9/0/7/907AD35F-9F9C-43A5-9789-52470555DB90/ENU/SQLServer2016SP1-FullSlipstream-x64-ENU.iso'
}

Write-Verbose -Message ('Running integration tests for SQL Server version {0}' -f $script:sqlVersion) -Verbose

<#
Workaround for issue #774. In the appveyor.yml file the folder
C:\Program Files (x86)\Microsoft SQL Server\**\Tools\PowerShell\Modules
Expand All @@ -72,7 +91,8 @@ function Show-SqlBootstrapLog
here we rename back the folder to the correct name. Only the version need
for our tests are renamed.
#>
$sqlModulePath = Get-ChildItem -Path 'C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell\*.old'
$sqlPsModulePath = 'C:\Program Files (x86)\Microsoft SQL Server\{0}\Tools\PowerShell\*.old' -f $script:sqlVersion
$sqlModulePath = Get-ChildItem -Path $sqlPsModulePath
$sqlModulePath | ForEach-Object -Process {
$newFolderName = (Split-Path -Path $_ -Leaf) -replace '\.old'
Write-Verbose ('Renaming ''{0}'' to ''..\{1}''' -f $_, $newFolderName) -Verbose
Expand All @@ -82,11 +102,9 @@ $sqlModulePath | ForEach-Object -Process {
# Using try/finally to always cleanup.
try
{
$configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName)_SQL2017.config.ps1"
$configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1"
. $configFile

$mockSourceMediaUrl = 'https://download.microsoft.com/download/E/F/2/EF23C21D-7860-4F05-88CE-39AA114B014B/SQLServer2017-x64-ENU.iso'

# Download SQL Server media
if (-not (Test-Path -Path $ConfigurationData.AllNodes.ImagePath))
{
Expand All @@ -96,7 +114,7 @@ try

Write-Verbose -Message "Start downloading the SQL Server media at $(Get-Date -Format 'yyyy-MM-dd hh:mm:ss')" -Verbose

Invoke-WebRequest -Uri $mockSourceMediaUrl -OutFile $ConfigurationData.AllNodes.ImagePath
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

Expand Down Expand Up @@ -199,12 +217,12 @@ try
$resourceCurrentState.AgtSvcAccountUsername | Should -Be ('.\{0}' -f (Split-Path -Path $ConfigurationData.AllNodes.SqlAgentServicePrimaryAccountUserName -Leaf))
$resourceCurrentState.AgtSvcStartupType | Should -Be 'Automatic'
$resourceCurrentState.ASServerMode | Should -Be $ConfigurationData.AllNodes.AnalysisServicesMultiServerMode
$resourceCurrentState.ASBackupDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSAS14.$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\OLAP\Backup")
$resourceCurrentState.ASBackupDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "$($ConfigurationData.AllNodes.AnalysisServiceInstanceIdPrefix).$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\OLAP\Backup")
$resourceCurrentState.ASCollation | Should -Be $ConfigurationData.AllNodes.Collation
$resourceCurrentState.ASConfigDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSAS14.$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\OLAP\Config")
$resourceCurrentState.ASDataDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSAS14.$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\OLAP\Data")
$resourceCurrentState.ASLogDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSAS14.$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\OLAP\Log")
$resourceCurrentState.ASTempDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSAS14.$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\OLAP\Temp")
$resourceCurrentState.ASConfigDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "$($ConfigurationData.AllNodes.AnalysisServiceInstanceIdPrefix).$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\OLAP\Config")
$resourceCurrentState.ASDataDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "$($ConfigurationData.AllNodes.AnalysisServiceInstanceIdPrefix).$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\OLAP\Data")
$resourceCurrentState.ASLogDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "$($ConfigurationData.AllNodes.AnalysisServiceInstanceIdPrefix).$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\OLAP\Log")
$resourceCurrentState.ASTempDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "$($ConfigurationData.AllNodes.AnalysisServiceInstanceIdPrefix).$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\OLAP\Temp")
$resourceCurrentState.ASSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.ASSvcAccountUsername | Should -Be ('.\{0}' -f (Split-Path -Path $ConfigurationData.AllNodes.SqlServicePrimaryAccountUserName -Leaf))
$resourceCurrentState.AsSvcStartupType | Should -Be 'Automatic'
Expand All @@ -223,8 +241,8 @@ try
$resourceCurrentState.FTSvcAccountUsername | Should -BeNullOrEmpty
$resourceCurrentState.InstallSharedDir | Should -Be $ConfigurationData.AllNodes.InstallSharedDir
$resourceCurrentState.InstallSharedWOWDir | Should -Be $ConfigurationData.AllNodes.InstallSharedWOWDir
$resourceCurrentState.InstallSQLDataDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSSQL14.$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\MSSQL")
$resourceCurrentState.InstanceDir | Should -Be $ConfigurationData.AllNodes.InstallSharedDir
$resourceCurrentState.InstallSQLDataDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSQLDataDir -ChildPath "$($ConfigurationData.AllNodes.SqlServerInstanceIdPrefix).$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\MSSQL")
$resourceCurrentState.InstanceDir | Should -Be $ConfigurationData.AllNodes.InstanceDir
$resourceCurrentState.InstanceID | Should -Be $ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName
$resourceCurrentState.InstanceName | Should -Be $ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName
$resourceCurrentState.ISSvcAccount | Should -BeNullOrEmpty
Expand All @@ -237,7 +255,6 @@ try
$resourceCurrentState.SetupProcessTimeout | Should -BeNullOrEmpty
$resourceCurrentState.SourceCredential | Should -BeNullOrEmpty
$resourceCurrentState.SourcePath | Should -Be "$($ConfigurationData.AllNodes.DriveLetter):\"
$resourceCurrentState.SQLBackupDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSSQL14.$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\MSSQL\Backup")
$resourceCurrentState.SQLCollation | Should -Be $ConfigurationData.AllNodes.Collation
$resourceCurrentState.SQLSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.SQLSvcAccountUsername | Should -Be ('.\{0}' -f (Split-Path -Path $ConfigurationData.AllNodes.SqlServicePrimaryAccountUserName -Leaf))
Expand All @@ -252,14 +269,15 @@ try
'sa'
)
$resourceCurrentState.SQLTempDBDir | Should -BeNullOrEmpty
$resourceCurrentState.SqlTempdbFileCount | Should -Be $ConfigurationData.AllNodes.SqlTempdbFileCount
$resourceCurrentState.SqlTempdbFileSize | Should -Be $ConfigurationData.AllNodes.SqlTempdbFileSize
$resourceCurrentState.SqlTempdbFileGrowth | Should -Be $ConfigurationData.AllNodes.SqlTempdbFileGrowth
$resourceCurrentState.SQLTempDBLogDir | Should -BeNullOrEmpty
$resourceCurrentState.SqlTempdbLogFileSize | Should -Be $ConfigurationData.AllNodes.SqlTempdbLogFileSize
$resourceCurrentState.SqlTempdbLogFileGrowth | Should -Be $ConfigurationData.AllNodes.SqlTempdbLogFileGrowth
$resourceCurrentState.SQLUserDBDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSSQL14.$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\MSSQL\DATA\")
$resourceCurrentState.SQLUserDBLogDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSSQL14.$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\MSSQL\DATA\")
$resourceCurrentState.SqlTempDbFileCount | Should -Be $ConfigurationData.AllNodes.SqlTempDbFileCount
$resourceCurrentState.SqlTempDbFileSize | Should -Be $ConfigurationData.AllNodes.SqlTempDbFileSize
$resourceCurrentState.SqlTempDbFileGrowth | Should -Be $ConfigurationData.AllNodes.SqlTempDbFileGrowth
$resourceCurrentState.SQLTempDbLogDir | Should -BeNullOrEmpty
$resourceCurrentState.SqlTempDbLogFileSize | Should -Be $ConfigurationData.AllNodes.SqlTempDbLogFileSize
$resourceCurrentState.SqlTempDbLogFileGrowth | Should -Be $ConfigurationData.AllNodes.SqlTempDbLogFileGrowth
$resourceCurrentState.SQLUserDBDir | Should -Be $ConfigurationData.AllNodes.SQLUserDBDir
$resourceCurrentState.SQLUserDBLogDir | Should -Be $ConfigurationData.AllNodes.SQLUserDBLogDir
$resourceCurrentState.SQLBackupDir | Should -Be $ConfigurationData.AllNodes.SQLBackupDir
$resourceCurrentState.SQMReporting | Should -BeNullOrEmpty
$resourceCurrentState.SuppressReboot | Should -BeNullOrEmpty
$resourceCurrentState.UpdateEnabled | Should -BeNullOrEmpty
Expand Down Expand Up @@ -366,7 +384,7 @@ try
$resourceCurrentState.FTSvcAccountUsername | Should -BeNullOrEmpty
$resourceCurrentState.InstallSharedDir | Should -Be $ConfigurationData.AllNodes.InstallSharedDir
$resourceCurrentState.InstallSharedWOWDir | Should -Be $ConfigurationData.AllNodes.InstallSharedWOWDir
$resourceCurrentState.InstallSQLDataDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSSQL14.$($ConfigurationData.AllNodes.DatabaseEngineDefaultInstanceName)\MSSQL")
$resourceCurrentState.InstallSQLDataDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "$($ConfigurationData.AllNodes.SqlServerInstanceIdPrefix).$($ConfigurationData.AllNodes.DatabaseEngineDefaultInstanceName)\MSSQL")
$resourceCurrentState.InstanceDir | Should -Be $ConfigurationData.AllNodes.InstallSharedDir
$resourceCurrentState.InstanceID | Should -Be $ConfigurationData.AllNodes.DatabaseEngineDefaultInstanceName
$resourceCurrentState.InstanceName | Should -Be $ConfigurationData.AllNodes.DatabaseEngineDefaultInstanceName
Expand All @@ -380,7 +398,7 @@ try
$resourceCurrentState.SetupProcessTimeout | Should -BeNullOrEmpty
$resourceCurrentState.SourceCredential | Should -BeNullOrEmpty
$resourceCurrentState.SourcePath | Should -Be "$($ConfigurationData.AllNodes.DriveLetter):\"
$resourceCurrentState.SQLBackupDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSSQL14.$($ConfigurationData.AllNodes.DatabaseEngineDefaultInstanceName)\MSSQL\Backup")
$resourceCurrentState.SQLBackupDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "$($ConfigurationData.AllNodes.SqlServerInstanceIdPrefix).$($ConfigurationData.AllNodes.DatabaseEngineDefaultInstanceName)\MSSQL\Backup")
$resourceCurrentState.SQLCollation | Should -Be $ConfigurationData.AllNodes.Collation
$resourceCurrentState.SQLSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.SQLSvcAccountUsername | Should -Be ('.\{0}' -f (Split-Path -Path $ConfigurationData.AllNodes.SqlServicePrimaryAccountUserName -Leaf))
Expand All @@ -395,12 +413,14 @@ try
)
$resourceCurrentState.SQLTempDBDir | Should -BeNullOrEmpty
$resourceCurrentState.SQLTempDBLogDir | Should -BeNullOrEmpty
$resourceCurrentState.SQLUserDBDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSSQL14.$($ConfigurationData.AllNodes.DatabaseEngineDefaultInstanceName)\MSSQL\DATA\")
$resourceCurrentState.SQLUserDBLogDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSSQL14.$($ConfigurationData.AllNodes.DatabaseEngineDefaultInstanceName)\MSSQL\DATA\")
$resourceCurrentState.SQMReporting | Should -BeNullOrEmpty
$resourceCurrentState.SuppressReboot | Should -BeNullOrEmpty
$resourceCurrentState.UpdateEnabled | Should -BeNullOrEmpty
$resourceCurrentState.UpdateSource | Should -BeNullOrEmpty

# Regression test for issue #1287
$resourceCurrentState.SQLUserDBDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "$($ConfigurationData.AllNodes.SqlServerInstanceIdPrefix).$($ConfigurationData.AllNodes.DatabaseEngineDefaultInstanceName)\MSSQL\DATA\")
$resourceCurrentState.SQLUserDBLogDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "$($ConfigurationData.AllNodes.SqlServerInstanceIdPrefix).$($ConfigurationData.AllNodes.DatabaseEngineDefaultInstanceName)\MSSQL\DATA\")
}

It 'Should return $true when Test-DscConfiguration is run' {
Expand Down Expand Up @@ -483,12 +503,12 @@ try
$resourceCurrentState.AgtSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.AgtSvcAccountUsername | Should -BeNullOrEmpty
$resourceCurrentState.ASServerMode | Should -Be $ConfigurationData.AllNodes.AnalysisServicesTabularServerMode
$resourceCurrentState.ASBackupDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSAS14.$($ConfigurationData.AllNodes.AnalysisServicesTabularInstanceName)\OLAP\Backup")
$resourceCurrentState.ASBackupDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "$($ConfigurationData.AllNodes.AnalysisServiceInstanceIdPrefix).$($ConfigurationData.AllNodes.AnalysisServicesTabularInstanceName)\OLAP\Backup")
$resourceCurrentState.ASCollation | Should -Be $ConfigurationData.AllNodes.Collation
$resourceCurrentState.ASConfigDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSAS14.$($ConfigurationData.AllNodes.AnalysisServicesTabularInstanceName)\OLAP\Config")
$resourceCurrentState.ASDataDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSAS14.$($ConfigurationData.AllNodes.AnalysisServicesTabularInstanceName)\OLAP\Data")
$resourceCurrentState.ASLogDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSAS14.$($ConfigurationData.AllNodes.AnalysisServicesTabularInstanceName)\OLAP\Log")
$resourceCurrentState.ASTempDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSAS14.$($ConfigurationData.AllNodes.AnalysisServicesTabularInstanceName)\OLAP\Temp")
$resourceCurrentState.ASConfigDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "$($ConfigurationData.AllNodes.AnalysisServiceInstanceIdPrefix).$($ConfigurationData.AllNodes.AnalysisServicesTabularInstanceName)\OLAP\Config")
$resourceCurrentState.ASDataDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "$($ConfigurationData.AllNodes.AnalysisServiceInstanceIdPrefix).$($ConfigurationData.AllNodes.AnalysisServicesTabularInstanceName)\OLAP\Data")
$resourceCurrentState.ASLogDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "$($ConfigurationData.AllNodes.AnalysisServiceInstanceIdPrefix).$($ConfigurationData.AllNodes.AnalysisServicesTabularInstanceName)\OLAP\Log")
$resourceCurrentState.ASTempDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "$($ConfigurationData.AllNodes.AnalysisServiceInstanceIdPrefix).$($ConfigurationData.AllNodes.AnalysisServicesTabularInstanceName)\OLAP\Temp")
$resourceCurrentState.ASSvcAccount | Should -BeNullOrEmpty
$resourceCurrentState.ASSvcAccountUsername | Should -Be ('.\{0}' -f (Split-Path -Path $ConfigurationData.AllNodes.SqlServicePrimaryAccountUserName -Leaf))
$resourceCurrentState.ASSysAdminAccounts | Should -Be @(
Expand Down
Loading

0 comments on commit 40e746c

Please sign in to comment.