test: advance lease clock and restore CI budget headroom
2 files changed,
+51
−12
.rastrillo/budgets.txt+6 −6internal/runner/lease_check_r1_test.go+45 −6
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt| index bfb7eac4..eb1c1e6a 100644 |
| --- a/.rastrillo/budgets.txt |
| +++ b/.rastrillo/budgets.txt |
| @@ -9,16 +9,16 @@ |
| # time <dir> <duration> <reason> |
| # perf <METHOD> <path> <duration>|skip <reason> |
| # boot <duration> <reason> |
| -size internal/equipo/team 8200 - Preserve the plan-mandated core layout; Task 14 raises 7900 after adding publication description provenance, receipt guards and scoped admission authorization (7931 lines). |
| +size internal/equipo/team 8500 - Preserve the mandated core layout; final fixes add conservative period settlement and authority guards. Current source count: 8041. |
| perf GET /* skip Unknown private paths render 404; this fallback contains no screens. |
| time internal/equipo/team 35s Task 18 whole-slice CI measured 26.546s for the copied core migration, recovery and concurrency suite on the shared machine. |
| -time internal/equipotest 180s Task 18 whole-slice CI measured 155.288s including the real HTTP runner workflow, browser-session authority, preparation sandbox, restore and label coverage. |
| +time internal/equipotest 300s Final review worst measured 172.4s; 300s allows 74 percent headroom and the added final regression tests. Final CI measurement will be recorded in the fix report. |
| -size internal/equipo 9600 - Task 16 adds the mandated task projections, live authorization and transaction notifier, connection and recovery pages, ordinary answer forms and flagged copy inventory beside the existing runner services. |
| -size internal/equipotest - 11600 Task 18 keeps the mandated runner_flow integration beside shared fixtures: real HTTP, Linux containment, local Git, exact evidence and publication assertions, plus confirmation-script checks (11230 total test lines before final review). |
| +size internal/equipo 10800 - Final fixes retain the plan layout and add bounded row-change notifications, aggregate task counts and runner refusal handling; current source count: 9648. |
| +size internal/equipotest - 13000 Final finding regressions stay beside the mandated integration fixtures; current test count: 11531. |
| time internal/runner/checks 25s Task 18 whole-slice CI measured 17.451s for real Go fixtures, Codex sandbox sentinels, timeout and child-process cleanup on the shared machine. |
| -time internal/runner 240s Task 18 restores missing budget timing for the complete runner suite; one lease test takes 65s, plus local Git workflows, real sandbox checks, Linux containment and fsynced recovery. The first whole-slice test lane took 182s with this package running throughout. |
| +time internal/runner 300s Final review worst measured 220.6s; 300s allows 36 percent headroom. Injected clock cuts the 65s lease check to 8.416s while retaining four renewals and a real sandboxed check. |
| perf GET /live skip Authorized notification stream, bounded to 30 seconds; not a GET screen. |
| perf GET /api/runner/v1/artifacts/{assignment}/{artifact} skip Authenticated runner artifact download, not a browser GET screen. Runner long-poll and blob downloads use POST and are outside the screen inventory. |
| -size internal/runner 5600 - Task 17 keeps the mandated service configuration, enrolment, discovery and production workflow wiring beside the Task 15 supervisor (5221 source lines before final formatting). |
| +size internal/runner 6500 - Final fixes add guarded journal reset, typed diagnostics and bounded prompts beside the mandated runner workflow; current source count: 5756. |
diff --git a/internal/runner/lease_check_r1_test.go b/internal/runner/lease_check_r1_test.go| index 8ea08741..0a95798b 100644 |
| --- a/internal/runner/lease_check_r1_test.go |
| +++ b/internal/runner/lease_check_r1_test.go |
| @@ -17,14 +17,32 @@ import ( |
| "amadan.net/oficina/equipo/internal/runnerproto" |
| ) |
| -type renewingCheckAPI struct{ renewals atomic.Int32 } |
| +type renewingCheckAPI struct { |
| + renewals atomic.Int32 |
| + clock ElapsedClock |
| +} |
| +type advancingCheckClock struct { |
| + start ClockReading |
| + offset atomic.Int64 |
| + reads atomic.Int32 |
| +} |
| + |
| +func (c *advancingCheckClock) Read() (ClockReading, error) { |
| + c.reads.Add(1) |
| + offset := time.Duration(c.offset.Load()) |
| + return ClockReading{Wall: c.start.Wall.Add(offset), Elapsed: c.start.Elapsed + offset, BootID: c.start.BootID}, nil |
| +} |
| func (a *renewingCheckAPI) Call(_ context.Context, op string, _ runnerproto.RunnerRequest, out any) error { |
| if op != "renew" { |
| return paseo.ErrContract |
| } |
| a.renewals.Add(1) |
| - *(out.(*time.Time)) = time.Now().Add(time.Minute) |
| + now, err := a.clock.Read() |
| + if err != nil { |
| + return err |
| + } |
| + *(out.(*time.Time)) = now.Wall.Add(time.Minute) |
| return nil |
| } |
| func TestRunnerLeaseLongCheck(t *testing.T) { |
| @@ -48,7 +66,7 @@ func TestRunnerLeaseLongCheck(t *testing.T) { |
| policy := paseo.ReadPolicy{ConfigHash: strings.Repeat("a", 64), DeniedPaths: []string{state}} |
| source := filepath.Join(root, "source") |
| wfMust(t, os.Mkdir(source, 0700)) |
| - files := map[string]string{"go.mod": "module longcheck\n\ngo 1.26.0\n", "long_test.go": "package longcheck\nimport(\"testing\";\"time\")\nfunc TestLong(t *testing.T){time.Sleep(61*time.Second)}\n"} |
| + files := map[string]string{"go.mod": "module longcheck\n\ngo 1.26.0\n", "long_test.go": "package longcheck\nimport(\"testing\";\"time\")\nfunc TestLong(t *testing.T){time.Sleep(time.Second)}\n"} |
| for name, value := range files { |
| wfMust(t, os.WriteFile(filepath.Join(source, name), []byte(value), 0600)) |
| } |
| @@ -58,7 +76,11 @@ func TestRunnerLeaseLongCheck(t *testing.T) { |
| d, err = checks.FreezeMaterial(ctx, d, source) |
| wfMust(t, err) |
| s, r, _, _ := cleanupFixture(t) |
| - api := &renewingCheckAPI{} |
| + start, err := s.clock.Read() |
| + wfMust(t, err) |
| + clock := &advancingCheckClock{start: start} |
| + s.clock = clock |
| + api := &renewingCheckAPI{clock: clock} |
| s.api = api |
| now, err := s.clock.Read() |
| wfMust(t, err) |
| @@ -98,10 +120,27 @@ func TestRunnerLeaseLongCheck(t *testing.T) { |
| wfMust(t, p.Track(ctx, o)) |
| ctx = checks.WithProcessOwnership(ctx, o.Marker, func(ctx context.Context, pid int) error { return p.TrackPID(ctx, o, pid) }) |
| ctx = runnerproto.WithCommandOwnership(ctx, func(ctx context.Context, pid int, key string) error { return p.BeginCommand(ctx, o, pid, key) }, func(ctx context.Context, key string) error { return p.EndCommand(ctx, o, key) }) |
| - started := time.Now() |
| + advanced := make(chan struct{}) |
| + go func() { |
| + defer close(advanced) |
| + tick := time.NewTicker(100 * time.Millisecond) |
| + defer tick.Stop() |
| + for i := int32(0); i < 4; { |
| + select { |
| + case <-ctx.Done(): |
| + return |
| + case <-tick.C: |
| + if clock.reads.Load() >= 2 && validations.Load() >= i { |
| + clock.offset.Add(int64(16 * time.Second)) |
| + i++ |
| + } |
| + } |
| + } |
| + }() |
| + defer func() { cancel(); <-advanced }() |
| baseline, err := e.CaptureBaseline(ctx, d) |
| wfMust(t, err) |
| - if time.Since(started) < time.Minute || len(baseline.Names) == 0 || api.renewals.Load() < 4 || validations.Load() < 4 { |
| + if time.Duration(clock.offset.Load()) < time.Minute || len(baseline.Names) == 0 || api.renewals.Load() < 4 || validations.Load() < 4 { |
| t.Fatal("check did not outlive renewed lease", api.renewals.Load(), validations.Load()) |
| } |
| } |