From 40e746cbffcba89237b9ada02de186b9baaf1bc3 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 5 Mar 2019 17:18:33 +0100 Subject: [PATCH] SqlSetup: Join integration tests into the same script (#1296) --- ...s1 => MSFT_SqlSetup.Integration.Tests.ps1} | 82 ++- ...17.config.ps1 => MSFT_SqlSetup.config.ps1} | 62 +- ...SFT_SqlSetup_SQL2016.Integration.Tests.ps1 | 603 ------------------ .../MSFT_SqlSetup_SQL2016.config.ps1 | 442 ------------- Tests/TestHelpers/CommonTestHelper.psm1 | 35 + 5 files changed, 136 insertions(+), 1088 deletions(-) rename Tests/Integration/{MSFT_SqlSetup._SQL2017.Integration.Tests.ps1 => MSFT_SqlSetup.Integration.Tests.ps1} (88%) rename Tests/Integration/{MSFT_SqlSetup_SQL2017.config.ps1 => MSFT_SqlSetup.config.ps1} (86%) delete mode 100644 Tests/Integration/MSFT_SqlSetup_SQL2016.Integration.Tests.ps1 delete mode 100644 Tests/Integration/MSFT_SqlSetup_SQL2016.config.ps1 diff --git a/Tests/Integration/MSFT_SqlSetup._SQL2017.Integration.Tests.ps1 b/Tests/Integration/MSFT_SqlSetup.Integration.Tests.ps1 similarity index 88% rename from Tests/Integration/MSFT_SqlSetup._SQL2017.Integration.Tests.ps1 rename to Tests/Integration/MSFT_SqlSetup.Integration.Tests.ps1 index ef5da124c..eaf77e99e 100644 --- a/Tests/Integration/MSFT_SqlSetup._SQL2017.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_SqlSetup.Integration.Tests.ps1 @@ -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 } @@ -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 @@ -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 @@ -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)) { @@ -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 @@ -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' @@ -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 @@ -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)) @@ -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 @@ -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 @@ -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)) @@ -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' { @@ -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 @( diff --git a/Tests/Integration/MSFT_SqlSetup_SQL2017.config.ps1 b/Tests/Integration/MSFT_SqlSetup.config.ps1 similarity index 86% rename from Tests/Integration/MSFT_SqlSetup_SQL2017.config.ps1 rename to Tests/Integration/MSFT_SqlSetup.config.ps1 index 00c00ee5c..061131bba 100644 --- a/Tests/Integration/MSFT_SqlSetup_SQL2017.config.ps1 +++ b/Tests/Integration/MSFT_SqlSetup.config.ps1 @@ -17,11 +17,39 @@ else $mockLastDrive = ((Get-Volume).DriveLetter | Sort-Object | Select-Object -Last 1) $mockIsoMediaDriveLetter = [char](([int][char]$mockLastDrive) + 1) + <# + The variable $script:sqlVersion is set in the integration script file, + which is available once this script is dot-sourced. + #> + switch ($script:sqlVersion) + { + '140' + { + $versionSpecificData = @{ + SqlServerInstanceIdPrefix = 'MSSQL14' + AnalysisServiceInstanceIdPrefix = 'MSAS14' + IsoImageName = 'SQL2017.iso' + } + } + + '130' + { + $versionSpecificData = @{ + SqlServerInstanceIdPrefix = 'MSSQL13' + AnalysisServiceInstanceIdPrefix = 'MSAS13' + IsoImageName = 'SQL2016.iso' + } + } + } + $ConfigurationData = @{ AllNodes = @( @{ NodeName = 'localhost' + SqlServerInstanceIdPrefix = $versionSpecificData.SqlServerInstanceIdPrefix + AnalysisServiceInstanceIdPrefix = $versionSpecificData.AnalysisServiceInstanceIdPrefix + # Database Engine properties. DatabaseEngineNamedInstanceName = 'DSCSQLTEST' DatabaseEngineNamedInstanceFeatures = 'SQLENGINE,AS,CONN,BC,SDK' @@ -50,22 +78,27 @@ else # General SqlSetup properties Collation = 'Finnish_Swedish_CI_AS' + InstanceDir = 'C:\Program Files\Microsoft SQL Server' InstallSharedDir = 'C:\Program Files\Microsoft SQL Server' InstallSharedWOWDir = 'C:\Program Files (x86)\Microsoft SQL Server' + InstallSQLDataDir = "C:\Db\$($script:sqlVersion)\System" + SQLUserDBDir = "C:\Db\$($script:sqlVersion)\Data\" + SQLUserDBLogDir = "C:\Db\$($script:sqlVersion)\Log\" + SQLBackupDir = "C:\Db\$($script:sqlVersion)\Backup" UpdateEnabled = 'False' SuppressReboot = $true # Make sure we don't reboot during testing. ForceReboot = $false # Properties for mounting media - ImagePath = "$env:TEMP\SQL2017.iso" + ImagePath = Join-Path -Path $env:TEMP -ChildPath $versionSpecificData.IsoImageName DriveLetter = $mockIsoMediaDriveLetter - # Parameters to configure Tempdb - SqlTempdbFileCount = '2' - SqlTempdbFileSize = '128' - SqlTempdbFileGrowth = '128' - SqlTempdbLogFileSize = '128' - SqlTempdbLogFileGrowth = '128' + # Parameters to configure TempDb + SqlTempDbFileCount = '2' + SqlTempDbFileSize = '128' + SqlTempDbFileGrowth = '128' + SqlTempDbLogFileSize = '128' + SqlTempDbLogFileGrowth = '128' SqlInstallAccountUserName = "$env:COMPUTERNAME\SqlInstall" SqlInstallAccountPassword = 'P@ssw0rd1' @@ -235,16 +268,21 @@ Configuration MSFT_SqlSetup_InstallDatabaseEngineNamedInstanceAsSystem_Config AsSvcStartupType = 'Automatic' ASCollation = $Node.Collation ASSvcAccount = $SqlServicePrimaryCredential + InstanceDir = $Node.InstanceDir InstallSharedDir = $Node.InstallSharedDir InstallSharedWOWDir = $Node.InstallSharedWOWDir + InstallSQLDataDir = $Node.InstallSQLDataDir + SQLUserDBDir = $Node.SQLUserDBDir + SQLUserDBLogDir = $Node.SQLUserDBLogDir + SQLBackupDir = $Node.SQLBackupDir UpdateEnabled = $Node.UpdateEnabled SuppressReboot = $Node.SuppressReboot ForceReboot = $Node.ForceReboot - SqlTempdbFileCount = $Node.SqlTempdbFileCount - SqlTempdbFileSize = $Node.SqlTempdbFileSize - SqlTempdbFileGrowth = $Node.SqlTempdbFileGrowth - SqlTempdbLogFileSize = $Node.SqlTempdbLogFileSize - SqlTempdbLogFileGrowth = $Node.SqlTempdbLogFileGrowth + SqlTempDbFileCount = $Node.SqlTempDbFileCount + SqlTempDbFileSize = $Node.SqlTempDbFileSize + SqlTempDbFileGrowth = $Node.SqlTempDbFileGrowth + SqlTempDbLogFileSize = $Node.SqlTempDbLogFileSize + SqlTempDbLogFileGrowth = $Node.SqlTempDbLogFileGrowth # This must be set if using SYSTEM account to install. SQLSysAdminAccounts = @( diff --git a/Tests/Integration/MSFT_SqlSetup_SQL2016.Integration.Tests.ps1 b/Tests/Integration/MSFT_SqlSetup_SQL2016.Integration.Tests.ps1 deleted file mode 100644 index f0cedc873..000000000 --- a/Tests/Integration/MSFT_SqlSetup_SQL2016.Integration.Tests.ps1 +++ /dev/null @@ -1,603 +0,0 @@ -# This is used to make sure the integration test run in the correct order. -[Microsoft.DscResourceKit.IntegrationTest(OrderNumber = 1)] -param() - -Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') - -if (Test-SkipContinuousIntegrationTask -Type 'Integration' -Category @('Integration_SQL2016')) -{ - return -} - -$script:dscModuleName = 'SqlServerDsc' -$script:dscResourceFriendlyName = 'SqlSetup' -$script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" - -#region HEADER -# Integration Test Template Version: 1.3.2 -[String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) -{ - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) -} - -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion - -<# - .SYNOPSIS - This function will output the Setup Bootstrap Summary.txt log file. - - .DESCRIPTION - This function will output the Summary.txt log file, this is to be - able to debug any problems that potentially occurred during setup. - This will pick up the newest Summary.txt log file, so any - other log files will be ignored (AppVeyor build worker has - SQL Server instances installed by default). - This code is meant to work regardless what SQL Server - major version is used for the integration test. -#> -function Show-SqlBootstrapLog -{ - [CmdletBinding()] - param - ( - ) - - $summaryLogPath = Get-ChildItem -Path 'C:\Program Files\Microsoft SQL Server\**\Setup Bootstrap\Log\Summary.txt' | - Sort-Object -Property LastWriteTime -Descending | - Select-Object -First 1 - - $summaryLog = Get-Content $summaryLogPath - - Write-Verbose -Message $('-' * 80) -Verbose - Write-Verbose -Message 'Summary.txt' -Verbose - Write-Verbose -Message $('-' * 80) -Verbose - $summaryLog | ForEach-Object { - Write-Verbose $_ -Verbose - } - Write-Verbose -Message $('-' * 80) -Verbose -} - -<# - Workaround for issue #774. In the appveyor.yml file the folder - C:\Program Files (x86)\Microsoft SQL Server\**\Tools\PowerShell\Modules - was renamed to - C:\Program Files (x86)\Microsoft SQL Server\**\Tools\PowerShell\Modules.old - 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\130\Tools\PowerShell\*.old' -$sqlModulePath | ForEach-Object -Process { - $newFolderName = (Split-Path -Path $_ -Leaf) -replace '\.old' - Write-Verbose ('Renaming ''{0}'' to ''..\{1}''' -f $_, $newFolderName) -Verbose - Rename-Item $_ -NewName $newFolderName -Force -} - -# Using try/finally to always cleanup. -try -{ - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName)_SQL2016.config.ps1" - . $configFile - - $mockSourceMediaUrl = 'https://download.microsoft.com/download/9/0/7/907AD35F-9F9C-43A5-9789-52470555DB90/ENU/SQLServer2016SP1-FullSlipstream-x64-ENU.iso' - - # Download SQL Server media - if (-not (Test-Path -Path $ConfigurationData.AllNodes.ImagePath)) - { - # By switching to 'SilentlyContinue' should theoretically increase the download speed. - $previousProgressPreference = $ProgressPreference - $ProgressPreference = 'SilentlyContinue' - - 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 - - Write-Verbose -Message ('SQL Server media file has SHA1 hash ''{0}''' -f (Get-FileHash -Path $ConfigurationData.AllNodes.ImagePath -Algorithm 'SHA1').Hash) -Verbose - - $ProgressPreference = $previousProgressPreference - - # Double check that the SQL media was downloaded. - if (-not (Test-Path -Path $ConfigurationData.AllNodes.ImagePath)) - { - Write-Warning -Message ('SQL media could not be downloaded, can not run the integration test.') - return - } - else - { - Write-Verbose -Message "Finished downloading the SQL Server media iso at $(Get-Date -Format 'yyyy-MM-dd hh:mm:ss')" -Verbose - } - } - else - { - Write-Verbose -Message 'SQL Server media is already downloaded' -Verbose - } - - Describe "$($script:dscResourceName)_Integration" { - BeforeAll { - $resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test" - } - - $configurationName = "$($script:dscResourceName)_CreateDependencies_Config" - - Context ('When using configuration {0}' -f $configurationName) { - It 'Should compile and apply the MOF without throwing' { - { - $configurationParameters = @{ - OutputPath = $TestDrive - # The variable $ConfigurationData was dot-sourced above. - ConfigurationData = $ConfigurationData - } - - & $configurationName @configurationParameters - - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' - } - - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } - } - - $configurationName = "$($script:dscResourceName)_InstallDatabaseEngineNamedInstanceAsSystem_Config" - - Context ('When using configuration {0}' -f $configurationName) { - It 'Should compile and apply the MOF without throwing' { - { - $configurationParameters = @{ - OutputPath = $TestDrive - # The variable $ConfigurationData was dot-sourced above. - ConfigurationData = $ConfigurationData - } - - & $configurationName @configurationParameters - - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' - } - - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } -ErrorVariable itBlockError - - # Check if previous It-block failed. If so output the SQL Server setup log file. - if ( $itBlockError.Count -ne 0 ) - { - Show-SqlBootstrapLog - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { - $script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop - } | Should -Not -Throw - } - - It 'Should have set the resource and all the parameters should match' { - $resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq $configurationName ` - -and $_.ResourceId -eq $resourceId - } - - $resourceCurrentState.Action | Should -BeNullOrEmpty - $resourceCurrentState.AgtSvcAccount | Should -BeNullOrEmpty - $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 "MSAS13.$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\OLAP\Backup") - $resourceCurrentState.ASCollation | Should -Be $ConfigurationData.AllNodes.Collation - $resourceCurrentState.ASConfigDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSAS13.$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\OLAP\Config") - $resourceCurrentState.ASDataDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSAS13.$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\OLAP\Data") - $resourceCurrentState.ASLogDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSAS13.$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\OLAP\Log") - $resourceCurrentState.ASTempDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSAS13.$($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' - $resourceCurrentState.ASSysAdminAccounts | Should -Be @( - $ConfigurationData.AllNodes.SqlAdministratorAccountUserName, - "NT SERVICE\SSASTELEMETRY`$$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)" - ) - $resourceCurrentState.BrowserSvcStartupType | Should -BeNullOrEmpty - $resourceCurrentState.ErrorReporting | Should -BeNullOrEmpty - $resourceCurrentState.FailoverClusterGroupName | Should -BeNullOrEmpty - $resourceCurrentState.FailoverClusterIPAddress | Should -BeNullOrEmpty - $resourceCurrentState.FailoverClusterNetworkName | Should -BeNullOrEmpty - $resourceCurrentState.Features | Should -Be $ConfigurationData.AllNodes.DatabaseEngineNamedInstanceFeatures - $resourceCurrentState.ForceReboot | Should -BeNullOrEmpty - $resourceCurrentState.FTSvcAccount | Should -BeNullOrEmpty - $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 "MSSQL13.$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\MSSQL") - $resourceCurrentState.InstanceDir | Should -Be $ConfigurationData.AllNodes.InstallSharedDir - $resourceCurrentState.InstanceID | Should -Be $ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName - $resourceCurrentState.InstanceName | Should -Be $ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName - $resourceCurrentState.ISSvcAccount | Should -BeNullOrEmpty - $resourceCurrentState.ISSvcAccountUsername | Should -BeNullOrEmpty - $resourceCurrentState.ProductKey | Should -BeNullOrEmpty - $resourceCurrentState.RSSvcAccount | Should -BeNullOrEmpty - $resourceCurrentState.RSSvcAccountUsername | Should -BeNullOrEmpty - $resourceCurrentState.SAPwd | Should -BeNullOrEmpty - $resourceCurrentState.SecurityMode | Should -Be 'SQL' - $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 "MSSQL13.$($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)) - $resourceCurrentState.SqlSvcStartupType | Should -Be 'Automatic' - $resourceCurrentState.SQLSysAdminAccounts | Should -Be @( - $ConfigurationData.AllNodes.SqlAdministratorAccountUserName, - $ConfigurationData.AllNodes.SqlInstallAccountUserName, - "NT SERVICE\MSSQL`$$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)", - "NT SERVICE\SQLAgent`$$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)", - 'NT SERVICE\SQLWriter', - 'NT SERVICE\Winmgmt', - '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 "MSSQL13.$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\MSSQL\DATA\") - $resourceCurrentState.SQLUserDBLogDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSSQL13.$($ConfigurationData.AllNodes.DatabaseEngineNamedInstanceName)\MSSQL\DATA\") - $resourceCurrentState.SQMReporting | Should -BeNullOrEmpty - $resourceCurrentState.SuppressReboot | Should -BeNullOrEmpty - $resourceCurrentState.UpdateEnabled | Should -BeNullOrEmpty - $resourceCurrentState.UpdateSource | Should -BeNullOrEmpty - } - - It 'Should return $true when Test-DscConfiguration is run' { - Test-DscConfiguration -Verbose | Should -Be $true - } - } - - $configurationName = "$($script:dscResourceName)_StopServicesInstance_Config" - - Context ('When using configuration {0}' -f $configurationName) { - It 'Should compile and apply the MOF without throwing' { - { - $configurationParameters = @{ - OutputPath = $TestDrive - # The variable $ConfigurationData was dot-sourced above. - ConfigurationData = $ConfigurationData - } - - & $configurationName @configurationParameters - - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' - } - - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } - } - - $configurationName = "$($script:dscResourceName)_InstallDatabaseEngineDefaultInstanceAsUser_Config" - - Context ('When using configuration {0}' -f $configurationName) { - It 'Should compile and apply the MOF without throwing' { - { - $configurationParameters = @{ - OutputPath = $TestDrive - # The variable $ConfigurationData was dot-sourced above. - ConfigurationData = $ConfigurationData - } - - & $configurationName @configurationParameters - - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' - } - - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } -ErrorVariable itBlockError - - # Check if previous It-block failed. If so output the SQL Server setup log file. - if ( $itBlockError.Count -ne 0 ) - { - Show-SqlBootstrapLog - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { - $script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop - } | Should -Not -Throw - } - - It 'Should have set the resource and all the parameters should match' { - $resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq $configurationName ` - -and $_.ResourceId -eq $resourceId - } - - $resourceCurrentState.Action | Should -BeNullOrEmpty - $resourceCurrentState.AgtSvcAccount | Should -BeNullOrEmpty - $resourceCurrentState.AgtSvcAccountUsername | Should -Be ('.\{0}' -f (Split-Path -Path $ConfigurationData.AllNodes.SqlAgentServicePrimaryAccountUserName -Leaf)) - $resourceCurrentState.ASServerMode | Should -BeNullOrEmpty - $resourceCurrentState.ASBackupDir | Should -BeNullOrEmpty - $resourceCurrentState.ASCollation | Should -BeNullOrEmpty - $resourceCurrentState.ASConfigDir | Should -BeNullOrEmpty - $resourceCurrentState.ASDataDir | Should -BeNullOrEmpty - $resourceCurrentState.ASLogDir | Should -BeNullOrEmpty - $resourceCurrentState.ASTempDir | Should -BeNullOrEmpty - $resourceCurrentState.ASSvcAccount | Should -BeNullOrEmpty - $resourceCurrentState.ASSvcAccountUsername | Should -BeNullOrEmpty - $resourceCurrentState.ASSysAdminAccounts | Should -BeNullOrEmpty - $resourceCurrentState.BrowserSvcStartupType | Should -BeNullOrEmpty - $resourceCurrentState.ErrorReporting | Should -BeNullOrEmpty - $resourceCurrentState.FailoverClusterGroupName | Should -BeNullOrEmpty - $resourceCurrentState.FailoverClusterIPAddress | Should -BeNullOrEmpty - $resourceCurrentState.FailoverClusterNetworkName | Should -BeNullOrEmpty - $resourceCurrentState.Features | Should -Be $ConfigurationData.AllNodes.DatabaseEngineDefaultInstanceFeatures - $resourceCurrentState.ForceReboot | Should -BeNullOrEmpty - $resourceCurrentState.FTSvcAccount | Should -BeNullOrEmpty - $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 "MSSQL13.$($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 - $resourceCurrentState.ISSvcAccount | Should -BeNullOrEmpty - $resourceCurrentState.ISSvcAccountUsername | Should -BeNullOrEmpty - $resourceCurrentState.ProductKey | Should -BeNullOrEmpty - $resourceCurrentState.RSSvcAccount | Should -BeNullOrEmpty - $resourceCurrentState.RSSvcAccountUsername | Should -BeNullOrEmpty - $resourceCurrentState.SAPwd | Should -BeNullOrEmpty - $resourceCurrentState.SecurityMode | Should -Be 'Windows' - $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 "MSSQL13.$($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)) - $resourceCurrentState.SQLSysAdminAccounts | Should -Be @( - $ConfigurationData.AllNodes.SqlAdministratorAccountUserName, - $ConfigurationData.AllNodes.SqlInstallAccountUserName, - "NT SERVICE\$($ConfigurationData.AllNodes.DatabaseEngineDefaultInstanceName)", - "NT SERVICE\SQLSERVERAGENT", - 'NT SERVICE\SQLWriter', - 'NT SERVICE\Winmgmt', - 'sa' - ) - $resourceCurrentState.SQLTempDBDir | Should -BeNullOrEmpty - $resourceCurrentState.SQLTempDBLogDir | Should -BeNullOrEmpty - $resourceCurrentState.SQLUserDBDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSSQL13.$($ConfigurationData.AllNodes.DatabaseEngineDefaultInstanceName)\MSSQL\DATA\") - $resourceCurrentState.SQLUserDBLogDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSSQL13.$($ConfigurationData.AllNodes.DatabaseEngineDefaultInstanceName)\MSSQL\DATA\") - $resourceCurrentState.SQMReporting | Should -BeNullOrEmpty - $resourceCurrentState.SuppressReboot | Should -BeNullOrEmpty - $resourceCurrentState.UpdateEnabled | Should -BeNullOrEmpty - $resourceCurrentState.UpdateSource | Should -BeNullOrEmpty - } - - It 'Should return $true when Test-DscConfiguration is run' { - Test-DscConfiguration -Verbose | Should -Be $true - } - } - - $configurationName = "$($script:dscResourceName)_StopSqlServerDefaultInstance_Config" - - Context ('When using configuration {0}' -f $configurationName) { - It 'Should compile and apply the MOF without throwing' { - { - $configurationParameters = @{ - OutputPath = $TestDrive - # The variable $ConfigurationData was dot-sourced above. - ConfigurationData = $ConfigurationData - } - - & $configurationName @configurationParameters - - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' - } - - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } - } - - $configurationName = "$($script:dscResourceName)_InstallTabularAnalysisServicesAsSystem_Config" - - Context ('When using configuration {0}' -f $configurationName) { - It 'Should compile and apply the MOF without throwing' { - { - $configurationParameters = @{ - OutputPath = $TestDrive - # The variable $ConfigurationData was dot-sourced above. - ConfigurationData = $ConfigurationData - } - - & $configurationName @configurationParameters - - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' - } - - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } -ErrorVariable itBlockError - - # Check if previous It-block failed. If so output the SQL Server setup log file. - if ( $itBlockError.Count -ne 0 ) - { - Show-SqlBootstrapLog - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { - $script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop - } | Should -Not -Throw - } - - It 'Should have set the resource and all the parameters should match' { - $resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq $configurationName ` - -and $_.ResourceId -eq $resourceId - } - - $resourceCurrentState.Action | Should -BeNullOrEmpty - $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 "MSAS13.$($ConfigurationData.AllNodes.AnalysisServicesTabularInstanceName)\OLAP\Backup") - $resourceCurrentState.ASCollation | Should -Be $ConfigurationData.AllNodes.Collation - $resourceCurrentState.ASConfigDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSAS13.$($ConfigurationData.AllNodes.AnalysisServicesTabularInstanceName)\OLAP\Config") - $resourceCurrentState.ASDataDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSAS13.$($ConfigurationData.AllNodes.AnalysisServicesTabularInstanceName)\OLAP\Data") - $resourceCurrentState.ASLogDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSAS13.$($ConfigurationData.AllNodes.AnalysisServicesTabularInstanceName)\OLAP\Log") - $resourceCurrentState.ASTempDir | Should -Be (Join-Path -Path $ConfigurationData.AllNodes.InstallSharedDir -ChildPath "MSAS13.$($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 @( - $ConfigurationData.AllNodes.SqlAdministratorAccountUserName, - "NT SERVICE\SSASTELEMETRY`$$($ConfigurationData.AllNodes.AnalysisServicesTabularInstanceName)" - ) - $resourceCurrentState.BrowserSvcStartupType | Should -BeNullOrEmpty - $resourceCurrentState.ErrorReporting | Should -BeNullOrEmpty - $resourceCurrentState.FailoverClusterGroupName | Should -BeNullOrEmpty - $resourceCurrentState.FailoverClusterIPAddress | Should -BeNullOrEmpty - $resourceCurrentState.FailoverClusterNetworkName | Should -BeNullOrEmpty - $resourceCurrentState.Features | Should -Be $ConfigurationData.AllNodes.AnalysisServicesTabularFeatures - $resourceCurrentState.ForceReboot | Should -BeNullOrEmpty - $resourceCurrentState.FTSvcAccount | Should -BeNullOrEmpty - $resourceCurrentState.FTSvcAccountUsername | Should -BeNullOrEmpty - $resourceCurrentState.InstallSharedDir | Should -Be $ConfigurationData.AllNodes.InstallSharedDir - $resourceCurrentState.InstallSharedWOWDir | Should -Be $ConfigurationData.AllNodes.InstallSharedWOWDir - $resourceCurrentState.InstallSQLDataDir | Should -BeNullOrEmpty - $resourceCurrentState.InstanceDir | Should -BeNullOrEmpty - $resourceCurrentState.InstanceID | Should -BeNullOrEmpty - $resourceCurrentState.InstanceName | Should -Be $ConfigurationData.AllNodes.AnalysisServicesTabularInstanceName - $resourceCurrentState.ISSvcAccount | Should -BeNullOrEmpty - $resourceCurrentState.ISSvcAccountUsername | Should -BeNullOrEmpty - $resourceCurrentState.ProductKey | Should -BeNullOrEmpty - $resourceCurrentState.RSSvcAccount | Should -BeNullOrEmpty - $resourceCurrentState.RSSvcAccountUsername | Should -BeNullOrEmpty - $resourceCurrentState.SAPwd | Should -BeNullOrEmpty - $resourceCurrentState.SecurityMode | Should -BeNullOrEmpty - $resourceCurrentState.SetupProcessTimeout | Should -BeNullOrEmpty - $resourceCurrentState.SourceCredential | Should -BeNullOrEmpty - $resourceCurrentState.SourcePath | Should -Be "$($ConfigurationData.AllNodes.DriveLetter):\" - $resourceCurrentState.SQLBackupDir | Should -BeNullOrEmpty - $resourceCurrentState.SQLCollation | Should -BeNullOrEmpty - $resourceCurrentState.SQLSvcAccount | Should -BeNullOrEmpty - $resourceCurrentState.SQLSvcAccountUsername | Should -BeNullOrEmpty - $resourceCurrentState.SQLSysAdminAccounts | Should -BeNullOrEmpty - $resourceCurrentState.SQLTempDBDir | Should -BeNullOrEmpty - $resourceCurrentState.SQLTempDBLogDir | Should -BeNullOrEmpty - $resourceCurrentState.SQLUserDBDir | Should -BeNullOrEmpty - $resourceCurrentState.SQLUserDBLogDir | Should -BeNullOrEmpty - $resourceCurrentState.SQMReporting | Should -BeNullOrEmpty - $resourceCurrentState.SuppressReboot | Should -BeNullOrEmpty - $resourceCurrentState.UpdateEnabled | Should -BeNullOrEmpty - $resourceCurrentState.UpdateSource | Should -BeNullOrEmpty - } - - It 'Should return $true when Test-DscConfiguration is run' { - Test-DscConfiguration -Verbose | Should -Be $true - } - } - - $configurationName = "$($script:dscResourceName)_StopTabularAnalysisServices_Config" - - Context ('When using configuration {0}' -f $configurationName) { - It 'Should compile and apply the MOF without throwing' { - { - $configurationParameters = @{ - OutputPath = $TestDrive - # The variable $ConfigurationData was dot-sourced above. - ConfigurationData = $ConfigurationData - } - - & $configurationName @configurationParameters - - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' - } - - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } - } - - $configurationName = "$($script:dscResourceName)_StartServicesInstance_Config" - - Context ('When using configuration {0}' -f $configurationName) { - It 'Should compile and apply the MOF without throwing' { - { - $configurationParameters = @{ - OutputPath = $TestDrive - # The variable $ConfigurationData was dot-sourced above. - ConfigurationData = $ConfigurationData - } - - & $configurationName @configurationParameters - - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' - } - - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } - } - } -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/MSFT_SqlSetup_SQL2016.config.ps1 b/Tests/Integration/MSFT_SqlSetup_SQL2016.config.ps1 deleted file mode 100644 index 4eaf3560e..000000000 --- a/Tests/Integration/MSFT_SqlSetup_SQL2016.config.ps1 +++ /dev/null @@ -1,442 +0,0 @@ -#region HEADER -# Integration Test Config Template Version: 1.2.0 -#endregion - -$configFile = [System.IO.Path]::ChangeExtension($MyInvocation.MyCommand.Path, 'json') -if (Test-Path -Path $configFile) -{ - <# - Allows reading the configuration data from a JSON file, - for real testing scenarios outside of the CI. - #> - $ConfigurationData = Get-Content -Path $configFile | ConvertFrom-Json -} -else -{ - # Get a spare drive letter - $mockLastDrive = ((Get-Volume).DriveLetter | Sort-Object | Select-Object -Last 1) - $mockIsoMediaDriveLetter = [char](([int][char]$mockLastDrive) + 1) - - $ConfigurationData = @{ - AllNodes = @( - @{ - NodeName = 'localhost' - - # Database Engine properties. - DatabaseEngineNamedInstanceName = 'DSCSQLTEST' - DatabaseEngineNamedInstanceFeatures = 'SQLENGINE,AS,CONN,BC,SDK' - AnalysisServicesMultiServerMode = 'MULTIDIMENSIONAL' - - <# - Analysis Services Tabular properties. - The features CONN,BC,SDK is installed with the DSCSQLTEST so those - features will found for DSCTABULAR instance as well. - The features is added here so the same property can be used to - evaluate the result in the test. - #> - AnalysisServicesTabularInstanceName = 'DSCTABULAR' - AnalysisServicesTabularFeatures = 'AS,CONN,BC,SDK' - AnalysisServicesTabularServerMode = 'TABULAR' - - <# - Database Engine default instance properties. - The features CONN,BC,SDK is installed with the DSCSQLTEST so those - features will found for DSCTABULAR instance as well. - The features is added here so the same property can be used to - evaluate the result in the test. - #> - DatabaseEngineDefaultInstanceName = 'MSSQLSERVER' - DatabaseEngineDefaultInstanceFeatures = 'SQLENGINE,CONN,BC,SDK' - - # General SqlSetup properties - Collation = 'Finnish_Swedish_CI_AS' - InstallSharedDir = 'C:\Program Files\Microsoft SQL Server' - InstallSharedWOWDir = 'C:\Program Files (x86)\Microsoft SQL Server' - UpdateEnabled = 'False' - SuppressReboot = $true # Make sure we don't reboot during testing. - ForceReboot = $false - - # Properties for mounting media - ImagePath = "$env:TEMP\SQL2016.iso" - DriveLetter = $mockIsoMediaDriveLetter - - # Parameters to configure Tempdb - SqlTempdbFileCount = '2' - SqlTempdbFileSize = '128' - SqlTempdbFileGrowth = '128' - SqlTempdbLogFileSize = '128' - SqlTempdbLogFileGrowth = '128' - - SqlInstallAccountUserName = "$env:COMPUTERNAME\SqlInstall" - SqlInstallAccountPassword = 'P@ssw0rd1' - SqlAdministratorAccountUserName = "$env:COMPUTERNAME\SqlAdmin" - SqlAdministratorAccountPassword = 'P@ssw0rd1' - SqlServicePrimaryAccountUserName = "$env:COMPUTERNAME\svc-SqlPrimary" - SqlServicePrimaryAccountPassword = 'yig-C^Equ3' - SqlAgentServicePrimaryAccountUserName = "$env:COMPUTERNAME\svc-SqlAgentPri" - SqlAgentServicePrimaryAccountPassword = 'yig-C^Equ3' - SqlServiceSecondaryAccountUserName = "$env:COMPUTERNAME\svc-SqlSecondary" - SqlServiceSecondaryAccountPassword = 'yig-C^Equ3' - SqlAgentServiceSecondaryAccountUserName = "$env:COMPUTERNAME\svc-SqlAgentSec" - SqlAgentServiceSecondaryAccountPassword = 'yig-C^Equ3' - - CertificateFile = $env:DscPublicCertificatePath - } - ) - } -} - -<# - Creating all the credential objects to save some repeating code. -#> - -$SqlInstallCredential = New-Object ` - -TypeName System.Management.Automation.PSCredential ` - -ArgumentList @($ConfigurationData.AllNodes.SqlInstallAccountUserName, - (ConvertTo-SecureString -String $ConfigurationData.AllNodes.SqlInstallAccountPassword -AsPlainText -Force)) - -$SqlAdministratorCredential = New-Object ` - -TypeName System.Management.Automation.PSCredential ` - -ArgumentList @($ConfigurationData.AllNodes.SqlAdministratorAccountUserName, - (ConvertTo-SecureString -String $ConfigurationData.AllNodes.SqlAdministratorAccountPassword -AsPlainText -Force)) - -$SqlServicePrimaryCredential = New-Object ` - -TypeName System.Management.Automation.PSCredential ` - -ArgumentList @($ConfigurationData.AllNodes.SqlServicePrimaryAccountUserName, - (ConvertTo-SecureString -String $ConfigurationData.AllNodes.SqlServicePrimaryAccountPassword -AsPlainText -Force)) - -$SqlAgentServicePrimaryCredential = New-Object ` - -TypeName System.Management.Automation.PSCredential ` - -ArgumentList @($ConfigurationData.AllNodes.SqlAgentServicePrimaryAccountUserName, - (ConvertTo-SecureString -String $ConfigurationData.AllNodes.SqlAgentServicePrimaryAccountPassword -AsPlainText -Force)) - -$SqlServiceSecondaryCredential = New-Object ` - -TypeName System.Management.Automation.PSCredential ` - -ArgumentList @( - $ConfigurationData.AllNodes.SqlServiceSecondaryAccountUserName, - (ConvertTo-SecureString -String $ConfigurationData.AllNodes.SqlServiceSecondaryAccountPassword -AsPlainText -Force)) - -$SqlAgentServiceSecondaryCredential = New-Object ` - -TypeName System.Management.Automation.PSCredential ` - -ArgumentList @($ConfigurationData.AllNodes.SqlAgentServiceSecondaryAccountUserName, - (ConvertTo-SecureString -String $ConfigurationData.AllNodes.SqlAgentServiceSecondaryAccountPassword -AsPlainText -Force)) - -<# - .SYNOPSIS - Setting up the dependencies to test installing SQL Server instances. -#> -Configuration MSFT_SqlSetup_CreateDependencies_Config -{ - Import-DscResource -ModuleName 'PSDscResources' - Import-DscResource -ModuleName 'StorageDsc' - - node $AllNodes.NodeName - { - MountImage 'MountIsoMedia' - { - ImagePath = $Node.ImagePath - DriveLetter = $Node.DriveLetter - Ensure = 'Present' - } - - WaitForVolume WaitForMountOfIsoMedia - { - DriveLetter = $Node.DriveLetter - RetryIntervalSec = 5 - RetryCount = 10 - } - - User 'CreateSqlServicePrimaryAccount' - { - Ensure = 'Present' - UserName = Split-Path -Path $SqlServicePrimaryCredential.UserName -Leaf - Password = $SqlServicePrimaryCredential - } - - User 'CreateSqlAgentServicePrimaryAccount' - { - Ensure = 'Present' - UserName = Split-Path -Path $SqlAgentServicePrimaryCredential.UserName -Leaf - Password = $SqlAgentServicePrimaryCredential - } - - User 'CreateSqlServiceSecondaryAccount' - { - Ensure = 'Present' - UserName = Split-Path -Path $SqlServiceSecondaryCredential.UserName -Leaf - Password = $SqlServicePrimaryCredential - } - - User 'CreateSqlAgentServiceSecondaryAccount' - { - Ensure = 'Present' - UserName = Split-Path -Path $SqlAgentServiceSecondaryCredential.UserName -Leaf - Password = $SqlAgentServicePrimaryCredential - } - - User 'CreateSqlInstallAccount' - { - Ensure = 'Present' - UserName = Split-Path -Path $SqlInstallCredential.UserName -Leaf - Password = $SqlInstallCredential - } - - Group 'AddSqlInstallAsAdministrator' - { - Ensure = 'Present' - GroupName = 'Administrators' - MembersToInclude = Split-Path -Path $SqlInstallCredential.UserName -Leaf - } - - User 'CreateSqlAdminAccount' - { - Ensure = 'Present' - UserName = Split-Path -Path $SqlAdministratorCredential.UserName -Leaf - Password = $SqlAdministratorCredential - } - - WindowsFeature 'NetFramework45' - { - Name = 'NET-Framework-45-Core' - Ensure = 'Present' - } - } -} - -<# - .SYNOPSIS - Installs a named instance of Database Engine and Analysis Services. - - .NOTES - This is the instance that is used for many of the other integration tests. -#> -Configuration MSFT_SqlSetup_InstallDatabaseEngineNamedInstanceAsSystem_Config -{ - Import-DscResource -ModuleName 'SqlServerDsc' - - node $AllNodes.NodeName - { - SqlSetup 'Integration_Test' - { - InstanceName = $Node.DatabaseEngineNamedInstanceName - Features = $Node.DatabaseEngineNamedInstanceFeatures - SourcePath = "$($Node.DriveLetter):\" - SqlSvcStartupType = 'Automatic' - AgtSvcStartupType = 'Automatic' - BrowserSvcStartupType = 'Automatic' - SecurityMode = 'SQL' - SAPwd = $SqlAdministratorCredential - SQLCollation = $Node.Collation - SQLSvcAccount = $SqlServicePrimaryCredential - AgtSvcAccount = $SqlAgentServicePrimaryCredential - ASServerMode = $Node.AnalysisServicesMultiServerMode - AsSvcStartupType = 'Automatic' - ASCollation = $Node.Collation - ASSvcAccount = $SqlServicePrimaryCredential - InstallSharedDir = $Node.InstallSharedDir - InstallSharedWOWDir = $Node.InstallSharedWOWDir - UpdateEnabled = $Node.UpdateEnabled - SuppressReboot = $Node.SuppressReboot - ForceReboot = $Node.ForceReboot - SqlTempdbFileCount = $Node.SqlTempdbFileCount - SqlTempdbFileSize = $Node.SqlTempdbFileSize - SqlTempdbFileGrowth = $Node.SqlTempdbFileGrowth - SqlTempdbLogFileSize = $Node.SqlTempdbLogFileSize - SqlTempdbLogFileGrowth = $Node.SqlTempdbLogFileGrowth - - # This must be set if using SYSTEM account to install. - SQLSysAdminAccounts = @( - Split-Path -Path $SqlAdministratorCredential.UserName -Leaf - <# - Must have permission to properties IsClustered and - IsHadrEnable for SqlAlwaysOnService. - #> - Split-Path -Path $SqlInstallCredential.UserName -Leaf - ) - - # This must be set if using SYSTEM account to install. - ASSysAdminAccounts = @( - Split-Path -Path $SqlAdministratorCredential.UserName -Leaf - ) - } - } -} - -<# - .SYNOPSIS - Stopping the named instance to save memory on the build worker. - - .NOTES - The named instance is restarted at the end of the tests. -#> -Configuration MSFT_SqlSetup_StopServicesInstance_Config -{ - Import-DscResource -ModuleName 'PSDscResources' - - node $AllNodes.NodeName - { - <# - Stopping the SQL Server Agent service for the named instance. - It will be restarted at the end of the tests. - #> - Service ('StopSqlServerAgentForInstance{0}' -f $Node.DatabaseEngineNamedInstanceName) - { - Name = ('SQLAGENT${0}' -f $Node.DatabaseEngineNamedInstanceName) - State = 'Stopped' - } - - <# - Stopping the Database Engine named instance. It will be restarted - at the end of the tests. - #> - Service ('StopSqlServerInstance{0}' -f $Node.DatabaseEngineNamedInstanceName) - { - Name = ('MSSQL${0}' -f $Node.DatabaseEngineNamedInstanceName) - State = 'Stopped' - } - - Service ('StopMultiAnalysisServicesInstance{0}' -f $Node.DatabaseEngineNamedInstanceName) - { - Name = ('MSOLAP${0}' -f $Node.DatabaseEngineNamedInstanceName) - State = 'Stopped' - } - } -} - -<# - .SYNOPSIS - Installs a default instance of Database Engine. -#> -Configuration MSFT_SqlSetup_InstallDatabaseEngineDefaultInstanceAsUser_Config -{ - Import-DscResource -ModuleName 'SqlServerDsc' - - node $AllNodes.NodeName - { - SqlSetup 'Integration_Test' - { - InstanceName = $Node.DatabaseEngineDefaultInstanceName - Features = $Node.DatabaseEngineDefaultInstanceFeatures - SourcePath = "$($Node.DriveLetter):\" - SQLCollation = $Node.Collation - SQLSvcAccount = $SqlServicePrimaryCredential - AgtSvcAccount = $SqlAgentServicePrimaryCredential - InstallSharedDir = $Node.InstallSharedDir - InstallSharedWOWDir = $Node.InstallSharedWOWDir - UpdateEnabled = $Node.UpdateEnabled - SuppressReboot = $Node.SuppressReboot - ForceReboot = $Node.ForceReboot - SQLSysAdminAccounts = @( - Split-Path -Path $SqlAdministratorCredential.UserName -Leaf - ) - - PsDscRunAsCredential = $SqlInstallCredential - } - } -} - -<# - .SYNOPSIS - Stopping the default instance to save memory on the build worker. -#> -Configuration MSFT_SqlSetup_StopSqlServerDefaultInstance_Config -{ - Import-DscResource -ModuleName 'PSDscResources' - - node $AllNodes.NodeName - { - Service ('StopSqlServerAgentForInstance{0}' -f $Node.DatabaseEngineDefaultInstanceName) - { - Name = 'SQLSERVERAGENT' - State = 'Stopped' - } - - - Service ('StopSqlServerInstance{0}' -f $Node.DatabaseEngineDefaultInstanceName) - { - Name = $Node.DatabaseEngineDefaultInstanceName - State = 'Stopped' - } - } -} - -<# - .SYNOPSIS - Installs a named instance of Analysis Services in tabular mode. -#> -Configuration MSFT_SqlSetup_InstallTabularAnalysisServicesAsSystem_Config -{ - Import-DscResource -ModuleName 'SqlServerDsc' - - node $AllNodes.NodeName - { - SqlSetup 'Integration_Test' - { - InstanceName = $Node.AnalysisServicesTabularInstanceName - Features = $Node.AnalysisServicesTabularFeatures - SourcePath = "$($Node.DriveLetter):\" - ASServerMode = $Node.AnalysisServicesTabularServerMode - ASCollation = $Node.Collation - ASSvcAccount = $SqlServicePrimaryCredential - InstallSharedDir = $Node.InstallSharedDir - InstallSharedWOWDir = $Node.InstallSharedWOWDir - UpdateEnabled = $Node.UpdateEnabled - SuppressReboot = $Node.SuppressReboot - ForceReboot = $Node.ForceReboot - - # This must be set if using SYSTEM account to install. - ASSysAdminAccounts = @( - Split-Path -Path $SqlAdministratorCredential.UserName -Leaf - ) - } - } -} - -<# - .SYNOPSIS - Stopping the Analysis Services tabular named instance to save memory on - the build worker. -#> -Configuration MSFT_SqlSetup_StopTabularAnalysisServices_Config -{ - Import-DscResource -ModuleName 'PSDscResources' - - node $AllNodes.NodeName - { - Service ('StopTabularAnalysisServicesInstance{0}' -f $Node.AnalysisServicesTabularInstanceName) - { - Name = ('MSOLAP${0}' -f $Node.DatabaseEngineNamedInstanceName) - State = 'Stopped' - } - } -} - -<# - .SYNOPSIS - Restarting the Database Engine named instance. - - .NOTES - This is so that other integration tests are dependent on this - named instance. -#> -Configuration MSFT_SqlSetup_StartServicesInstance_Config -{ - Import-DscResource -ModuleName 'PSDscResources' - - node $AllNodes.NodeName - { - # Start the Database Engine named instance. - Service ('StartSqlServerInstance{0}' -f $Node.DatabaseEngineNamedInstanceName) - { - Name = ('MSSQL${0}' -f $Node.DatabaseEngineNamedInstanceName) - State = 'Running' - } - - # Starting the SQL Server Agent service for the named instance. - Service ('StartSqlServerAgentForInstance{0}' -f $Node.DatabaseEngineNamedInstanceName) - { - Name = ('SQLAGENT${0}' -f $Node.DatabaseEngineNamedInstanceName) - State = 'Running' - } - } -} diff --git a/Tests/TestHelpers/CommonTestHelper.psm1 b/Tests/TestHelpers/CommonTestHelper.psm1 index f81ac7514..6eee6a16a 100644 --- a/Tests/TestHelpers/CommonTestHelper.psm1 +++ b/Tests/TestHelpers/CommonTestHelper.psm1 @@ -299,6 +299,11 @@ function New-SQLSelfSignedCertificate .PARAMETER Type Type of tests in the test file. Can be set to Unit or Integration. + + .PARAMETER Category + Optional. One or more categories to check if they are set in + $env:CONFIGURATION. If this are not set, the parameter Type + is used as category. #> function Test-SkipContinuousIntegrationTask { @@ -343,3 +348,33 @@ function Test-SkipContinuousIntegrationTask return $result } + +<# + .SYNOPSIS + Returns $true if the the environment variable APPVEYOR is set to $true, + and the environment variable CONFIGURATION is set to the value passed + in the parameter Type. + + .PARAMETER Category + One or more categories to check if they are set in $env:CONFIGURATION. +#> +function Test-ContinuousIntegrationTaskCategory +{ + [OutputType([System.Boolean])] + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + [System.String[]] + $Category + ) + + $result = $false + + if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -in $Category) + { + $result = $true + } + + return $result +}