diff --git a/modules/mesh-self-check/cmd/mesh-self-check/whole_integration_test.go b/modules/mesh-self-check/cmd/mesh-self-check/whole_integration_test.go index fcb372384..07a99b160 100644 --- a/modules/mesh-self-check/cmd/mesh-self-check/whole_integration_test.go +++ b/modules/mesh-self-check/cmd/mesh-self-check/whole_integration_test.go @@ -49,6 +49,8 @@ type player struct { in io.Writer next int pending map[string]chan wire + // times is what the gate's gate_times answers the budget probe (design 47 H2 §810). + times map[string]any } func (p *player) send(m map[string]any) { @@ -147,7 +149,7 @@ func (p *player) handle(m wire) { } _ = json.Unmarshal(m.Params, &g) if g.Kind == "config" && g.Key == "probes" { - p.answer(m.ID, []string{"D2", "D7", "DW", "D15"}, nil) + p.answer(m.ID, []string{"D2", "D7", "DW", "D15", "D-budget"}, nil) return } p.answer(m.ID, nil, fmt.Errorf("no %s value %s here", g.Kind, g.Key)) @@ -179,6 +181,13 @@ func (p *player) handle(m wire) { Key string `json:"key"` } _ = json.Unmarshal(m.Params, &ask) + if ask.Key == TimesTool { + p.mu.Lock() + times := p.times + p.mu.Unlock() + p.answer(m.ID, times, nil) + return + } if ask.Key != StreamsTool { p.answer(m.ID, nil, errors.New("nats: no responders available for request")) return @@ -268,7 +277,14 @@ func TestTheSelfCheckWholeRunsOnTheBus(t *testing.T) { t.Fatal(err) } t.Cleanup(func() { _ = stdin.Close(); cancel(); _ = cmd.Wait() }) - p := &player{ctx: ctx, nc: nc, js: js, in: stdin, pending: map[string]chan wire{}} + // SC1 (design 47 H2 §810; H-A-453 (3)): the gate's newest core delivery took 11 minutes from its merge call, over its + // budget of ten. + coreTimes := func(took string, over bool) map[string]any { + return map[string]any{"core": map[string]any{"budget": "10m0s", "last": map[string]any{"record": "record/main_7", + "milestone": "main.7", "ended": "2026-11-22T01:00:00Z", "delivery-time": took, "longest-phase": "placing", + "longest-phase-time": "6m0s", "over": over}}, "leaf": map[string]any{"budget": "3m0s"}} + } + p := &player{ctx: ctx, nc: nc, js: js, in: stdin, pending: map[string]chan wire{}, times: coreTimes("11m0s", true)} go p.serve(stdout) raw, err := p.call(DoctorTool, map[string]any{"run": true}) @@ -323,4 +339,33 @@ func TestTheSelfCheckWholeRunsOnTheBus(t *testing.T) { if raw, err := p.call(VerdictsTool, map[string]any{}); err != nil || !strings.Contains(string(raw), answer.Run.Run) { t.Errorf("the week's verdicts answered %s, %v", raw, err) } + + // SC1: the over-budget core delivery raised over-budget for the class core, naming its record and longest phase; the next + // core delivery within its budget clears it. + overBudget := func() (string, bool) { + keys, err := findings.Keys(ctx) + if err != nil { + return "", false + } + for _, k := range keys { + if strings.Contains(k, ".core.") && strings.HasSuffix(k, "."+kindOverBudget) { + e, err := findings.Get(ctx, k) + return string(e.Value()), err == nil + } + } + return "", false + } + if raised, ok := overBudget(); verdicts["D-budget"] != VerdictFail || !ok || !strings.Contains(raised, "main.7") || + !strings.Contains(raised, "placing") { + t.Errorf("the over-budget core delivery: the probe's verdict %q, the finding %q (%v)", verdicts["D-budget"], raised, ok) + } + p.mu.Lock() + p.times = coreTimes("4m0s", false) + p.mu.Unlock() + if _, err := p.call(DoctorTool, map[string]any{"run": true}); err != nil { + t.Fatal(err) + } + if raised, ok := overBudget(); ok { + t.Errorf("a core delivery within its budget left over-budget raised: %s", raised) + } }