Skip to content

Commit dc3e796

Browse files
Test Improvements: Move last tests to new scenarios (#10100)
1 parent ab01603 commit dc3e796

387 files changed

Lines changed: 2657 additions & 2696 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

appveyor.yml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,33 +47,24 @@ environment:
4747
appveyor_rdp_password: 2odCuiKmYiem
4848

4949
matrix:
50-
- scenario: 2008R2
51-
main_instance: localhost\SQL2008R2SP2
52-
setup_scripts: \tests\appveyor.SQL2008R2SP2.ps1
53-
- scenario: 2016
54-
main_instance: localhost\SQL2016
50+
- scenario: SINGLE
51+
part: 1/3
5552
setup_scripts: \tests\appveyor.SQL2016.ps1
56-
- scenario: 2016_2017
57-
main_instance: localhost\SQL2017,localhost\SQL2016
58-
setup_scripts: \tests\appveyor.SQL2017.ps1,\tests\appveyor.SQL2016.ps1
5953
- scenario: SINGLE
60-
main_instance: localhost\SQL2017
61-
setup_scripts: \tests\appveyor.SQL2017.ps1
54+
part: 2/3
55+
setup_scripts: \tests\appveyor.SQL2016.ps1
56+
- scenario: SINGLE
57+
part: 3/3
58+
setup_scripts: \tests\appveyor.SQL2016.ps1
6259
- scenario: MULTI
63-
main_instance: localhost\SQL2017,localhost\SQL2016
6460
setup_scripts: \tests\appveyor.SQL2017.ps1,\tests\appveyor.SQL2016.ps1
6561
- scenario: COPY
66-
main_instance: localhost\SQL2017,localhost\SQL2016
6762
setup_scripts: \tests\appveyor.SQL2017.ps1,\tests\appveyor.SQL2016.ps1
6863
- scenario: HADR
69-
main_instance: localhost\SQL2017
7064
setup_scripts: \tests\appveyor.SQL2017.ps1
7165
- scenario: RESTART
72-
main_instance: localhost\SQL2017
7366
setup_scripts: \tests\appveyor.SQL2017.ps1
7467
- scenario: default
75-
main_instance: localhost\SQL2008R2SP2,localhost\SQL2016
76-
setup_scripts: \tests\appveyor.SQL2008R2SP2.ps1,\tests\appveyor.SQL2016.ps1
7768

7869
# Set alternative clone folder
7970
clone_folder: c:\github\dbatools

private/testing/Get-TestConfig.ps1

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ function Get-TestConfig {
5050
# This configuration is used for the automated test on AppVeyor
5151
$config['DbaToolsCi_Computer'] = "$(hostname)"
5252

53-
$config['Instance1'] = "$(hostname)\sql2008r2sp2"
54-
$config['Instance2'] = "$(hostname)\sql2016"
55-
$config['InstanceSingle'] = "$(hostname)\sql2017"
53+
$config['InstanceSingle'] = "$(hostname)\sql2016"
5654
$config['InstanceMulti1'] = "$(hostname)\sql2016"
5755
$config['InstanceMulti2'] = "$(hostname)\sql2017"
5856
$config['InstanceCopy1'] = "$(hostname)\sql2016"

tests/Add-DbaDbMirrorMonitor.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ Describe $CommandName -Tag UnitTests {
2323
Describe $CommandName -Tag IntegrationTests {
2424
Context "When adding mirror monitor" {
2525
AfterAll {
26-
$null = Remove-DbaDbMirrorMonitor -SqlInstance $TestConfig.instance2
26+
$null = Remove-DbaDbMirrorMonitor -SqlInstance $TestConfig.InstanceSingle
2727
}
2828

2929
It "Adds the mirror monitor" {
30-
$results = Add-DbaDbMirrorMonitor -SqlInstance $TestConfig.instance2
30+
$results = Add-DbaDbMirrorMonitor -SqlInstance $TestConfig.InstanceSingle
3131
$results.MonitorStatus | Should -Be "Added"
3232
}
3333
}

tests/Add-DbaExtendedProperty.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Describe $CommandName -Tag IntegrationTests {
3434
$newDbName = "dbatoolsci_newdb_$random"
3535

3636
# Connect to instance and clean up any existing connections
37-
$server2 = Connect-DbaInstance -SqlInstance $TestConfig.instance2
37+
$server2 = Connect-DbaInstance -SqlInstance $TestConfig.InstanceSingle
3838
$null = Get-DbaProcess -SqlInstance $server2 | Where-Object Program -match dbatools | Stop-DbaProcess -WarningAction SilentlyContinue
3939

4040
# Create test database

tests/Add-DbaPfDataCollectorCounter.Tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Describe $CommandName -Tag IntegrationTests {
2929
$PSDefaultParameterValues["*-Dba*:EnableException"] = $true
3030

3131
$null = Get-DbaPfDataCollectorSetTemplate -Template "Long Running Queries" |
32-
Import-DbaPfDataCollectorSetTemplate -ComputerName $TestConfig.instance1 |
32+
Import-DbaPfDataCollectorSetTemplate -ComputerName $TestConfig.InstanceSingle |
3333
Get-DbaPfDataCollector |
3434
Get-DbaPfDataCollectorCounter -Counter "\LogicalDisk(*)\Avg. Disk Queue Length" |
3535
Remove-DbaPfDataCollectorCounter
@@ -40,15 +40,15 @@ Describe $CommandName -Tag IntegrationTests {
4040
AfterAll {
4141
$PSDefaultParameterValues["*-Dba*:EnableException"] = $true
4242

43-
$null = Get-DbaPfDataCollectorSet -ComputerName $TestConfig.instance1 -CollectorSet "Long Running Queries" |
43+
$null = Get-DbaPfDataCollectorSet -ComputerName $TestConfig.InstanceSingle -CollectorSet "Long Running Queries" |
4444
Remove-DbaPfDataCollectorSet
4545

4646
$PSDefaultParameterValues.Remove("*-Dba*:EnableException")
4747
}
4848

4949
Context "When adding a counter to a data collector" {
5050
BeforeAll {
51-
$results = Get-DbaPfDataCollectorSet -ComputerName $TestConfig.instance1 -CollectorSet "Long Running Queries" |
51+
$results = Get-DbaPfDataCollectorSet -ComputerName $TestConfig.InstanceSingle -CollectorSet "Long Running Queries" |
5252
Get-DbaPfDataCollector |
5353
Add-DbaPfDataCollectorCounter -Counter "\LogicalDisk(*)\Avg. Disk Queue Length"
5454
}

tests/Add-DbaRegServerGroup.Tests.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ Describe $CommandName -Tag IntegrationTests {
4444
$PSDefaultParameterValues["*-Dba*:EnableException"] = $true
4545

4646
# Cleanup all created objects.
47-
Get-DbaRegServerGroup -SqlInstance $TestConfig.instance1 | Where-Object Name -match dbatoolsci | Remove-DbaRegServerGroup
47+
Get-DbaRegServerGroup -SqlInstance $TestConfig.InstanceSingle | Where-Object Name -match dbatoolsci | Remove-DbaRegServerGroup
4848

4949
$PSDefaultParameterValues.Remove("*-Dba*:EnableException")
5050
}
5151

5252
Context "When adding a registered server group" {
5353
It "adds a registered server group" {
5454
$splatAddGroup = @{
55-
SqlInstance = $TestConfig.instance1
55+
SqlInstance = $TestConfig.InstanceSingle
5656
Name = $group
5757
}
5858
$results = Add-DbaRegServerGroup @splatAddGroup
@@ -62,7 +62,7 @@ Describe $CommandName -Tag IntegrationTests {
6262

6363
It "adds a registered server group with extended properties" {
6464
$splatAddGroupExtended = @{
65-
SqlInstance = $TestConfig.instance1
65+
SqlInstance = $TestConfig.InstanceSingle
6666
Name = $group2
6767
Description = $description
6868
}
@@ -75,7 +75,7 @@ Describe $CommandName -Tag IntegrationTests {
7575

7676
Context "When using pipeline input" {
7777
It "supports pipeline input" {
78-
$results = Get-DbaRegServerGroup -SqlInstance $TestConfig.instance1 -Id 1 |
78+
$results = Get-DbaRegServerGroup -SqlInstance $TestConfig.InstanceSingle -Id 1 |
7979
Add-DbaRegServerGroup -Name dbatoolsci-first |
8080
Add-DbaRegServerGroup -Name dbatoolsci-second |
8181
Add-DbaRegServerGroup -Name dbatoolsci-third |
@@ -87,7 +87,7 @@ Describe $CommandName -Tag IntegrationTests {
8787
Context "When adding nested groups" {
8888
It "adds a registered server group and sub-group when not exists" {
8989
$splatAddNested = @{
90-
SqlInstance = $TestConfig.instance1
90+
SqlInstance = $TestConfig.InstanceSingle
9191
Name = "$group\$group2"
9292
Description = $description
9393
}
@@ -98,7 +98,7 @@ Describe $CommandName -Tag IntegrationTests {
9898

9999
It "updates description of sub-group when it already exists" {
100100
$splatUpdateNested = @{
101-
SqlInstance = $TestConfig.instance1
101+
SqlInstance = $TestConfig.InstanceSingle
102102
Name = "$group\$group2"
103103
Description = $descriptionUpdated
104104
}

tests/Add-DbaServerRoleMember.Tests.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Describe $CommandName -Tag IntegrationTests {
2929
# We want to run all commands in the BeforeAll block with EnableException to ensure that the test fails if the setup fails.
3030
$PSDefaultParameterValues["*-Dba*:EnableException"] = $true
3131

32-
$server = Connect-DbaInstance -SqlInstance $TestConfig.instance2
32+
$server = Connect-DbaInstance -SqlInstance $TestConfig.InstanceSingle
3333
$login1 = "dbatoolsci_login1_$(Get-Random)"
3434
$login2 = "dbatoolsci_login2_$(Get-Random)"
3535
$customServerRole = "dbatoolsci_customrole_$(Get-Random)"
@@ -38,12 +38,12 @@ Describe $CommandName -Tag IntegrationTests {
3838
"processadmin"
3939
)
4040
$splatNewLogin = @{
41-
SqlInstance = $TestConfig.instance2
41+
SqlInstance = $TestConfig.InstanceSingle
4242
Password = ("Password1234!" | ConvertTo-SecureString -asPlainText -Force)
4343
}
4444
$null = New-DbaLogin @splatNewLogin -Login $login1
4545
$null = New-DbaLogin @splatNewLogin -Login $login2
46-
$null = New-DbaServerRole -SqlInstance $TestConfig.instance2 -ServerRole $customServerRole -Owner sa
46+
$null = New-DbaServerRole -SqlInstance $TestConfig.InstanceSingle -ServerRole $customServerRole -Owner sa
4747

4848
# We want to run all commands outside of the BeforeAll block without EnableException to be able to test for specific warnings.
4949
$PSDefaultParameterValues.Remove("*-Dba*:EnableException")
@@ -53,19 +53,19 @@ Describe $CommandName -Tag IntegrationTests {
5353
$PSDefaultParameterValues["*-Dba*:EnableException"] = $true
5454

5555
$splatRemoveLogin = @{
56-
SqlInstance = $TestConfig.instance2
56+
SqlInstance = $TestConfig.InstanceSingle
5757
Login = $login1, $login2
5858
}
5959
$null = Remove-DbaLogin @splatRemoveLogin
60-
$null = Remove-DbaServerRole -SqlInstance $TestConfig.instance2 -ServerRole $customServerRole -Confirm:$false
60+
$null = Remove-DbaServerRole -SqlInstance $TestConfig.InstanceSingle -ServerRole $customServerRole -Confirm:$false
6161

6262
$PSDefaultParameterValues.Remove("*-Dba*:EnableException")
6363
}
6464

6565
Context "Functionality" {
6666
It "Adds Login to Role" {
6767
$splatAddRole = @{
68-
SqlInstance = $TestConfig.instance2
68+
SqlInstance = $TestConfig.InstanceSingle
6969
ServerRole = $fixedServerRoles[0]
7070
Login = $login1
7171
}
@@ -79,7 +79,7 @@ Describe $CommandName -Tag IntegrationTests {
7979
It "Adds Login to Multiple Roles" {
8080
$serverRoles = Get-DbaServerRole -SqlInstance $server -ServerRole $fixedServerRoles
8181
$splatAddRoles = @{
82-
SqlInstance = $TestConfig.instance2
82+
SqlInstance = $TestConfig.InstanceSingle
8383
ServerRole = $serverRoles
8484
Login = $login1
8585
}
@@ -92,7 +92,7 @@ Describe $CommandName -Tag IntegrationTests {
9292

9393
It "Adds Customer Server-Level Role Membership" {
9494
$splatAddCustomRole = @{
95-
SqlInstance = $TestConfig.instance2
95+
SqlInstance = $TestConfig.InstanceSingle
9696
ServerRole = $customServerRole
9797
Role = $fixedServerRoles[-1]
9898
}

tests/Backup-DbaDbCertificate.Tests.ps1

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ Describe $CommandName -Tag IntegrationTests {
4545
$db2Name = "dbatoolscli_db2_$random"
4646
$pw = ConvertTo-SecureString -String "GoodPass1234!" -AsPlainText -Force
4747

48-
$db1 = New-DbaDatabase -SqlInstance $TestConfig.instance1 -Name $db1Name
49-
$null = New-DbaDbMasterKey -SqlInstance $TestConfig.instance1 -Database $db1Name -Password $pw
48+
$db1 = New-DbaDatabase -SqlInstance $TestConfig.InstanceSingle -Name $db1Name
49+
$null = New-DbaDbMasterKey -SqlInstance $TestConfig.InstanceSingle -Database $db1Name -Password $pw
5050

51-
$db2 = New-DbaDatabase -SqlInstance $TestConfig.instance1 -Name $db2Name
52-
$null = New-DbaDbMasterKey -SqlInstance $TestConfig.instance1 -Database $db2Name -Password $pw
51+
$db2 = New-DbaDatabase -SqlInstance $TestConfig.InstanceSingle -Name $db2Name
52+
$null = New-DbaDbMasterKey -SqlInstance $TestConfig.InstanceSingle -Database $db2Name -Password $pw
5353

54-
$cert1 = New-DbaDbCertificate -SqlInstance $TestConfig.instance1 -Database $db1Name -Password $pw -Name "dbatoolscli_cert1_$random"
55-
$cert2 = New-DbaDbCertificate -SqlInstance $TestConfig.instance1 -Database $db1Name -Password $pw -Name "dbatoolscli_cert2_$random"
56-
$cert3 = New-DbaDbCertificate -SqlInstance $TestConfig.instance1 -Database $db2Name -Password $pw -Name "dbatoolscli_cert3_$random"
54+
$cert1 = New-DbaDbCertificate -SqlInstance $TestConfig.InstanceSingle -Database $db1Name -Password $pw -Name "dbatoolscli_cert1_$random"
55+
$cert2 = New-DbaDbCertificate -SqlInstance $TestConfig.InstanceSingle -Database $db1Name -Password $pw -Name "dbatoolscli_cert2_$random"
56+
$cert3 = New-DbaDbCertificate -SqlInstance $TestConfig.InstanceSingle -Database $db2Name -Password $pw -Name "dbatoolscli_cert3_$random"
5757

5858
# We want to run all commands outside of the BeforeAll block without EnableException to be able to test for specific warnings.
5959
$PSDefaultParameterValues.Remove("*-Dba*:EnableException")
@@ -62,7 +62,7 @@ Describe $CommandName -Tag IntegrationTests {
6262
# We want to run all commands in the AfterAll block with EnableException to ensure that the test fails if the cleanup fails.
6363
$PSDefaultParameterValues["*-Dba*:EnableException"] = $true
6464

65-
Remove-DbaDatabase -SqlInstance $TestConfig.instance1 -Database $db1Name, $db2Name
65+
Remove-DbaDatabase -SqlInstance $TestConfig.InstanceSingle -Database $db1Name, $db2Name
6666

6767
# Remove the backup directory.
6868
Remove-Item -Path $backupPath -Recurse
@@ -73,7 +73,7 @@ Describe $CommandName -Tag IntegrationTests {
7373
Context "Can backup a database certificate" {
7474
It "Returns results with proper data" {
7575
$splatBackupCert = @{
76-
SqlInstance = $TestConfig.instance1
76+
SqlInstance = $TestConfig.InstanceSingle
7777
Database = $db1Name
7878
Certificate = $cert1.Name
7979
EncryptionPassword = $pw
@@ -90,7 +90,7 @@ Describe $CommandName -Tag IntegrationTests {
9090
Context "Can backup a database certificate with a filename (see #9485)" {
9191
It "Returns results with proper data" {
9292
$splatBackupCertWithName = @{
93-
SqlInstance = $TestConfig.instance1
93+
SqlInstance = $TestConfig.InstanceSingle
9494
Database = $db1Name
9595
Certificate = $cert1.Name
9696
EncryptionPassword = $pw
@@ -112,7 +112,7 @@ Describe $CommandName -Tag IntegrationTests {
112112
$invalidDBCertName = "dbatoolscli_invalidCertName"
113113
$invalidDBCertName2 = "dbatoolscli_invalidCertName2"
114114
$splatBackupInvalidCert = @{
115-
SqlInstance = $TestConfig.instance1
115+
SqlInstance = $TestConfig.InstanceSingle
116116
Database = $db1Name
117117
Certificate = @($invalidDBCertName, $invalidDBCertName2, $cert2.Name)
118118
EncryptionPassword = $pw
@@ -128,7 +128,7 @@ Describe $CommandName -Tag IntegrationTests {
128128
Context "Backs up all db certs for a database" {
129129
It "Returns results with proper data" {
130130
$splatBackupDbCerts = @{
131-
SqlInstance = $TestConfig.instance1
131+
SqlInstance = $TestConfig.InstanceSingle
132132
Database = $db1Name
133133
EncryptionPassword = $pw
134134
DecryptionPassword = $pw
@@ -143,7 +143,7 @@ Describe $CommandName -Tag IntegrationTests {
143143
Context "Backs up all db certs for an instance" {
144144
It "Returns results with proper data" {
145145
$splatBackupAllCerts = @{
146-
SqlInstance = $TestConfig.instance1
146+
SqlInstance = $TestConfig.InstanceSingle
147147
EncryptionPassword = $pw
148148
DecryptionPassword = $pw
149149
}

tests/Backup-DbaDbMasterKey.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Describe $CommandName -Tag IntegrationTests {
4343

4444
# Set variables. They are available in all the It blocks.
4545
$random = Get-Random
46-
$testInstance = $TestConfig.instance1
46+
$testInstance = $TestConfig.InstanceSingle
4747
$testDatabase = "dbatoolscli_db_$random"
4848
$masterKeyPass = ConvertTo-SecureString -String "GoodPass1234!" -AsPlainText -Force
4949

tests/Backup-DbaServiceMasterKey.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Describe $CommandName -Tag IntegrationTests {
6565

6666
It "backs up the SMK" {
6767
$splatBackup = @{
68-
SqlInstance = $TestConfig.instance1
68+
SqlInstance = $TestConfig.InstanceSingle
6969
SecurePassword = $securePassword
7070
Path = $backupPath
7171
}
@@ -77,7 +77,7 @@ Describe $CommandName -Tag IntegrationTests {
7777
It "backs up the SMK with a specific filename (see #9483)" {
7878
$randomNum = Get-Random
7979
$splatFileBackup = @{
80-
SqlInstance = $TestConfig.instance1
80+
SqlInstance = $TestConfig.InstanceSingle
8181
SecurePassword = $securePassword
8282
Path = $backupPath
8383
FileBaseName = "smk($randomNum)"

0 commit comments

Comments
 (0)