Skip to content

Commit

Permalink
so that we can test linked server connections #882
Browse files Browse the repository at this point in the history
  • Loading branch information
SQLDBAWithABeard committed Mar 28, 2023
1 parent c11bfea commit 1a625b8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions source/checks/Instancev5.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,16 @@ Describe "Network Latency" -Tag NetworkLatency, Connectivity, Medium, Instance -
}
}
}

Describe "Linked Servers" -Tags LinkedServerConnection, Connectivity, Medium, Instance -ForEach $InstancesToTest {
$skip = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.instance.linkedserverconnection' }).Value
Context "Testing Linked Server Connection on <_.Name>" {
It "should be able to connect to <_.LinkedServerName> for Linked Server <_.RemoteServer> on <_.InstanceName>" -Skip:$skip -ForEach @($Psitem.LinkedServerResults) {
$psitem.Connectivity | Should -BeTrue -Because "Linked server connection should be successful but the result was $($Psitem.Result)"
}
}
}

<#
Describe "TempDB Configuration" -Tags TempDbConfiguration, Medium, Instance -ForEach $InstancesToTest {
Context "Testing TempDB Configuration on $psitem" -Skip:(($__dbcconfig | Where-Object { $_.Name
Expand Down
1 change: 1 addition & 0 deletions source/internal/configurations/configuration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ Set-PSFConfig -Module dbachecks -Name skip.instance.errorlogentries -Validation
Set-PSFConfig -Module dbachecks -Name skip.instance.tempdb -Validation bool -Value $false -Initialize -Description "Skip all the checks for the tempdb database"
Set-PSFConfig -Module dbachecks -Name skip.instance.BackupPathAccess -Validation bool -Value $false -Initialize -Description "Skip the check for the backup path access check"
Set-PSFConfig -Module dbachecks -Name skip.instance.networklatency -Validation bool -Value $false -Initialize -Description "Skip the check for network latency"
Set-PSFConfig -Module dbachecks -Name skip.instance.linkedserverconnection -Validation bool -Value $false -Initialize -Description "Skip the check for linked server connection"



Expand Down
23 changes: 23 additions & 0 deletions source/internal/functions/NewGet-AllInstanceInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ function NewGet-AllInstanceInfo {
$Latency = (Test-DbaNetworkLatency -SqlInstance $Instance).NetworkOnlyTotal.TotalMilliseconds
}

'LinkedServerConnection' {
$LinkedServerResults = Test-DbaLinkedServerConnection -SqlInstance $Instance
}

Default { }
}

Expand Down Expand Up @@ -399,6 +403,25 @@ function NewGet-AllInstanceInfo {
Latency = $Latency
Threshold = $NetworkThreshold
}
LinkedServerResults = if ($LinkedServerResults) {
$LinkedServerResults.ForEach{
[pscustomobject]@{
InstanceName = $Instance.Name
LinkedServerName = $PSItem.LinkedServerName
RemoteServer = $PSItem.RemoteServer
Connectivity = $PSItem.Connectivity
Result = $PSItem.Result
}
}
} else {
[pscustomobject]@{
InstanceName = $Instance.Name
LinkedServerName = 'None found'
RemoteServer = 'None'
Connectivity = $true
Result = 'None'
}
}
# TempDbConfig = [PSCustomObject]@{
# TF118EnabledCurrent = $tempDBTest[0].CurrentSetting
# TF118EnabledRecommended = $tempDBTest[0].Recommended
Expand Down

0 comments on commit 1a625b8

Please sign in to comment.