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
8 changes: 7 additions & 1 deletion build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,13 @@ function Start-PSPester {
Write-Verbose "Running pester tests at '$path' with tag '$($Tag -join ''', ''')' and ExcludeTag '$($ExcludeTag -join ''', ''')'" -Verbose
if(!$SkipTestToolBuild.IsPresent)
{
Publish-PSTestTools | ForEach-Object {Write-Host $_}
$publishArgs = @{ }
# if we are building for Alpine, we must include the runtime as linux-x64
# will not build runnable test tools
if ( $Environment.IsAlpine ) {
$publishArgs['runtime'] = 'alpine-x64'
}
Publish-PSTestTools @publishArgs | ForEach-Object {Write-Host $_}
}

# All concatenated commands/arguments are suffixed with the delimiter (space)
Expand Down
5 changes: 5 additions & 0 deletions test/powershell/Host/Startup.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ Describe "Validate start of console host" -Tag CI {
}

It "No new assemblies are loaded" {
if ( (Get-PlatformInfo) -eq "alpine" ) {
Set-ItResult -Pending -Because "Missing MI library causes list to be different"
return
}

$diffs = Compare-Object -ReferenceObject $allowedAssemblies -DifferenceObject $loadedAssemblies

if ($null -ne $diffs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ Describe "Test-Connection" -tags "CI" {
# After .Net Core fix we should have 'DontFragment | Should -Be $true' here.
$result1.Replies[0].Options.Ttl | Should -BeLessOrEqual 128
if (!$isWindows) {
$result1.Replies[0].Options.DontFragment | Should -BeNullOrEmpty
if ( (Get-PlatformInfo) -eq "alpine" ) {
$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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ Describe "Get-Date DRT Unit Tests" -Tags "CI" {

$seconds | Should -Be "1577836800"
if ($isLinux) {
$seconds | Should -Be (date --date='01/01/2020 UTC' +%s)
$dateString = "01/01/2020 UTC"
if ( (Get-PlatformInfo) -eq "alpine" ) {
$dateString = "2020-01-01"
}
$expected = date --date=${dateString} +%s
$seconds | Should -Be $expected
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Describe "DSC MOF Compilation" -tags "CI" {
}

BeforeAll {
$IsAlpine = (Get-PlatformInfo) -eq "alpine"
Import-Module PSDesiredStateConfiguration
$dscModule = Get-Module PSDesiredStateConfiguration
$baseSchemaPath = Join-Path $dscModule.ModuleBase 'Configuration'
Expand All @@ -20,7 +21,7 @@ Describe "DSC MOF Compilation" -tags "CI" {
$env:PSModulePath = join-path ([io.path]::GetDirectoryName($powershellexe)) Modules
}

It "Should be able to compile a MOF from a basic configuration" -Skip:($IsMacOS -or $IsWindows) {
It "Should be able to compile a MOF from a basic configuration" -Skip:($IsMacOS -or $IsWindows -or $IsAlpine) {
[Scriptblock]::Create(@"
configuration DSCTestConfig
{
Expand All @@ -39,7 +40,7 @@ Describe "DSC MOF Compilation" -tags "CI" {
"TestDrive:\DscTestConfig1\localhost.mof" | Should -Exist
}

It "Should be able to compile a MOF from another basic configuration" -Skip:($IsMacOS -or $IsWindows) {
It "Should be able to compile a MOF from another basic configuration" -Skip:($IsMacOS -or $IsWindows -or $IsAlpine) {
[Scriptblock]::Create(@"
configuration DSCTestConfig
{
Expand All @@ -61,7 +62,7 @@ Describe "DSC MOF Compilation" -tags "CI" {
"TestDrive:\DscTestConfig2\localhost.mof" | Should -Exist
}

It "Should be able to compile a MOF from a complex configuration" -Skip:($IsMacOS -or $IsWindows) {
It "Should be able to compile a MOF from a complex configuration" -Skip:($IsMacOS -or $IsWindows -or $IsAlpine) {
[Scriptblock]::Create(@"
Configuration WordPressServer{

Expand Down Expand Up @@ -170,7 +171,7 @@ Describe "DSC MOF Compilation" -tags "CI" {
"TestDrive:\DscTestConfig3\CentOS.mof" | Should -Exist
}

It "Should be able to compile a MOF from a basic configuration on Windows" -Skip:($IsMacOS -or $IsLinux) {
It "Should be able to compile a MOF from a basic configuration on Windows" -Skip:($IsMacOS -or $IsLinux -or $IsAlpine) {
[Scriptblock]::Create(@"
configuration DSCTestConfig
{
Expand All @@ -190,7 +191,7 @@ Describe "DSC MOF Compilation" -tags "CI" {
"TestDrive:\DscTestConfig4\localhost.mof" | Should -Exist
}

It "Should be able to compile a MOF from a configuration with multiple resources on Windows" -Skip:($IsMacOS -or $IsLinux) {
It "Should be able to compile a MOF from a configuration with multiple resources on Windows" -Skip:($IsMacOS -or $IsLinux -or $IsAlpine) {
[Scriptblock]::Create(@"
configuration DSCTestConfig
{
Expand Down
5 changes: 5 additions & 0 deletions test/powershell/engine/Remoting/PSSession.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ Describe "SkipCACheck and SkipCNCheck PSSession options are required for New-PSS
It "<Name>" -TestCases $testCases {
param ($scriptBlock, $expectedErrorCode)

if ( (Get-PlatformInfo) -eq "alpine" ) {
Set-ItResult -Pending -Because "MI library not available for Alpine"
return
}

$er = { & $scriptBlock } | Should -Throw -ErrorId 'System.Management.Automation.Remoting.PSRemotingDataStructureException,Microsoft.PowerShell.Commands.NewPSSessionCommand' -PassThru
$er.Exception.ErrorCode | Should -Be $expectedErrorCode
}
Expand Down
15 changes: 15 additions & 0 deletions test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@ Import-Module HelpersCommon

Describe "New-PSSession basic test" -Tag @("CI") {
It "New-PSSession should not crash powershell" {
if ( (Get-PlatformInfo) -eq "alpine" ) {
Set-ItResult -Pending -Because "MI library not available for Alpine"
return
}

{ New-PSSession -ComputerName nonexistcomputer -Authentication Basic } |
Should -Throw -ErrorId "InvalidOperation,Microsoft.PowerShell.Commands.NewPSSessionCommand"
}
}

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) {
if ( (Get-PlatformInfo) -eq "alpine" ) {
Set-ItResult -Pending -Because "MI library not available for Alpine"
return
}

$password = ConvertTo-SecureString -String "password" -AsPlainText -Force
$credential = [PSCredential]::new('username', $password)

Expand All @@ -23,6 +33,11 @@ Describe "Basic Auth over HTTP not allowed on Unix" -Tag @("CI") {
}

It "New-PSSession should NOT throw a ConnectFailed exception when specifying Basic Auth over HTTPS on Unix" -skip:($IsWindows) {
if ( (Get-PlatformInfo) -eq "alpine" ) {
Set-ItResult -Pending -Because "MI library not available for Alpine"
return
}

$password = ConvertTo-SecureString -String "password" -AsPlainText -Force
$credential = [PSCredential]::new('username', $password)

Expand Down
1 change: 1 addition & 0 deletions test/tools/Modules/HelpersCommon/HelpersCommon.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ FunctionsToExport = @(
'Test-TesthookIsSet'
'Wait-FileToBePresent'
'Wait-UntilTrue'
'Get-PlatformInfo'
)

CmdletsToExport= @()
Expand Down
18 changes: 18 additions & 0 deletions test/tools/Modules/HelpersCommon/HelpersCommon.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,21 @@ function New-ComplexPassword

$password
}

# return a specific string with regard to platform information
function Get-PlatformInfo
{
if ( $IsWindows ) {
return "windows"
}
if ( $IsMacOS ) {
return "macos"
}
if ( $IsLinux ) {
$osrelease = Get-Content /etc/os-release | ConvertFrom-StringData
if ( -not [string]::IsNullOrEmpty($osrelease.ID) ) {
return $osrelease.ID
}
return "unknown"
}
}