Skip to content

Enable port forwarding tests for WSL2 #3357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2025
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
13 changes: 7 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,13 @@ jobs:
run: make
- name: Integration tests (WSL2, Windows host)
run: |
$env:Path = "$pwd\_output\bin;" + 'C:\Program Files\Git\usr\bin;' + $env:Path
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $env:Path
$env:MSYS2_ENV_CONV_EXCL='HOME_HOST;HOME_GUEST'
$env:HOME_HOST=$(cygpath.exe "$env:USERPROFILE")
$env:HOME_GUEST="/mnt$env:HOME_HOST"
$env:LIMACTL_CREATE_ARGS='--vm-type=wsl2 --mount-type=wsl2 --containerd=system'
$env:PATH = "$pwd\_output\bin;" + 'C:\msys64\usr\bin;' + $env:PATH
pacman -Sy --noconfirm openbsd-netcat diffutils
$env:MSYS2_ENV_CONV_EXCL = 'HOME_HOST;HOME_GUEST;_LIMA_WINDOWS_EXTRA_PATH'
$env:HOME_HOST = $(cygpath.exe "$env:USERPROFILE")
$env:HOME_GUEST = "/mnt$env:HOME_HOST"
$env:LIMACTL_CREATE_ARGS = '--vm-type=wsl2 --mount-type=wsl2 --containerd=system'
$env:_LIMA_WINDOWS_EXTRA_PATH = 'C:\Program Files\Git\usr\bin'
bash.exe -c "./hack/test-templates.sh templates/experimental/wsl2.yaml"

qemu:
Expand Down
15 changes: 13 additions & 2 deletions hack/test-port-forwarding.pl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
# Otherwise $instance must be the name of an already running instance that has been
# configured with our portForwards settings.

my $instanceType = qx(limactl ls --json "$instance" | jq -r '.vmType' | sed s/x/x/);
chomp $instanceType;

# Get sshLocalPort for lima instance
my $sshLocalPort;
open(my $ls, "limactl ls --json |") or die;
Expand Down Expand Up @@ -96,12 +99,20 @@
/^(forward|ignore):\s+([0-9.:]+)\s+(\d+)(?:\s+→)?(?:\s+([0-9.:]+)(?:\s+(\d+))?)?/;
die "Cannot parse test '$_'" unless $1;
my %test; @test{qw(mode guest_ip guest_port host_ip host_port)} = ($1, $2, $3, $4, $5);
$test{host_ip} ||= "127.0.0.1";
$test{host_port} ||= $test{guest_port};
if ($test{mode} eq "forward" && $test{host_port} < 1024 && $Config{osname} ne "darwin") {
printf "🚧 Not supported on $Config{osname}: # $_\n";
next;
}
$test{host_ip} ||= "127.0.0.1";
$test{host_port} ||= $test{guest_port};
if ($test{mode} eq "ignore" && ($test{guest_ip} eq "0.0.0.0" || $test{guest_ip} eq "127.0.0.1") && "$instanceType" eq "wsl2") {
printf "🚧 Not supported for $instanceType machines: # $_\n";
next;
}
if ($test{guest_ip} eq "192.168.5.15" && "$instanceType" eq "wsl2") {
printf "🚧 Not supported for $instanceType machines: # $_\n";
next;
}

my $remote = JoinHostPort($test{guest_ip},$test{guest_port});
my $local = JoinHostPort($test{host_ip},$test{host_port});
Expand Down
1 change: 0 additions & 1 deletion hack/test-templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ case "$NAME" in
"wsl2")
# TODO https://github.com/lima-vm/lima/issues/3268
CHECKS["proxy-settings"]=
CHECKS["port-forwards"]=
;;
esac

Expand Down
Loading