From a4721a247c75cb07c425bd21c75d1071ad166fe6 Mon Sep 17 00:00:00 2001 From: "devsy-app[bot]" <277138668+devsy-app[bot]@users.noreply.github.com> Date: Sun, 9 Aug 2026 12:27:14 +0000 Subject: [PATCH 1/2] test(e2e): cover matchIPv4 IP-selection helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Adds unit test coverage for the previously-untested `matchIPv4` helper in `e2e/framework/server_utils.go`. ## Context `matchIPv4` is a pure helper used by `getIP` / `ServeAgent` (the test-only HTTP server that serves the locally-built devsy agent binary to non-Linux CI runners, setting `DEVSY_AGENT_URL`). It selects an IPv4 address whose classful default mask is `/24` (class C, `ffffff00`) or `/8` (class A, `ff000000`) — class B (`/16`) is deliberately skipped — so the agent server binds to a reachable LAN address. It had **zero** test coverage (no `server_utils_test.go` existed), and its subtle behavior (ignoring the configured subnet mask and using only the IP's classful default mask; returning the network address for `*net.IPNet`) is easy to regress. ## Edge cases covered - `*net.IPNet` class C (`192.168.1.0/24`) → selected - `*net.IPNet` class A (`10.0.0.0/8`) → selected - `*net.IPNet` class B (`172.16.0.0/16`) → **not** selected (the gap the helper exists to enforce) - `*net.IPAddr` class C → selected - IPv6 (`fd00::1/64`) → not selected - Unknown `net.Addr` type (`*net.UDPAddr`) → not selected Tests exercise the real `matchIPv4` code path (no mocks). ## Logs inspected Reviewed CI runs for the `up-workspaces` suite. The failing `up-workspaces` run (#31305514055) was environmental (`signal: killed` / OOM), not a code bug, so this run instead closes a real test-coverage gap in the e2e framework rather than patching flakiness. ## Verification - `task cli:format` — clean - `task cli:lint:ci` — `0 issues` (new-from-patch against origin/main) - `go test ./e2e/framework/...` (incl. `TestMatchIPv4*`) — **PASS** - `task cli:test` — unit tests pass; the only failures are the known pre-existing `pkg/git` `TestRepoClone*` (stale assertion on origin/main, untouched by this change) and the Ginkgo `e2e` suites that require Docker/the devsy binary (environmental, not run as unit tests). This PR was created by an AI agent as part of an automated daily e2e review job. --- e2e/framework/server_utils_test.go | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 e2e/framework/server_utils_test.go diff --git a/e2e/framework/server_utils_test.go b/e2e/framework/server_utils_test.go new file mode 100644 index 0000000000..8833b64e79 --- /dev/null +++ b/e2e/framework/server_utils_test.go @@ -0,0 +1,48 @@ +package framework + +import ( + "net" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// matchIPv4 selects an IPv4 address whose classful default mask is /24 +// (class C, "ffffff00") or /8 (class A, "ff000000"); class B (/16) is skipped. +// It does not consult the subnet mask carried by *net.IPNet, only the IP's +// classful default mask. For *net.IPNet the IP is the network address. + +func TestMatchIPv4_IPNet_ClassC(t *testing.T) { + _, ipNet, err := net.ParseCIDR("192.168.1.0/24") + require.NoError(t, err) + assert.Equal(t, "192.168.1.0", matchIPv4(ipNet)) +} + +func TestMatchIPv4_IPNet_ClassA(t *testing.T) { + _, ipNet, err := net.ParseCIDR("10.0.0.0/8") + require.NoError(t, err) + assert.Equal(t, "10.0.0.0", matchIPv4(ipNet)) +} + +func TestMatchIPv4_IPNet_ClassB_NotSelected(t *testing.T) { + _, ipNet, err := net.ParseCIDR("172.16.0.0/16") + require.NoError(t, err) + assert.Empty(t, matchIPv4(ipNet)) +} + +func TestMatchIPv4_IPAddr_ClassC(t *testing.T) { + addr := &net.IPAddr{IP: net.ParseIP("192.168.1.5")} + require.NotNil(t, addr.IP) + assert.Equal(t, "192.168.1.5", matchIPv4(addr)) +} + +func TestMatchIPv4_IPv6_NotSelected(t *testing.T) { + _, ipNet, err := net.ParseCIDR("fd00::1/64") + require.NoError(t, err) + assert.Empty(t, matchIPv4(ipNet)) +} + +func TestMatchIPv4_UnknownAddrType_NotSelected(t *testing.T) { + assert.Empty(t, matchIPv4(&net.UDPAddr{IP: net.ParseIP("192.168.1.5"), Port: 1234})) +} From 5fc174d6f499b84f3770b8d0eec66b8bfd401ec1 Mon Sep 17 00:00:00 2001 From: Samuel K Date: Sun, 9 Aug 2026 17:00:28 +0000 Subject: [PATCH 2/2] style: update comments Signed-off-by: GitHub --- e2e/framework/server_utils_test.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/e2e/framework/server_utils_test.go b/e2e/framework/server_utils_test.go index 8833b64e79..ec435ea389 100644 --- a/e2e/framework/server_utils_test.go +++ b/e2e/framework/server_utils_test.go @@ -8,11 +8,6 @@ import ( "github.com/stretchr/testify/require" ) -// matchIPv4 selects an IPv4 address whose classful default mask is /24 -// (class C, "ffffff00") or /8 (class A, "ff000000"); class B (/16) is skipped. -// It does not consult the subnet mask carried by *net.IPNet, only the IP's -// classful default mask. For *net.IPNet the IP is the network address. - func TestMatchIPv4_IPNet_ClassC(t *testing.T) { _, ipNet, err := net.ParseCIDR("192.168.1.0/24") require.NoError(t, err)