From f6db29fc73116a6721cbd56a254a08f663c342aa Mon Sep 17 00:00:00 2001 From: Landon Cox Date: Thu, 16 Apr 2026 07:59:04 -0700 Subject: [PATCH] Fix TestFullDIFCConfigFromJSON timeout waiting for backend connections The test waited 5s for 'Starting MCPG' in stderr, but that message only prints after NewUnified() returns. NewUnified blocks on registerAllTools() which tries to connect backends (Docker container launch has a 30s timeout). The test's assertions only need DIFC guard registration output. Fix: wait for '[DIFC] Registered guard' instead, which appears before the blocking backend connections. Remove the health check (requires full startup) and the now-unused encoding/json import. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- test/integration/difc_config_test.go | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/test/integration/difc_config_test.go b/test/integration/difc_config_test.go index 673d672e..b8287c21 100644 --- a/test/integration/difc_config_test.go +++ b/test/integration/difc_config_test.go @@ -3,7 +3,6 @@ package integration import ( "bytes" "context" - "encoding/json" "fmt" "net" "net/http" @@ -412,19 +411,15 @@ func TestFullDIFCConfigFromJSON(t *testing.T) { err := cmd.Start() require.NoError(t, err, "Failed to start gateway") - ok := waitForStderr(&stderr, "Starting MCPG", 5*time.Second) - require.Truef(t, ok, "timeout waiting for gateway stderr to contain %q within %s; stderr:\n%s", "Starting MCPG", 5*time.Second, stderr.String()) - - // Try health check - resp, err := http.Get(fmt.Sprintf("http://127.0.0.1:%d/health", port)) - if err == nil { - defer resp.Body.Close() - assert.Equal(t, http.StatusOK, resp.StatusCode) + // Wait for guard registration (appears before the blocking registerAllTools + // backend connections that may take 30+ seconds for Docker containers). + // "Starting MCPG" only prints after NewUnified returns, which blocks on + // backend connections — too slow for this test's DIFC-config-only assertions. + ok := waitForStderr(&stderr, "[DIFC] Registered guard", 5*time.Second) + require.Truef(t, ok, "timeout waiting for DIFC guard registration within %s; stderr:\n%s", 5*time.Second, stderr.String()) - var health map[string]interface{} - json.NewDecoder(resp.Body).Decode(&health) - t.Logf("Health response: %+v", health) - } + // Brief pause to let remaining sequential guard registrations flush to stderr + time.Sleep(300 * time.Millisecond) cmd.Process.Kill() cmd.Wait()