From 383e05aee82319d3e0470e9a86759363c249caf9 Mon Sep 17 00:00:00 2001 From: "pulse-triage[bot]" <249995291+pulse-triage[bot]@users.noreply.github.com> Date: Mon, 28 Sep 2026 10:37:32 +0100 Subject: [PATCH] Accept either completion order in agent handoff test The supervisor sends its commit call before returning, but both channels can be ready when the test wakes. Treat a completed successful supervisor with the recorded commit as success, and bound the post-commit wait. Change-source: pulse-maintainer --- cmd/pulse-agent/main_test.go | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/cmd/pulse-agent/main_test.go b/cmd/pulse-agent/main_test.go index 2ed7a0cff..263c0f97d 100644 --- a/cmd/pulse-agent/main_test.go +++ b/cmd/pulse-agent/main_test.go @@ -1968,18 +1968,37 @@ func TestPendingPrivilegedUpdateCommitsOnlyAfterReadinessAndAcceptedReport(t *te default: } ready.Store(true) + var activation agenthelper.UpdateResult + finished := false select { - case activation := <-stub.commitCalls: - if activation != pending.Activation { - t.Fatalf("commit activation = %#v", activation) - } + case activation = <-stub.commitCalls: case err := <-result: - t.Fatalf("pending update supervisor stopped before committing: %v", err) + if err != nil { + t.Fatalf("pending update supervisor stopped before committing: %v", err) + } + finished = true + // Commit sends its recorded call before the supervisor can return. If + // both channels are ready, selecting result first is still success. + select { + case activation = <-stub.commitCalls: + default: + t.Fatal("pending update supervisor returned without committing") + } case <-time.After(10 * time.Second): t.Fatal("pending update was not committed after both health signals") } - if err := <-result; err != nil { - t.Fatal(err) + if activation != pending.Activation { + t.Fatalf("commit activation = %#v", activation) + } + if !finished { + select { + case err := <-result: + if err != nil { + t.Fatal(err) + } + case <-time.After(10 * time.Second): + t.Fatal("pending update supervisor did not finish after commit") + } } if loaded, err := agentupdate.LoadPendingPrivilegedUpdate(stateDir); err != nil || loaded != nil { t.Fatalf("committed handoff = %#v, %v", loaded, err)