Skip to content

test: improve TestDdevXdebugEnabled to use Windows-side listener for WSL2 docker-ce #8277

@rfay

Description

@rfay

Problem

TestDdevXdebugEnabled on WSL2 with docker-ce (non-Docker Desktop) currently sets xdebug_ide_location=wsl2, which tests only the "IDE inside WSL2" path. It does not test the common case where the IDE runs on the Windows side. The existing nc.exe listener (used for the Docker Desktop path) relies on a Chocolatey x86 netcat package that isn't available on ARM64 Windows.

Goal

Replace nc.exe with a cross-architecture listener (PowerShell or ncat from nmap) and extend the Windows-side listener path to cover virtioproxy mode in addition to Docker Desktop. The test should be run manually on all WSL2 networking modes (nat, mirrored, virtioproxy) and on both amd64 and arm64 Windows.

Approaches tried

PowerShell TcpListener

We attempted to use PowerShell's [System.Net.Sockets.TcpListener] as a replacement for nc.exe:

$listener = [System.Net.Sockets.TcpListener]::new([System.Net.IPAddress]::Any, 9003)
$listener.Start()
# ... AcceptTcpClient, read data, etc.

Issues encountered:

  • Timing: PowerShell startup is slow (~1-2s). The test must wait for "LISTENING" output via stdout pipe before triggering the HTTP request, otherwise Xdebug's 200ms connection timeout expires before PowerShell is ready.
  • Connection never received: Even with confirmed readiness (stdout pipe approach), dual-stack listening (IPv6Any + DualMode), and correct host.docker.internal (172.20.48.1) inside the container, the PowerShell listener never received the Xdebug connection. PhpStorm listening on the same port (:::9003) works fine. The root cause is unclear — may be related to how Windows routes Hyper-V virtual switch traffic to different listener types.
  • Stale processes: When the test times out, the PowerShell process must be explicitly killed or it holds the port across test runs.

The PowerShell approach works for the xdebug-diagnose interactive command (where it's used for connectivity testing), but not for the actual Xdebug protocol connection in the test.

ncat (from nmap)

ncat.exe from the nmap package has ARM64 Windows support and could replace nc.exe. The syntax differs slightly:

  • nc.exe: nc.exe -l -w 1 -p 9003
  • ncat.exe: ncat.exe -l -w 1 9003 (no -p flag)

This was not tested but is a viable alternative.

Suggested approach

  1. Install nmap (which includes ncat.exe) via Chocolatey on test machines
  2. Replace the nc.exe path in TestDdevXdebugEnabled with ncat.exe
  3. Extend the Windows-side listener to cover IsWSL2VirtioProxyMode() in addition to IsDockerDesktop()
  4. Update buildkite-testmachine-setup.md to document ncat installation
  5. Manually verify on all WSL2 networking modes (nat, mirrored, virtioproxy) and on both amd64 and arm64 Windows

Refs #8220

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions