Skip to content

Commit 140cbab

Browse files
authored
Merge pull request #939 from jpomfret/qsproper
qs disabled
2 parents 5d90592 + c8e575a commit 140cbab

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

source/checks/Databasev5.Tests.ps1

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,18 @@ Describe "Query Store Enabled" -Tag QueryStoreEnabled, Medium, Database -ForEach
198198

199199
Context "Testing to see if Query Store is enabled on <_.Name>" {
200200
It "Database <_.Name> should have Query Store enabled on <_.SqlInstance>" -Skip:$skip -ForEach $psitem.Databases.Where{ if ($Database) { $_.Name -in $Database } else { $psitem.ConfigValues.qsenabledexclude -notcontains $PsItem.Name } } {
201-
$psitem.QueryStoreEnabled | Should -Not -BeIn ('OFF', 'ERROR') -Because "We expect the Query Store to be enabled"
201+
$psitem.QueryStore | Should -Not -BeIn ('OFF', 'ERROR') -Because "We expect the Query Store to be enabled"
202202
}
203203
}
204204
}
205+
206+
Describe "Query Store Disabled" -Tag QueryStoreDisabled, Medium, Database -ForEach $InstancesToTest {
207+
$skip = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.security.querystoredisabled' }).Value
208+
209+
Context "Testing to see if Query Store is disabled on <_.Name>" {
210+
It "Database <_.Name> should have Query Store disabled on <_.SqlInstance>" -Skip:$skip -ForEach $psitem.Databases.Where{ if ($Database) { $_.Name -in $Database } else { $psitem.ConfigValues.qsdisabledexclude -notcontains $PsItem.Name } } {
211+
$psitem.QueryStore | Should -Not -Be 'OFF' -Because "We expect the Query Store to be disabled"
212+
}
213+
}
214+
}
215+

source/internal/configurations/configuration.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ Set-PSFConfig -Module dbachecks -Name policy.database.status.excludereadonly -Va
162162
Set-PSFConfig -Module dbachecks -Name policy.database.status.excludeoffline -Value @() -Initialize -Description "Database names that we expect to be offline"
163163
Set-PSFConfig -Module dbachecks -Name policy.database.status.excluderestoring -Value @() -Initialize -Description "Database names that we expect to be restoring"
164164
Set-PSFConfig -Module dbachecks -Name database.querystoreenabled.excludedb -Value @('model', 'tempdb', 'master') -Initialize -Description "A List of databases that we do not want to check for Query Store enabled"
165-
Set-PSFConfig -Module dbachecks -Name database.querystoredisabled.excludedb -Value @() -Initialize -Description "A List of databases that we do not want to check for Query Store disabled"
165+
Set-PSFConfig -Module dbachecks -Name database.querystoredisabled.excludedb -Value @('model', 'tempdb', 'master') -Initialize -Description "A List of databases that we do not want to check for Query Store disabled"
166166
Set-PSFConfig -Module dbachecks -Name policy.database.filegrowthdaystocheck -Value $null -Initialize -Description "The number of days to go back to check for growth events"
167167
Set-PSFConfig -Module dbachecks -Name policy.database.trustworthyexcludedb -Value @('msdb') -Initialize -Description "A List of databases that we do not want to check for Trustworthy being on"
168168
Set-PSFConfig -Module dbachecks -Name policy.database.duplicateindexexcludedb -Value @('msdb', 'ReportServer', 'ReportServerTempDB') -Initialize -Description "A List of databases we do not want to check for Duplicate Indexes"

source/internal/functions/Get-AllDatabaseInfo.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,14 @@ function Get-AllDatabaseInfo {
124124
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'statusexclude' -Value (Get-DbcConfigValue policy.database.statusexcludedb)
125125
}
126126
'QueryStoreEnabled' {
127-
$qsenabled = $true
127+
$qs = $true
128128
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'qsenabledexclude' -Value (Get-DbcConfigValue database.querystoreenabled.excludedb)
129129
}
130+
'QueryStoreDisabled' {
131+
$qs = $true
132+
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'qsdisabledexclude' -Value (Get-DbcConfigValue database.querystoredisabled.excludedb)
133+
}
134+
130135
Default { }
131136
}
132137

@@ -158,7 +163,7 @@ function Get-AllDatabaseInfo {
158163
Status = @(if ($status) { $psitem.Status })
159164
IsDatabaseSnapshot = @(if ($status) { $psitem.IsDatabaseSnapshot }) # needed for status test
160165
Readonly = @(if ($status) { $psitem.Readonly }) # needed for status test
161-
QueryStoreEnabled = @(if ($qsenabled) { $psitem.QueryStoreOptions.ActualState })
166+
QueryStore = @(if ($qs) { $psitem.QueryStoreOptions.ActualState })
162167

163168
}
164169
}

0 commit comments

Comments
 (0)