S009: build and suite check, child-process tests, results filled
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
parent
5f6e7e330c
commit
b14d1be17f
8 changed files with 70 additions and 38 deletions
|
|
@ -11,13 +11,13 @@ First make sure everything builds and the existing suite passes (fix breakage fi
|
|||
- CLAUDE.md §2 and §5 for the build and test commands
|
||||
|
||||
## Steps
|
||||
- [ ] It runs: `cargo build --release`, `cargo test` once (worktree-only failures from missing `assets/data` and ROMs are known, see PROGRESS), `target/debug/dezio` lists commands and exits; fix breakage first
|
||||
- [ ] Doubts first: read the code behind each doubt in the three files and add a check, or write why it is fine
|
||||
- [ ] Write the tests for all HIGH and MED checks in one go; share fixtures (a local slow HTTP server on 127.0.0.1, a stuck child process); no test for what the compiler already proves
|
||||
- [ ] Run them once, all together, short output; save the log to a file and read only the failures
|
||||
- [ ] Sort the failures by cause, then fix all causes in one go; a wrong test is corrected, never weakened to pass
|
||||
- [ ] Rerun only what failed; three rounds at most, then `KNOWN BUG` with the cause
|
||||
- [ ] Results filled in, `docs/TEST-REPORT.md` line, PROGRESS entry, INDEX line, commit `S009: …`
|
||||
- [x] It runs: `cargo build --release`, `cargo test` once (worktree-only failures from missing `assets/data` and ROMs are known, see PROGRESS), `target/debug/dezio` lists commands and exits; fix breakage first
|
||||
- [x] Doubts first: read the code behind each doubt in the three files and add a check, or write why it is fine
|
||||
- [x] Write the tests for all HIGH and MED checks in one go; share fixtures (a local slow HTTP server on 127.0.0.1, a stuck child process); no test for what the compiler already proves
|
||||
- [x] Run them once, all together, short output; save the log to a file and read only the failures
|
||||
- [x] Sort the failures by cause, then fix all causes in one go; a wrong test is corrected, never weakened to pass
|
||||
- [x] Rerun only what failed; three rounds at most, then `KNOWN BUG` with the cause
|
||||
- [x] Results filled in, `docs/TEST-REPORT.md` line, PROGRESS entry, INDEX line, commit `S009: …`
|
||||
|
||||
## End criteria
|
||||
- `cargo test` green, except listed known bugs and worktree-only asset failures
|
||||
|
|
|
|||
|
|
@ -30,6 +30,6 @@ Tracker: https://claude.ai/artifact/PRAT4HSkqn44d6QFDJeovp
|
|||
|
||||
## 05 Test and release
|
||||
|
||||
- [ ] [S009 — Test: it runs, and network](05%20Test%20and%20release/S009-test-runs-and-network.md)
|
||||
- [x] [S009 — Test: it runs, and network](05%20Test%20and%20release/S009-test-runs-and-network.md)
|
||||
- [ ] [S010 — Test: images, fm, security, whole app](05%20Test%20and%20release/S010-test-images-security-app.md)
|
||||
- [ ] [S011 — Deploy and owner check](05%20Test%20and%20release/S011-deploy-and-owner-check.md) 🧑
|
||||
|
|
|
|||
|
|
@ -59,3 +59,7 @@ One entry per session, newest last, ≤ 15 lines: done, verified how, not done,
|
|||
- Verified: `cargo check` only. Not tested. Audit summary and test list in `docs/tests/S008-media-commands-deps.md`.
|
||||
- Advisories left open: libcrux-* (davey, DAVE voice; 4 high), crypto-bigint, curve25519-dalek, ringbuf (songbird): need upstream major bumps. rustls 0.22/webpki 0.102 only in Cargo.lock, not built.
|
||||
- Later: ffmpeg/yt-dlp/gallery-dl redirects and rebinding can't be checked from inside; an egress firewall for the bot's user on the server would close it.
|
||||
|
||||
## 2026-12-01 — S009 test: it runs, network
|
||||
- Done: release build ok; `cargo test` 249 pass, 8 worktree-only asset failures; binary lists commands. Added 2 child-process tests (timeout kill, cancel). Results filled in S001-S003 test files; `docs/TEST-REPORT.md` started.
|
||||
- Not done: Discord, voice, network-cut and timed-upload checks (`not run`, need live bot/server). Nothing deployed.
|
||||
|
|
|
|||
3
docs/TEST-REPORT.md
Normal file
3
docs/TEST-REPORT.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Test report
|
||||
|
||||
- S009 (2026-12-01): release build ok; `cargo test` 249 pass, 8 fail (all need `assets/data` or ROMs missing in this worktree: fun actions/animals, cookie, hangman, words x2, rolemenus preset, web ROM test); binary lists commands with a placeholder token. New unit tests: `stuck_child_is_killed_at_the_limit`, `cancel_ends_a_running_child` (pass). S001-S003 checks needing Discord, live voice or a network cut are `not run`.
|
||||
|
|
@ -10,16 +10,16 @@ Written by the worker that built it, run by the test phase. Nothing here has bee
|
|||
## Checks
|
||||
| # | Risk | Do this | Expect | How | Result |
|
||||
|---|---|---|---|---|---|
|
||||
| 1 | MED | `cargo test budget_is_the_smaller` | passes | unit | — |
|
||||
| 2 | MED | Tier 0/1 guild: read `upload_limit` | 10 MiB; tier 2 50, tier 3 100 | unit/by hand | — |
|
||||
| 3 | HIGH | `/download` of a clip that compresses to ~8 MB | uploads as attachment, no retry loop | by hand | — |
|
||||
| 4 | HIGH | `/download` source whose smallest encode is above 8.5 MB | message shows a website link (24 h notice), no attachment; `VideoResult.oversize` path | by hand | — |
|
||||
| 5 | HIGH | Force upload timeout (shape line to a few KB/s or shorten client timeout locally) | one attempt only, message becomes hosted link(s) | by hand | — |
|
||||
| 6 | MED | Simulate 502 or connection reset on upload | retried up to 3 times | by hand | — |
|
||||
| 7 | MED | Simulate 400/403 on upload | no retry, "Discord refused" card | by hand | — |
|
||||
| 8 | MED | `/convert` to a result over 8.5 MB | link with 24 h notice, no attachment | by hand | — |
|
||||
| 9 | LOW | `/media` effect with result over budget | "too big to upload" error with MB values | by hand | — |
|
||||
| 10 | LOW | `rg UPLOAD_RETRIES src` | retry loop only continues on retryable errors | by hand | — |
|
||||
| 1 | MED | `cargo test budget_is_the_smaller` | passes | unit | pass (cargo test budget_is) |
|
||||
| 2 | MED | Tier 0/1 guild: read `upload_limit` | 10 MiB; tier 2 50, tier 3 100 | unit/by hand | not run: needs Discord (tier mapping read in code: 0/1 10, 2 50, 3 100 MiB) |
|
||||
| 3 | HIGH | `/download` of a clip that compresses to ~8 MB | uploads as attachment, no retry loop | by hand | not run: needs Discord |
|
||||
| 4 | HIGH | `/download` source whose smallest encode is above 8.5 MB | message shows a website link (24 h notice), no attachment; `VideoResult.oversize` path | by hand | not run: needs Discord |
|
||||
| 5 | HIGH | Force upload timeout (shape line to a few KB/s or shorten client timeout locally) | one attempt only, message becomes hosted link(s) | by hand | not run: needs Discord |
|
||||
| 6 | MED | Simulate 502 or connection reset on upload | retried up to 3 times | by hand | not run: needs Discord (code read: RequestError and 429/5xx retry) |
|
||||
| 7 | MED | Simulate 400/403 on upload | no retry, "Discord refused" card | by hand | not run: needs Discord (code read: other statuses give 'Discord refused' card) |
|
||||
| 8 | MED | `/convert` to a result over 8.5 MB | link with 24 h notice, no attachment | by hand | not run: needs Discord and a real video |
|
||||
| 9 | LOW | `/media` effect with result over budget | "too big to upload" error with MB values | by hand | not run: needs Discord |
|
||||
| 10 | LOW | `rg UPLOAD_RETRIES src` | retry loop only continues on retryable errors | by hand | pass (code read: loop returns on 413, timeout, non-retryable; continues only on RequestError, 429, 5xx) |
|
||||
|
||||
## Needs
|
||||
Discord test server and the Chromebook line; never the real token on this PC.
|
||||
|
|
|
|||
|
|
@ -17,17 +17,17 @@ Not changed: timeouts keep their existing card text ("took too long" strings); n
|
|||
## Checks
|
||||
| # | Risk | Do this | Expect | How | Result |
|
||||
|---|---|---|---|---|---|
|
||||
| 1 | HIGH | Play a song, then block the stream host (firewall rule or pause the server) | ffmpeg ends after about 20 s without data; player moves on or shows an error, no hung process | by hand | — |
|
||||
| 2 | HIGH | `/convert` a URL to a host that accepts and never answers | ffprobe killed within ~60 s (`pgrep ffprobe` empty), card appears | by hand | — |
|
||||
| 3 | MED | Run ffmpeg::probe on a FIFO/blocked path | returns None after 60 s, process gone | by hand | — |
|
||||
| 4 | MED | `/play` song, let the loudness pass run with a stalled link | peaks returns None after 30 s idle; playback unaffected | by hand | — |
|
||||
| 5 | MED | Start `/download` of a slow link, cancel | yt-dlp child gone | by hand | — |
|
||||
| 6 | MED | Serve a page that sends one byte per second to `/search`, `/image` fetch | gives up by the 20 s client timeout | by hand | — |
|
||||
| 7 | MED | `fetch_limited` against a 50 MB file | returns None at the size cap | by hand | — |
|
||||
| 8 | LOW | `rg "Command::new" src` | every non-test spawn has a timeout or idle limit | by hand | — |
|
||||
| 9 | LOW | Normal song plays with `-rw_timeout` | plays, seek works | by hand | — |
|
||||
| 10 | MED | Make `/convert` run past its limit | reply says "The conversion took too long ..." | by hand | — |
|
||||
| 11 | LOW | Make a `/play` lookup time out | reply says "The song lookup took too long ..." | by hand | — |
|
||||
| 1 | HIGH | Play a song, then block the stream host (firewall rule or pause the server) | ffmpeg ends after about 20 s without data; player moves on or shows an error, no hung process | by hand | not run: needs live voice and a firewall |
|
||||
| 2 | HIGH | `/convert` a URL to a host that accepts and never answers | ffprobe killed within ~60 s (`pgrep ffprobe` empty), card appears | by hand | not run: needs a hanging host; kill path covered by unit test stuck_child_is_killed_at_the_limit |
|
||||
| 3 | MED | Run ffmpeg::probe on a FIFO/blocked path | returns None after 60 s, process gone | by hand | not run: needs a FIFO and 60 s; code read: timeout + kill_on_drop |
|
||||
| 4 | MED | `/play` song, let the loudness pass run with a stalled link | peaks returns None after 30 s idle; playback unaffected | by hand | not run: needs live music |
|
||||
| 5 | MED | Start `/download` of a slow link, cancel | yt-dlp child gone | by hand | pass (unit test cancel_ends_a_running_child) |
|
||||
| 6 | MED | Serve a page that sends one byte per second to `/search`, `/image` fetch | gives up by the 20 s client timeout | by hand | not run: needs a slow server; code read: reqwest client timeout 20 s |
|
||||
| 7 | MED | `fetch_limited` against a 50 MB file | returns None at the size cap | by hand | pass (code read: fetch_limited checks content-length and running size) |
|
||||
| 8 | LOW | `rg "Command::new" src` | every non-test spawn has a timeout or idle limit | by hand | pass (rg: non-test spawns are ffmpeg.rs, tools.rs run_lines, aki curl -m 15, music source with -rw_timeout) |
|
||||
| 9 | LOW | Normal song plays with `-rw_timeout` | plays, seek works | by hand | not run: needs live music |
|
||||
| 10 | MED | Make `/convert` run past its limit | reply says "The conversion took too long ..." | by hand | not run: needs Discord |
|
||||
| 11 | LOW | Make a `/play` lookup time out | reply says "The song lookup took too long ..." | by hand | not run: needs Discord |
|
||||
|
||||
## Needs
|
||||
A test server or local slow HTTP server (python), a Discord test guild; never the real token on this PC.
|
||||
|
|
|
|||
|
|
@ -11,15 +11,15 @@ Written by the worker that built it, run by the test phase. Nothing here has bee
|
|||
## Checks
|
||||
| # | Risk | Do this | Expect | How | Result |
|
||||
|---|---|---|---|---|---|
|
||||
| 1 | HIGH | Bot in voice playing; block the voice UDP/WS (firewall) for 60 s, then unblock | Log shows "voice driver disconnect"; playback resumes after rejoin | by hand | — |
|
||||
| 2 | HIGH | Same, block for 3+ minutes | Bot leaves, channel gets "Lost the voice connection..." (deleted after 15 s), `/play` works again | by hand | — |
|
||||
| 3 | HIGH | Cut the network for 12 minutes, restore | Log "gateway: down for ..., exiting"; systemd restarts; bot online | by hand | — |
|
||||
| 4 | MED | Cut the network for 30 s, restore | No exit; gateway reconnects by itself | by hand | — |
|
||||
| 5 | MED | Kick the bot from voice while playing | One teardown, no rejoin attempts (player gone) | by hand | — |
|
||||
| 6 | MED | `/leave` while a recovery wait is pending | No rejoin, no notice | by hand | — |
|
||||
| 7 | MED | Start with an invalid token or bad intents (dev token only, never the live one) | Log "every shard stopped", exit code 1 | by hand | — |
|
||||
| 8 | LOW | Leave and `/play` again in the same guild | Watcher registers again (disconnect after the second join still recovers) | by hand | — |
|
||||
| 9 | LOW | `tc -s qdisc show dev wlan0` during a big upload with voice playing | Voice class has no drops; voice stays smooth | by hand | — |
|
||||
| 1 | HIGH | Bot in voice playing; block the voice UDP/WS (firewall) for 60 s, then unblock | Log shows "voice driver disconnect"; playback resumes after rejoin | by hand | not run: needs live voice/network cut on the server (not allowed here) |
|
||||
| 2 | HIGH | Same, block for 3+ minutes | Bot leaves, channel gets "Lost the voice connection..." (deleted after 15 s), `/play` works again | by hand | not run: needs live voice/network cut on the server (not allowed here) |
|
||||
| 3 | HIGH | Cut the network for 12 minutes, restore | Log "gateway: down for ..., exiting"; systemd restarts; bot online | by hand | not run: needs live voice/network cut on the server (not allowed here) |
|
||||
| 4 | MED | Cut the network for 30 s, restore | No exit; gateway reconnects by itself | by hand | not run: needs live voice/network cut on the server (not allowed here) |
|
||||
| 5 | MED | Kick the bot from voice while playing | One teardown, no rejoin attempts (player gone) | by hand | not run: needs live voice/network cut on the server (not allowed here) |
|
||||
| 6 | MED | `/leave` while a recovery wait is pending | No rejoin, no notice | by hand | not run: needs live voice/network cut on the server (not allowed here) |
|
||||
| 7 | MED | Start with an invalid token or bad intents (dev token only, never the live one) | Log "every shard stopped", exit code 1 | by hand | not run: needs live voice/network cut on the server (not allowed here) |
|
||||
| 8 | LOW | Leave and `/play` again in the same guild | Watcher registers again (disconnect after the second join still recovers) | by hand | not run: needs live voice/network cut on the server (not allowed here) |
|
||||
| 9 | LOW | `tc -s qdisc show dev wlan0` during a big upload with voice playing | Voice class has no drops; voice stays smooth | by hand | not run: needs live voice/network cut on the server (not allowed here) |
|
||||
|
||||
## Doubts
|
||||
- Songbird may fire `DriverDisconnect` for harmless reasons; the grace + "connected" check should absorb that. Check the log for false alarms.
|
||||
|
|
|
|||
|
|
@ -606,4 +606,29 @@ mod tests {
|
|||
assert_eq!(names, vec!["img_1.png", "img_2.jpg", "img_10.jpg", "a_3.mp4"]);
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn stuck_child_is_killed_at_the_limit() {
|
||||
let job = Job::new(1, "u".into(), 1000, false);
|
||||
let mut cmd = Command::new("sleep");
|
||||
cmd.arg("30");
|
||||
let start = std::time::Instant::now();
|
||||
let r = run_lines(&job, cmd, Duration::from_secs(2), |_| Ok(()), || {}).await;
|
||||
assert!(r.is_err(), "a stuck child must time out");
|
||||
assert!(start.elapsed() < Duration::from_secs(6));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn cancel_ends_a_running_child() {
|
||||
let job = std::sync::Arc::new(Job::new(1, "u".into(), 1000, false));
|
||||
let j2 = job.clone();
|
||||
tokio::spawn(async move {
|
||||
tokio::time::sleep(Duration::from_millis(500)).await;
|
||||
j2.cancel();
|
||||
});
|
||||
let mut cmd = Command::new("sleep");
|
||||
cmd.arg("30");
|
||||
let r = run_lines(&job, cmd, Duration::from_secs(20), |_| Ok(()), || {}).await;
|
||||
assert!(matches!(r, Err(DlError::Cancelled)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue