Fix timing in execContainer

This commit is contained in:
Riccardo Biraghi
2018-06-14 11:54:35 +01:00
parent f0faac6af7
commit 16e244427b

View File

@@ -27,7 +27,6 @@ import (
"os"
"os/exec"
"path/filepath"
"regexp"
"runtime"
"strconv"
"strings"
@@ -347,7 +346,9 @@ func execContainer(t *testing.T, cli *client.Client, ID string, user string, cmd
if err != nil {
t.Fatal(err)
}
cli.ContainerExecStart(context.Background(), resp.ID, types.ExecStartCheck{
defer hijack.Close()
time.Sleep(time.Millisecond * 10)
err = cli.ContainerExecStart(context.Background(), resp.ID, types.ExecStartCheck{
Detach: false,
Tty: false,
})
@@ -376,12 +377,17 @@ func execContainer(t *testing.T, cli *client.Client, ID string, user string, cmd
outputStr = strings.TrimSpace(buf.String())
// Before we go let's just double check it did actually finish running
// because sometimes we get a "Exec command already running error"
alreadyRunningErr := regexp.MustCompile("Error: Exec command .* is already running")
if alreadyRunningErr.MatchString(outputStr) {
continue
}
/* Commented out on 14/06/2018 as it might not be needed after adding
* pause between ContainerExecAttach and ContainerExecStart.
* TODO If intermittent failures do not occur, remove and refactor.
*
* // Before we go let's just double check it did actually finish running
* // because sometimes we get a "Exec command already running error"
* alreadyRunningErr := regexp.MustCompile("Error: Exec command .* is already running")
* if alreadyRunningErr.MatchString(outputStr) {
* continue
* }
*/
break
}