Medlar/docs/tests/S021-queues-schedule-power.md
2026-11-25 21:23:13 -06:00

4.9 KiB

S021 — Queues, schedule, power: test file

Written by the worker that built it, run by the test phase. Nothing here has been tested until its Result says so.

Built

crates/core/src/schedule.rs · Clock, SystemClock, ManualClock, Schedule::contains, open, opened_between, Grid, cycle. crates/core/src/power.rs · Action, Scope, WhenDone, Watcher::{arm,cancel,step} (countdown, conditions), Power trait, Logind, Inhibitor. crates/core/src/run.rs · RunSpec, Vars, expand, run (no shell, timeout, output to log). crates/core/src/manager/{actor,pick}.rs · choose reads queue paused, max_active, schedule and task after; Config.clock; Error::Cycle on Edit.

Checks

Risk: HIGH = data loss, security, crash, wrong result · MED = feature broken · LOW = looks or comfort.

# Risk Do this Expect How Result
1 HIGH Queue with paused, add a task to it task stays Queued, nothing downloads; unpause starts it integration (testserver, Config.clock default) —
2 HIGH Queue max_active = 1, three tasks, global max 4 only one runs at a time, the others follow in order integration —
3 HIGH Queue schedule Mon 22:00-06:00 on a ManualClock at Mon 21:59, then advance 2 minutes task starts within one look (~15 s real, or send a command to force choose) integration —
4 HIGH Running task, clock leaves the window task goes back to Queued, not Failed; returns when the window opens integration —
5 HIGH Start by hand (forced) in a paused or closed queue it runs integration —
6 HIGH Task B after A; A Running B stays Queued; when A is Done, B starts integration —
7 HIGH after pointing at itself, at a chain that returns, at a removed task first two give Error::Cycle and nothing is saved; the last is accepted and B isn't held integration —
8 HIGH Watcher with even_failed = false, one Done and one Failed Step::Blocked, disarmed, never fires unit —
9 HIGH Same with even_failed = true countdown starts, fires after the countdown unit —
10 MED Cancel during the countdown; a task of the scope starts again Idle after cancel; a new running task resets the countdown unit —
11 MED Scope Queue(2) while queue 1 still runs fires when queue 2 is done unit —
12 HIGH ManualClock zone with +1 h at the 2026-03-29 01:00 UTC step (Europe), window 02:00-03:00 contains follows local time: closed before, open after; no panic in the skipped hour unit —
13 MED Zone change (offset +0 to +9 h) while window 22:00-06:00 open/closed follows the new wall time at once unit —
14 MED opened_between over a 10-hour sleep that spans a window start, and one that spans none or only an end true for the first; false for the others; scan capped at 8 days unit —
15 MED Night window Mon 22:00-06:00 Tuesday 05:59 open, 06:00 closed, Monday 05:00 closed; from == to is the whole day unit —
16 MED Grid::new with 167 and 168 cells; at on Monday 00:30 and Sunday 23:30 None for 167; first and last cell unit —
17 HIGH expand with {file} = /a b/c; rm -rf / one argument, unchanged; no shell run unit —
18 MED run with sleep 5, timeout 1 s; with echo hi; with a missing program; with exit code 1 timeout error naming seconds; Ok("hi\n"); "did not start"; "ended with" error integration —
19 HIGH Fake Power that records calls: drive a Fire(Shutdown) through the caller only the fake is called; Logind is never used in tests unit —
20 LOW Logind::can on this PC (capabilities only, no perform) Shutdown/Suspend answer without calling the methods; Quit and Run always true by hand —

Needs

crates/testserver on 127.0.0.1; a throwaway home; a ManualClock in Config.clock. Never call Logind::perform or Inhibitor::take for real in tests except by hand on check 20 (capabilities only).

Doubts

  • Not wired yet: the app's UI for queues, schedules and when-done; nothing calls Watcher, Logind, Inhibitor or run::run outside tests; the speed Grid is not applied to the limiter; no model fields for once-only schedules (a task's start_at is the once rule and is still Hold::Until, untouched).
  • schedule is read when choose runs; a clock jump is seen at most 15 s later (SCHEDULE_LOOK), and Hold::Until still uses Instant, so time asleep does not count for a start time.
  • A closed or paused queue pushes running tasks back to Queued; a task running in a queue that gets paused is suspended, not paused.
  • pick and Candidate got a field and a parameter; the unit tests in pick.rs were edited to match, not run.
  • Fall-back hour: the window counts twice (documented); not covered by a check.