Skip to content

Commit faabe08

Browse files
authored
Fix TestFullDIFCConfigFromJSON timeout waiting for backend connections (#3960)
## Problem `TestFullDIFCConfigFromJSON` fails with a 5s timeout waiting for `"Starting MCPG"` in stderr: ``` Error: Should be true Messages: timeout waiting for gateway stderr to contain "Starting MCPG" within 5s ``` ## Root Cause `"Starting MCPG in ROUTED/UNIFIED mode"` only prints **after** `NewUnified()` returns. `NewUnified()` blocks on `registerAllTools()` which tries to connect to all backends — including a Docker container (`test/server1:latest`) with a **30s launch timeout**. The test's 5s deadline expires while waiting for Docker to fail. ## Fix The test's assertions only verify DIFC guard registration output, which appears **before** the blocking backend connections. Changed the wait string from `"Starting MCPG"` to `"[DIFC] Registered guard"`, added a 300ms flush delay, and removed the health check (which requires full startup). ## Changes | File | Change | |------|--------| | `test/integration/difc_config_test.go` | Wait for guard registration instead of full startup; remove health check and unused `encoding/json` import | `make agent-finished` ✓
2 parents 20d8dae + f6db29f commit faabe08

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

test/integration/difc_config_test.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package integration
33
import (
44
"bytes"
55
"context"
6-
"encoding/json"
76
"fmt"
87
"net"
98
"net/http"
@@ -412,19 +411,15 @@ func TestFullDIFCConfigFromJSON(t *testing.T) {
412411
err := cmd.Start()
413412
require.NoError(t, err, "Failed to start gateway")
414413

415-
ok := waitForStderr(&stderr, "Starting MCPG", 5*time.Second)
416-
require.Truef(t, ok, "timeout waiting for gateway stderr to contain %q within %s; stderr:\n%s", "Starting MCPG", 5*time.Second, stderr.String())
417-
418-
// Try health check
419-
resp, err := http.Get(fmt.Sprintf("http://127.0.0.1:%d/health", port))
420-
if err == nil {
421-
defer resp.Body.Close()
422-
assert.Equal(t, http.StatusOK, resp.StatusCode)
414+
// Wait for guard registration (appears before the blocking registerAllTools
415+
// backend connections that may take 30+ seconds for Docker containers).
416+
// "Starting MCPG" only prints after NewUnified returns, which blocks on
417+
// backend connections — too slow for this test's DIFC-config-only assertions.
418+
ok := waitForStderr(&stderr, "[DIFC] Registered guard", 5*time.Second)
419+
require.Truef(t, ok, "timeout waiting for DIFC guard registration within %s; stderr:\n%s", 5*time.Second, stderr.String())
423420

424-
var health map[string]interface{}
425-
json.NewDecoder(resp.Body).Decode(&health)
426-
t.Logf("Health response: %+v", health)
427-
}
421+
// Brief pause to let remaining sequential guard registrations flush to stderr
422+
time.Sleep(300 * time.Millisecond)
428423

429424
cmd.Process.Kill()
430425
cmd.Wait()

0 commit comments

Comments
 (0)