Merged PR 6310: Fix test failures

Fix test failures on release build
This commit is contained in:
Jim Truher
2019-01-08 19:27:31 +00:00
committed by Travis Plunk
parent b340bfea2d
commit e2c9125d63
3 changed files with 40 additions and 27 deletions
@@ -19,8 +19,14 @@ Describe "Test-Connection" -tags "CI" {
# $targetAddressIPv6 = "::1"
$targetAddressIPv6 = [System.Net.Dns]::GetHostEntry($targetName).AddressList[0].IPAddressToString
$UnreachableAddress = "10.11.12.13"
$realName = "google-public-dns-a.google.com"
$realAddress = [System.Net.Dns]::GetHostEntry($realName).AddressList[0].IPAddressToString
# this resolves to an actual IP rather than 127.0.0.1
# this can also include both IPv4 and IPv6, so select InterNetwork rather than InterNetworkV6
$realAddress = [System.Net.Dns]::GetHostEntry($hostName).AddressList |
Where-Object {$_.AddressFamily -eq "InterNetwork"} |
Select-Object -First 1 |
Foreach-Object {$_.IPAddressToString}
# under some environments, we can't round trip this and retrieve the real name from the address
# in this case we will simply use the hostname
$jobContinues = Start-Job { Test-Connection $using:targetAddress -Continues }
}
@@ -79,29 +85,37 @@ Describe "Test-Connection" -tags "CI" {
}
# In VSTS, address is 0.0.0.0
It "Force IPv4 with implicit PingOptions" -Skip:((Test-IsVstsLinux) -or (Test-IsVstsWindows)) {
$result = Test-Connection $realName -Count 1 -IPv4
It "Force IPv4 with implicit PingOptions" {
$result = Test-Connection $hostName -Count 1 -IPv4
$result.Replies[0].Address | Should -BeExactly $realAddress
$result.Replies[0].Options.Ttl | Should -BeLessThan 128
$result.Replies[0].Options.Ttl | Should -BeLessOrEqual 128
if ($isWindows) {
$result.Replies[0].Options.DontFragment | Should -BeFalse
}
}
# In VSTS, address is 0.0.0.0
It "Force IPv4 with explicit PingOptions" -Skip:((Test-IsVstsLinux) -or (Test-IsVstsWindows)) {
$result1 = Test-Connection $realName -Count 1 -IPv4 -MaxHops 10 -DontFragment
It "Force IPv4 with explicit PingOptions" {
$result1 = Test-Connection $hostName -Count 1 -IPv4 -MaxHops 10 -DontFragment
$result2 = Test-Connection $realName -Count 1 -IPv4 -MaxHops 1 -DontFragment
# explicitly go to google dns. this test will pass even if the destination is unreachable
# it's more about breaking out of the loop
$result2 = Test-Connection 8.8.8.8 -Count 1 -IPv4 -MaxHops 1 -DontFragment
$result1.Replies[0].Address | Should -BeExactly $realAddress
# .Net Core (.Net Framework) returns Options based on default PingOptions() constructor (Ttl=128, DontFragment = false).
# After .Net Core fix we should have 'DontFragment | Should -Be $true' here.
$result1.Replies[0].Options.Ttl | Should -BeLessThan 128
$result1.Replies[0].Options.Ttl | Should -BeLessOrEqual 128
if (!$isWindows) {
$result1.Replies[0].Options.DontFragment | Should -BeNullOrEmpty
$result2.Replies[0].Status | Should -BeExactly "Success"
if ( $env:__InContainer ) {
$result1.Replies[0].Options.DontFragment | Should -Be $True
}
else {
$result1.Replies[0].Options.DontFragment | Should -BeNullOrEmpty
}
# depending on the network configuration any of the following should be returned
$result2.Replies[0].Status | Should -BeIn "TtlExpired","TimedOut","Success"
} else {
$result1.Replies[0].Options.DontFragment | Should -BeFalse
# We expect 'TtlExpired' but if a router don't reply we get `TimeOut`
@@ -196,19 +210,18 @@ Describe "Test-Connection" -tags "CI" {
}
# TODO: We skip the MTUSizeDetect tests on Unix because we expect 'TtlExpired' but get 'TimeOut' internally from .Net Core
# Skipping on VSTS in Windows due to `TimedOut`
Context "MTUSizeDetect" {
It "MTUSizeDetect works" -Pending:(!$isWindows -or (Test-IsVstsWindows)) {
$result = Test-Connection $realName -MTUSizeDetect
It "MTUSizeDetect works" -pending:($IsMacOS) {
$result = Test-Connection $hostName -MTUSizeDetect
$result | Should -BeOfType "System.Net.NetworkInformation.PingReply"
$result.Destination | Should -BeExactly $realName
$result.Destination | Should -BeExactly $hostName
$result.Status | Should -BeExactly "Success"
$result.MTUSize | Should -BeGreaterThan 0
}
It "Quiet works" -Pending:(!$isWindows -or (Test-IsVstsWindows)) {
$result = Test-Connection $realName -MTUSizeDetect -Quiet
It "Quiet works" -pending:($IsMacOS) {
$result = Test-Connection $hostName -MTUSizeDetect -Quiet
$result | Should -BeOfType "Int32"
$result | Should -BeGreaterThan 0
@@ -216,9 +229,9 @@ Describe "Test-Connection" -tags "CI" {
}
Context "TraceRoute" {
# Hangs in VSTS Linux
It "TraceRoute works" -skip:((Test-IsVstsLinux) -or (Test-IsVstsWindows)) {
$result = Test-Connection $realName -TraceRoute
It "TraceRoute works" {
# real address is an ipv4 address, so force IPv4
$result = Test-Connection $hostName -TraceRoute -IPv4
$replies = $result.Replies
# Check target host reply.
$pingReplies = $replies[-1].PingReplies
@@ -227,7 +240,7 @@ Describe "Test-Connection" -tags "CI" {
$result | Should -BeOfType "Microsoft.PowerShell.Commands.TestConnectionCommand+TraceRouteResult"
$result.Source | Should -BeExactly $hostName
$result.DestinationAddress | Should -BeExactly $realAddress
$result.DestinationHost | Should -BeExactly $realName
$result.DestinationHost | Should -BeExactly $hostName
$replies.Count | Should -BeGreaterThan 0
$replies[0] | Should -BeOfType "Microsoft.PowerShell.Commands.TestConnectionCommand+TraceRouteReply"
@@ -237,15 +250,14 @@ Describe "Test-Connection" -tags "CI" {
$pingReplies[0].Address | Should -BeExactly $realAddress
$pingReplies[0].Status | Should -BeExactly "Success"
if (!$isWindows) {
$pingReplies[0].Buffer.Count | Should -Be 0
$pingReplies[0].Buffer.Count | Should -Match '^0$|^32$'
} else {
$pingReplies[0].Buffer.Count | Should -Be 32
}
}
# Hangs in VSTS Linux
It "Quiet works" -skip:((Test-IsVstsLinux) -or (Test-IsVstsWindows)) {
$result = Test-Connection $realName -TraceRoute -Quiet
It "Quiet works" {
$result = Test-Connection $hostName -TraceRoute -Quiet 6>$null
$result | Should -BeTrue
}
@@ -78,7 +78,7 @@ Describe "Invoke-Item basic tests" -Tags "Feature" {
## On Unix, we use `UseShellExecute = false`
## 'ping' on Unix write out usage to stderr
& $powershell -noprofile -c "Invoke-Item '$ping'" 2> $redirectFile
Get-Content $redirectFile -Raw | Should -Match "usage: ping"
Get-Content $redirectFile -Raw | Should -Match "usage: ping|ping:"
}
}
@@ -48,7 +48,8 @@ Describe 'Online help tests for PowerShell Core Cmdlets' -Tags "CI" {
Describe 'Get-Help -Online opens the default web browser and navigates to the cmdlet help content' -Tags "Feature" {
$skipTest = [System.Management.Automation.Platform]::IsIoT -or
[System.Management.Automation.Platform]::IsNanoServer
[System.Management.Automation.Platform]::IsNanoServer -or
$env:__InContainer -eq 1
# this code is a workaround for issue: https://github.com/PowerShell/PowerShell/issues/3079
if((-not ($skipTest)) -and $IsWindows)