fix: L4 UDP proxy routing and TCP disable/re-enable test reliability

- Add udp/ prefix to upstream dial addresses for UDP proxy hosts
  (Caddy L4 requires udp/ prefix on both listen and dial for UDP)
- Fix TCP "disabled host" test to check data echo instead of connection
  refusal (Docker port mapping always accepts TCP handshake)
- Add waitForTcpRoute before "both ports" test to handle re-enable timing
- Increase UDP route wait timeout to 30s for listener startup

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
fuomag9
2026-03-23 08:10:02 +01:00
parent 6b297a11ad
commit 2d081372f0
2 changed files with 14 additions and 7 deletions
+11 -6
View File
@@ -54,18 +54,19 @@ test.describe.serial('L4 TCP Proxy Routing', () => {
expect(res.data).not.toContain('probe');
});
test('disabled TCP proxy host stops accepting connections', async ({ page }) => {
test('disabled TCP proxy host stops proxying data', async ({ page }) => {
await page.goto('/l4-proxy-hosts');
const row = page.locator('tr', { hasText: 'L4 TCP Echo Test' });
await row.getByRole('switch').click();
await page.waitForTimeout(3_000);
const connected = await tcpConnect('127.0.0.1', TCP_PORT, 2000);
expect(connected).toBe(false);
// Docker still accepts the TCP connection, but Caddy should not proxy/echo data
const res = await tcpSend('127.0.0.1', TCP_PORT, 'should-not-echo\n', 2000);
expect(res.data).not.toContain('should-not-echo');
// Re-enable
// Re-enable and wait for route to come back
await row.getByRole('switch').click();
await page.waitForTimeout(2_000);
await waitForTcpRoute('127.0.0.1', TCP_PORT);
});
});
@@ -81,6 +82,9 @@ test.describe.serial('L4 Multiple TCP Hosts', () => {
});
test('both TCP ports route traffic independently', async () => {
// Ensure both ports are ready (port 1 may have been toggled in earlier test)
await waitForTcpRoute('127.0.0.1', TCP_PORT);
await waitForTcpRoute('127.0.0.1', TCP_PORT_2);
const res1 = await tcpSend('127.0.0.1', TCP_PORT, 'port1\n');
const res2 = await tcpSend('127.0.0.1', TCP_PORT_2, 'port2\n');
expect(res1.connected).toBe(true);
@@ -102,7 +106,8 @@ test.describe.serial('L4 UDP Proxy Routing', () => {
listenAddress: `:${UDP_PORT}`,
upstream: 'udp-echo:9001',
});
await waitForUdpRoute('127.0.0.1', UDP_PORT);
// UDP listeners may take longer to start than TCP — use a longer timeout
await waitForUdpRoute('127.0.0.1', UDP_PORT, 30_000);
});
test('routes UDP datagrams to the upstream echo server', async () => {