dev: maintenance
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
# WM-001: Automate the Docker shutdown integration test
|
||||
|
||||
Shutdown is currently tested manually in Docker. Wingmate is designed to act as Linux init: it broadcasts shutdown signals so that even orphaned descendants receive them. Add an opt-in test runner that verifies real signal delivery in disposable containers. The runner must work on a separate Linux test machine without a coding agent and produce a portable diagnostic bundle for analysis back in the development environment.
|
||||
|
||||
## Scope
|
||||
|
||||
### In scope
|
||||
|
||||
- A shell runner, disposable child fixtures, and test-specific Docker setup to build and test the current checkout on Linux.
|
||||
- Two shutdown scenarios in isolated containers: a child that exits on TERM and a child that stays alive after TERM until Wingmate escalates.
|
||||
- A portable diagnostic archive and instructions for running the test, finding its results, and bringing them back to the development environment.
|
||||
|
||||
### Out of scope
|
||||
|
||||
- Changes to Wingmate's production shutdown behavior or PID 1 enforcement.
|
||||
- Unit-test refactors, CI wiring, and support for other container engines.
|
||||
- General supervisor coverage, including service restarts, cron scheduling, and orphan reaping.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [ ] Provide a standalone shell script with one documented command that builds Wingmate from the current checkout and runs the test on a Linux Docker engine. Document the prerequisites and how to copy the result back. Running `go test ./...` alone does not invoke this test.
|
||||
- [ ] Start Wingmate directly as PID 1 in a dedicated container PID namespace. Verify that it is PID 1 before sending any shutdown signal. Do not use Docker's `--init`, host PID mode, or another container's PID namespace.
|
||||
- [ ] In a fresh container with a cooperative child, wait for an explicit readiness marker, send `SIGTERM` to Wingmate through Docker, and verify that the child received `SIGTERM` and Wingmate exited without escalating.
|
||||
- [ ] In a fresh container with a TERM-resistant child, verify that the child receives `SIGTERM` and stays alive until Wingmate escalates to `SIGKILL`. Send `SIGTERM` without scheduling a Docker fallback kill, and require the container to exit before the test timeout and before forced cleanup.
|
||||
- [ ] Bound readiness and shutdown waits. Collect diagnostics before removing containers on success or failure. Preserve partial diagnostics if the build fails, a case times out, or a container never starts.
|
||||
- [ ] Print a concise result for each case and the path to a timestamped diagnostic archive in a caller-selectable output directory. Return a nonzero exit status if setup fails, a case fails, or a case times out.
|
||||
|
||||
## Diagnostic bundle
|
||||
|
||||
The archive should be usable without access to the test machine or the original containers. Include:
|
||||
|
||||
- A plain-text summary with the result of each case, the first failed assertion with expected and actual results, and whether any cases could not run.
|
||||
- The Git revision and whether the checkout was dirty, the Docker client and engine versions, and the test platform and architecture.
|
||||
- Build output and timestamped container logs for each case, including Wingmate and child output.
|
||||
- A timestamped record of the PID 1 and readiness checks, when TERM was sent, any observed escalation, the container exit status, and whether a timeout or forced cleanup occurred.
|
||||
|
||||
Capture only the configuration and container metadata needed to diagnose the run. Keep host environment variables and Docker credentials out of the archive.
|
||||
|
||||
## Implementation notes
|
||||
|
||||
- Use a readiness marker that the child emits after installing its TERM handler. Wait for the marker with a deadline rather than sleeping for a fixed interval.
|
||||
- Have the TERM-resistant fixture log that it received TERM while continuing to run. Use Wingmate's `start pumping SIGKILL signal` log and the container's exit as evidence of escalation; a container exit alone is insufficient.
|
||||
- Record the shutdown outcome before forced cleanup so cleanup cannot turn a timeout into a pass. Keep the logs from failures that occur before either shutdown scenario starts.
|
||||
- Use UTC timestamps across the event timeline and logs so they can be compared after the archive is copied to another machine.
|
||||
|
||||
## Relevant code
|
||||
|
||||
- [Signal handler](../../init/sighandler.go) and [shutdown escalation](../../init/signal-pump.go)
|
||||
- [Bookworm Dockerfile](../../docker/bookworm/Dockerfile) and [entrypoint](../../docker/bookworm/entry.sh)
|
||||
Reference in New Issue
Block a user