Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
| ... | ... |
@@ -10,29 +10,37 @@ import ( |
| 10 | 10 |
func TestRestartStoppedContainer(t *testing.T) {
|
| 11 | 11 |
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "echo", "foobar") |
| 12 | 12 |
out, _, err := runCommandWithOutput(runCmd) |
| 13 |
- errorOut(err, t, out) |
|
| 13 |
+ if err != nil {
|
|
| 14 |
+ t.Fatal(out, err) |
|
| 15 |
+ } |
|
| 14 | 16 |
|
| 15 | 17 |
cleanedContainerID := stripTrailingCharacters(out) |
| 16 | 18 |
|
| 17 | 19 |
runCmd = exec.Command(dockerBinary, "wait", cleanedContainerID) |
| 18 |
- out, _, err = runCommandWithOutput(runCmd) |
|
| 19 |
- errorOut(err, t, out) |
|
| 20 |
+ if out, _, err = runCommandWithOutput(runCmd); err != nil {
|
|
| 21 |
+ t.Fatal(out, err) |
|
| 22 |
+ } |
|
| 20 | 23 |
|
| 21 | 24 |
runCmd = exec.Command(dockerBinary, "logs", cleanedContainerID) |
| 22 | 25 |
out, _, err = runCommandWithOutput(runCmd) |
| 23 |
- errorOut(err, t, out) |
|
| 26 |
+ if err != nil {
|
|
| 27 |
+ t.Fatal(out, err) |
|
| 28 |
+ } |
|
| 24 | 29 |
|
| 25 | 30 |
if out != "foobar\n" {
|
| 26 | 31 |
t.Errorf("container should've printed 'foobar'")
|
| 27 | 32 |
} |
| 28 | 33 |
|
| 29 | 34 |
runCmd = exec.Command(dockerBinary, "restart", cleanedContainerID) |
| 30 |
- out, _, err = runCommandWithOutput(runCmd) |
|
| 31 |
- errorOut(err, t, out) |
|
| 35 |
+ if out, _, err = runCommandWithOutput(runCmd); err != nil {
|
|
| 36 |
+ t.Fatal(out, err) |
|
| 37 |
+ } |
|
| 32 | 38 |
|
| 33 | 39 |
runCmd = exec.Command(dockerBinary, "logs", cleanedContainerID) |
| 34 | 40 |
out, _, err = runCommandWithOutput(runCmd) |
| 35 |
- errorOut(err, t, out) |
|
| 41 |
+ if err != nil {
|
|
| 42 |
+ t.Fatal(out, err) |
|
| 43 |
+ } |
|
| 36 | 44 |
|
| 37 | 45 |
if out != "foobar\nfoobar\n" {
|
| 38 | 46 |
t.Errorf("container should've printed 'foobar' twice")
|
| ... | ... |
@@ -46,7 +54,9 @@ func TestRestartStoppedContainer(t *testing.T) {
|
| 46 | 46 |
func TestRestartRunningContainer(t *testing.T) {
|
| 47 | 47 |
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", "echo foobar && sleep 30 && echo 'should not print this'") |
| 48 | 48 |
out, _, err := runCommandWithOutput(runCmd) |
| 49 |
- errorOut(err, t, out) |
|
| 49 |
+ if err != nil {
|
|
| 50 |
+ t.Fatal(out, err) |
|
| 51 |
+ } |
|
| 50 | 52 |
|
| 51 | 53 |
cleanedContainerID := stripTrailingCharacters(out) |
| 52 | 54 |
|
| ... | ... |
@@ -54,19 +64,24 @@ func TestRestartRunningContainer(t *testing.T) {
|
| 54 | 54 |
|
| 55 | 55 |
runCmd = exec.Command(dockerBinary, "logs", cleanedContainerID) |
| 56 | 56 |
out, _, err = runCommandWithOutput(runCmd) |
| 57 |
- errorOut(err, t, out) |
|
| 57 |
+ if err != nil {
|
|
| 58 |
+ t.Fatal(out, err) |
|
| 59 |
+ } |
|
| 58 | 60 |
|
| 59 | 61 |
if out != "foobar\n" {
|
| 60 | 62 |
t.Errorf("container should've printed 'foobar'")
|
| 61 | 63 |
} |
| 62 | 64 |
|
| 63 | 65 |
runCmd = exec.Command(dockerBinary, "restart", "-t", "1", cleanedContainerID) |
| 64 |
- out, _, err = runCommandWithOutput(runCmd) |
|
| 65 |
- errorOut(err, t, out) |
|
| 66 |
+ if out, _, err = runCommandWithOutput(runCmd); err != nil {
|
|
| 67 |
+ t.Fatal(out, err) |
|
| 68 |
+ } |
|
| 66 | 69 |
|
| 67 | 70 |
runCmd = exec.Command(dockerBinary, "logs", cleanedContainerID) |
| 68 | 71 |
out, _, err = runCommandWithOutput(runCmd) |
| 69 |
- errorOut(err, t, out) |
|
| 72 |
+ if err != nil {
|
|
| 73 |
+ t.Fatal(out, err) |
|
| 74 |
+ } |
|
| 70 | 75 |
|
| 71 | 76 |
time.Sleep(1 * time.Second) |
| 72 | 77 |
|
| ... | ... |
@@ -83,13 +98,17 @@ func TestRestartRunningContainer(t *testing.T) {
|
| 83 | 83 |
func TestRestartWithVolumes(t *testing.T) {
|
| 84 | 84 |
runCmd := exec.Command(dockerBinary, "run", "-d", "-v", "/test", "busybox", "top") |
| 85 | 85 |
out, _, err := runCommandWithOutput(runCmd) |
| 86 |
- errorOut(err, t, out) |
|
| 86 |
+ if err != nil {
|
|
| 87 |
+ t.Fatal(out, err) |
|
| 88 |
+ } |
|
| 87 | 89 |
|
| 88 | 90 |
cleanedContainerID := stripTrailingCharacters(out) |
| 89 | 91 |
|
| 90 | 92 |
runCmd = exec.Command(dockerBinary, "inspect", "--format", "{{ len .Volumes }}", cleanedContainerID)
|
| 91 | 93 |
out, _, err = runCommandWithOutput(runCmd) |
| 92 |
- errorOut(err, t, out) |
|
| 94 |
+ if err != nil {
|
|
| 95 |
+ t.Fatal(out, err) |
|
| 96 |
+ } |
|
| 93 | 97 |
|
| 94 | 98 |
if out = strings.Trim(out, " \n\r"); out != "1" {
|
| 95 | 99 |
t.Errorf("expect 1 volume received %s", out)
|
| ... | ... |
@@ -97,15 +116,20 @@ func TestRestartWithVolumes(t *testing.T) {
|
| 97 | 97 |
|
| 98 | 98 |
runCmd = exec.Command(dockerBinary, "inspect", "--format", "{{ .Volumes }}", cleanedContainerID)
|
| 99 | 99 |
volumes, _, err := runCommandWithOutput(runCmd) |
| 100 |
- errorOut(err, t, volumes) |
|
| 100 |
+ if err != nil {
|
|
| 101 |
+ t.Fatal(volumes, err) |
|
| 102 |
+ } |
|
| 101 | 103 |
|
| 102 | 104 |
runCmd = exec.Command(dockerBinary, "restart", cleanedContainerID) |
| 103 |
- out, _, err = runCommandWithOutput(runCmd) |
|
| 104 |
- errorOut(err, t, out) |
|
| 105 |
+ if out, _, err = runCommandWithOutput(runCmd); err != nil {
|
|
| 106 |
+ t.Fatal(out, err) |
|
| 107 |
+ } |
|
| 105 | 108 |
|
| 106 | 109 |
runCmd = exec.Command(dockerBinary, "inspect", "--format", "{{ len .Volumes }}", cleanedContainerID)
|
| 107 | 110 |
out, _, err = runCommandWithOutput(runCmd) |
| 108 |
- errorOut(err, t, out) |
|
| 111 |
+ if err != nil {
|
|
| 112 |
+ t.Fatal(out, err) |
|
| 113 |
+ } |
|
| 109 | 114 |
|
| 110 | 115 |
if out = strings.Trim(out, " \n\r"); out != "1" {
|
| 111 | 116 |
t.Errorf("expect 1 volume after restart received %s", out)
|
| ... | ... |
@@ -113,7 +137,9 @@ func TestRestartWithVolumes(t *testing.T) {
|
| 113 | 113 |
|
| 114 | 114 |
runCmd = exec.Command(dockerBinary, "inspect", "--format", "{{ .Volumes }}", cleanedContainerID)
|
| 115 | 115 |
volumesAfterRestart, _, err := runCommandWithOutput(runCmd) |
| 116 |
- errorOut(err, t, volumesAfterRestart) |
|
| 116 |
+ if err != nil {
|
|
| 117 |
+ t.Fatal(volumesAfterRestart, err) |
|
| 118 |
+ } |
|
| 117 | 119 |
|
| 118 | 120 |
if volumes != volumesAfterRestart {
|
| 119 | 121 |
volumes = strings.Trim(volumes, " \n\r") |