m/pkg/logtree/unraw: deflake tests
This test was flaking quite seriously on CI, due to races between the
supervisor's test harness logging a startup message and the test's own
logging exercise logic.
Fixing that, I also spotted a rare flake that occurs when a
NamedPipeReader restart races a write to the named pipe, possible
causing the write to be sent to the old but still running
NamedPipeReader. We fix that in the test, as fixing this in the code
itself is difficult and the resulting problem (a lost log line in this
rare race condition) isn't that bad.
Change-Id: If749798498acb9bf9e6557fd9cbcc441207b9726
Reviewed-on: https://review.monogon.dev/c/monogon/+/345
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/metropolis/pkg/supervisor/supervisor_testhelpers.go b/metropolis/pkg/supervisor/supervisor_testhelpers.go
index b2812c2..85361c2 100644
--- a/metropolis/pkg/supervisor/supervisor_testhelpers.go
+++ b/metropolis/pkg/supervisor/supervisor_testhelpers.go
@@ -52,6 +52,7 @@
Logger(ctx).Infof("Starting test %s...", t.Name())
if err := r(ctx); err != nil && !errors.Is(err, ctx.Err()) {
t.Errorf("Supervised runnable in harness returned error: %v", err)
+ return err
}
return nil
}, WithExistingLogtree(lt))