Skip to content

Commit

Permalink
Merge branch 'main' into agentV5
Browse files Browse the repository at this point in the history
  • Loading branch information
SQLDBAWithABeard authored Aug 26, 2023
2 parents ceef968 + e23709f commit f8a93ec
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 12 deletions.
41 changes: 32 additions & 9 deletions containers/JessAndBeard.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2372,6 +2372,13 @@ The Tags are the same"
PassedChange = -5 # + or - the number of tests passed for v4
FailedChange = -1 # + or - the number of tests failed for v4
SkippedChange = +3 # + or - the number of tests skipped for v4
},
@{
Name = 'SqlEngineServiceAccount'
RunChange = -3 # + or - the number of tests run for v5
PassedChange = 0 # + or - the number of tests passed for v5
FailedChange = 0 # + or - the number of tests failed for v5
SkippedChange = -3 # + or - the number of tests skipped for v5
}
)
$runchange = 0
Expand Down Expand Up @@ -2421,6 +2428,7 @@ The Total Tests Run are the same {0} {1}

#total passed checks
If ($v5Passed -ne $v4code.PassedCount) {

$Message = "
Uh-Oh - The total tests Passed between v4 and v5 are not the same somehow.
For v4 We Passed
Expand All @@ -2429,11 +2437,16 @@ and
for v4 we Passed
{1} tests
{2}
" -f $v4code.PassedCount, $v5Passed, $messageAppend
if($MessageAppend){
$Message += "
v4 TestNames
{3}
{0}
v5 TestNames
{4}
" -f $v4code.PassedCount, $v5Passed, $messageAppend, ($v4code.TestResult.Where{$_.Result -eq 'Passed'}.Name |Out-String),($v5code.Passed.ExpandedName |Out-String)
{1}
" -f ($v4code.TestResult.Where{$_.Result -eq 'Passed'}.Name |Out-String),($v5code.Passed.ExpandedName |Out-String)
}
Write-PSFMessage -Message $Message -Level Warning
} else {
$message = "
Expand All @@ -2450,11 +2463,16 @@ For v4 We Failed
and
for v4 we Failed
{1} tests
" -f $v4code.FailedCount, $v5Failed, $messageAppend
if($MessageAppend){
$Message += "
v4 TestNames
{2}
{0}
v5 TestNames
{3}
" -f $v4code.FailedCount, $v5failed,($v4code.TestResult.Where{$_.Result -eq 'Failed'}.Name |Out-String),($v5code.Failed.ExpandedName |Out-String)
{1}
" -f ($v4code.TestResult.Where{$_.Result -eq 'Failed'}.Name |Out-String),($v5code.Failed.ExpandedName |Out-String)
}
Write-PSFMessage -Message $Message -Level Warning
} else {
$message = "
Expand All @@ -2471,11 +2489,16 @@ For v4 We Skipped
and
For v5 we Skipped
{1}
" -f $v4code.SkippedCount, $v5Skipped, $messageAppend
if($MessageAppend){
$Message += "
v4 TestNames
{3}
{0}
v5 TestNames
{4}
{2}" -f $v4code.SkippedCount, $v5skipped, $messageAppend,($v4code.TestResult.Where{$_.Result -eq 'Skipped'}.Name |Out-String),($v5code.Skipped.ExpandedName |Out-String)
{1}
" -f ($v4code.TestResult.Where{$_.Result -eq 'Skipped'}.Name |Out-String),($v5code.Skipped.ExpandedName |Out-String)
}
Write-PSFMessage -Message $Message -Level Warning
} else {
$message = "
Expand Down
2 changes: 1 addition & 1 deletion source/checks/Instancev5.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ Describe "SQL and Windows names match" -Tag ServerNameMatch, Medium, Instance -F
}
}

Describe "SQL Engine Service" -Tags SqlEngineServiceAccount, ServiceAccount, High, Instance -ForEach $InstancesToTest {
Describe "SQL Engine Service" -Tag SqlEngineServiceAccount, ServiceAccount, High, Instance -ForEach $InstancesToTest {
$skip = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.instance.sqlengineserviceaccount' }).Value
Context "Testing SQL Engine Service on <_.Name>" -Skip:$skip {
It "SQL Engine service account should be <_.State> on <_.InstanceName>" -ForEach $PsItem.SqlEngineServiceAccount {
Expand Down
12 changes: 10 additions & 2 deletions source/functions/Invoke-DbcCheck.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -367,18 +367,26 @@ function Invoke-DbcCheck {
$configuration = New-PesterConfiguration
$configuration.Output.Verbosity = $NewShow
$configuration.Filter.Tag = $check + 'FailedConnections'
$configuration.Filter.ExcludeTag = $ExcludeCheck
# Exclude the excluded checks and the not converted checks
$notv5 = (Get-PSFConfigValue -FullName 'dbachecks.checks.notv5ready')
$configuration.Filter.ExcludeTag = $ExcludeCheck + $notv5

if ($PassThru) {
$configuration.Run.PassThru = $true
}
# So that if the only check passed in is not yet converted - so that we dont get red.
if ($check -in $notv5) {
Write-PSFMessage -Message "You are running a single check that is not yet converted to v5." -Level Warning
Return
}
} catch {
Write-PSFMessage -Message 'Something Went wrong' -Level Warning -ErrorRecord $_
Return
}
$null = $PSBoundParameters.Remove('legacy')
$null = $PSBoundParameters.Remove('Show')
$null = $PSBoundParameters.Remove('PassThru')
Write-PSFMessage -Message ($PSBoundParameters | Out-String) -Level Significant
Write-PSFMessage -Message ($PSBoundParameters | Out-String) -Level Verbose
Invoke-DbcCheckv5 @PSBoundParameters -configuration $configuration
}
}
Expand Down
4 changes: 4 additions & 0 deletions source/internal/configurations/configuration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ $EmailValidationSb = {
}
Register-PSFConfigValidation -Name validation.EmailValidation -ScriptBlock $EmailValidationSb

$__dbachecksNotv5 = 'ADUser', 'BuiltInAdmin', 'EngineServiceAdmin', 'FullTextServiceAdmin', 'LocalWindowsGroup', 'PublicPermission', 'SqlBrowserServiceAccount', 'TempDbConfiguration'',CertificateExpiration', 'DatabaseExists', 'DatabaseGrowthEvent', 'DatabaseMailEnabled', 'DatabaseMailProfile', 'DatafileAutoGrowthType', 'DisabledIndex', 'DuplicateIndex', 'FileGroupBalanced', 'FKCKTrusted', 'FutureFileGrowth', 'IdentityUsage', 'LastDiffBackup', 'LastFullBackup', 'LastGoodCheckDb', 'LastLogBackup', 'LogfilePercentUsed', 'LogfileSize', 'MaxDopDatabase', 'OrphanedUser', 'PageVerify', 'SymmetricKeyEncryptionLevel', 'TestLastBackup', 'TestLastBackupVerifyOnly', 'UnusedIndex', 'DatabaseMailEnabled', 'AgentServiceAccount', 'DbaOperator', 'FailsafeOperator', 'DatabaseMailProfile', 'AgentMailProfile', 'FailedJob', 'ValidJobOwner', 'InValidJobOwner', 'AgentAlert', 'JobHistory', 'LongRunningJob', 'LastJobRunTime', 'PowerPlan', 'SPN', 'DiskCapacity', 'PingComputer', 'CPUPrioritisation', 'DiskAllocationUnit', 'NonStandardPort', 'ServerProtocol', 'OlaInstalled', 'SystemFull', 'UserFull', 'UserDiff', 'UserLog', 'CommandLog', 'SystemIntegrityCheck', 'UserIntegrityCheck', 'UserIndexOptimize', 'OutputFileCleanup', 'DeleteBackupHistory', 'PurgeJobHistory', 'DomainName', 'OrganizationalUnit', 'ClusterHealth', 'LogShippingPrimary', 'LogShippingSecondary'

Set-PSFConfig -Module dbachecks -Name checks.notv5ready -Value @($__dbachecksNotv5) -Initialize -Description "Checks that have not been converted to v5 yet"


# some configs to help with autocompletes and other module level stuff
#apps
Expand Down

0 comments on commit f8a93ec

Please sign in to comment.