From 5fc69444f66388054f3371995c8eaaa3f7dd33cf Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 28 Oct 2026 18:15:18 +0100 Subject: [PATCH] Node agent integration tests: candidates keyed by proposal, under the node's real grant on the seat's states (issue 1126) --- cmd/mesh-host/nodeagent_integration_test.go | 29 +++++++++------------ 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/cmd/mesh-host/nodeagent_integration_test.go b/cmd/mesh-host/nodeagent_integration_test.go index 1afc6f2..ab3dde5 100644 --- a/cmd/mesh-host/nodeagent_integration_test.go +++ b/cmd/mesh-host/nodeagent_integration_test.go @@ -419,7 +419,7 @@ func h8once(t *testing.T, b *itBed, resolved, candidates nats.KeyValue, place [] defer b.mu.Unlock() n := 0 for _, l := range b.said { - if strings.HasPrefix(l, "answering placement candidate feat/x ") { + if strings.HasPrefix(l, "answering placement candidate feat-x ") { n++ } } @@ -428,7 +428,7 @@ func h8once(t *testing.T, b *itBed, resolved, candidates nats.KeyValue, place [] time.Sleep(time.Second) settled := answering() if settled == 0 { - t.Fatal("feat/x was never answered") + t.Fatal("feat-x was never answered") } hkey, _ := delivery.HaveKey(itNode, "web") for _, detail := range []string{"its tool web_health: no link to the bus is open", "its tool web_health: no answer within 10s"} { @@ -447,15 +447,14 @@ func h8once(t *testing.T, b *itBed, resolved, candidates nats.KeyValue, place [] } time.Sleep(1500 * time.Millisecond) if got := answering(); got != settled { - t.Errorf("feat/x answered %d more time(s) at the same revision, with nothing it is composed from changed", got-settled) + t.Errorf("feat-x answered %d more time(s) at the same revision, with nothing it is composed from changed", got-settled) } same, _ := delivery.DecodePlacement(place) - craw, err := delivery.EncodePlacementCandidate(delivery.PlacementCandidate{Group: "feat/x", - Pull: delivery.Head{Repository: delivery.CatalogueRepository, Number: 1, Head: "h1b"}, Placement: &same}) + craw, err := delivery.EncodePlacementCandidate(delivery.PlacementCandidate{Proposal: "feat-x", Placement: &same}) if err != nil { t.Fatal(err) } - ckey, _ := delivery.PlacementCandidateKey("feat/x", itNode) + ckey, _ := delivery.PlacementCandidateKey("feat-x", itNode) if _, err := candidates.Put(ckey, craw); err != nil { t.Fatal(err) } @@ -482,20 +481,19 @@ func h8back(t *testing.T, b *itBed, placement, resolved, candidates nats.KeyValu if n := node(); n.Composes != delivery.ComposesOwn { t.Errorf("a node composing its own says it composes %q", n.Composes) } - craw, err := delivery.EncodePlacementCandidate(delivery.PlacementCandidate{Group: "revert/x", - Pull: delivery.Head{Repository: delivery.CatalogueRepository, Number: 2, Head: "h2"}}) + craw, err := delivery.EncodePlacementCandidate(delivery.PlacementCandidate{Proposal: "revert-x"}) if err != nil { t.Fatal(err) } - ckey, _ := delivery.PlacementCandidateKey("revert/x", itNode) + ckey, _ := delivery.PlacementCandidateKey("revert-x", itNode) if _, err := candidates.Put(ckey, craw); err != nil { t.Fatal(err) } // The controller holds no composition at web's want (the node composed its own): returning would leave web with // nothing to apply, and the answer says so rather than "same" (review of the shadow, round 1). within(t, 10*time.Second, "the node did not refuse returning to compositions the controller does not hold", func() bool { - a := node().Candidates["revert/x"] - return a.Head == "h2" && a.Returns == "" && a.Verdict == delivery.CandidateRefused && + a := node().Candidates["revert-x"] + return a.Proposal == "revert-x" && a.Returns == "" && a.Verdict == delivery.CandidateRefused && strings.Contains(a.Refused, "web: the controller holds no composition") }) ran := b.have("web").Composed @@ -683,12 +681,11 @@ func h8rest(t *testing.T, b *itBed, resolved, candidates nats.KeyValue, hkey str map[string]any{"name": "service-manager", "present": true}}}}) second := b.have("web").Composed same, _ := delivery.DecodePlacement(place) - craw, err := delivery.EncodePlacementCandidate(delivery.PlacementCandidate{Group: "feat/x", - Pull: delivery.Head{Repository: delivery.CatalogueRepository, Number: 1, Head: "h1"}, Placement: &same}) + craw, err := delivery.EncodePlacementCandidate(delivery.PlacementCandidate{Proposal: "feat-x", Placement: &same}) if err != nil { t.Fatal(err) } - ckey, _ := delivery.PlacementCandidateKey("feat/x", itNode) + ckey, _ := delivery.PlacementCandidateKey("feat-x", itNode) crev, err := candidates.Put(ckey, craw) if err != nil { t.Fatal(err) @@ -700,8 +697,8 @@ func h8rest(t *testing.T, b *itBed, resolved, candidates nats.KeyValue, hkey str return false } n, err := delivery.DecodeHaveNode(e.Value()) - answer = n.Candidates["feat/x"] - return err == nil && answer.Head == "h1" && n.Record != nil + answer = n.Candidates["feat-x"] + return err == nil && answer.Proposal == "feat-x" && n.Record != nil }) if answer.Verdict != delivery.CandidateSame || answer.Revision != crev || len(answer.Same) != 1 || answer.Same[0] != "web" { t.Errorf("the answer to a candidate equal to the placement: %+v", answer)