Skip to content

Commit aea3db6

Browse files
authored
Fix integration tests broken by logging consolidation (#3516)
## Summary Fixes 4 integration test failures caused by the logging consolidation in commit 66398ee, which moved operational log messages from stderr to the file/debug logger. ### Root Cause Commit `66398ee` ("Consolidate dual logging") changed: - `log.Printf("Guards enforcement...")` → `logger.LogInfo("startup", ...)` (file-only, not stderr) - `log.Printf("Registered tool:...")` → `logUnified.Printf(...)` (debug-only, not stderr unless `DEBUG` is set) Integration tests run the binary and read stderr — they can't see file-only or debug-only messages. ### Changes **`test/integration/difc_config_test.go`** (3 tests): - `waitForStderr` now waits for `"Starting MCPG"` (still on stderr via `root.go`) instead of `"Guards enforcement"` - Assertions changed from `"Guards enforcement disabled"` to `"[DIFC] Registered guard 'noop'"` (still on stderr via `guard_init.go`) **`test/integration/playwright_test.go`** (1 test): - `ToolsRegistered` subtest now verifies playwright server registration via the `/health` endpoint instead of grepping stderr for tool log messages ### Testing `make agent-finished` passes — all unit and integration tests green.
2 parents 66398ee + 37d0296 commit aea3db6

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

test/integration/difc_config_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ func TestDIFCModeFilterViaEnv(t *testing.T) {
294294
err := cmd.Start()
295295
require.NoError(t, err, "Failed to start gateway")
296296

297-
ok := waitForStderr(&stderr, "Guards enforcement", 5*time.Second)
298-
require.Truef(t, ok, "timeout waiting for gateway stderr to contain %q within %s; stderr:\n%s", "Guards enforcement", 5*time.Second, stderr.String())
297+
ok := waitForStderr(&stderr, "Starting MCPG", 5*time.Second)
298+
require.Truef(t, ok, "timeout waiting for gateway stderr to contain %q within %s; stderr:\n%s", "Starting MCPG", 5*time.Second, stderr.String())
299299

300300
cmd.Process.Kill()
301301
cmd.Wait()
@@ -304,8 +304,8 @@ func TestDIFCModeFilterViaEnv(t *testing.T) {
304304
t.Logf("STDERR: %s", stderrStr)
305305

306306
// Verify gateway starts with filter mode configuration accepted
307-
// Without a guard policy or WASM guard, DIFC is not auto-enabled
308-
assert.Contains(t, stderrStr, "Guards enforcement disabled", "Guards should be disabled without a policy")
307+
// Without a guard policy or WASM guard, DIFC is not auto-enabled — noop guard is registered
308+
assert.Contains(t, stderrStr, "[DIFC] Registered guard 'noop'", "Noop guard should be registered without a policy")
309309
t.Log("✓ Guards filter mode env var accepted via MCP_GATEWAY_GUARDS_MODE=filter")
310310
}
311311

@@ -346,8 +346,8 @@ func TestDIFCModePropagateViaEnv(t *testing.T) {
346346
err := cmd.Start()
347347
require.NoError(t, err, "Failed to start gateway")
348348

349-
ok := waitForStderr(&stderr, "Guards enforcement", 5*time.Second)
350-
require.Truef(t, ok, "timeout waiting for gateway stderr to contain %q within %s; stderr:\n%s", "Guards enforcement", 5*time.Second, stderr.String())
349+
ok := waitForStderr(&stderr, "Starting MCPG", 5*time.Second)
350+
require.Truef(t, ok, "timeout waiting for gateway stderr to contain %q within %s; stderr:\n%s", "Starting MCPG", 5*time.Second, stderr.String())
351351

352352
cmd.Process.Kill()
353353
cmd.Wait()
@@ -356,8 +356,8 @@ func TestDIFCModePropagateViaEnv(t *testing.T) {
356356
t.Logf("STDERR: %s", stderrStr)
357357

358358
// Verify gateway starts with propagate mode configuration accepted
359-
// Without a guard policy or WASM guard, DIFC is not auto-enabled
360-
assert.Contains(t, stderrStr, "Guards enforcement disabled", "Guards should be disabled without a policy")
359+
// Without a guard policy or WASM guard, DIFC is not auto-enabled — noop guard is registered
360+
assert.Contains(t, stderrStr, "[DIFC] Registered guard 'noop'", "Noop guard should be registered without a policy")
361361
t.Log("✓ Guards propagate mode env var accepted via MCP_GATEWAY_GUARDS_MODE=propagate")
362362
}
363363

@@ -412,8 +412,8 @@ func TestFullDIFCConfigFromJSON(t *testing.T) {
412412
err := cmd.Start()
413413
require.NoError(t, err, "Failed to start gateway")
414414

415-
ok := waitForStderr(&stderr, "Guards enforcement", 5*time.Second)
416-
require.Truef(t, ok, "timeout waiting for gateway stderr to contain %q within %s; stderr:\n%s", "Guards enforcement", 5*time.Second, stderr.String())
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())
417417

418418
// Try health check
419419
resp, err := http.Get(fmt.Sprintf("http://127.0.0.1:%d/health", port))
@@ -435,6 +435,6 @@ func TestFullDIFCConfigFromJSON(t *testing.T) {
435435
// Verify configuration was loaded — WASM guard fails to load (no file), all servers get noop
436436
assert.Contains(t, stderrStr, "server1", "Should contain server1")
437437
assert.Contains(t, stderrStr, "server2", "Should contain server2")
438-
assert.Contains(t, stderrStr, "Guards enforcement disabled", "Guards should be disabled when all guards fall back to noop")
438+
assert.Contains(t, stderrStr, "[DIFC] Registered guard 'noop'", "Noop guard should be registered when all guards fall back to noop")
439439
t.Log("✓ Full guards configuration loaded successfully")
440440
}

test/integration/playwright_test.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,19 @@ func TestPlaywrightMCPServer(t *testing.T) {
199199

200200
// Test 3: Verify tools were registered (this confirms draft-07 schemas work)
201201
// The main goal is to ensure the gateway doesn't panic when loading playwright tools
202-
// Looking at the server logs, we can see if tools were registered successfully
203202
t.Run("ToolsRegistered", func(t *testing.T) {
204-
// The fact that the server started and we reached this point means
205-
// the playwright tools with draft-07 schemas were processed without panicking
206-
stderrStr := stderr.String()
203+
// Verify via health endpoint that the playwright server was registered
204+
resp, err := http.Get(serverURL + "/health")
205+
require.NoError(t, err, "Health check failed")
206+
defer resp.Body.Close()
207207

208-
// Check that tools were registered
209-
if !strings.Contains(stderrStr, "tools from playwright") &&
210-
!strings.Contains(stderrStr, "Registered tool: playwright-browser_close") {
211-
t.Fatal("Expected playwright tools to be registered in server logs")
212-
}
208+
var health map[string]interface{}
209+
require.NoError(t, json.NewDecoder(resp.Body).Decode(&health))
210+
211+
servers, ok := health["servers"].(map[string]interface{})
212+
require.True(t, ok, "Health response should contain servers map")
213+
_, hasPlaywright := servers["playwright"]
214+
require.True(t, hasPlaywright, "Health response should contain playwright server")
213215

214216
t.Log("✓ Playwright tools registered successfully (draft-07 schemas handled correctly)")
215217
})

0 commit comments

Comments
 (0)