Skip to content

Commit e9f7ca9

Browse files
committed
support e2e for WSL
Signed-off-by: nasusoba <[email protected]>
1 parent e8b15a1 commit e9f7ca9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

test/framework/cluster_proxy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ func (p *clusterProxy) GetWorkloadCluster(ctx context.Context, namespace, name s
287287
// gets the kubeconfig from the cluster
288288
config := p.getKubeconfig(ctx, namespace, name)
289289

290-
// if we are on mac and the cluster is a DockerCluster, it is required to fix the control plane address
290+
// if we are on mac or Windows Subsystem for Linux (WSL), and the cluster is a DockerCluster, it is required to fix the control plane address
291291
// by using localhost:load-balancer-host-port instead of the address used in the docker network.
292-
if goruntime.GOOS == "darwin" && p.isDockerCluster(ctx, namespace, name) {
292+
if (goruntime.GOOS == "darwin" || os.Getenv("WSL_DISTRO_NAME") != "") && p.isDockerCluster(ctx, namespace, name) {
293293
p.fixConfig(ctx, name, config)
294294
}
295295

test/framework/kubetest/run.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,9 @@ func dockeriseKubeconfig(kubetestConfigDir string, kubeConfigPath string) (strin
243243
}
244244
newPath := path.Join(kubetestConfigDir, "kubeconfig")
245245

246-
// On CAPD, if not running on Linux, we need to use Docker's proxy to connect back to the host
246+
// On CAPD, if not running on Linux or the environment is Windows Subsystem for Linux (WSL), we need to use Docker's proxy to connect back to the host
247247
// to the CAPD cluster. Moby on Linux doesn't use the host.docker.internal DNS name.
248-
if runtime.GOOS != "linux" {
248+
if runtime.GOOS != "linux" || os.Getenv("WSL_DISTRO_NAME") != "" {
249249
for i := range kubeConfig.Clusters {
250250
kubeConfig.Clusters[i].Server = strings.ReplaceAll(kubeConfig.Clusters[i].Server, "127.0.0.1", "host.docker.internal")
251251
}

0 commit comments

Comments
 (0)