Skip to content

Commit fa86dec

Browse files
committed
add scenario multi
1 parent 7a7af44 commit fa86dec

File tree

4 files changed

+21
-26
lines changed

4 files changed

+21
-26
lines changed

appveyor.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ environment:
5656
- scenario: 2016_2017
5757
main_instance: localhost\SQL2017,localhost\SQL2016
5858
setup_scripts: \tests\appveyor.SQL2017.ps1,\tests\appveyor.SQL2016.ps1
59+
- scenario: MULTI
60+
main_instance: localhost\SQL2017,localhost\SQL2016
61+
setup_scripts: \tests\appveyor.SQL2017.ps1,\tests\appveyor.SQL2016.ps1
5962
- scenario: COPY
6063
main_instance: localhost\SQL2017,localhost\SQL2016
6164
setup_scripts: \tests\appveyor.SQL2017.ps1,\tests\appveyor.SQL2016.ps1

private/testing/Get-TestConfig.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ function Get-TestConfig {
5959
$config['Instance2'] = "$(hostname)\sql2016"
6060
$config['Instance3'] = "$(hostname)\sql2017"
6161
$config['Instances'] = @($config['Instance1'], $config['Instance2'])
62+
$config['InstanceMulti1'] = "$(hostname)\sql2016"
63+
$config['InstanceMulti2'] = "$(hostname)\sql2017"
6264
$config['InstanceCopy1'] = "$(hostname)\sql2016"
6365
$config['InstanceCopy2'] = "$(hostname)\sql2017"
6466
$config['InstanceHadr'] = "$(hostname)\sql2017"

tests/Set-DbaStartupParameter.Tests.ps1

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,51 +39,39 @@ Describe $CommandName -Tag UnitTests {
3939
}
4040

4141
Describe $CommandName -Tag IntegrationTests {
42-
BeforeAll {
43-
# We want to run all commands in the BeforeAll block with EnableException to ensure that the test fails if the setup fails.
44-
$PSDefaultParameterValues["*-Dba*:EnableException"] = $true
45-
46-
$defaultInstance = $TestConfig.instance1
47-
$namedInstance = $TestConfig.instance2
48-
$SkipLocalTest = $true # Change to $false to run the tests on a local instance.
49-
50-
# We want to run all commands outside of the BeforeAll block without EnableException to be able to test for specific warnings.
51-
$PSDefaultParameterValues.Remove("*-Dba*:EnableException")
52-
}
53-
5442
Context "Validate command functionality" {
5543
# See https://github.com/dataplat/dbatools/issues/7035
56-
It -Skip:$SkipLocalTest "Ensure the startup params are not duplicated when more than one server is modified in the same invocation" {
44+
It "Ensure the startup params are not duplicated when more than one server is modified in the same invocation" {
5745
$splatSetStartup = @{
58-
SqlInstance = $defaultInstance, $namedInstance
46+
SqlInstance = $TestConfig.instanceMulti1, $TestConfig.instanceMulti2
5947
TraceFlag = 3226
6048
}
6149
$result = Set-DbaStartupParameter @splatSetStartup
6250

63-
$resultDefaultInstance = Get-DbaStartupParameter -SqlInstance $defaultInstance
64-
$resultDefaultInstance.TraceFlags.Count | Should -Be 1
65-
$resultDefaultInstance.TraceFlags[0] | Should -Be 3226
51+
$result1 = Get-DbaStartupParameter -SqlInstance $TestConfig.instanceMulti1
52+
$result1.TraceFlags.Count | Should -Be 1
53+
$result1.TraceFlags[0] | Should -Be 3226
6654

6755
# The duplication occurs after the first server is processed.
68-
$resultNamedInstance = Get-DbaStartupParameter -SqlInstance $namedInstance
56+
$result2 = Get-DbaStartupParameter -SqlInstance $TestConfig.instanceMulti2
6957
# Using the defaults to test locally
70-
$resultNamedInstance.MasterData.Count | Should -Be 1
71-
$resultNamedInstance.MasterLog.Count | Should -Be 1
72-
$resultNamedInstance.ErrorLog.Count | Should -Be 1
58+
$result2.MasterData.Count | Should -Be 1
59+
$result2.MasterLog.Count | Should -Be 1
60+
$result2.ErrorLog.Count | Should -Be 1
7361

74-
$resultNamedInstance.TraceFlags.Count | Should -Be 1
75-
$resultNamedInstance.TraceFlags[0] | Should -Be 3226
62+
$result2.TraceFlags.Count | Should -Be 1
63+
$result2.TraceFlags[0] | Should -Be 3226
7664
}
7765

7866
# See https://github.com/dataplat/dbatools/issues/7035
79-
It -Skip:$SkipLocalTest "Ensure the correct instance name is returned" {
67+
It "Ensure the correct instance name is returned" {
8068
$splatSetInstance = @{
81-
SqlInstance = $namedInstance
69+
SqlInstance = $TestConfig.instanceMulti1
8270
TraceFlag = 3226
8371
}
8472
$result = Set-DbaStartupParameter @splatSetInstance
8573

86-
$result.SqlInstance | Should -Be $namedInstance
74+
$result.SqlInstance | Should -Be $TestConfig.instanceMulti1
8775
$result.TraceFlags.Count | Should -Be 1
8876
$result.TraceFlags[0] | Should -Be 3226
8977
}

tests/pester.groups.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ $TestsRunGroups = @{
77
"2016" = 'autodetect_$TestConfig.instance2'
88
# run on scenario 2016_2017 - tests that need developer license
99
"2016_2017" = 'autodetect_$TestConfig.instance2,$TestConfig.instance3'
10+
# run on scenario MULTI - tests that need multiple instances
11+
"MULTI" = 'autodetect_$TestConfig.instanceMulti'
1012
# run on scenario COPY - tests that need to copy between instances
1113
"COPY" = 'autodetect_$TestConfig.instanceCopy'
1214
# run on scenario HADR - tests that need AGs, mirroring, logshipping

0 commit comments

Comments
 (0)