Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}

Expand Down Expand Up @@ -79,29 +85,32 @@ 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"
# 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`
Expand Down Expand Up @@ -196,29 +205,28 @@ 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
}
}

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
Expand All @@ -227,7 +235,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"
Expand All @@ -237,15 +245,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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ Describe "Invoke-Item basic tests" -Tags "Feature" {
} else {
## On Unix, we use `UseShellExecute = false`
## 'ping' on Unix write out usage to stderr
## some ping show 'usage: ping' and others show 'ping:'
& $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:"
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/powershell/engine/Help/HelpSystem.OnlineHelp.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this defined?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment about $env:__InContainer

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code to open help in a browser is pretty simple. Perhaps rather than skipping these tests in non-desktop environments, we should instead have a test hook to validate that it hit the right code path or even start a test executable passed the URL as an argument?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a test hook here already, and it is used to validate all the uris. This is a single test which starts the browser.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this for now


# this code is a workaround for issue: https://github.com/PowerShell/PowerShell/issues/3079
if((-not ($skipTest)) -and $IsWindows)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ Describe "Parameter Binding Tests" -Tags "CI" {

$dllPath = Join-Path $tempDir TestBindingCmdlet.dll

Add-Type -OutputAssembly $dllPath -TypeDefinition '
$typeDefinition = '
using System;
using System.Management.Automation;

Expand All @@ -354,6 +354,10 @@ Describe "Parameter Binding Tests" -Tags "CI" {
}
}
'
if ( !(Test-Path $dllPath))
{
Add-Type -OutputAssembly $dllPath -TypeDefinition $typeDefinition
}

Import-Module $dllPath
}
Expand Down