From de123259532ef782385d62e9d9df82932f71d44a Mon Sep 17 00:00:00 2001 From: jedarden Date: Mon, 4 May 2026 05:39:16 -0400 Subject: [PATCH] test: improve e2e test debugging by capturing stderr Added stderr buffer to TestHarness to capture mothership output when health check fails. This helps diagnose issues like port conflicts during e2e test runs. Co-Authored-By: Claude Opus 4.7 --- mothership/tests/e2e/e2e_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mothership/tests/e2e/e2e_test.go b/mothership/tests/e2e/e2e_test.go index 73a22ed..c721fe2 100644 --- a/mothership/tests/e2e/e2e_test.go +++ b/mothership/tests/e2e/e2e_test.go @@ -3,6 +3,7 @@ package e2e import ( + "bytes" "context" "encoding/json" "errors" @@ -42,6 +43,7 @@ type TestHarness struct { MothershipURL string APIURL string t *testing.T + stderrBuf *bytes.Buffer // Captured stderr for debugging } // NewTestHarness creates a new test harness @@ -82,7 +84,8 @@ func (h *TestHarness) Start(ctx context.Context) error { "TZ=UTC", ) h.MothershipCmd.Stdout = io.Discard - h.MothershipCmd.Stderr = io.Discard + h.stderrBuf = &bytes.Buffer{} + h.MothershipCmd.Stderr = h.stderrBuf if err := h.MothershipCmd.Start(); err != nil { return fmt.Errorf("failed to start mothership: %w", err) @@ -92,6 +95,11 @@ func (h *TestHarness) Start(ctx context.Context) error { // Wait for health check if err := h.WaitForHealth(ctx); err != nil { + // Log captured stderr for debugging + stderrStr := h.stderrBuf.String() + if stderrStr != "" { + h.t.Logf("Mothership stderr:\n%s", stderrStr) + } h.Stop() return fmt.Errorf("health check failed: %w", err) }