| index a366d2aba..d1e7502df 100644 |
| --- a/internal/host/fleet_forward_budget_test.go |
| +++ b/internal/host/fleet_forward_budget_test.go |
| @@ -60,9 +60,11 @@ func TestBoxProvisionConfigArmsForwardingOnTheHubOnly(t *testing.T) { |
| if err != nil { |
| t.Fatal(err) |
| } |
| - // Parity: the owners the edge's fleet arm, the edges file and the alias |
| - // pass judge by on this box (fleetArmInputs), so the phase never mints a |
| - // row the hub's edge refuses for want of an owner, nor the reverse. |
| + // Parity: the owners the edges file and the alias pass judge by on this |
| + // box (fleetArmInputs) are the phase's own read. The edge's Reload reads |
| + // the fleets table itself, so it can trail them by one pass; it |
| + // converges on its next reload and fails closed meanwhile, serving a |
| + // forward row only on its own read of the owner (hubFleetOwners). |
| edgeOwners, edgeHub, tunnels, err := fleetArmInputs(reg, hub) |
| if err != nil { |
| t.Fatal(err) |
| @@ -94,7 +96,10 @@ func TestBoxProvisionConfigArmsForwardingOnTheHubOnly(t *testing.T) { |
| } |
| |
| // budgetStore counts every call made through it by operation and key while |
| -// counting is on. |
| +// counting is on. It embeds release.Store, so it hides every optional |
| +// interface the DirStore below has (release.ConditionalGetter, ETagLister, |
| +// ModLister, SizeLister, PageLister and Opener among them): each reader |
| +// that asks for one takes its fallback path here, on both hubs alike. |
| type budgetStore struct { |
| release.Store |
| mu sync.Mutex |
| @@ -287,8 +292,11 @@ func (w *budgetWorld) passSet(t *testing.T, cfg provision.ReconcileConfig) { |
| // nothing (the hub as it is today, settled), then two with the forward |
| // phase as armed says. It returns the calls of the first of those (where a |
| // forward row first appears) and of the second (steady state: nothing |
| -// changing). |
| -func budgetRun(t *testing.T, c budgetCase, armed bool) (first, steady map[string]int, reg *registry.Registry) { |
| +// changing). Then it deletes the fleet app's records and returns the calls |
| +// of one more pass set (gone: where the armed hub retires the rows). On an |
| +// armed world it checks a forward row stands at each host before the |
| +// deletion and none after. |
| +func budgetRun(t *testing.T, c budgetCase, armed bool) (first, steady, gone map[string]int) { |
| t.Helper() |
| w := newBudgetWorld(t, c) |
| cfg := BoxProvisionConfig(w.reg, func(k string) string { |
| @@ -315,7 +323,26 @@ func budgetRun(t *testing.T, c budgetCase, armed bool) (first, steady map[string |
| } |
| first = w.s.count(func() { w.passSet(t, cfg) }) |
| steady = w.s.count(func() { w.passSet(t, cfg) }) |
| - return first, steady, w.reg |
| + if armed { |
| + for _, h := range c.shopHosts { |
| + rt, err := w.reg.Get(h) |
| + if err != nil || rt == nil || !rt.IsForward() { |
| + t.Fatalf("the armed hub holds no forward row at %s (%+v, %v): the comparison measures nothing", h, rt, err) |
| + } |
| + } |
| + } |
| + for _, h := range c.shopHosts { |
| + if err := provision.DeleteRecord(context.Background(), w.s, fpOwner, "shop", h); err != nil { |
| + t.Fatalf("delete record %s: %v", h, err) |
| + } |
| + } |
| + gone = w.s.count(func() { w.passSet(t, cfg) }) |
| + for _, h := range c.shopHosts { |
| + if rt, err := w.reg.Get(h); err != nil || rt != nil { |
| + t.Fatalf("after the records went the hub still holds %+v at %s (%v)", rt, h, err) |
| + } |
| + } |
| + return first, steady, gone |
| } |
| |
| // writes is how many PUTs and DELETEs calls holds. |
| @@ -376,7 +403,16 @@ func showCalls(m map[string]int) string { |
| // (C = 1: no other row of the owner's is on the hub). Bindings, build |
| // states, retention, canary status, the domains pass and the alias pass |
| // without a catch-all: unchanged. The edges file: one PUT when the row |
| -// appears, none in steady state. |
| +// appears, none in steady state, and one when the row goes (the app's |
| +// records deleted, the phase retires the row). |
| +// |
| +// The numbers hold for the store this test counts through, as the telemetry |
| +// rows hold for the index off: budgetStore hides the store's optional |
| +// interfaces, so every reader that would use one (a conditional GET, an |
| +// ETag or modification-time listing, a paged listing) runs its fallback, on |
| +// the dormant hub and the armed one alike. A production store that has them |
| +// can make other calls than these on both hubs; the difference between the |
| +// two is what this test pins. |
| // |
| // Two more cases (R3-2): an instance catch-all claim for shop adds one List |
| // of the app's instance records per alias pass (K = 1); two of shop's |
| @@ -426,14 +462,8 @@ func TestForwardRequestBudget(t *testing.T) { |
| twoHosts}, |
| } { |
| t.Run(tc.name, func(t *testing.T) { |
| - beforeFirst, before, _ := budgetRun(t, tc.c, false) |
| - afterFirst, after, reg := budgetRun(t, tc.c, true) |
| - for _, h := range tc.c.shopHosts { |
| - rt, err := reg.Get(h) |
| - if err != nil || rt == nil || !rt.IsForward() { |
| - t.Fatalf("the armed hub holds no forward row at %s (%+v, %v): the comparison measures nothing", h, rt, err) |
| - } |
| - } |
| + beforeFirst, before, beforeGone := budgetRun(t, tc.c, false) |
| + afterFirst, after, afterGone := budgetRun(t, tc.c, true) |
| if got := callDiff(before, after); !reflect.DeepEqual(got, tc.want) { |
| t.Errorf("steady-state difference per pass set:%s\nwant:%s", showCalls(got), showCalls(tc.want)) |
| } |
| @@ -454,6 +484,10 @@ func TestForwardRequestBudget(t *testing.T) { |
| if b, a := edgesPuts(beforeFirst), edgesPuts(afterFirst); a != b+1 { |
| t.Errorf("edges file PUTs on the pass the forward row appears: %d, want %d (one more than the dormant hub's)%s", a, b+1, showCalls(callDiff(beforeFirst, afterFirst))) |
| } |
| + // The pass where the forward row goes: one more PUT again. |
| + if b, a := edgesPuts(beforeGone), edgesPuts(afterGone); a != b+1 { |
| + t.Errorf("edges file PUTs on the pass the forward row goes: %d, want %d (one more than the dormant hub's)%s", a, b+1, showCalls(callDiff(beforeGone, afterGone))) |
| + } |
| }) |
| } |
| } |