diff --git a/internal/link/replay331_test.go b/internal/link/replay331_test.go new file mode 100644 index 0000000..3c5b677 --- /dev/null +++ b/internal/link/replay331_test.go @@ -0,0 +1,25 @@ +package link + +import ( + "strings" + "testing" +) + +// TestReplay331 is the replay of hq issue 331 (mesh-lab R331), written with only what the node-engine had +// before its fix so it can be laid over the commit before: every declared tool check on a live machine +// read "no link to the bus is open" while the link was up, because the link the engine attaches — the NATS +// link — could not ask a tool, and the queue said that as no link. +// +// The NATS link is attached with no connection under it, so no bus is needed: the question must reach the +// link and fail there, not stop at the queue as if no link were open. +func TestReplay331(t *testing.T) { + q := &Queue{Membership: Membership{Node: "laptop"}} + q.attach(t.Context(), &natsLink{node: "laptop"}) + _, _, err := q.AskTool(t.Context(), "sensors", "sensors_health") + if err == nil { + t.Fatal("asked on no connection and was answered") + } + if strings.Contains(err.Error(), "no link to the bus is open") { + t.Fatalf("a tool check on the attached NATS link was refused as no link: %v", err) + } +}