Skip to content

Commit

Permalink
Merge pull request #998 from dataplat/instancecheckscontinued
Browse files Browse the repository at this point in the history
Instancecheckscontinued
  • Loading branch information
SQLDBAWithABeard authored Aug 19, 2023
2 parents 2d98eb7 + b1a6883 commit a51edfd
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 16 deletions.
26 changes: 20 additions & 6 deletions containers/JessAndBeard.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2304,8 +2304,9 @@ New Code runs in {2} % of the time
Write-PSFMessage -Message $savingMessage -Level Output

##validate we got the right answers too

If (Compare-Object $v5code.Configuration.Filter.Tag.Value $v4code.TagFilter) {
[System.Collections.ArrayList]$v5CodeTags = $v5code.Configuration.Filter.Tag.Value
$v5CodeTags.Remove('FailedConnections')
If (Compare-Object $v5CodeTags $v4code.TagFilter) {
$Message = "
Uh-Oh - The Tag filters between v4 and v5 are not the same somehow.
For v4 We returned
Expand Down Expand Up @@ -2420,7 +2421,12 @@ For v4 We Passed
and
For v5 we Passed
{1} tests
{2}" -f $v4code.PassedCount, $v5Passed, $messageAppend
{2}
v4 TestNames
{3}
v5 TestNames
{4}
" -f $v4code.PassedCount, $v5Passed, $messageAppend, ($v4code.TestResult.Where{$_.Result -eq 'Passed'}.Name |Out-String),($v5code.Passed.ExpandedName |Out-String)
Write-PSFMessage -Message $Message -Level Warning
} else {
$message = "
Expand All @@ -2437,7 +2443,11 @@ For v4 We Failed
and
For v5 we Failed
{1} tests
" -f $v4code.FailedCount, $v5failed
v4 TestNames
{2}
v5 TestNames
{3}
" -f $v4code.FailedCount, $v5failed,($v4code.TestResult.Where{$_.Result -eq 'Failed'}.Name |Out-String),($v5code.Failed.ExpandedName |Out-String)
Write-PSFMessage -Message $Message -Level Warning
} else {
$message = "
Expand All @@ -2453,8 +2463,12 @@ For v4 We Skipped
{0} tests
and
For v5 we Skipped
{1} tests
{2}" -f $v4code.SkippedCount, $v5skipped, $messageAppend
{1}
v4 TestNames
{3}
v5 TestNames
{4}
{2}" -f $v4code.SkippedCount, $v5skipped, $messageAppend,($v4code.TestResult.Where{$_.Result -eq 'Skipped'}.Name |Out-String),($v5code.Skipped.ExpandedName |Out-String)
Write-PSFMessage -Message $Message -Level Warning
} else {
$message = "
Expand Down
4 changes: 2 additions & 2 deletions containers/base/profile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ function Load-Profile {
)
$global:__currentTheme = (Get-Random -InputObject $themes)
function global:Get-CurrentPoshTheme { $__currentTheme }
Set-PoshPrompt -Theme $__currentTheme

# Set-PoshPrompt -Theme $__currentTheme
Set-PoshPrompt -Theme 'chips'
if ($psstyle) {
$psstyle.FileInfo.Directory = $psstyle.FileInfo.Executable = $psstyle.FileInfo.SymbolicLink = ""
$PSStyle.FileInfo.Extension.Clear()
Expand Down
35 changes: 27 additions & 8 deletions developing/Oslo Demo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,47 @@ $cred = New-Object -TypeName System.Management.Automation.PSCredential -Argument
$show = 'All'
#endregion

#region What do we have?

Get-DbaDatabase -SqlInstance $Sqlinstances -SqlCredential $cred -ExcludeSystem | Select-Object Sqlinstance, DatabaseName, Status

Get-DbaAgentJob -SqlInstance $Sqlinstances -SqlCredential $cred | Select-Object Sqlinstance, Name, Enabled
#end region

Get-DbaLastBackup -SqlInstance $Sqlinstances -SqlCredential $cred | Select-Object Sqlinstance, Database, LastFullBackup | Format-Table

# lets run a couple of tests

Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check InstanceConnection, DatabaseStatus -legacy $true -Show $show
# this one shows that the old existing code will work
# the legacy switch is set to true by default

Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check InstanceConnection, DatabaseStatus -Show $show

# that failed but shouldnt have - set config
# So lets show the shiny new faster code - legacy switch set to false

Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check InstanceConnection, DatabaseStatus -Show $show -legacy $false


# The Authentication check failed but we would like to pass - lets set config
Set-DbcConfig -Name policy.connection.authscheme -Value SQL

# run again

# what about skips?
Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check InstanceConnection, DatabaseStatus -Show $show -legacy $false

# Hmmm, we know that we will never be able to remote onto these containers so let talk about skipping. No Claudio not that sort of skipping!!
Set-DbcConfig -Name skip.connection.remoting -Value $true

# run again

# ok now in v5 mode
Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check InstanceConnection, DatabaseStatus -legacy $false -Show $show
Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check InstanceConnection, DatabaseStatus -Show $show -legacy $false

# So much quicker !!!
# So much quicker !!! OK for one check it will be slower. For two it will probably be about the same but for 3 or more it will be quicker. Much quicket. Exrapolate that to 100 checks and a 1000 instances you can see the difference.

# show our perf test ????
# This is how we know - We perf test our PowerShell code
# This will take about 80-100 seconds to run so run first then talk!

$Checks = 'ErrorLogCount', 'XESessionExists', 'XESessionStopped', 'XpCmdShellDisabled', 'WhoIsActiveInstalled', 'CLREnabled', 'TwoDigitYearCutoff', 'MaxDopInstance', 'ErrorLogCount', 'ModelDbGrowth', 'DefaultBackupCompression', 'SaExist', 'SaDisabled', 'SaRenamed', 'DefaultFilePath', 'AdHocDistributedQueriesEnabled', 'AdHocWorkload', 'DefaultTrace', 'OleAutomationProceduresDisabled', 'CrossDBOwnershipChaining', 'ScanForStartupProceduresDisabled', 'RemoteAccessDisabled', 'SQLMailXPsDisabled', 'DAC', 'OLEAutomation', 'ServerNameMatch', 'OrphanedFile', 'MaxMemory', 'NetworkLatency', 'PublicPermission'
$Checks = 'ErrorLogCount', 'XpCmdShellDisabled', 'WhoIsActiveInstalled', 'CLREnabled', 'TwoDigitYearCutoff', 'MaxDopInstance', 'ErrorLogCount', 'ModelDbGrowth', 'DefaultBackupCompression', 'SaExist', 'SaDisabled', 'SaRenamed', 'DefaultFilePath', 'AdHocDistributedQueriesEnabled', 'AdHocWorkload', 'DefaultTrace', 'OleAutomationProceduresDisabled', 'CrossDBOwnershipChaining', 'ScanForStartupProceduresDisabled', 'RemoteAccessDisabled', 'SQLMailXPsDisabled', 'DAC', 'OLEAutomation', 'ServerNameMatch', 'OrphanedFile', 'MaxMemory', 'PublicPermission'

Invoke-PerfAndValidateCheck -Checks $Checks

Expand Down

0 comments on commit a51edfd

Please sign in to comment.