Skip to content

Commit

Permalink
Backport test fixes for 7.2 (#17494)
Browse files Browse the repository at this point in the history
  • Loading branch information
TravisEz13 committed Jun 7, 2022
1 parent 896466b commit ff8311e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 44 deletions.
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
}

0 comments on commit ff8311e

Please sign in to comment.