From 3a6afdda08252db80980207ea0e52df73534cdd7 Mon Sep 17 00:00:00 2001 From: Vibe Coder Date: Sun, 25 Oct 2026 21:30:41 +0000 Subject: [PATCH] Fix two integration test failures seen in CI TestRunReturnsStartError expected a start with no TLS flags to fail; since the first-install wizard that start succeeds (install mode with a self-signed certificate) and Run blocked until the 10 min timeout. Use --tls-cert without --tls-key, which is always refused. TestICMPStateMachine could advance the fake clock twice in one step on a slow runner, firing an extra probe ([1 1 1 0 0 1 1]). Advance once, only after the ICMP loop has re-armed its timer. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017TuKgyKve2XLFtrrXWMi2w --- internal/app/lifecycle_test.go | 7 +++++-- internal/poller/poller_test.go | 12 +++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/internal/app/lifecycle_test.go b/internal/app/lifecycle_test.go index 777cb57..9a73956 100644 --- a/internal/app/lifecycle_test.go +++ b/internal/app/lifecycle_test.go @@ -235,8 +235,11 @@ func TestRunStopsWhenContextEnds(t *testing.T) { } func TestRunReturnsStartError(t *testing.T) { - if err := Run(context.Background(), config.Flags{DataDir: t.TempDir()}); err == nil { - t.Fatal("expected the --insecure-http refusal") + // No TLS flags is no longer an error (install mode serves a self-signed certificate), so use a flag combination + // that is always refused. + f := config.Flags{DataDir: t.TempDir(), TLSCert: "cert.pem"} + if err := Run(context.Background(), f); err == nil { + t.Fatal("expected the --tls-cert without --tls-key refusal") } } diff --git a/internal/poller/poller_test.go b/internal/poller/poller_test.go index 2ad3085..5b1b3c4 100644 --- a/internal/poller/poller_test.go +++ b/internal/poller/poller_test.go @@ -304,17 +304,19 @@ func TestICMPStateMachine(t *testing.T) { h.startWaiters(2) // ICMP timer and selfmon ticker; no SNMP credential var ups []float64 + // One probe per step: advance only once the ICMP loop has written and re-armed its timer (two waiters: that + // timer and the selfmon ticker), so a slow runner can never fire two probes in one step. + armed := func() bool { return clk.Waiters() >= 2 } step := func() { + eventually(t, armed) before := h.ping.count() - for h.ping.count() == before { - clk.Advance(15 * time.Second) - time.Sleep(2 * time.Millisecond) - } - time.Sleep(20 * time.Millisecond) // the write follows the ping + clk.Advance(15 * time.Second) + eventually(t, func() bool { return h.ping.count() > before }) } for i := 0; i < 6; i++ { step() } + eventually(t, armed) // the last write is done for _, s := range h.w.samples("nmon_icmp_up") { ups = append(ups, s.Value) }