| index 07401bb3d..d4d07293d 100644 |
| --- a/internal/edge/rank_property_test.go |
| +++ b/internal/edge/rank_property_test.go |
| @@ -31,7 +31,11 @@ package edge |
| // file's age. |
| // - The classes are fixed marks (platform on a real candidate in the |
| // first file or local, wildcard on a ready candidate in the second), so |
| -// varying a pair never changes them. |
| +// varying a pair never changes them. That an alias never carries the |
| +// platform class is a property of these fixtures here; the admission |
| +// that enforces it is pinned by TestRemoteCandidatesKeepTheAdmissions |
| +// and exercised by TestRankEqualsFoldWithoutHolds, whose alias rows are |
| +// all marked platform. |
| |
| import ( |
| "fmt" |
| @@ -381,12 +385,7 @@ func TestRankingProperties(t *testing.T) { |
| continue |
| } |
| anyReady = true |
| - if m.stamp != 0 { |
| - anyStamped = true |
| - if specSuppressed(set, i) { |
| - fail(set, "(b) spec: a stamped candidate suppressed") |
| - } |
| - } |
| + anyStamped = anyStamped || m.stamp != 0 |
| if specSuppressed(set, i) { |
| continue |
| } |
| @@ -428,9 +427,6 @@ func TestRankingProperties(t *testing.T) { |
| if d.kind != decHolding || d.hold != cs[holdWin].hold { |
| fail(set, "(n) decision %s, want the sorted fold's %s", describeDecision(d), cs[holdWin].app) |
| } |
| - if anyStamped { |
| - fail(set, "(b) a stamped ready lost to a hold") |
| - } |
| default: |
| if d.kind != decNone { |
| fail(set, "decision %s, want none: no live ready or hold", describeDecision(d)) |
| @@ -443,6 +439,27 @@ func TestRankingProperties(t *testing.T) { |
| fail(set, "(c)/(e) a hold beat a surviving ready candidate") |
| } |
| |
| + // (b): with a stamped ready candidate in the set no hold answers, and |
| + // the winner is the one the set has with every hold and every |
| + // candidate the spec suppresses taken out, so the holds did nothing |
| + // to the stamped one. (Taking out the holds alone is not the same |
| + // set: the unstamped candidates they suppress come back, a local |
| + // ready or a real route beside a stamped alias, and may win.) |
| + if anyStamped { |
| + if d.kind == decHolding { |
| + fail(set, "(b) a hold answered beside a stamped ready: %s", describeDecision(d)) |
| + } |
| + var bare []candidate |
| + for i, m := range set { |
| + if m.kind == candReady && !specSuppressed(set, i) { |
| + bare = append(bare, cs[i]) |
| + } |
| + } |
| + if db := rank(modelName, bare, rankNow); !sameWinner(d, db) { |
| + fail(set, "(b) with the holds the answer is %s, with them and what they suppress removed %s", describeDecision(d), describeDecision(db)) |
| + } |
| + } |
| + |
| // (d): removing a suppressed candidate changes no winner. |
| for i := range set { |
| if !specSuppressed(set, i) { |
| @@ -494,7 +511,9 @@ func TestRankingProperties(t *testing.T) { |
| } |
| } |
| }) |
| - t.Logf("%d candidate sets", sets) |
| + if sets != 504206 { |
| + t.Fatalf("%d candidate sets, want 504206: the enumeration changed", sets) |
| + } |
| } |
| |
| // TestLocalReadyIsUnstamped: this box's own ready candidate is never |
| @@ -618,7 +637,9 @@ func TestHoldingSortedFold(t *testing.T) { |
| return false |
| }) |
| }) |
| - t.Logf("%d holding sets", sets) |
| + if sets != 148980 { |
| + t.Fatalf("%d holding sets, want 148980: the enumeration changed", sets) |
| + } |
| } |
| |
| // The no-hold differential (invariant (a), Review Focus 2): with no live |
| @@ -675,17 +696,19 @@ func todaysDispatch(table map[string]upstream, files map[string]edgesFileView, s |
| return diffWant{} |
| } |
| |
| -// diffHostEntry is one file's publication of diffHost: none, a real route |
| -// or an alias (of modelPrimary, or naming no target), at each pair, |
| -// stamped or not; the real one in the first file carries platform. |
| +// diffHostEntries is one file's publication of diffHost: none, a real |
| +// route or an alias (of modelPrimary, or naming no target), at each pair, |
| +// stamped or not. The real one carries the platform mark in the first file |
| +// only; every alias carries it, so the differential runs buildCandidates' |
| +// and foldHomes' rule that an alias is never the platform class. |
| func diffHostEntries(first bool) []*edgesHostView { |
| out := []*edgesHostView{nil} |
| for p, pair := range modelPairs { |
| for stamp := int64(0); stamp < 2; stamp++ { |
| out = append(out, |
| &edgesHostView{Role: edgeRoleHome, Platform: first, Incarnation: pair[0], ServingSeq: pair[1], Stamp: stamp, App: fmt.Sprintf("real%d%d", p, stamp)}, |
| - &edgesHostView{Role: edgeRoleHome, Alias: true, TargetHost: modelPrimary, Incarnation: pair[0], ServingSeq: pair[1], Stamp: stamp, App: fmt.Sprintf("alias%d%d", p, stamp)}, |
| - &edgesHostView{Role: edgeRoleHome, Alias: true, Incarnation: pair[0], ServingSeq: pair[1], Stamp: stamp, App: fmt.Sprintf("legacy%d%d", p, stamp)}) |
| + &edgesHostView{Role: edgeRoleHome, Alias: true, Platform: true, TargetHost: modelPrimary, Incarnation: pair[0], ServingSeq: pair[1], Stamp: stamp, App: fmt.Sprintf("alias%d%d", p, stamp)}, |
| + &edgesHostView{Role: edgeRoleHome, Alias: true, Platform: true, Incarnation: pair[0], ServingSeq: pair[1], Stamp: stamp, App: fmt.Sprintf("legacy%d%d", p, stamp)}) |
| } |
| } |
| return out |
| @@ -897,6 +920,8 @@ func TestRankEqualsFoldWithoutHolds(t *testing.T) { |
| } |
| } |
| } |
| - t.Logf("%d resolutions", cases) |
| + if cases != 415872 { |
| + t.Fatalf("%d resolutions, want 415872: the enumeration changed", cases) |
| + } |
| }) |
| } |