Merge branch 'master' into metrics-doc
This commit is contained in:
@@ -329,9 +329,9 @@ func TestVolumeUnmount(t *testing.T) {
|
|||||||
defer cleanContainer(t, cli, ctr.ID)
|
defer cleanContainer(t, cli, ctr.ID)
|
||||||
waitForReady(t, cli, ctr.ID)
|
waitForReady(t, cli, ctr.ID)
|
||||||
// Unmount the volume as root
|
// Unmount the volume as root
|
||||||
rc, _ := execContainer(t, cli, ctr.ID, "root", []string{"umount", "-l", "-f", "/mnt/mqm"})
|
rc, out := execContainer(t, cli, ctr.ID, "root", []string{"umount", "-l", "-f", "/mnt/mqm"})
|
||||||
if rc != 0 {
|
if rc != 0 {
|
||||||
t.Fatalf("Expected umount to work with rc=0, got %v", rc)
|
t.Fatalf("Expected umount to work with rc=0, got %v. Output was: %s", rc, out)
|
||||||
}
|
}
|
||||||
time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
rc, _ = execContainer(t, cli, ctr.ID, "mqm", []string{"chkmqhealthy"})
|
rc, _ = execContainer(t, cli, ctr.ID, "mqm", []string{"chkmqhealthy"})
|
||||||
@@ -366,7 +366,9 @@ func TestZombies(t *testing.T) {
|
|||||||
// will be adopted by PID 1, and should then be reaped when they die.
|
// will be adopted by PID 1, and should then be reaped when they die.
|
||||||
_, out := execContainer(t, cli, id, "mqm", []string{"pkill", "--signal", "kill", "-c", "amqzxma0"})
|
_, out := execContainer(t, cli, id, "mqm", []string{"pkill", "--signal", "kill", "-c", "amqzxma0"})
|
||||||
if out == "0" {
|
if out == "0" {
|
||||||
t.Fatalf("Expected pkill to kill a process, got %v", out)
|
t.Log("Failed to kill process 'amqzxma0'")
|
||||||
|
_, out := execContainer(t, cli, id, "root", []string{"ps", "-lA"})
|
||||||
|
t.Fatalf("Here is a list of currently running processes:\n%s", out)
|
||||||
}
|
}
|
||||||
time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
_, out = execContainer(t, cli, id, "mqm", []string{"bash", "-c", "ps -lA | grep '^. Z'"})
|
_, out = execContainer(t, cli, id, "mqm", []string{"bash", "-c", "ps -lA | grep '^. Z'"})
|
||||||
@@ -635,6 +637,7 @@ func TestCorrectLicense(t *testing.T) {
|
|||||||
}
|
}
|
||||||
id := runContainer(t, cli, &containerConfig)
|
id := runContainer(t, cli, &containerConfig)
|
||||||
defer cleanContainer(t, cli, id)
|
defer cleanContainer(t, cli, id)
|
||||||
|
waitForReady(t, cli, id)
|
||||||
|
|
||||||
rc, license := execContainer(t, cli, id, "mqm", []string{"dspmqver", "-f", "8192", "-b"})
|
rc, license := execContainer(t, cli, id, "mqm", []string{"dspmqver", "-f", "8192", "-b"})
|
||||||
if rc != 0 {
|
if rc != 0 {
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -328,7 +327,6 @@ func waitForContainer(t *testing.T, cli *client.Client, ID string, timeout int64
|
|||||||
|
|
||||||
// execContainer runs a command in a running container, and returns the exit code and output
|
// execContainer runs a command in a running container, and returns the exit code and output
|
||||||
func execContainer(t *testing.T, cli *client.Client, ID string, user string, cmd []string) (int, string) {
|
func execContainer(t *testing.T, cli *client.Client, ID string, user string, cmd []string) (int, string) {
|
||||||
rerun:
|
|
||||||
config := types.ExecConfig{
|
config := types.ExecConfig{
|
||||||
User: user,
|
User: user,
|
||||||
Privileged: false,
|
Privileged: false,
|
||||||
@@ -348,7 +346,9 @@ rerun:
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
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,
|
Detach: false,
|
||||||
Tty: false,
|
Tty: false,
|
||||||
})
|
})
|
||||||
@@ -357,30 +357,38 @@ rerun:
|
|||||||
}
|
}
|
||||||
// Wait for the command to finish
|
// Wait for the command to finish
|
||||||
var exitcode int
|
var exitcode int
|
||||||
|
var outputStr string
|
||||||
for {
|
for {
|
||||||
inspect, err := cli.ContainerExecInspect(context.Background(), resp.ID)
|
inspect, err := cli.ContainerExecInspect(context.Background(), resp.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !inspect.Running {
|
if inspect.Running {
|
||||||
exitcode = inspect.ExitCode
|
continue
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
buf := new(bytes.Buffer)
|
|
||||||
// Each output line has a header, which needs to be removed
|
|
||||||
_, err = stdcopy.StdCopy(buf, buf, hijack.Reader)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputStr := strings.TrimSpace(buf.String())
|
exitcode = inspect.ExitCode
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
// Each output line has a header, which needs to be removed
|
||||||
|
_, err = stdcopy.StdCopy(buf, buf, hijack.Reader)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
// Before we go let's just double check it did actually run because sometimes we get a "Exec command already running error"
|
outputStr = strings.TrimSpace(buf.String())
|
||||||
alreadyRunningErr := regexp.MustCompile("Error: Exec command .* is already running")
|
|
||||||
if alreadyRunningErr.MatchString(outputStr) {
|
/* Commented out on 14/06/2018 as it might not be needed after adding
|
||||||
time.Sleep(1 * time.Second)
|
* pause between ContainerExecAttach and ContainerExecStart.
|
||||||
goto rerun
|
* 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
|
||||||
}
|
}
|
||||||
|
|
||||||
return exitcode, outputStr
|
return exitcode, outputStr
|
||||||
|
|||||||
Reference in New Issue
Block a user