Skip to content

Commit

Permalink
Update integ tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johlju committed May 9, 2024
1 parent 6114dfb commit c8be949
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ Describe 'Install-SqlDscServer' -Tag @('Integration_SQL2016', 'Integration_SQL20
InstanceName = 'MSSQLSERVER'
Features = 'SQLENGINE'
SqlSysAdminAccounts = @('MyAdminAccount')
MediaPath = 'E:\'
MediaPath = (Join-Path -Path $env:TEMP -ChildPath 'media.iso')
Verbose = $true
ErrorAction = 'Stop'
}

# Install-SqlDscServer @installSqlDscServerParameters
Install-SqlDscServer @installSqlDscServerParameters
} | Should -Not -Throw
}
}
Expand Down
47 changes: 39 additions & 8 deletions tests/Integration/Commands/Prerequisites.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,48 +29,48 @@ Describe 'Prerequisites' -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'I
$password = ConvertTo-SecureString -String 'P@ssw0rd1' -AsPlainText -Force
}

It 'Creates SqlInstall user' {
It 'Should create SqlInstall user' {
$user = New-LocalUser -Name 'SqlInstall' -Password $password -FullName 'SQL Install User' -Description 'User for SQL installation.'

$user.Name | Should -Be 'SqlInstall'
(Get-LocalUser -Name 'SqlInstall').Name | Should -Be 'SqlInstall'
}

It 'Creates SqlAdmin user' {
It 'Should create SqlAdmin user' {
$user = New-LocalUser -Name 'SqlAdmin' -Password $password -FullName 'SQL Admin User' -Description 'User for SQL administration.'

$user.Name | Should -Be 'SqlAdmin'
(Get-LocalUser -Name 'SqlAdmin').Name | Should -Be 'SqlAdmin'
}
}

Context 'Create required local Windows service accounts' {
Context 'Should create required local Windows service accounts' {
BeforeAll {
$password = ConvertTo-SecureString -String 'yig-C^Equ3' -AsPlainText -Force
}

It 'Creates svc-SqlPrimary user' {
It 'Should create svc-SqlPrimary user' {
$user = New-LocalUser -Name 'svc-SqlPrimary' -Password $password -FullName 'svc-SqlPrimary' -Description 'Runs the SQL Server service.'

$user.Name | Should -Be 'svc-SqlPrimary'
(Get-LocalUser -Name 'svc-SqlPrimary').Name | Should -Be 'svc-SqlPrimary'
}

It 'Creates svc-SqlAgentPri user' {
It 'Should create svc-SqlAgentPri user' {
$user = New-LocalUser -Name 'svc-SqlAgentPri' -Password $password -FullName 'svc-SqlAgentPri' -Description 'Runs the SQL Server Agent service.'

$user.Name | Should -Be 'svc-SqlAgentPri'
(Get-LocalUser -Name 'svc-SqlAgentPri').Name | Should -Be 'svc-SqlAgentPri'
}

It 'Creates svc-SqlSecondary user' {
It 'Should create svc-SqlSecondary user' {
$user = New-LocalUser -Name 'svc-SqlSecondary' -Password $password -FullName 'svc-SqlSecondary' -Description 'Runs the SQL Server service.'

$user.Name | Should -Be 'svc-SqlSecondary'
(Get-LocalUser -Name 'svc-SqlSecondary').Name | Should -Be 'svc-SqlSecondary'
}

It 'Creates svc-SqlAgentSec user' {
It 'Should create svc-SqlAgentSec user' {
$user = New-LocalUser -Name 'svc-SqlAgentSec' -Password $password -FullName 'svc-SqlAgentSec' -Description 'Runs the SQL Server Agent service.'

$user.Name | Should -Be 'svc-SqlAgentSec'
Expand All @@ -79,7 +79,7 @@ Describe 'Prerequisites' -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'I
}

Context 'Add local Windows users to local groups' {
It 'Adds SqlInstall to local administrator group' {
It 'Should add SqlInstall to local administrator group' {
# Add user to local administrator group
Add-LocalGroupMember -Group 'Administrators' -Member 'SqlInstall'

Expand All @@ -91,5 +91,36 @@ Describe 'Prerequisites' -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'I
}

Context 'Download correct SQL Server media' {
It 'Should download SQL Server 2016 media' -Tag @('Integration_SQL2016') {
$url = 'https://download.microsoft.com/download/9/0/7/907AD35F-9F9C-43A5-9789-52470555DB90/ENU/SQLServer2016SP1-FullSlipstream-x64-ENU.iso'

$mediaFile = Save-SqlDscSqlServerMedia -Url $url -DestinationPath $env:TEMP -Force -Quiet -ErrorAction 'Stop'

$mediaFile.Name | Should -Be 'media.iso'
}

It 'Should download SQL Server 2017 media' -Tag @('Integration_SQL2017') {
$url = 'https://download.microsoft.com/download/E/F/2/EF23C21D-7860-4F05-88CE-39AA114B014B/SQLServer2017-x64-ENU.iso'

$mediaFile = Save-SqlDscSqlServerMedia -Url $url -DestinationPath $env:TEMP -Force -Quiet -ErrorAction 'Stop'

$mediaFile.Name | Should -Be 'media.iso'
}

It 'Should download SQL Server 2019 media' -Tag @('Integration_SQL2019') {
$url = 'https://download.microsoft.com/download/d/a/2/da259851-b941-459d-989c-54a18a5d44dd/SQL2019-SSEI-Dev.exe'

$mediaFile = Save-SqlDscSqlServerMedia -Url $url -DestinationPath $env:TEMP -Force -Quiet -ErrorAction 'Stop'

$mediaFile.Name | Should -Be 'media.iso'
}

It 'Should download SQL Server 2022 media' -Tag @('Integration_SQL2022') {
$url = 'https://download.microsoft.com/download/c/c/9/cc9c6797-383c-4b24-8920-dc057c1de9d3/SQL2022-SSEI-Dev.exe'

$mediaFile = Save-SqlDscSqlServerMedia -Url $url -DestinationPath $env:TEMP -Force -Quiet -ErrorAction 'Stop'

$mediaFile.Name | Should -Be 'media.iso'
}
}
}

0 comments on commit c8be949

Please sign in to comment.