Fix occasional timing error in tests
This commit is contained in:
@@ -309,13 +309,23 @@ func execContainerWithOutput(t *testing.T, cli *client.Client, ID string, user s
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
cli.ContainerExecStart(context.Background(), resp.ID, types.ExecStartCheck{
|
err = cli.ContainerExecStart(context.Background(), resp.ID, types.ExecStartCheck{
|
||||||
Detach: false,
|
Detach: false,
|
||||||
Tty: false,
|
Tty: false,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
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)
|
buf := new(bytes.Buffer)
|
||||||
// Each output line has a header, which needs to be removed
|
// Each output line has a header, which needs to be removed
|
||||||
_, err = stdcopy.StdCopy(buf, buf, hijack.Reader)
|
_, err = stdcopy.StdCopy(buf, buf, hijack.Reader)
|
||||||
|
|||||||
Reference in New Issue
Block a user