Skip to content

Commit

Permalink
Merge pull request #939 from jpomfret/qsproper
Browse files Browse the repository at this point in the history
qs disabled
  • Loading branch information
jpomfret authored Apr 11, 2023
2 parents 5d90592 + c8e575a commit 140cbab
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
13 changes: 12 additions & 1 deletion source/checks/Databasev5.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,18 @@ Describe "Query Store Enabled" -Tag QueryStoreEnabled, Medium, Database -ForEach

Context "Testing to see if Query Store is enabled on <_.Name>" {
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 } } {
$psitem.QueryStoreEnabled | Should -Not -BeIn ('OFF', 'ERROR') -Because "We expect the Query Store to be enabled"
$psitem.QueryStore | Should -Not -BeIn ('OFF', 'ERROR') -Because "We expect the Query Store to be enabled"
}
}
}

Describe "Query Store Disabled" -Tag QueryStoreDisabled, Medium, Database -ForEach $InstancesToTest {
$skip = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.security.querystoredisabled' }).Value

Context "Testing to see if Query Store is disabled on <_.Name>" {
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 } } {
$psitem.QueryStore | Should -Not -Be 'OFF' -Because "We expect the Query Store to be disabled"
}
}
}

2 changes: 1 addition & 1 deletion source/internal/configurations/configuration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ Set-PSFConfig -Module dbachecks -Name policy.database.status.excludereadonly -Va
Set-PSFConfig -Module dbachecks -Name policy.database.status.excludeoffline -Value @() -Initialize -Description "Database names that we expect to be offline"
Set-PSFConfig -Module dbachecks -Name policy.database.status.excluderestoring -Value @() -Initialize -Description "Database names that we expect to be restoring"
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"
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"
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"
Set-PSFConfig -Module dbachecks -Name policy.database.filegrowthdaystocheck -Value $null -Initialize -Description "The number of days to go back to check for growth events"
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"
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"
Expand Down
9 changes: 7 additions & 2 deletions source/internal/functions/Get-AllDatabaseInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,14 @@ function Get-AllDatabaseInfo {
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'statusexclude' -Value (Get-DbcConfigValue policy.database.statusexcludedb)
}
'QueryStoreEnabled' {
$qsenabled = $true
$qs = $true
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'qsenabledexclude' -Value (Get-DbcConfigValue database.querystoreenabled.excludedb)
}
'QueryStoreDisabled' {
$qs = $true
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'qsdisabledexclude' -Value (Get-DbcConfigValue database.querystoredisabled.excludedb)
}

Default { }
}

Expand Down Expand Up @@ -158,7 +163,7 @@ function Get-AllDatabaseInfo {
Status = @(if ($status) { $psitem.Status })
IsDatabaseSnapshot = @(if ($status) { $psitem.IsDatabaseSnapshot }) # needed for status test
Readonly = @(if ($status) { $psitem.Readonly }) # needed for status test
QueryStoreEnabled = @(if ($qsenabled) { $psitem.QueryStoreOptions.ActualState })
QueryStore = @(if ($qs) { $psitem.QueryStoreOptions.ActualState })

}
}
Expand Down

0 comments on commit 140cbab

Please sign in to comment.