diff options
| author | aur-build <aur-build@localhost> | 2026-11-18 16:49:40 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-18 16:49:40 +0000 |
| commit | 41fa1684de8eb13c5b76c3a3e174fece04ac5afa (patch) | |
| tree | 491a2faf2dd2314f537300ccaf1e0150b54d1123 /tests/crash.rs | |
| parent | 101f077200e80c7869e4549db645ed94b01acb1b (diff) | |
| download | aur-build-41fa1684de8eb13c5b76c3a3e174fece04ac5afa.tar.gz aur-build-41fa1684de8eb13c5b76c3a3e174fece04ac5afa.zip | |
db: the review, step, release and subscription states are enums too
M-8 named four more machines after `build_state`, and each had the same defect
in miniature: `&str` constants, a writer that took any `&str`, and a rule that
lived only in the caller's discipline. They are `CandidateState`, `StepState`,
`ReleaseState` and `SubscriptionState` now, all parsed through one
`db::state_col` at the row boundary — a column value the code cannot name fails
the read rather than becoming a state it did not ask for.
The one that mattered is the review machine. `resolve_in(tx, id, &str)` would
move a candidate to any state from any state, so an approval racing a
rejection, or a stale worker resolving a review that had already been
superseded, silently overwrote what a human had decided — the direct route to
breaking I2 and I3 with no symptom anywhere. It is a compare-and-swap on
`CandidateState` now: a decided review is only ever frozen, never re-decided,
and a refusal names both states. `supersede_in` goes through it, so the freeze
cannot resurrect a superseded review either.
`StepState` gives I5 teeth. `begin_step` upserted over any existing checkpoint,
including one recorded `succeeded`, so a resume that asked to re-run a finished
step could rewrite the very row that told it to skip; the upsert now refuses to
touch a done checkpoint and `finish_step` is a CAS. The blocked path
(`running → pending`) and the reaper's `running → interrupted` are unchanged,
and both are in the table.
Two behaviour changes, both for the better and both tested: the UI's pause
button now says "orphaned: nothing to pause" instead of rewriting an orphaned
subscription back to a pausable state, and a step checkpoint that is already
done makes `begin_step` an error rather than a quiet overwrite.
Five tests in `tests/state_machine.rs` cover the review CAS in both directions,
the frozen checkpoint, the interrupted/blocked transitions, and the unknown
value in a candidate and a step row.
Diffstat (limited to 'tests/crash.rs')
| -rw-r--r-- | tests/crash.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/crash.rs b/tests/crash.rs index 0510aab..66e6043 100644 --- a/tests/crash.rs +++ b/tests/crash.rs @@ -67,13 +67,13 @@ fn a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work b.state ); assert_eq!( - builds::step_status(&env.db, &id, "build").unwrap().as_deref(), - Some(step_state::RUNNING), + builds::step_status(&env.db, &id, "build").unwrap(), + Some(StepState::Running), "the step that was running should be recorded as running" ); assert_eq!( - builds::step_status(&env.db, &id, "chroot").unwrap().as_deref(), - Some(step_state::SUCCEEDED), + builds::step_status(&env.db, &id, "chroot").unwrap(), + Some(StepState::Succeeded), "the completed step before the crash must be checkpointed" ); assert!(db::accepted_release(&env.db, "plain-make").unwrap().is_none(), "nothing was published"); @@ -83,8 +83,8 @@ fn a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work env.exec("UPDATE build SET lease_expires_at='2000-01-01T00:00:00Z' WHERE id=?1", ¶ms(vec![id.as_str()])); assert_eq!(builds::reap_expired(&env.db).unwrap(), 1); assert_eq!( - builds::step_status(&env.db, &id, "build").unwrap().as_deref(), - Some(step_state::INTERRUPTED) + builds::step_status(&env.db, &id, "build").unwrap(), + Some(StepState::Interrupted) ); // Resume. The completed steps are not repeated; only the interrupted one and |
