mirror of
https://github.com/docker/compose.git
synced 2026-11-17 13:45:39 +00:00
A foreground up does stream a pre_start hook's output into the session since the hook's log stream is opened once it is started. The hook scenario had stopped asserting it on the belief it never did; its fixture only wrote to a file, so nothing could reach stdout. The pre_start now also prints a marker the service never logs, asserted on stdout, and the scenario states a single intent covering both hooks. Also tighten the scenarios after review: - assert a container's printed output on stdout rather than on the whole output, and add the state or negative checks that were missing (ContainerEnv after a recreation, web exited once its dependency was healthy, no output of the replaced container); - the dependency timeout scenario carries the "deadline exceeded" guard of its detached counterpart, with a fixture aligned on it; - drop the abort message and the useless wait from the immediate-exit scenario: up only returns once the application is stopped; - rename the dry-run scenario after the others, minimize its fixture and stop coupling it to the dry-run end-of-output wording; - explain the sleeps of the fixtures, and give the hook one a larger margin; - build tag e2e only: nothing here is Unix-specific. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
17 lines
608 B
YAML
17 lines
608 B
YAML
services:
|
|
app:
|
|
image: alpine
|
|
# the sleep keeps the container running while post_start execs into it and
|
|
# the session streams its output
|
|
command: sh -c 'echo "app-read:$(cat /shared/init.txt)"; sleep 5'
|
|
volumes:
|
|
- data:/shared
|
|
pre_start:
|
|
- image: alpine
|
|
# prints a marker the service never logs, so its presence in the
|
|
# session can only come from the hook's own output stream
|
|
command: sh -c 'echo pre-start-hook-stdout; echo "pre-start-file-content" > /shared/init.txt'
|
|
post_start:
|
|
- command: echo post-start-hook-ran
|
|
volumes:
|
|
data:
|