Fix occasional timing error in tests

This commit is contained in:
Arthur Barr
2018-03-12 16:28:40 +00:00
parent c75aed0851
commit b240a84ce0

View File

@@ -309,13 +309,23 @@ func execContainerWithOutput(t *testing.T, cli *client.Client, ID string, user s
if err != nil {
t.Fatal(err)
}
cli.ContainerExecStart(context.Background(), resp.ID, types.ExecStartCheck{
err = cli.ContainerExecStart(context.Background(), resp.ID, types.ExecStartCheck{
Detach: false,
Tty: false,
})
if err != nil {
t.Fatal(err)
}
// Wait for the command to finish
for {
inspect, err := cli.ContainerExecInspect(context.Background(), resp.ID)
if err != nil {
t.Fatal(err)
}
if !inspect.Running {
break
}
}
buf := new(bytes.Buffer)
// Each output line has a header, which needs to be removed
_, err = stdcopy.StdCopy(buf, buf, hijack.Reader)