Skip to content

Commit db487be

Browse files
failsafe Operators
1 parent 9eb5111 commit db487be

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

source/checks/Agentv5.Tests.ps1

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,18 @@ Describe "SQL Agent Account" -Tag AgentServiceAccount, ServiceAccount -ForEach $
4848
$skipServiceState = Get-DbcConfigValue skip.agent.servicestate
4949
$skipServiceStartMode = Get-DbcConfigValue skip.agent.servicestartmode
5050

51-
# cant check agent on container - hmm does this actually work with instance need to check
52-
if (-not $IsLinux -and ($InstanceSMO.HostPlatform -ne 'Linux')) {
53-
Context "Testing SQL Agent is running on <_.Name>" {
54-
It "SQL Agent should be running for <_.InstanceName> on <_.Name>" -Skip:$skipServiceState {
55-
$PSItem.Agent.State | Should -Be "Running" -Because 'The agent service is required to run SQL Agent jobs'
56-
}
51+
Context "Testing SQL Agent is running on <_.Name>" {
52+
It "SQL Agent should be running for <_.InstanceName> on <_.Name>" -Skip:$skipServiceState {
53+
$PSItem.Agent.State | Should -Be "Running" -Because 'The agent service is required to run SQL Agent jobs'
5754
}
58-
if ($PSItem.IsClustered) {
59-
It "SQL Agent service should have a start mode of Manual for FailOver Clustered Instance <_.InstanceName> on <_.Name>" -Skip:$skipServiceStartMode {
60-
$PSItem.Agent.StartMode | Should -Be "Manual" -Because 'Clustered Instances required that the Agent service is set to manual'
61-
}
62-
} else {
63-
It "SQL Agent service should have a start mode of Automatic for standalone instance <_.InstanceName> on <_.Name>" -Skip:$skipServiceStartMode {
64-
$PSItem.Agent.StartMode | Should -Be "Automatic" -Because 'Otherwise the Agent Jobs wont run if the server is restarted'
65-
}
55+
}
56+
if ($PSItem.IsClustered) {
57+
It "SQL Agent service should have a start mode of Manual for FailOver Clustered Instance <_.InstanceName> on <_.Name>" -Skip:$skipServiceStartMode {
58+
$PSItem.Agent.StartMode | Should -Be "Manual" -Because 'Clustered Instances required that the Agent service is set to manual'
6659
}
6760
} else {
68-
Context "Testing SQL Agent is running on $psitem" {
69-
It "Running on Linux or connecting to container so can't check Services on $Psitem" -Skip {
70-
}
61+
It "SQL Agent service should have a start mode of Automatic for standalone instance <_.InstanceName> on <_.Name>" -Skip:$skipServiceStartMode {
62+
$PSItem.Agent.StartMode | Should -Be "Automatic" -Because 'Otherwise the Agent Jobs wont run if the server is restarted'
7163
}
7264
}
7365
}
@@ -92,7 +84,7 @@ Describe "Failsafe Operator" -Tag FailsafeOperator, Operator -ForEach $Instances
9284
$failsafeoperator = Get-DbcConfigValue agent.failsafeoperator
9385

9486
Context "Testing failsafe Operators exists on <_.Name>" {
95-
It "The Failsafe operator <_.FailSafeOperator> exists on <_.Name>" -Skip:$skipFailsafeoperator -ForEach ($PSItem.JobServer.AlertSystem | Where-Object FailSafeOperator -NE $null) {
87+
It "The Failsafe operator <_.FailSafeOperator> exists on <_.Name>" -Skip:$skipFailsafeoperator -ForEach ($PSItem.JobServer.AlertSystem | Where-Object FailSafeOperator -EQ 'null') {
9688
$PSItem.ExpectedFailSafeOperator | Should -Be $failsafeoperator -Because 'The failsafe operator will ensure that any job failures will be notified to someone if not set explicitly'
9789
}
9890
}

0 commit comments

Comments
 (0)