mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
tests/int: fix TestHook flakiness
Since commit 3cdda46 the poststart hooks runs after the container
process start, and so they race.
Move the poststart hook check to a separate step after the container
process has exited.
Fixes 5245.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -1075,11 +1075,14 @@ func TestHook(t *testing.T) {
|
||||
container, err := newContainer(t, config)
|
||||
ok(t, err)
|
||||
|
||||
// e.g: 'ls /prestart ...'
|
||||
var cmd strings.Builder
|
||||
cmd.WriteString("ls ")
|
||||
for _, hook := range hookFiles {
|
||||
cmd.WriteString("/" + hook + " ")
|
||||
// The poststart hook is racing with this ls command (run as the
|
||||
// container init), so we don't check that hook worked here yet.
|
||||
if hook != "poststart" {
|
||||
cmd.WriteString("/" + hook + " ")
|
||||
}
|
||||
}
|
||||
|
||||
var stdout strings.Builder
|
||||
@@ -1098,6 +1101,13 @@ func TestHook(t *testing.T) {
|
||||
// Wait for process
|
||||
waitProcess(&pconfig, t)
|
||||
|
||||
// Check that poststart hook worked.
|
||||
f, err = os.Open(config.Rootfs + "/poststart")
|
||||
if err != nil {
|
||||
t.Fatalf("poststart hook failed: %s", err)
|
||||
}
|
||||
f.Close()
|
||||
|
||||
if err := container.Destroy(); err != nil {
|
||||
t.Fatalf("container destroy %s", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user