Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport test fixes for 7.2 #17494

Merged
merged 2 commits into from Jun 7, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -96,15 +96,8 @@ Describe "Test-Connection" -tags "CI" {
{ Test-Connection "fakeHost" -Count 1 -ErrorAction Stop } |
Should -Throw -ErrorId "TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand"
# Error code = 11001 - Host not found.
$platform = Get-PlatformInfo
if ($platform.Platform -match "raspbian" -or ( $platform.Platform -match 'ubuntu' -and $platform.Version -eq '20.04')) {
$code = 11
} elseif (!$IsWindows) {
$code = -131073
} else {
$code = 11001
}
$error[0].Exception.InnerException.ErrorCode | Should -Be $code
# Error code = -131073 - Invalid address
$error[0].Exception.InnerException.ErrorCode | Should -BeIn 11, -131073, 11001
}

It "Force IPv4 with implicit PingOptions" {
Expand Down
10 changes: 2 additions & 8 deletions test/powershell/engine/Remoting/PSSession.Tests.ps1
Expand Up @@ -79,14 +79,8 @@ Describe "SkipCACheck and SkipCNCheck PSSession options are required for New-PSS
It "<Name>" -TestCases $testCases {
param ($scriptBlock, $expectedErrorCode)

$platformInfo = Get-PlatformInfo
if (
($platformInfo.Platform -match "alpine|raspbian") -or
($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID
($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') -or
($platformInfo.Platform -eq 'ubuntu' -and $platformInfo.Version -eq '20.04')
) {
Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, and CentOS 8"
if ( -not (Get-WsManSupport)) {
Set-ItResult -Skipped -Because "MI library not available for this platform"
return
}

Expand Down
33 changes: 6 additions & 27 deletions test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1
Expand Up @@ -10,15 +10,8 @@ function GetRandomString()

Describe "New-PSSession basic test" -Tag @("CI") {
It "New-PSSession should not crash powershell" {
$platformInfo = Get-PlatformInfo
if (
($platformInfo.Platform -match "alpine|raspbian") -or
($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID
($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') -or
($platformInfo.Platform -eq 'ubuntu' -and $platformInfo.Version -eq '20.04') -or
($IsMacOS)
) {
Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, CentOS 8, and not compatible with macOS"
if ( -not (Get-WsManSupport)) {
Set-ItResult -Skipped -Because "MI library not available for this platform"
return
}

Expand All @@ -29,15 +22,8 @@ Describe "New-PSSession basic test" -Tag @("CI") {

Describe "Basic Auth over HTTP not allowed on Unix" -Tag @("CI") {
It "New-PSSession should throw when specifying Basic Auth over HTTP on Unix" -Skip:($IsWindows) {
$platformInfo = Get-PlatformInfo
if (
($platformInfo.Platform -match "alpine|raspbian") -or
($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID
($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') -or
($platformInfo.Platform -eq 'ubuntu' -and $platformInfo.Version -eq '20.04') -or
($IsMacOS)
) {
Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, CentOS 8, and not compatible with macOS"
if ( -not (Get-WsManSupport)) {
Set-ItResult -Skipped -Because "MI library not available for this platform"
return
}

Expand All @@ -53,15 +39,8 @@ Describe "Basic Auth over HTTP not allowed on Unix" -Tag @("CI") {

# Skip this test for macOS because the latest OS release is incompatible with our shipped libmi for WinRM/OMI.
It "New-PSSession should NOT throw a ConnectFailed exception when specifying Basic Auth over HTTPS on Unix" -Skip:($IsWindows) {
$platformInfo = Get-PlatformInfo
if (
($platformInfo.Platform -match "alpine|raspbian") -or
($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID
($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') -or
($platformInfo.Platform -eq 'ubuntu' -and $platformInfo.Version -eq '20.04') -or
($IsMacOS)
) {
Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, CentOS 8, and not compatible with macOS"
if ( -not (Get-WsManSupport)) {
Set-ItResult -Skipped -Because "MI library not available for this platform"
return
}

Expand Down
1 change: 1 addition & 0 deletions test/tools/Modules/HelpersCommon/HelpersCommon.psd1
Expand Up @@ -35,6 +35,7 @@ FunctionsToExport = @(
'Wait-FileToBePresent'
'Wait-UntilTrue'
'Get-PlatformInfo'
'Get-WSManSupport'
)

CmdletsToExport= @()
Expand Down
14 changes: 14 additions & 0 deletions test/tools/Modules/HelpersCommon/HelpersCommon.psm1
Expand Up @@ -388,3 +388,17 @@ function Get-PlatformInfo {
return "unknown"
}
}

# return true if WsMan is supported on the current platform
function Get-WsManSupport {
$platformInfo = Get-PlatformInfo
if (($platformInfo.Platform -eq 'ubuntu' -and $platformInfo.Version -eq '18.04') -or
($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '7') -or
$IsWindows
)
{
return $true
}

return $false
}