Skip to content

Commit b240a84

Browse files
committed
Fix occasional timing error in tests
1 parent c75aed0 commit b240a84

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/docker/docker_api_test_util.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,13 +309,23 @@ func execContainerWithOutput(t *testing.T, cli *client.Client, ID string, user s
309309
if err != nil {
310310
t.Fatal(err)
311311
}
312-
cli.ContainerExecStart(context.Background(), resp.ID, types.ExecStartCheck{
312+
err = cli.ContainerExecStart(context.Background(), resp.ID, types.ExecStartCheck{
313313
Detach: false,
314314
Tty: false,
315315
})
316316
if err != nil {
317317
t.Fatal(err)
318318
}
319+
// Wait for the command to finish
320+
for {
321+
inspect, err := cli.ContainerExecInspect(context.Background(), resp.ID)
322+
if err != nil {
323+
t.Fatal(err)
324+
}
325+
if !inspect.Running {
326+
break
327+
}
328+
}
319329
buf := new(bytes.Buffer)
320330
// Each output line has a header, which needs to be removed
321331
_, err = stdcopy.StdCopy(buf, buf, hijack.Reader)

0 commit comments

Comments
 (0)