mirror of
https://github.com/containers/podman.git
synced 2025-06-20 17:13:43 +08:00
Cirrus: Execute Windows podman-machine e2e tests
Also, de-duplicate power-shell variables and functions as they're beginning to sprawl. This does not completely address all duplicates, mainly those involved in the podman-machine CI workflow. So, nothing under `contrib/win-installer` has been touched. [NO NEW TESTS NEEDED] Signed-off-by: Chris Evich <cevich@redhat.com>
This commit is contained in:
@ -418,7 +418,7 @@ dotest() {
|
||||
|& logformatter
|
||||
}
|
||||
|
||||
_run_machine() {
|
||||
_run_machine-linux() {
|
||||
# N/B: Can't use _bail_if_test_can_be_skipped here b/c content isn't under test/
|
||||
showrun make localmachine |& logformatter
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ case "$TEST_FLAVOR" in
|
||||
showrun minikube config set driver podman
|
||||
install_test_configs
|
||||
;;
|
||||
machine)
|
||||
machine-linux)
|
||||
showrun dnf install -y podman-gvproxy*
|
||||
remove_packaged_podman_files
|
||||
showrun make install PREFIX=/usr ETCDIR=/etc
|
||||
|
@ -1,27 +0,0 @@
|
||||
# Update service is required for dotnet 3.5 (dep of wix)
|
||||
Set-Service -Name wuauserv -StartupType "Manual"
|
||||
function retryInstall {
|
||||
param([Parameter(ValueFromRemainingArguments)] [string[]] $pkgs)
|
||||
|
||||
foreach ($pkg in $pkgs) {
|
||||
for ($retries = 0; ; $retries++) {
|
||||
if ($retries -gt 5) {
|
||||
throw "Could not install package $pkg"
|
||||
}
|
||||
|
||||
if ($pkg -match '(.[^\@]+)@(.+)') {
|
||||
$pkg = @("--version", $Matches.2, $Matches.1)
|
||||
}
|
||||
|
||||
choco install -y --allow-downgrade $pkg
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
break
|
||||
}
|
||||
Write-Output "Error installing, waiting before retry..."
|
||||
Start-Sleep -Seconds 6
|
||||
}
|
||||
}
|
||||
}
|
||||
# Force mingw version 11.2 since later versions are incompatible
|
||||
# with CGO on some versions of golang
|
||||
retryInstall wixtoolset mingw@11.2 golang archiver
|
@ -1,52 +1,12 @@
|
||||
# Powershell doesn't exit after
|
||||
function CheckExit {
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Exit code = $LASTEXITCODE"
|
||||
}
|
||||
}
|
||||
function DownloadFile {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$url,
|
||||
[Parameter(Mandatory)]
|
||||
[string]$file,
|
||||
[Int]$retries=5,
|
||||
[Int]$delay=8
|
||||
)
|
||||
$ProgressPreference = 'SilentlyContinue';
|
||||
Write-Host "Downloading $url to $file"
|
||||
For($i = 0;;) {
|
||||
Try {
|
||||
Invoke-WebRequest -UseBasicParsing -ErrorAction Stop -Uri $url -OutFile $file
|
||||
Break
|
||||
} Catch {
|
||||
if (++$i -gt $retries) {
|
||||
throw $_.Exception
|
||||
}
|
||||
Write-Host "Download failed - retrying:" $_.Exception.Response.StatusCode
|
||||
Start-Sleep -Seconds $delay
|
||||
}
|
||||
}
|
||||
}
|
||||
# Drop global envs which have unix paths, defaults are fine
|
||||
Remove-Item Env:\GOPATH -ErrorAction:Ignore
|
||||
Remove-Item Env:\GOSRC -ErrorAction:Ignore
|
||||
Remove-Item Env:\GOCACHE -ErrorAction:Ignore
|
||||
#!/usr/bin/env powershell
|
||||
|
||||
# Drop large known env variables (an env > 32k will break MSI/ICE validation)
|
||||
Remove-Item Env:\CIRRUS_COMMIT_MESSAGE -ErrorAction:Ignore
|
||||
Remove-Item Env:\CIRRUS_PR_BODY -ErrorAction:Ignore
|
||||
. $PSScriptRoot\win-lib.ps1
|
||||
|
||||
Set-Location contrib\win-installer
|
||||
|
||||
# Download and extract alt_build win release zip
|
||||
$url = "${ENV:ART_URL}/Windows Cross/repo/repo.tbz"
|
||||
# Arc requires extension to be "tbz2"
|
||||
DownloadFile "$url" "repo.tbz2"
|
||||
arc unarchive repo.tbz2 .; CheckExit
|
||||
Set-Location "$ENV:CIRRUS_WORKING_DIR\repo\contrib\win-installer"
|
||||
|
||||
# Build Installer
|
||||
.\build.ps1 $Env:WIN_INST_VER dev repo; CheckExit
|
||||
# Note: consumes podman-remote-release-windows_amd64.zip from repo.tbz2
|
||||
Run-Command ".\build.ps1 $Env:WIN_INST_VER dev `"$ENV:CIRRUS_WORKING_DIR\repo`""
|
||||
|
||||
# Run the installer silently and WSL install option disabled (prevent reboots, wsl requirements)
|
||||
# We need AllowOldWin=1 for server 2019 (cirrus image), can be dropped after server 2022
|
||||
|
72
contrib/cirrus/win-lib.ps1
Normal file
72
contrib/cirrus/win-lib.ps1
Normal file
@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env powershell
|
||||
|
||||
# This powershell script is intended to be "dot-sourced" by other scripts.
|
||||
# It's purpose is identical to that of the `lib.sh` script for Linux environments.
|
||||
|
||||
# Behave similar to `set -e` in bash, but ONLY for powershell commandlets!
|
||||
# For all legacy, program, and script calls use Run-Command() or Check-Exit()
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
# Any golang compilation needs to know what it's building for.
|
||||
$Env:GOOS = "windows"
|
||||
$Env:GOARCH = "amd64"
|
||||
|
||||
# Unnecessary and intrusive. They claim parameter/variable
|
||||
# values aren't collected, but there could be a bug leading
|
||||
# to a concern over leaking of some sensitive-value. Stop this.
|
||||
$Env:POWERSHELL_TELEMETRY_OPTOUT = "true"
|
||||
|
||||
# Unnecessary and potentially disruptive. Powershell will
|
||||
# never ever be updated during automation execution. Stop this.
|
||||
$Env:POWERSHELL_UPDATECHECK = "off"
|
||||
|
||||
# Color in output may confuse tooling and makes logs hard to read.
|
||||
# TODO: There are probably other places where color needs to be disabled
|
||||
# in a slightly different way :(
|
||||
$Env:NO_COLOR = "true"
|
||||
|
||||
# Items only relevant in a CI environment.
|
||||
if ($Env:CI -eq "true") {
|
||||
# Defined by .cirrus.yml for use by all the linux tasks.
|
||||
# Drop all global envs which have unix paths, defaults are fine.
|
||||
Remove-Item Env:\GOPATH -ErrorAction:Ignore
|
||||
Remove-Item Env:\GOSRC -ErrorAction:Ignore
|
||||
Remove-Item Env:\GOCACHE -ErrorAction:Ignore
|
||||
|
||||
# Defined by Cirrus-CI
|
||||
# Drop large known env variables (an env > 32k will break MSI/ICE validation)
|
||||
Remove-Item Env:\CIRRUS_COMMIT_MESSAGE -ErrorAction:Ignore
|
||||
Remove-Item Env:\CIRRUS_CHANGE_MESSAGE -ErrorAction:Ignore
|
||||
Remove-Item Env:\CIRRUS_PR_BODY -ErrorAction:Ignore
|
||||
}
|
||||
|
||||
# Non-powershell commands do not halt execution on error! This helper
|
||||
# should be called after every critical operation to check and halt on a
|
||||
# non-zero exit code. Be careful not to use this for powershell commandlets
|
||||
# (builtins)! They set '$?' to "True" (failed) or "False" success so calling
|
||||
# this would mask failures. Rely on $ErrorActionPreference = 'Stop' instead.
|
||||
function Check-Exit {
|
||||
$result = $LASTEXITCODE # WARNING: might not be a number!
|
||||
if ( ($result -ne $null) -and ($result -ne 0) ) {
|
||||
# https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.callstackframe
|
||||
$caller = (Get-PSCallStack)[1]
|
||||
Write-Host "Exit code = '$result' from $($caller.ScriptName):$($caller.ScriptLineNumber)"
|
||||
Exit $result
|
||||
}
|
||||
}
|
||||
|
||||
# Small helper to avoid needing to write 'Check-Exit' after every
|
||||
# non-powershell instruction. It simply prints then executes the _QUOTED_
|
||||
# argument followed by Check-Exit.
|
||||
# N/B: Escape any nested quotes with back-tick ("`") characters.
|
||||
# WARNING: DO NOT use this with powershell builtins! It will not do what you expect!
|
||||
function Run-Command {
|
||||
param (
|
||||
[string] $command
|
||||
)
|
||||
|
||||
Write-Host $command
|
||||
|
||||
Invoke-Expression $command
|
||||
Check-Exit
|
||||
}
|
@ -1,39 +1,20 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
#!/usr/bin/env powershell
|
||||
|
||||
# Powershell doesn't exit after command failures
|
||||
# Note, due to a bug in cirrus that does not correctly evaluate exit
|
||||
# code, error conditions should always be thrown
|
||||
function CheckExit {
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Exit code failure = $LASTEXITCODE"
|
||||
}
|
||||
}
|
||||
. $PSScriptRoot\win-lib.ps1
|
||||
|
||||
# Drop global envs which have unix paths, defaults are fine
|
||||
Remove-Item Env:\GOPATH -ErrorAction:Ignore
|
||||
Remove-Item Env:\GOSRC -ErrorAction:Ignore
|
||||
Remove-Item Env:\GOCACHE -ErrorAction:Ignore
|
||||
Set-Location "$ENV:CIRRUS_WORKING_DIR\repo"
|
||||
|
||||
mkdir tmp
|
||||
Set-Location tmp
|
||||
|
||||
# Download and extract alt_build win release zip
|
||||
$url = "${ENV:ART_URL}/Windows%20Cross/repo/repo.tbz"
|
||||
Write-Output "URL: $url"
|
||||
# Arc requires extension to be "tbz2"
|
||||
curl.exe -L -o repo.tbz2 "$url"; CheckExit
|
||||
arc unarchive repo.tbz2 .; CheckExit
|
||||
Set-Location repo
|
||||
Expand-Archive -Path "podman-remote-release-windows_amd64.zip" `
|
||||
-DestinationPath extracted
|
||||
Set-Location extracted
|
||||
$x = Get-ChildItem -Path bin -Recurse
|
||||
Set-Location $x
|
||||
Write-Host "Saving selection of CI env. vars."
|
||||
# Env. vars will not pass through win-sess-launch.ps1
|
||||
Get-ChildItem -Path "Env:\*" -include @("PATH", "Chocolatey*", "CIRRUS*", "TEST_*", "CI_*") `
|
||||
| Export-CLIXML "$ENV:TEMP\envars.xml"
|
||||
|
||||
# Recent versions of WSL are packaged as a Windows store app running in
|
||||
# an appX container, which is incompatible with non-interactive
|
||||
# session 0 execution (where the cirrus agent runs).
|
||||
# Run verification under an interactive session instead.
|
||||
powershell.exe -File "$PSScriptRoot\wsl-env-launch.ps1" `
|
||||
"$PSScriptRoot\win-podman-machine-verify.ps1"
|
||||
CheckExit
|
||||
Write-Host "Spawning new session to execute $PSScriptRoot\win-podman-machine-test.ps1"
|
||||
# Can't use Run-Command(), would need overly-complex nested quoting
|
||||
powershell.exe -File "$PSScriptRoot\win-sess-launch.ps1" `
|
||||
"$PSScriptRoot\win-podman-machine-test.ps1"
|
||||
Check-Exit
|
||||
|
33
contrib/cirrus/win-podman-machine-test.ps1
Normal file
33
contrib/cirrus/win-podman-machine-test.ps1
Normal file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env powershell
|
||||
|
||||
. $PSScriptRoot\win-lib.ps1
|
||||
|
||||
Write-Host "Recovering env. vars."
|
||||
Import-CLIXML "$ENV:TEMP\envars.xml" | % {
|
||||
Write-Host " $($_.Name) = $($_.Value)"
|
||||
Set-Item "Env:$($_.Name)" "$($_.Value)"
|
||||
}
|
||||
|
||||
if ($Env:TEST_FLAVOR -eq "machine-wsl") {
|
||||
# FIXME: Test-modes should be definitively set and positively asserted.
|
||||
# Otherwise if the var. goes out-of-scope, defaults change, or definition
|
||||
# fails: Suddenly assumed behavior != actual behaviorr, esp. if/when only
|
||||
# quickly glancing at a green status check-mark.
|
||||
$Env:CONTAINERS_MACHINE_PROVIDER = "" # IMPLIES WSL
|
||||
} elseif ($Env:TEST_FLAVOR -eq "machine-hyperv") {
|
||||
$Env:CONTAINERS_MACHINE_PROVIDER = "hyperv"
|
||||
} else {
|
||||
Write-Host "Unsupported value for `$TEST_FLAVOR '$Env:TEST_FLAVOR'"
|
||||
Exit 1
|
||||
}
|
||||
# Make sure an observer knows the value of this critical variable (consumed by tests).
|
||||
Write-Host " CONTAINERS_MACHINE_PROVIDER = $Env:CONTAINERS_MACHINE_PROVIDER"
|
||||
Write-Host "`n"
|
||||
|
||||
# The repo.tbz artifact was extracted here
|
||||
Set-Location "$ENV:CIRRUS_WORKING_DIR\repo"
|
||||
# Tests hard-code this location for podman-remote binary, make sure it actually runs.
|
||||
Run-Command ".\bin\windows\podman.exe --version"
|
||||
|
||||
Write-Host "`nRunning podman-machine e2e tests"
|
||||
Run-Command ".\winmake localmachine"
|
@ -1,27 +0,0 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
function CheckExit {
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Exit code failure = $LASTEXITCODE"
|
||||
}
|
||||
}
|
||||
|
||||
# Verify extracted podman binary
|
||||
Write-Output `n"Starting init...`n"
|
||||
.\podman machine init; CheckExit
|
||||
Write-Output "`nStarting podman machine...`n"
|
||||
.\podman machine start; CheckExit
|
||||
Write-Output "`nDumping info...`n"
|
||||
for ($i =0; $i -lt 60; $i++) {
|
||||
.\podman info
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
break
|
||||
}
|
||||
Start-Sleep -Seconds 2
|
||||
}
|
||||
Write-Output "`nRunning container...`n"
|
||||
.\podman run ubi8-micro sh -c "exit 123"
|
||||
if ($LASTEXITCODE -ne 123) {
|
||||
throw "Expected 123, got $LASTEXITCODE"
|
||||
}
|
||||
Write-Host "`nMachine verification is successful!`n"
|
||||
Exit 0
|
Reference in New Issue
Block a user