Skip to content

Commit f6db29f

Browse files
lpcoxCopilot
andcommitted
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 <[email protected]>
1 parent 20d8dae commit f6db29f

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)