mirror of
https://github.com/docker/compose.git
synced 2026-11-20 15:09:50 +00:00
test(e2e): stop asserting pre_start output the foreground up never streams
The hook scenario matched "pre-start-hook-ran" in the output, but the service's own line "app-read:pre-start-hook-ran" contains it, so the assertion passed without any pre_start output reaching the session. A foreground up streams post_start's output but not pre_start's today (checked on main too). Lock what actually holds: pre_start's effect, read by the service through a value distinct from anything it logs. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
07306856b4
commit
0dd199257f
2 changed files with 6 additions and 5 deletions
|
|
@ -6,7 +6,7 @@ services:
|
|||
- data:/shared
|
||||
pre_start:
|
||||
- image: alpine
|
||||
command: sh -c 'echo "pre-start-hook-ran" | tee /shared/init.txt'
|
||||
command: sh -c 'echo "pre-start-file-content" > /shared/init.txt'
|
||||
post_start:
|
||||
- command: echo post-start-hook-ran
|
||||
volumes:
|
||||
|
|
|
|||
|
|
@ -29,12 +29,13 @@ import (
|
|||
// it (epic #14081, lot 2) can be reviewed against a fixed specification.
|
||||
// Most e2e coverage of the start phase runs detached; these do not.
|
||||
|
||||
// pre_start output is not asserted: a foreground up does not stream it into the
|
||||
// session today, only post_start's. What is locked for pre_start is its effect.
|
||||
func TestUpInteractiveHookLogs(t *testing.T) {
|
||||
NewScenario(t, "a foreground up must stream pre_start and post_start hook output into its session").
|
||||
Step("up prints both hooks' output, and the service reads what pre_start wrote before it started",
|
||||
NewScenario(t, "a foreground up must run pre_start before the service starts and stream post_start output into its session").
|
||||
Step("up shows post_start's output, and the service reads what pre_start wrote before it started",
|
||||
ComposeCmd("up", "--menu=false").Within(120*time.Second),
|
||||
OutputContains("pre-start-hook-ran"),
|
||||
OutputContains("app-read:pre-start-hook-ran"),
|
||||
OutputContains("app-read:pre-start-file-content"),
|
||||
OutputContains("post-start-hook-ran"),
|
||||
ServiceState("app", "exited"))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue