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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017TuKgyKve2XLFtrrXWMi2w
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user