From 85c423d24e8b943076eb4dc5bd02090dccf7e40c Mon Sep 17 00:00:00 2001 From: Eli Mallon Date: Wed, 14 Oct 2026 22:55:37 -0700 Subject: [PATCH] multitest: stop the metrics scraper before killing a node Cleanup killed a node while its scraper goroutine could be mid-scrape, and the failed scrape then failed a test that had already completed, which panics and blames the next test (TestOriginSwap). Wait for the scraper to return before killing the process. --- pkg/multitest/multitest_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/multitest/multitest_test.go b/pkg/multitest/multitest_test.go index ff7afd89..99c18f19 100644 --- a/pkg/multitest/multitest_test.go +++ b/pkg/multitest/multitest_test.go @@ -203,7 +203,11 @@ func startStreamplaceNode(ctx context.Context, name string, t *testing.T, dev *d <-nodeCtx.Done() node.Shutdown(t) }() + // The scraper must be done before shutdown kills the node: a scrape of a + // dead node after the test has completed fails it, which panics. + scraperDone := make(chan struct{}) go func() { + defer close(scraperDone) for { select { case <-nodeCtx.Done(): @@ -235,6 +239,7 @@ func startStreamplaceNode(ctx context.Context, name string, t *testing.T, dev *d } shuttingDown = true nodeCancel() + <-scraperDone _ = cmd.Process.Kill() _, _ = cmd.Process.Wait() // Wait for stdout/stderr readers to finish -- 2.51.2