Skip to content

Commit 72588bf

Browse files
committed
Enable port forwarding tests for WSL2
Signed-off-by: Arthur Sengileyev <[email protected]>
1 parent 05ff20d commit 72588bf

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,14 @@ jobs:
166166
run: make
167167
- name: Integration tests (WSL2, Windows host)
168168
run: |
169-
$env:Path = "$pwd\_output\bin;" + 'C:\Program Files\Git\usr\bin;' + $env:Path
169+
$env:Path = "$pwd\_output\bin;" + 'C:\msys64\usr\bin;' + $env:Path
170+
pacman -Sy --noconfirm openbsd-netcat diffutils
170171
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $env:Path
171-
$env:MSYS2_ENV_CONV_EXCL='HOME_HOST;HOME_GUEST'
172-
$env:HOME_HOST=$(cygpath.exe "$env:USERPROFILE")
173-
$env:HOME_GUEST="/mnt$env:HOME_HOST"
174-
$env:LIMACTL_CREATE_ARGS='--vm-type=wsl2 --mount-type=wsl2 --containerd=system'
172+
$env:MSYS2_ENV_CONV_EXCL = 'HOME_HOST;HOME_GUEST;_LIMA_WINDOWS_EXTRA_PATH'
173+
$env:HOME_HOST = $(cygpath.exe "$env:USERPROFILE")
174+
$env:HOME_GUEST = "/mnt$env:HOME_HOST"
175+
$env:LIMACTL_CREATE_ARGS = '--vm-type=wsl2 --mount-type=wsl2 --containerd=system'
176+
$env:_LIMA_WINDOWS_EXTRA_PATH = 'C:\Program Files\Git\usr\bin'
175177
bash.exe -c "./hack/test-templates.sh templates/experimental/wsl2.yaml"
176178
177179
qemu:

hack/test-port-forwarding.pl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@
6868
# Otherwise $instance must be the name of an already running instance that has been
6969
# configured with our portForwards settings.
7070

71+
my $instanceType = qx(limactl ls --json "$instance" | jq -r '.vmType' | sed s/x/x/);
72+
chomp $instanceType;
73+
7174
# Get sshLocalPort for lima instance
7275
my $sshLocalPort;
7376
open(my $ls, "limactl ls --json |") or die;
@@ -96,12 +99,20 @@
9699
/^(forward|ignore):\s+([0-9.:]+)\s+(\d+)(?:\s+→)?(?:\s+([0-9.:]+)(?:\s+(\d+))?)?/;
97100
die "Cannot parse test '$_'" unless $1;
98101
my %test; @test{qw(mode guest_ip guest_port host_ip host_port)} = ($1, $2, $3, $4, $5);
102+
$test{host_ip} ||= "127.0.0.1";
103+
$test{host_port} ||= $test{guest_port};
99104
if ($test{mode} eq "forward" && $test{host_port} < 1024 && $Config{osname} ne "darwin") {
100105
printf "🚧 Not supported on $Config{osname}: # $_\n";
101106
next;
102107
}
103-
$test{host_ip} ||= "127.0.0.1";
104-
$test{host_port} ||= $test{guest_port};
108+
if ($test{mode} eq "ignore" && ($test{guest_ip} eq "0.0.0.0" || $test{guest_ip} eq "127.0.0.1") && "$instanceType" eq "wsl2") {
109+
printf "🚧 Not supported for $instanceType machines: # $_\n";
110+
next;
111+
}
112+
if ($test{guest_ip} eq "192.168.5.15" && "$instanceType" eq "wsl2") {
113+
printf "🚧 Not supported for $instanceType machines: # $_\n";
114+
next;
115+
}
105116

106117
my $remote = JoinHostPort($test{guest_ip},$test{guest_port});
107118
my $local = JoinHostPort($test{host_ip},$test{host_port});

hack/test-templates.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ case "$NAME" in
9393
"wsl2")
9494
# TODO https://github.com/lima-vm/lima/issues/3268
9595
CHECKS["proxy-settings"]=
96-
CHECKS["port-forwards"]=
9796
;;
9897
esac
9998

0 commit comments

Comments
 (0)