mesh-delivery: an unreliable time names its phases with no number; tests that it is never counted and that phases short of the walk's end are unreliable
mesh/merge-gate pass: builds mesh-delivery → novox; no bus step; every machine composes with the change as it did without (4 of 4 compose)
mesh/repo-check pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-check-typescript.sh (typescript)
mesh/delivery delivered
mesh/merge-gate pass: builds mesh-delivery → novox; no bus step; every machine composes with the change as it did without (4 of 4 compose)
mesh/repo-check pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-check-typescript.sh (typescript)
mesh/delivery delivered
This commit is contained in:
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -104,7 +103,11 @@ func timeOf(d *Delivery, w Walk) *DeliveryTime {
|
||||
from = from.Truncate(time.Millisecond)
|
||||
t := &DeliveryTime{Walk: w.ID, Class: p.Class, From: from, End: *p.End, Silent: p.Silent}
|
||||
unreliable := func(why string) *DeliveryTime {
|
||||
t.Unreliable, t.Phases = why, slices.Clone(p.Phases)
|
||||
// Its phases are named, never timed: a moment out of order makes every number in them suspect.
|
||||
t.Unreliable, t.Phases = why, nil
|
||||
for _, ph := range p.Phases {
|
||||
t.Phases = append(t.Phases, WalkPhase{Name: ph.Name, Tier: ph.Tier, State: phaseUnknown, Said: "unreliable"})
|
||||
}
|
||||
return t
|
||||
}
|
||||
if from.After(*p.End) {
|
||||
|
||||
@@ -116,6 +116,18 @@ func TestADeliveryKeepsItsTimeFromItsOwnMerge(t *testing.T) {
|
||||
if dt.Unreliable == "" || dt.TookMS != 0 {
|
||||
t.Fatalf("out of order is unreliable, with no time: %+v", dt)
|
||||
}
|
||||
for _, ph := range dt.Phases {
|
||||
if ph.TookMS != 0 || ph.Start != nil || ph.State != phaseUnknown {
|
||||
t.Fatalf("an unreliable time says no phase's time: %+v", ph)
|
||||
}
|
||||
}
|
||||
// The walk's phases not reaching its end: unreliable.
|
||||
short := phasesOf("leaf", from, ph{"window", 30 * time.Second})
|
||||
later := from.Add(time.Minute)
|
||||
short.End = &later
|
||||
if dt := timeOf(&Delivery{MergedAt: from}, Walk{ID: "w", Phases: short}); dt.Unreliable == "" || dt.TookMS != 0 {
|
||||
t.Fatalf("phases short of the walk's end: %+v", dt)
|
||||
}
|
||||
// Merged after the walk's end: unreliable.
|
||||
if dt := timeOf(&Delivery{MergedAt: from.Add(time.Hour)}, Walk{ID: "w", Phases: p}); dt.Unreliable == "" || dt.TookMS != 0 {
|
||||
t.Fatalf("merged after its walk's end: %+v", dt)
|
||||
@@ -217,3 +229,29 @@ func assertSums(t *testing.T, dt *DeliveryTime) {
|
||||
t.Fatalf("the phases add up to %dms, the delivery time is %dms: %+v", sum, dt.TookMS, dt)
|
||||
}
|
||||
}
|
||||
|
||||
// An unreliable time is said among the unknown, never in a median, an over count or the newest of its class.
|
||||
func TestAnUnreliableTimeIsNeverCounted(t *testing.T) {
|
||||
w := newWorld(t)
|
||||
good := walkedOnce(w, 11, "headgood", "mergegood1", phasesOf("leaf", t0, ph{"build", 2 * time.Minute}))
|
||||
bad := phasesOf("leaf", t0.Add(time.Hour), ph{"window", 30 * time.Second}, ph{"build", 9 * time.Minute})
|
||||
early := t0.Add(time.Hour + 10*time.Second)
|
||||
bad.Phases[1].End, bad.End = &early, &early
|
||||
unreliable := walkedOnce(w, 12, "headbad", "mergebad01", bad)
|
||||
if d := w.delivery(unreliable); d.Time == nil || d.Time.Unreliable == "" {
|
||||
t.Fatalf("the out-of-order walk gave a time: %+v", d.Time)
|
||||
}
|
||||
w.later(2 * time.Hour)
|
||||
a := w.h.times(7)
|
||||
l := a.Classes[0]
|
||||
if l.Count != 1 || l.Over != 0 || l.Latest == nil || l.Latest.ID != good || l.WorstID != good {
|
||||
t.Fatalf("an unreliable time was counted: %+v", l)
|
||||
}
|
||||
found := false
|
||||
for _, u := range a.Unknown {
|
||||
found = found || strings.HasPrefix(u, unreliable+": its time is unreliable")
|
||||
}
|
||||
if !found {
|
||||
t.Fatalf("the unreliable delivery is not said among the unknown: %v", a.Unknown)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user