Skip to content

Commit e23709f

Browse files
Merge pull request #1004 from dataplat/instancecheckscontinued
So we can ignore existing checks and dont have output
2 parents 7637efe + fcab7db commit e23709f

File tree

4 files changed

+47
-12
lines changed

4 files changed

+47
-12
lines changed

containers/JessAndBeard.psm1

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2365,6 +2365,13 @@ The Tags are the same"
23652365
PassedChange = +2 # + or - the number of tests passed for v5
23662366
FailedChange = -2 # + or - the number of tests failed for v5
23672367
SkippedChange = 0 # + or - the number of tests skipped for v5
2368+
},
2369+
@{
2370+
Name = 'SqlEngineServiceAccount'
2371+
RunChange = -3 # + or - the number of tests run for v5
2372+
PassedChange = 0 # + or - the number of tests passed for v5
2373+
FailedChange = 0 # + or - the number of tests failed for v5
2374+
SkippedChange = -3 # + or - the number of tests skipped for v5
23682375
}
23692376
)
23702377
$runchange = 0
@@ -2414,6 +2421,7 @@ The Total Tests Run are the same {0} {1}
24142421

24152422
#total passed checks
24162423
If ($v5Passed -ne $v4code.PassedCount) {
2424+
24172425
$Message = "
24182426
Uh-Oh - The total tests Passed between v4 and v5 are not the same somehow.
24192427
For v4 We Passed
@@ -2422,11 +2430,16 @@ and
24222430
For v5 we Passed
24232431
{1} tests
24242432
{2}
2433+
2434+
" -f $v4code.PassedCount, $v5Passed, $messageAppend
2435+
if($MessageAppend){
2436+
$Message += "
24252437
v4 TestNames
2426-
{3}
2438+
{0}
24272439
v5 TestNames
2428-
{4}
2429-
" -f $v4code.PassedCount, $v5Passed, $messageAppend, ($v4code.TestResult.Where{$_.Result -eq 'Passed'}.Name |Out-String),($v5code.Passed.ExpandedName |Out-String)
2440+
{1}
2441+
" -f ($v4code.TestResult.Where{$_.Result -eq 'Passed'}.Name |Out-String),($v5code.Passed.ExpandedName |Out-String)
2442+
}
24302443
Write-PSFMessage -Message $Message -Level Warning
24312444
} else {
24322445
$message = "
@@ -2443,11 +2456,16 @@ For v4 We Failed
24432456
and
24442457
For v5 we Failed
24452458
{1} tests
2459+
2460+
" -f $v4code.FailedCount, $v5Failed, $messageAppend
2461+
if($MessageAppend){
2462+
$Message += "
24462463
v4 TestNames
2447-
{2}
2464+
{0}
24482465
v5 TestNames
2449-
{3}
2450-
" -f $v4code.FailedCount, $v5failed,($v4code.TestResult.Where{$_.Result -eq 'Failed'}.Name |Out-String),($v5code.Failed.ExpandedName |Out-String)
2466+
{1}
2467+
" -f ($v4code.TestResult.Where{$_.Result -eq 'Failed'}.Name |Out-String),($v5code.Failed.ExpandedName |Out-String)
2468+
}
24512469
Write-PSFMessage -Message $Message -Level Warning
24522470
} else {
24532471
$message = "
@@ -2464,11 +2482,16 @@ For v4 We Skipped
24642482
and
24652483
For v5 we Skipped
24662484
{1}
2485+
2486+
" -f $v4code.SkippedCount, $v5Skipped, $messageAppend
2487+
if($MessageAppend){
2488+
$Message += "
24672489
v4 TestNames
2468-
{3}
2490+
{0}
24692491
v5 TestNames
2470-
{4}
2471-
{2}" -f $v4code.SkippedCount, $v5skipped, $messageAppend,($v4code.TestResult.Where{$_.Result -eq 'Skipped'}.Name |Out-String),($v5code.Skipped.ExpandedName |Out-String)
2492+
{1}
2493+
" -f ($v4code.TestResult.Where{$_.Result -eq 'Skipped'}.Name |Out-String),($v5code.Skipped.ExpandedName |Out-String)
2494+
}
24722495
Write-PSFMessage -Message $Message -Level Warning
24732496
} else {
24742497
$message = "

source/checks/Instancev5.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ Describe "SQL and Windows names match" -Tag ServerNameMatch, Medium, Instance -F
426426
}
427427
}
428428

429-
Describe "SQL Engine Service" -Tags SqlEngineServiceAccount, ServiceAccount, High, Instance -ForEach $InstancesToTest {
429+
Describe "SQL Engine Service" -Tag SqlEngineServiceAccount, ServiceAccount, High, Instance -ForEach $InstancesToTest {
430430
$skip = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.instance.sqlengineserviceaccount' }).Value
431431
Context "Testing SQL Engine Service on <_.Name>" -Skip:$skip {
432432
It "SQL Engine service account should be <_.State> on <_.InstanceName>" -ForEach $PsItem.SqlEngineServiceAccount {

source/functions/Invoke-DbcCheck.ps1

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,18 +367,26 @@ function Invoke-DbcCheck {
367367
$configuration = New-PesterConfiguration
368368
$configuration.Output.Verbosity = $NewShow
369369
$configuration.Filter.Tag = $check + 'FailedConnections'
370-
$configuration.Filter.ExcludeTag = $ExcludeCheck
370+
# Exclude the excluded checks and the not converted checks
371+
$notv5 = (Get-PSFConfigValue -FullName 'dbachecks.checks.notv5ready')
372+
$configuration.Filter.ExcludeTag = $ExcludeCheck + $notv5
373+
371374
if ($PassThru) {
372375
$configuration.Run.PassThru = $true
373376
}
377+
# So that if the only check passed in is not yet converted - so that we dont get red.
378+
if ($check -in $notv5) {
379+
Write-PSFMessage -Message "You are running a single check that is not yet converted to v5." -Level Warning
380+
Return
381+
}
374382
} catch {
375383
Write-PSFMessage -Message 'Something Went wrong' -Level Warning -ErrorRecord $_
376384
Return
377385
}
378386
$null = $PSBoundParameters.Remove('legacy')
379387
$null = $PSBoundParameters.Remove('Show')
380388
$null = $PSBoundParameters.Remove('PassThru')
381-
Write-PSFMessage -Message ($PSBoundParameters | Out-String) -Level Significant
389+
Write-PSFMessage -Message ($PSBoundParameters | Out-String) -Level Verbose
382390
Invoke-DbcCheckv5 @PSBoundParameters -configuration $configuration
383391
}
384392
}

source/internal/configurations/configuration.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ $EmailValidationSb = {
1818
}
1919
Register-PSFConfigValidation -Name validation.EmailValidation -ScriptBlock $EmailValidationSb
2020

21+
$__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'
22+
23+
Set-PSFConfig -Module dbachecks -Name checks.notv5ready -Value @($__dbachecksNotv5) -Initialize -Description "Checks that have not been converted to v5 yet"
24+
2125

2226
# some configs to help with autocompletes and other module level stuff
2327
#apps

0 commit comments

Comments
 (0)