| index 533f4d53e..cc1f4ec8b 100644 |
| --- a/internal/host/movespass_lost_test.go |
| +++ b/internal/host/movespass_lost_test.go |
| @@ -185,3 +185,42 @@ func TestLostBoxGateCoversTheWholePass(t *testing.T) { |
| }) |
| } |
| } |
| + |
| +// Fix round 1, item 4: the gate names this box's region through the shared |
| +// placement rule (park.PlacementMatches under the verified home binding), |
| +// never raw string equality: on the home box (placement code "") a record |
| +// that spells the home by its roster name names this box, and is gated; |
| +// without the verified binding it names another region. |
| +func TestLostBoxGateReadsHomeSpellingsUnderTheBinding(t *testing.T) { |
| + s := release.NewDirStore(t.TempDir()) |
| + inc, err := hostclaim.Incarnation("bab", "app", p1Host, p1Created) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := hostclaim.Update(t.Context(), s, hostclaim.Observed{Host: p1Host, Absent: true}, func(c *hostclaim.Claim) error { |
| + c.Holder = &hostclaim.Holder{Family: "instance", Key: provision.RecordKey("bab", "app", p1Host), Account: "bab", App: "app", Incarnation: inc, CreatedAt: p1Created, Location: "instances/" + p1Host, Generation: "cur", Stamp: 1} |
| + c.Op = hostclaim.Op{Kind: hostclaim.KindServing, Exec: "home-box"} |
| + c.Lost, c.LostRevisions = []string{"home-box"}, map[string]uint64{"home-box": 1} |
| + return nil |
| + }); err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, spelling := range []provision.Record{ |
| + {Host: p1Host, Region: "ie", Move: &provision.MoveState{ID: p1ID, From: "ie", To: "uk"}}, |
| + {Host: p1Host, Region: "uk", Move: &provision.MoveState{ID: p1ID, From: "uk", To: "ie"}}, |
| + {Host: p1Host, Region: "", Move: &provision.MoveState{ID: p1ID, From: "", To: "uk"}}, |
| + } { |
| + bound := &movesWorker{cfg: moveCfg{Box: "home-box", Region: "", ParkHomeRegion: "ie"}} |
| + if !movesNamesBox(bound.cfg, spelling) || !bound.lostHere(t.Context(), s, spelling) { |
| + t.Fatalf("the home box under the binding does not gate %+v", spelling.Move) |
| + } |
| + } |
| + unbound := moveCfg{Box: "home-box", Region: ""} |
| + if movesNamesBox(unbound, provision.Record{Host: p1Host, Region: "ie", Move: &provision.MoveState{ID: p1ID, From: "ie", To: "uk"}}) { |
| + t.Fatal("a roster name matched the home without the verified binding") |
| + } |
| + named := moveCfg{Box: "de-box", Region: "de", ParkHomeRegion: "ie"} |
| + if movesNamesBox(named, provision.Record{Host: p1Host, Region: "", Move: &provision.MoveState{ID: p1ID, From: "", To: "uk"}}) { |
| + t.Fatal("a named box matched the home") |
| + } |
| +} |