Refuse the flip on an account naming nothing reachable, and mark such an account partial in the preview (hq ADR 0100)
This commit is contained in:
@@ -473,3 +473,32 @@ func TestThePreviewNamesEveryHeldKind(t *testing.T) {
|
||||
t.Fatal("the digest does not change with what is held")
|
||||
}
|
||||
}
|
||||
|
||||
// novox/hq ADR 0100: the flip acts on what the node said is reachable, so an account naming nothing
|
||||
// is refused. Every machine that is up answers on ssh; nothing reported means the host's collectors
|
||||
// did not, and flipping would close ports the preview never named.
|
||||
func TestTheFlipIsRefusedOnAnAccountNamingNothingReachable(t *testing.T) {
|
||||
open, sent := anAdoptedAnchor(t)
|
||||
ctx := t.Context()
|
||||
if _, err := take(ctx, open, "anchor", "hello-web"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Only a loopback listener: nothing off the machine, which is the same silence.
|
||||
reportsReaching(t, open, []link.Reach{
|
||||
{Protocol: "tcp", Address: "127.0.0.1", Port: 15672, By: "mesh-broker"},
|
||||
}, heldFile)
|
||||
preview, err := converge(ctx, open, "anchor", false, "", "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(preview, "this account looks partial") {
|
||||
t.Errorf("the preview does not mark a partial account:\n%s", preview)
|
||||
}
|
||||
_, err = converge(ctx, open, "anchor", true, digestIn(t, preview), "")
|
||||
if err == nil || !strings.Contains(err.Error(), "says nothing is reachable on it") {
|
||||
t.Fatalf("the flip was not refused on an account naming nothing: %v", err)
|
||||
}
|
||||
if n, _ := open.inventory.NodeByName(ctx, "anchor"); !n.Adopted || len(*sent) != 0 {
|
||||
t.Fatal("a refused flip changed something")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user