diff --git a/Perf Testing pesterv5.ps1 b/Perf Testing pesterv5.ps1 index 51e1b5c6..b4561766 100644 --- a/Perf Testing pesterv5.ps1 +++ b/Perf Testing pesterv5.ps1 @@ -14,8 +14,8 @@ ipmo ./dbachecks.psd1 # -$Checks = 'TwoDigitYearCutoff','MaxDopInstance','ErrorLogCount','ModelDbGrowth','DefaultBackupCompression','SaExist','SaDisabled','SaRenamed','DefaultFilePath','AdHocDistributedQueriesEnabled','AdHocWorkload', 'DefaultTrace', 'OleAutomationProceduresDisabled', 'CrossDBOwnershipChaining', 'ScanForStartupProceduresDisabled', 'RemoteAccessDisabled', 'SQLMailXPsDisabled', 'DAC', 'OLEAutomation' -$Checks = 'TwoDigitYearCutoff' +$Checks = 'TraceFlagsExpected','TwoDigitYearCutoff','MaxDopInstance','ErrorLogCount','ModelDbGrowth','DefaultBackupCompression','SaExist','SaDisabled','SaRenamed','DefaultFilePath','AdHocDistributedQueriesEnabled','AdHocWorkload', 'DefaultTrace', 'OleAutomationProceduresDisabled', 'CrossDBOwnershipChaining', 'ScanForStartupProceduresDisabled', 'RemoteAccessDisabled', 'SQLMailXPsDisabled', 'DAC', 'OLEAutomation' +$Checks = 'TraceFlagsExpected' Compare-CheckRuns -Checks $checks <# @@ -40,6 +40,15 @@ Set-DbcConfig policy.instancemaxdop.maxdop -Value 0 Set-DbcConfig policy.instancemaxdop.excludeinstance -Value $null Set-DbcConfig policy.instancemaxdop.excludeinstance -Value 'localhost,7401' +Get-DbcConfigValue policy.traceflags.expected +Get-DbaTraceFlag -SqlInstance $Sqlinstances -SqlCredential $cred +Set-DbcConfig policy.traceflags.expected -Value 1117,1118 +Set-DbcConfig policy.traceflags.expected -Value $null + +Enable-DbaTraceFlag -SqlInstance $Sqlinstances -SqlCredential $cred -TraceFlag 1117,1118 +Disable-DbaTraceFlag -SqlInstance $Sqlinstances -SqlCredential $cred -TraceFlag 1117,1118 +Disable-DbaTraceFlag -SqlInstance $Sqlinstances -SqlCredential $cred -TraceFlag 1118 + #> # Load the function below and then you can keep running the checks defined above in v4 and v5 and compare the performance diff --git a/Validate v4 adn v5.ps1 b/Validate v4 adn v5.ps1 index 597e0165..54d034b4 100644 --- a/Validate v4 adn v5.ps1 +++ b/Validate v4 adn v5.ps1 @@ -14,8 +14,8 @@ ipmo ./dbachecks.psd1 # -$Checks = 'TwoDigitYearCutoff','MaxDopInstance','ErrorLogCount','ModelDbGrowth','DefaultBackupCompression','SaExist','SaDisabled','SaRenamed','DefaultFilePath','AdHocDistributedQueriesEnabled','AdHocWorkload', 'DefaultTrace', 'OleAutomationProceduresDisabled', 'CrossDBOwnershipChaining', 'ScanForStartupProceduresDisabled', 'RemoteAccessDisabled', 'SQLMailXPsDisabled', 'DAC', 'OLEAutomation' -$Checks = 'TwoDigitYearCutoff' +$Checks = 'TraceFlagsExpected','TwoDigitYearCutoff','MaxDopInstance','ErrorLogCount','ModelDbGrowth','DefaultBackupCompression','SaExist','SaDisabled','SaRenamed','DefaultFilePath','AdHocDistributedQueriesEnabled','AdHocWorkload', 'DefaultTrace', 'OleAutomationProceduresDisabled', 'CrossDBOwnershipChaining', 'ScanForStartupProceduresDisabled', 'RemoteAccessDisabled', 'SQLMailXPsDisabled', 'DAC', 'OLEAutomation' +$Checks = 'TraceFlagsExpected' Compare-v4andv5Results -Checks $Checks <# @@ -40,6 +40,15 @@ Set-DbcConfig policy.instancemaxdop.maxdop -Value 0 Set-DbcConfig policy.instancemaxdop.excludeinstance -Value $null Set-DbcConfig policy.instancemaxdop.excludeinstance -Value 'localhost,7402' +Get-DbcConfigValue policy.traceflags.expected +Get-DbaTraceFlag -SqlInstance $Sqlinstances -SqlCredential $cred +Set-DbcConfig policy.traceflags.expected -Value 1117,1118 +Set-DbcConfig policy.traceflags.expected -Value $null + +Enable-DbaTraceFlag -SqlInstance $Sqlinstances -SqlCredential $cred -TraceFlag 1117,1118 +Disable-DbaTraceFlag -SqlInstance $Sqlinstances -SqlCredential $cred -TraceFlag 1117,1118 +Disable-DbaTraceFlag -SqlInstance $Sqlinstances -SqlCredential $cred -TraceFlag 1118 + #> # Load the function below and then you can keep running the checks defined above in v4 and v5 and compare the performance diff --git a/checks/Instancev5.Tests.ps1 b/checks/Instancev5.Tests.ps1 index fef4805f..8938f58a 100644 --- a/checks/Instancev5.Tests.ps1 +++ b/checks/Instancev5.Tests.ps1 @@ -212,8 +212,21 @@ Describe "Instance MaxDop" -Tag MaxDopInstance, MaxDop, Medium, Instance -ForEac Describe "Two Digit Year Cutoff" -Tag TwoDigitYearCutoff, Low, Instance -ForEach $InstancesToTest { $skip = Get-DbcConfigValue skip.instance.TwoDigitYearCutoff Context "Testing Two Digit Year Cutoff on <_.Name>" { - It "Two Digit Year Cutoff is set to <_.ConfigValues.TwoDigitYearCutoff> on <_.Name>" -Skip:$skip { + It "Two Digit Year Cutoff is set to <_.ConfigValues.TwoDigitYearCutoff> on <_.Name>" -Skip:$skip { $PSItem.Configuration.TwoDigitYearCutoff.ConfigValue | Should -Be $psitem.ConfigValues.TwoDigitYearCutoff -Because 'This is the value that you have chosen for Two Digit Year Cutoff configuration' } } } + +Describe "Trace Flags Expected" -Tag TraceFlagsExpected, TraceFlag, High, Instance -ForEach $InstancesToTest { + $skip = Get-DbcConfigValue skip.instance.TraceFlagsExpected + Context "Testing Expected Trace Flags on <_.Name>" { + It "Expected No Trace Flags to exist on <_.Name>" -Skip:$skip -ForEach ($Psitem | Where-Object { $null -eq $psitem.ConfigValues.TraceFlagsExpected }) { + $PsItem.ExpectedTraceFlags.ActualTraceFlags.TraceFlag | Should -BeNullOrEmpty -Because "We expect that there will be no Trace Flags set on $($Psitem.Name) " + } + It "Expected Trace Flags <_.ExpectedTraceFlag> to exist on <_.InstanceName>" -Skip:$skip -ForEach ($PsItem.ExpectedTraceFlags | Where-Object { $psitem.ExpectedTraceFlag -ne 'null' }) { + $PsItem.ActualTraceFlags.TraceFlag | Should -Contain $PsItem.ExpectedTraceFlag -Because "We expect that Trace Flag $($PsItem.ExpectedTraceFlag) will be set on $($Psitem.InstanceName) " + } + } +} + diff --git a/internal/functions/NewGet-AllInstanceInfo.ps1 b/internal/functions/NewGet-AllInstanceInfo.ps1 index 9714a2ec..3391f41c 100644 --- a/internal/functions/NewGet-AllInstanceInfo.ps1 +++ b/internal/functions/NewGet-AllInstanceInfo.ps1 @@ -147,24 +147,41 @@ function NewGet-AllInstanceInfo { $ConfigValues | Add-Member -MemberType NoteProperty -Name 'TwoDigitYearCutoff' -Value (Get-DbcConfigValue policy.twodigityearcutoff) } - + 'TraceFlagsExpected' { + $TraceFlagsExpected = Get-DbcConfigValue policy.traceflags.expected + $TraceFlagsActual = $Instance.EnumActiveGlobalTraceFlags() + $ConfigValues | Add-Member -MemberType NoteProperty -Name 'TraceFlagsExpected' -Value $TraceFlagsExpected + $ExpectedTraceFlags = $TraceFlagsExpected.Foreach{ + [PSCustomObject]@{ + InstanceName = $Instance.Name + ExpectedTraceFlag = $PSItem + ActualTraceFlags = $TraceFlagsActual + } + } + $ExpectedTraceFlags += [PSCustomObject]@{ + InstanceName = $Instance.Name + ExpectedTraceFlag = 'null' + ActualTraceFlags = $TraceFlagsActual + } + } Default { } } #build the object $testInstanceObject = [PSCustomObject]@{ - ComputerName = $Instance.ComputerName - InstanceName = $Instance.DbaInstanceName - Name = $Instance.Name - ConfigValues = $ConfigValues - VersionMajor = $Instance.VersionMajor - Configuration = if ($configurations) { $Instance.Configuration } else { $null } - Settings = $Instance.Settings - Logins = $Instance.Logins - Databases = $Instance.Databases - NumberOfLogFiles = $Instance.NumberOfLogFiles - MaxDopSettings = $MaxDopSettings + ComputerName = $Instance.ComputerName + InstanceName = $Instance.DbaInstanceName + Name = $Instance.Name + ConfigValues = $ConfigValues + VersionMajor = $Instance.VersionMajor + Configuration = if ($configurations) { $Instance.Configuration } else { $null } + Settings = $Instance.Settings + Logins = $Instance.Logins + Databases = $Instance.Databases + NumberOfLogFiles = $Instance.NumberOfLogFiles + MaxDopSettings = $MaxDopSettings + ExpectedTraceFlags = $ExpectedTraceFlags } if ($ScanForStartupProceduresDisabled) { $StartUpSPs = $Instance.Databases['master'].StoredProcedures.Where{ $_. Name -ne 'sp_MSrepl_startup' -and $_.StartUp -eq $true }.count