fix: pgtest left an anonymous volume behind on every run (#175)
## Problem `go test ./...` leaked one Docker volume per test package. `pgtest.Main` tore its throwaway container down with `docker rm -f` — no `-v`. The `postgres:17-alpine` image declares a `VOLUME` for `/var/lib/postgresql/data`, and an explicit `rm` without `-v` orphans that anonymous volume even though the container was created with `--rm`. Found in passing: a 13-hour-old orphaned pgtest container (AutoRemove, `fsync=off`, one mount) still running from a killed test binary — the same leak's other half. Removed on the dev machine. ## Change - `backend/internal/pgtest/pgtest.go`: `-v` on all three `docker rm -f` teardown sites (`Main`'s defer, and both error paths in `start`). - `AGENTS.md`: cleanup expectation under Commands — `docker compose down -v` for a stack, `docker rm -f -v` for a hand-run container, then check `docker volume ls` and `docker system df`. Explicitly out of bounds: removing the user's `postgres-data` volume, or a blanket `docker system prune` of their images and build cache. ## Verification `docker volume ls` snapshot diffed across a real `./internal/store` run: no new volumes, `docker system df` reports 0 local volumes. Reviewed-on: #175 Co-authored-by: Sulthan Zaki <sultankiki05@gmail.com> Co-committed-by: Sulthan Zaki <sultankiki05@gmail.com>
This commit was merged in pull request #175.
This commit is contained in:
@@ -50,6 +50,15 @@ Backend (`cd backend`):
|
||||
|
||||
Local stack: `docker compose up` (bookmark-api + postgres only; `postgres-data` named volume, `restart: unless-stopped`). No browser — without `BROWSER_WS_URL` the poller logs and skips kagane and comix. To run one: `cd chrome && BROWSER_BIND_ADDR=172.17.0.1 docker compose up -d --build`, then `BROWSER_WS_URL=ws://172.17.0.1:9222` in the root `.env` (bridge gateway, so the API container can name it by IP).
|
||||
|
||||
**Clean up Docker after testing.** Storage on the dev machine is scarce, so
|
||||
anything you started for a test you also tear down before calling the work
|
||||
done: `docker compose down -v` for a stack you brought up, `docker rm -f -v`
|
||||
for a container you ran by hand (`-v`, or the image's anonymous data volume
|
||||
survives). Then check `docker volume ls` and `docker system df` for leftovers
|
||||
and reclaim them — a dangling volume nobody notices is the leak that fills the
|
||||
disk. Never remove the `postgres-data` volume of a stack the user is actually
|
||||
running, and never blanket-`docker system prune` their images or build cache.
|
||||
|
||||
Live CDP proof (needs that browser and network, skipped otherwise):
|
||||
`SMOKE_BROWSER_WS_URL=ws://<ip>:<port> go test -run 'TestSmokeKagane|TestSmokeComix' ./internal/latest`
|
||||
— fetches a real kagane and comix cover and chapter list. A red run means the challenge is
|
||||
|
||||
Reference in New Issue
Block a user