Skip to content

Commit 7ad8f0c

Browse files
committed
WSL machine tests: increase kernel boot timeout
This is to avoid CI/CD flakes and is based on this analysis of the WSL flakes logs: microsoft/WSL#13301 (comment) Signed-off-by: Mario Loriedo <[email protected]>
1 parent 80b20c7 commit 7ad8f0c

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

contrib/cirrus/win-podman-machine-test.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,25 @@ $Env:TEMP = 'Z:\'
4343
Write-Host "`nRunning podman-machine e2e tests"
4444

4545
if ($Env:TEST_FLAVOR -eq "machine-wsl") {
46+
if ($Env:CIRRUS_CI -eq "true") {
47+
# Add a WSL configuration file
48+
# The `kernelBootTimeout` configuration is to prevent CI/CD flakes
49+
# See
50+
# https://github.com/microsoft/WSL/issues/13301#issuecomment-3367452109
51+
Write-Host "`nAdding WSL configuration file"
52+
$wslConfigPath = "$env:UserProfile\.wslconfig"
53+
$wslConfigContent = @"
54+
[wsl2]
55+
kernelBootTimeout=300000 # 5 minutes
56+
"@
57+
Set-Content -Path $wslConfigPath -Value $wslConfigContent -Encoding utf8
58+
wsl --shutdown
59+
Write-Host "`n$wslConfigPath content:"
60+
Get-Content -Path $wslConfigPath
61+
}
62+
4663
# Output info so we know what version we are testing.
64+
Write-Host "`nOutputting WSL version:"
4765
wsl --version
4866
Run-Command "$PSScriptRoot\win-collect-wsl-logs-start.ps1"
4967
}

pkg/machine/e2e/machine_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,21 @@ func setup() (string, *machineTestBuilder) {
144144
if err := os.Setenv("USERPROFILE", homeDir); err != nil {
145145
Fail("unable to set home dir on windows")
146146
}
147+
if testProvider.VMType() == define.WSLVirt {
148+
// create file $USERPROFILE/.wslconfig
149+
// https://github.com/microsoft/WSL/issues/13301#issuecomment-3367452109
150+
wslconfig, err := os.Create(filepath.Join(homeDir, ".wslconfig"))
151+
if err != nil {
152+
Fail(fmt.Sprintf("failed to create wslconfig file: %q", err))
153+
}
154+
_, err = wslconfig.WriteString("[wsl]\nkernelBootTimeout=300000")
155+
if err != nil {
156+
Fail(fmt.Sprintf("failed to write wslconfig file: %q", err))
157+
}
158+
if err := wslconfig.Close(); err != nil {
159+
Fail(fmt.Sprintf("failed to close wslconfig file: %q", err))
160+
}
161+
}
147162
}
148163
if err := os.Setenv("XDG_RUNTIME_DIR", homeDir); err != nil {
149164
Fail("failed to set xdg_runtime dir")

0 commit comments

Comments
 (0)