compose/pkg/e2e
Guillaume Lours 9d444a667a
Some checks failed
ci / validate (lint) (push) Has been cancelled
ci / validate (validate-docs) (push) Has been cancelled
ci / validate (validate-go-mod) (push) Has been cancelled
ci / validate (validate-headers) (push) Has been cancelled
ci / binary (push) Has been cancelled
ci / bin-image-test (push) Has been cancelled
ci / test (push) Has been cancelled
ci / e2e (plugin, oldstable) (push) Has been cancelled
ci / e2e (standalone, oldstable) (push) Has been cancelled
ci / e2e (plugin, stable) (push) Has been cancelled
ci / e2e (standalone, stable) (push) Has been cancelled
merge / bin-image-prepare (push) Has been cancelled
merge / module-image (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
ci / binary-finalize (push) Has been cancelled
ci / coverage (push) Has been cancelled
ci / release (push) Has been cancelled
merge / bin-image (push) Has been cancelled
merge / desktop-edge-test (push) Has been cancelled
pre_start: support pre_start lifecycle hooks
runPreStart executes a service's pre_start hooks sequentially as
ephemeral containers that share the first non-running replica's
volumes via VolumesFrom and attach to the same networks. A non-zero
hook exit gates service start.

per_replica: false is the only currently supported mode; per_replica:
true is rejected up front. The donor replica is the lowest-numbered
one so the choice is deterministic. ContainerWait uses
WaitConditionNextExit, and the wait loop deterministically handles
the daemon's clean-close (nil on Error + exit code on Result) and
transport-error races to avoid spurious hook failures.

The log stream is opened before ContainerStart to avoid racing
AutoRemove on fast-exiting hooks, and runs under a derived context
so a daemon that keeps the connection open cannot deadlock the call.
Hook containers carry project/service/version labels; the two
cleanup paths force-remove the never-started container explicitly
and warn when removal fails.

pre_start runs once per service when no replica is already running
(initial up, force-recreate or spec change), and is skipped on
scale-up so additional replicas don't re-trigger the hooks.

Coverage: 11 unit tests (including scheduler-race stress) with
goroutine-leak verification via goleak, plus 10 E2E tests (success
path, hook failure gating start, build-image inheritance, idempotent
re-up, spec change, force-recreate, mid-sequence failure, ordering,
scale-up, scaled service).

Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
2026-06-30 10:49:04 +02:00
..
fixtures pre_start: support pre_start lifecycle hooks 2026-06-30 10:49:04 +02:00
assert.go fix mixed assertion libraries in tests 2026-03-31 17:32:51 +02:00
bridge_test.go use fixed version of compose bridge transformer images 2025-10-14 09:21:59 +02:00
build_test.go refactor: replace Split in loops with more efficient SplitSeq and replace HasPrefix+TrimPrefix with CutPrefix 2026-06-05 15:52:36 +02:00
cancel_test.go test: replace context.Background()/context.TODO() with t.Context() 2026-01-20 11:34:11 +01:00
cascade_test.go fix linting issues 2025-11-16 14:54:58 +01:00
commit_test.go fix: commit tests 2024-11-27 07:39:46 +01:00
compose_environment_test.go empty env variable with no value must be unset in container 2024-07-10 14:23:34 +02:00
compose_exec_test.go be sure everything has been cleanup at the end of each tests 2024-12-04 15:28:16 +01:00
compose_run_build_once_test.go fix: make e2e tests pass reliably locally with Docker Desktop 2026-05-18 10:55:41 +02:00
compose_run_test.go Normalize --no-TTY flag to --no-tty 2026-06-29 20:56:31 +02:00
compose_test.go fix: make e2e tests pass reliably locally with Docker Desktop 2026-05-18 10:55:41 +02:00
compose_up_test.go fix various linting issues 2025-10-31 17:44:38 +01:00
config_test.go e2e: add tests 2025-05-06 22:33:52 +02:00
configs_test.go be sure everything has been cleanup at the end of each tests 2024-12-04 15:28:16 +01:00
container_name_test.go fix linting issues 2025-11-16 14:54:58 +01:00
cp_test.go align --format flag and UX with docker cli 2022-12-14 22:53:43 +01:00
e2e_config_plugin.go chore(e2e): fix flaky test & standalone behavior (#11382) 2024-01-30 10:49:53 -05:00
e2e_config_standalone.go
env_file_test.go fix: make e2e tests pass reliably locally with Docker Desktop 2026-05-18 10:55:41 +02:00
exec_test.go prefer application container vs one-off running exec without index 2025-09-07 14:41:34 +02:00
export_test.go fix: lint 2024-10-02 21:15:59 +02:00
expose_test.go Fix support for port range 2025-11-16 20:38:54 +01:00
framework.go fix mixed assertion libraries in tests 2026-03-31 17:32:51 +02:00
healthcheck_test.go fix various linting issues 2025-10-31 17:44:38 +01:00
hooks_test.go pre_start: support pre_start lifecycle hooks 2026-06-30 10:49:04 +02:00
ipc_test.go
logs_test.go modernize some code 2026-02-12 15:31:35 +01:00
main_test.go
model_test.go fix: make e2e tests pass reliably locally with Docker Desktop 2026-05-18 10:55:41 +02:00
networks_test.go fix: make e2e tests pass reliably locally with Docker Desktop 2026-05-18 10:55:41 +02:00
noDeps_test.go fix linting issues 2025-11-16 14:54:58 +01:00
orphans_test.go be sure everything has been cleanup at the end of each tests 2024-12-04 15:28:16 +01:00
pause_test.go fix: make e2e tests pass reliably locally with Docker Desktop 2026-05-18 10:55:41 +02:00
profiles_test.go COMPOSE_PROFILES can be set by .env file 2024-05-30 07:40:01 +02:00
providers_test.go Fix rawsetenv nil-pointer guard for inherit-from-shell env vars 2026-06-23 15:01:33 +02:00
ps_test.go fix: make e2e tests pass reliably locally with Docker Desktop 2026-05-18 10:55:41 +02:00
publish_test.go fix(publish): prompt on sensitive-looking env literals 2026-05-20 15:48:38 +02:00
pull_test.go distinguish event (short) status text and details 2025-11-04 10:18:55 +01:00
recreate_no_deps_test.go
restart_test.go fix mixed assertion libraries in tests 2026-03-31 17:32:51 +02:00
scale_test.go fix mixed assertion libraries in tests 2026-03-31 17:32:51 +02:00
secrets_test.go Compose can't create a tar with adequate uid:gid ownership 2025-10-20 09:51:58 +02:00
start_stop_test.go fix mixed assertion libraries in tests 2026-03-31 17:32:51 +02:00
up_test.go fix mixed assertion libraries in tests 2026-03-31 17:32:51 +02:00
volumes_test.go compose: recreate container when mounted image digest changes 2026-01-26 15:55:44 +01:00
wait_test.go golangci-lint: use gci formatter instead of goimports 2025-12-01 12:21:50 +01:00
watch_test.go watch: do not rebuild depends_on services on file change 2026-06-19 11:23:50 +02:00