7.0 KiB
7.0 KiB
Scheduled Actions Test Plan / QA Checklist
Test objectives
Verify that qBittorrent speed collection is backend-owned, configurable per service, resilient to transient failures, observable, and safe when the frontend is not open.
Backend unit tests
Configuration
- Existing qBittorrent configs receive polling defaults without changing secrets.
polling_enabledaccepts booleans and defaults to enabled.- Poll intervals below 5 seconds or above 300 seconds are rejected.
- Retention below 60 seconds or above 86,400 seconds is rejected.
- Sample caps below the minimum or above 1,200 are rejected.
- Credential-looking fields remain rejected from service config.
Sample storage
- Samples remain isolated by
service_id. - Timestamp retention removes rows older than the configured window.
- Row-cap retention removes the oldest rows when the cap is exceeded.
- Both retention rules are applied together.
- Samples are ordered oldest to newest for chart responses.
- Service cascade deletion removes samples.
- Empty and missing databases initialize safely.
Scheduler core
- Only registered action keys can execute.
- Disabled services do not run.
- Enabled services run immediately after startup with deterministic staggering.
- A normal run waits the configured interval after completion.
- A slow run cannot overlap itself.
- A slow run does not create queued backlog entries.
- Stop interrupts the wait and joins the worker within the configured timeout.
- A configuration change is applied on the next reconciliation cycle.
- Disabling a service allows an in-flight run to finish, then prevents new runs.
- Deleting a service removes its schedule state and history.
Backoff and manual runs
- A failed run is persisted with safe error text and increments failure state.
- Retry delay increases exponentially and respects the configured cap.
- Backoff does not create duplicate queued runs.
- A successful scheduled run clears failures and backoff.
- A successful manual run clears failures and backoff.
- A failed manual run follows normal failure persistence and retry behavior.
- Manual runs do not alter the configured interval.
qBittorrent action and widget separation
- The scheduled action calls qBittorrent and appends exactly one sample per successful poll.
- The qBittorrent client cache is reused correctly per service.
- Timeouts become failed runs without blocking the scheduler indefinitely.
- The
speedwidget adapter reads samples but does not call qBittorrent. - Multiple widgets or browser tabs do not multiply samples.
- A failed latest poll still returns last-known samples with stale status.
Backend API tests
- Scheduler status requires normal API authentication.
- Status returns effective configuration, last attempt, last success, failure count, backoff, and stale state.
- Missing service returns 404 or the project’s established service error shape.
- Disabled service status is explicit and does not run an action.
- Run history is paginated and supports status/trigger filters.
- Run history is bounded by 30 days and 1,000 records per service/action.
- Manual-run endpoint returns a typed result and records the attempt.
- Samples endpoint accepts a display window and is read-only.
- Widget-data requests never cause a qBittorrent external call.
- Responses never expose usernames, passwords, API keys, headers, or raw payloads.
Observability tests
- Run counters increment for success and failure.
- Duration metrics record completed attempts.
- Last-success gauges update only after successful sampling.
- Failure/stale gauges reset after recovery.
- Metric labels are bounded and contain no secrets or raw URLs.
- Structured logs include action/service/status context and sanitize errors.
Frontend unit/component tests
- qBittorrent schedule fields render only for qBittorrent services.
- Invalid interval, retention, and cap values show validation feedback.
- Save preserves existing encrypted-secret behavior.
- Disabled polling clearly shows paused state.
- Status card renders healthy, running, backoff, stale, disabled, and never-run states.
Run nowshows pending state and disables duplicate clicks.- Successful manual run refreshes status/history and clears backoff display.
- Failed manual run renders a safe error.
- Chart window selector requests samples without changing sampler settings.
- Stale warning appears while last-known speed data remains visible.
- Run history renders pagination, trigger, status, duration, timestamp, and error details.
- Empty history and no-data states are readable on mobile.
Integration / lifespan tests
- Starting the FastAPI lifespan starts the scheduler exactly once.
- Repeated
start()calls do not create duplicate workers. - Lifespan shutdown stops the scheduler and does not leak a thread.
- A test app can override the scheduler/action registry cleanly.
- Existing mail queue and backup poller lifecycle behavior remains unchanged.
Manual QA scenarios
Headless collection
- Configure an enabled qBittorrent service.
- Start the backend without opening the frontend.
- Wait for at least two intervals.
- Query scheduler status and samples directly.
- Confirm samples and successful run records exist.
Duplicate prevention
- Open the speed widget in multiple browser tabs.
- Compare sample count growth to scheduler run count.
- Confirm browser refreshes do not add samples or external qBittorrent calls.
Outage and recovery
- Make qBittorrent unreachable.
- Confirm failures and increasing backoff appear in status/history.
- Confirm last-known samples remain visible with a stale warning.
- Restore qBittorrent.
- Confirm the next successful scheduled or manual run clears backoff and stale state.
Configuration reload
- Change the interval and retention in the qBittorrent service editor.
- Confirm the existing worker remains alive.
- Confirm the new effective values appear after reconciliation.
- Confirm pruning follows the new retention/cap.
Service lifecycle
- Disable a service and confirm no new runs are created while history remains.
- Re-enable it and confirm polling resumes.
- Delete it and confirm service-owned samples and run records are removed.
Deployment constraint
- Run the documented single-worker deployment.
- Confirm one scheduler worker is active.
- Verify the deployment documentation warns against multiple scheduler-capable replicas.
Release gate
- Backend test suite passes.
- Frontend tests pass.
- Frontend lint passes with no new violations.
- Frontend build passes.
- No secret appears in logs, API responses, metrics, or scheduler run records.
- Project maps are patched for new files and validated.
- Requirements and runbook documentation match the shipped behavior.