diff --git a/.cirrus.yml b/.cirrus.yml index c2e75b787b..6db5aae1c8 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -856,6 +856,8 @@ podman_machine_windows_task: Get-Volume main_script: ".\\repo\\contrib\\cirrus\\win-podman-machine-main.ps1" always: + wsl_logs_artifacts: + path: ./*.zip # Required for `contrib/cirrus/logformatter` to work properly html_artifacts: path: ./*.html diff --git a/contrib/cirrus/win-collect-wsl-logs-start.ps1 b/contrib/cirrus/win-collect-wsl-logs-start.ps1 new file mode 100644 index 0000000000..4dec63228f --- /dev/null +++ b/contrib/cirrus/win-collect-wsl-logs-start.ps1 @@ -0,0 +1,108 @@ +# MIT License +# +# Copyright (c) Microsoft Corporation. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE + +# This script is an adapted version of +# https://github.com/Microsoft/WSL/blob/master/diagnostics/collect-wsl-logs.ps1 + +#Requires -RunAsAdministrator + +[CmdletBinding()] +Param ( + $LogProfile = $null + ) + +Set-StrictMode -Version Latest + +$folder = "WslLogs" + (Get-Date -Format "yyyy-MM-dd_HH-mm-ss") +mkdir -p $folder | Out-Null + +if ($LogProfile -eq $null -Or ![System.IO.File]::Exists($LogProfile)) +{ + if ($LogProfile -eq $null) + { + $url = "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp" + } + elseif ($LogProfile -eq "storage") + { + $url = "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl_storage.wprp" + } + else + { + Write-Error "Unknown log profile: $LogProfile" + exit 1 + } + + $LogProfile = "$folder/wsl.wprp" + try { + Invoke-WebRequest -UseBasicParsing $url -OutFile $LogProfile + } + catch { + throw + } +} + +reg.exe export HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss $folder/HKCU.txt 2>&1 | Out-Null +reg.exe export HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Lxss $folder/HKLM.txt 2>&1 | Out-Null +reg.exe export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\P9NP $folder/P9NP.txt 2>&1 | Out-Null +reg.exe export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2 $folder/Winsock2.txt 2>&1 | Out-Null +# Skipping the next reg.exe command because it's failing with error +# "ERROR: The system was unable to find the specified registry key or value" +# on the CI server (Windows Server 2022) +# reg.exe export "HKEY_CLASSES_ROOT\CLSID\{e66b0f30-e7b4-4f8c-acfd-d100c46c6278}" $folder/wslsupport-proxy.txt 2>&1 | Out-Null +reg.exe export "HKEY_CLASSES_ROOT\CLSID\{a9b7a1b9-0671-405c-95f1-e0612cb4ce7e}" $folder/wslsupport-impl.txt 2>&1 | Out-Null +Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" > $folder/windows-version.txt + +Get-Service wslservice -ErrorAction Ignore | Format-list * -Force > $folder/wslservice.txt + +$wslconfig = "$env:USERPROFILE/.wslconfig" +if (Test-Path $wslconfig) +{ + Copy-Item $wslconfig $folder | Out-Null +} + +get-appxpackage MicrosoftCorporationII.WindowsSubsystemforLinux -ErrorAction Ignore > $folder/appxpackage.txt +get-acl "C:\ProgramData\Microsoft\Windows\WindowsApps" -ErrorAction Ignore | Format-List > $folder/acl.txt +Get-WindowsOptionalFeature -Online > $folder/optional-components.txt +bcdedit.exe > $folder/bcdedit.txt + +$uninstallLogs = "$env:TEMP/wsl-uninstall-logs.txt" +if (Test-Path $uninstallLogs) +{ + Copy-Item $uninstallLogs $folder | Out-Null +} + +$wprOutputLog = "$folder/wpr.txt" + +wpr.exe -start $LogProfile -filemode 2>&1 >> $wprOutputLog +if ($LastExitCode -Ne 0) +{ + Write-Host -ForegroundColor Yellow "Log collection failed to start (exit code: $LastExitCode), trying to reset it." + wpr.exe -cancel 2>&1 >> $wprOutputLog + + wpr.exe -start $LogProfile -filemode 2>&1 >> $wprOutputLog + if ($LastExitCode -Ne 0) + { + Write-Host -ForegroundColor Red "Couldn't start log collection (exitCode: $LastExitCode)" + } +} + +Write-Host "`nWSL Log collection is running." diff --git a/contrib/cirrus/win-collect-wsl-logs-stop.ps1 b/contrib/cirrus/win-collect-wsl-logs-stop.ps1 new file mode 100644 index 0000000000..be71966f4b --- /dev/null +++ b/contrib/cirrus/win-collect-wsl-logs-stop.ps1 @@ -0,0 +1,45 @@ +# MIT License +# +# Copyright (c) Microsoft Corporation. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE + +# This script is an adapted version of +# https://github.com/Microsoft/WSL/blob/master/diagnostics/collect-wsl-logs.ps1 + +#Requires -RunAsAdministrator + +Set-StrictMode -Version Latest + +# get the directory that has a name that starts with WslLogs +$folder = Get-ChildItem -Directory | Where-Object { $_.Name -like "WslLogs*" } | Select-Object -First 1 +$wprOutputLog = "$folder/wpr.txt" + +Write-Host "Saving WSL logs..." +wpr.exe -stop $folder/logs.etl 2>&1 >> $wprOutputLog + +$logArchive = "$(Resolve-Path $folder).zip" +Compress-Archive -Path $folder -DestinationPath $logArchive +Remove-Item $folder -Recurse + +$fileName = (Get-Item $logArchive).Name +$parentFolder = (Get-Item $logArchive).Directory.Parent.FullName +Move-Item -Path $logArchive -Destination $parentFolder + +Write-Host -ForegroundColor Green "Logs saved in: ${parentFolder}/${fileName}" diff --git a/contrib/cirrus/win-podman-machine-test.ps1 b/contrib/cirrus/win-podman-machine-test.ps1 index 6ef782033f..098a892279 100644 --- a/contrib/cirrus/win-podman-machine-test.ps1 +++ b/contrib/cirrus/win-podman-machine-test.ps1 @@ -41,4 +41,15 @@ $Env:TMP = 'Z:\' $Env:TEMP = 'Z:\' Write-Host "`nRunning podman-machine e2e tests" -Run-Command ".\winmake localmachine" + +if ($Env:TEST_FLAVOR -eq "machine-wsl") { + Run-Command "$PSScriptRoot\win-collect-wsl-logs-start.ps1" +} + +try { + Run-Command ".\winmake localmachine" +} finally { + if ($Env:TEST_FLAVOR -eq "machine-wsl") { + Run-Command "$PSScriptRoot\win-collect-wsl-logs-stop.ps1" + } +} diff --git a/winmake.ps1 b/winmake.ps1 index a02fe344e3..247b729986 100644 --- a/winmake.ps1 +++ b/winmake.ps1 @@ -86,7 +86,7 @@ function Local-Machine { $focus = "--focus ""$FOCUS"" --silence-skips" } - Run-Command "./bin/ginkgo.exe -vv --tags `"$remotetags`" --timeout=90m --trace --no-color $focus $files pkg/machine/e2e/." + Run-Command "./bin/ginkgo.exe -vv --tags `"$remotetags`" --timeout=50m --trace --no-color $focus $files pkg/machine/e2e/." } # Expect starting directory to be /podman