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
2 changes: 1 addition & 1 deletion test/powershell/Host/Startup.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Describe "Validate start of console host" -Tag CI {
}
Comment thread
adityapatwardhan marked this conversation as resolved.
Comment thread
adityapatwardhan marked this conversation as resolved.
Comment thread
adityapatwardhan marked this conversation as resolved.
Comment thread
adityapatwardhan marked this conversation as resolved.
Comment thread
TravisEz13 marked this conversation as resolved.
Comment thread
adityapatwardhan marked this conversation as resolved.

It "No new assemblies are loaded" {
if ( (Get-PlatformInfo) -eq "alpine" ) {
if ( (Get-PlatformInfo).Platform -eq "alpine" ) {
Set-ItResult -Pending -Because "Missing MI library causes list to be different"
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Describe "Test-Connection" -tags "CI" {
{ $result = Test-Connection "fakeHost" -Count 1 -Quiet -ErrorAction Stop } |
Should -Throw -ErrorId "TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand"
# Error code = 11001 - Host not found.
if ((Get-PlatformInfo) -match "raspbian") {
if ((Get-PlatformInfo).Platform -match "raspbian") {
$code = 11
}
elseif (!$IsWindows) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Describe "Get-Date DRT Unit Tests" -Tags "CI" {
$seconds | Should -Be "1577836800"
if ($IsLinux) {
$dateString = "01/01/2020 UTC"
if ( (Get-PlatformInfo) -eq "alpine" ) {
if ( (Get-PlatformInfo).Platform -eq "alpine" ) {
$dateString = "2020-01-01"
}
$expected = date --date=${dateString} +%s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ Describe "DSC MOF Compilation" -tags "CI" {
}

BeforeAll {
$SkipAdditionalPlatforms = (Get-PlatformInfo) -match "alpine|raspbian"
$platformInfo = Get-PlatformInfo
$SkipAdditionalPlatforms =
($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')

Import-Module PSDesiredStateConfiguration
$dscModule = Get-Module PSDesiredStateConfiguration
$baseSchemaPath = Join-Path $dscModule.ModuleBase 'Configuration'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ Function Test-IsInvokeDscResourceEnable {
Describe "Test PSDesiredStateConfiguration" -tags CI {
BeforeAll {
$MissingLibmi = $false
if ((Get-PlatformInfo) -match "alpine|raspbian") {
$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')
) {
$MissingLibmi = $true
}
}
Expand Down
8 changes: 6 additions & 2 deletions test/powershell/engine/Remoting/PSSession.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ Describe "SkipCACheck and SkipCNCheck PSSession options are required for New-PSS
param ($scriptBlock, $expectedErrorCode)

$platformInfo = Get-PlatformInfo
if (($platformInfo -eq "alpine") -or ($platformInfo -eq "raspbian")) {
Set-ItResult -Skipped -Because "MI library not available for Alpine or Raspberry Pi"
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')
) {
Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, and CentOS 8"
return
}

Expand Down
16 changes: 12 additions & 4 deletions test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ Import-Module HelpersCommon
Describe "New-PSSession basic test" -Tag @("CI") {
It "New-PSSession should not crash powershell" {
$platformInfo = Get-PlatformInfo
if (($platformInfo -eq "alpine") -or ($platformInfo -eq "raspbian")) {
Set-ItResult -Skipped -Because "MI library not available for Alpine or Raspberry Pi"
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')
) {
Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, and CentOS 8"
return
}

Expand All @@ -19,8 +23,12 @@ 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 -eq "alpine") -or ($platformInfo -eq "raspbian")) {
Set-ItResult -Skipped -Because "MI library not available for Alpine or Raspberry Pi"
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')
) {
Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, and CentOS 8"
return
}

Expand Down
18 changes: 13 additions & 5 deletions test/tools/Modules/HelpersCommon/HelpersCommon.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -365,18 +365,26 @@ function New-ComplexPassword
}

# return a specific string with regard to platform information
function Get-PlatformInfo
{
function Get-PlatformInfo {
if ( $IsWindows ) {
return "windows"
return @{Platform = "windows"; Version = '' }
Comment thread
adityapatwardhan marked this conversation as resolved.
}
if ( $IsMacOS ) {
return "macos"
return @{Platform = "macos"; Version = '' }
}
if ( $IsLinux ) {
$osrelease = Get-Content /etc/os-release | ConvertFrom-StringData
if ( -not [string]::IsNullOrEmpty($osrelease.ID) ) {
return $osrelease.ID

$versionId = if (-not $osrelease.Version_ID ) {
''
} else {
$osrelease.Version_ID.trim('"')
}

$platform = $osrelease.ID.trim('"')

return @{Platform = $platform; Version = $versionId }
}
return "unknown"
}
Expand Down