Signed-off-by: Antonio Murdaca <me@runcom.ninja>
| ... | ... |
@@ -12,18 +12,12 @@ import ( |
| 12 | 12 |
func (s *DockerSuite) TestExportContainerAndImportImage(c *check.C) {
|
| 13 | 13 |
containerID := "testexportcontainerandimportimage" |
| 14 | 14 |
|
| 15 |
- runCmd := exec.Command(dockerBinary, "run", "-d", "--name", containerID, "busybox", "true") |
|
| 15 |
+ runCmd := exec.Command(dockerBinary, "run", "--name", containerID, "busybox", "true") |
|
| 16 | 16 |
out, _, err := runCommandWithOutput(runCmd) |
| 17 | 17 |
if err != nil {
|
| 18 | 18 |
c.Fatal("failed to create a container", out, err)
|
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 |
- inspectCmd := exec.Command(dockerBinary, "inspect", containerID) |
|
| 22 |
- out, _, err = runCommandWithOutput(inspectCmd) |
|
| 23 |
- if err != nil {
|
|
| 24 |
- c.Fatalf("output should've been a container id: %s %s ", containerID, err)
|
|
| 25 |
- } |
|
| 26 |
- |
|
| 27 | 21 |
exportCmd := exec.Command(dockerBinary, "export", containerID) |
| 28 | 22 |
if out, _, err = runCommandWithOutput(exportCmd); err != nil {
|
| 29 | 23 |
c.Fatalf("failed to export container: %s, %v", out, err)
|
| ... | ... |
@@ -37,30 +31,21 @@ func (s *DockerSuite) TestExportContainerAndImportImage(c *check.C) {
|
| 37 | 37 |
} |
| 38 | 38 |
|
| 39 | 39 |
cleanedImageID := strings.TrimSpace(out) |
| 40 |
- |
|
| 41 |
- inspectCmd = exec.Command(dockerBinary, "inspect", cleanedImageID) |
|
| 42 |
- if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
|
|
| 43 |
- c.Fatalf("output should've been an image id: %s, %v", out, err)
|
|
| 40 |
+ if cleanedImageID == "" {
|
|
| 41 |
+ c.Fatalf("output should have been an image id, got: %s", out)
|
|
| 44 | 42 |
} |
| 45 |
- |
|
| 46 | 43 |
} |
| 47 | 44 |
|
| 48 | 45 |
// Used to test output flag in the export command |
| 49 | 46 |
func (s *DockerSuite) TestExportContainerWithOutputAndImportImage(c *check.C) {
|
| 50 | 47 |
containerID := "testexportcontainerwithoutputandimportimage" |
| 51 | 48 |
|
| 52 |
- runCmd := exec.Command(dockerBinary, "run", "-d", "--name", containerID, "busybox", "true") |
|
| 49 |
+ runCmd := exec.Command(dockerBinary, "run", "--name", containerID, "busybox", "true") |
|
| 53 | 50 |
out, _, err := runCommandWithOutput(runCmd) |
| 54 | 51 |
if err != nil {
|
| 55 | 52 |
c.Fatal("failed to create a container", out, err)
|
| 56 | 53 |
} |
| 57 | 54 |
|
| 58 |
- inspectCmd := exec.Command(dockerBinary, "inspect", containerID) |
|
| 59 |
- out, _, err = runCommandWithOutput(inspectCmd) |
|
| 60 |
- if err != nil {
|
|
| 61 |
- c.Fatalf("output should've been a container id: %s %s ", containerID, err)
|
|
| 62 |
- } |
|
| 63 |
- |
|
| 64 | 55 |
defer os.Remove("testexp.tar")
|
| 65 | 56 |
|
| 66 | 57 |
exportCmd := exec.Command(dockerBinary, "export", "--output=testexp.tar", containerID) |
| ... | ... |
@@ -81,10 +66,7 @@ func (s *DockerSuite) TestExportContainerWithOutputAndImportImage(c *check.C) {
|
| 81 | 81 |
} |
| 82 | 82 |
|
| 83 | 83 |
cleanedImageID := strings.TrimSpace(out) |
| 84 |
- |
|
| 85 |
- inspectCmd = exec.Command(dockerBinary, "inspect", cleanedImageID) |
|
| 86 |
- if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
|
|
| 87 |
- c.Fatalf("output should've been an image id: %s, %v", out, err)
|
|
| 84 |
+ if cleanedImageID == "" {
|
|
| 85 |
+ c.Fatalf("output should have been an image id, got: %s", out)
|
|
| 88 | 86 |
} |
| 89 |
- |
|
| 90 | 87 |
} |
| ... | ... |
@@ -15,11 +15,7 @@ func (s *DockerSuite) TestKillContainer(c *check.C) {
|
| 15 | 15 |
} |
| 16 | 16 |
|
| 17 | 17 |
cleanedContainerID := strings.TrimSpace(out) |
| 18 |
- |
|
| 19 |
- inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID) |
|
| 20 |
- if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
|
|
| 21 |
- c.Fatalf("out should've been a container id: %s, %v", out, err)
|
|
| 22 |
- } |
|
| 18 |
+ c.Assert(waitRun(cleanedContainerID), check.IsNil) |
|
| 23 | 19 |
|
| 24 | 20 |
killCmd := exec.Command(dockerBinary, "kill", cleanedContainerID) |
| 25 | 21 |
if out, _, err = runCommandWithOutput(killCmd); err != nil {
|
| ... | ... |
@@ -48,11 +44,7 @@ func (s *DockerSuite) TestKillDifferentUserContainer(c *check.C) {
|
| 48 | 48 |
} |
| 49 | 49 |
|
| 50 | 50 |
cleanedContainerID := strings.TrimSpace(out) |
| 51 |
- |
|
| 52 |
- inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID) |
|
| 53 |
- if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
|
|
| 54 |
- c.Fatalf("out should've been a container id: %s, %v", out, err)
|
|
| 55 |
- } |
|
| 51 |
+ c.Assert(waitRun(cleanedContainerID), check.IsNil) |
|
| 56 | 52 |
|
| 57 | 53 |
killCmd := exec.Command(dockerBinary, "kill", cleanedContainerID) |
| 58 | 54 |
if out, _, err = runCommandWithOutput(killCmd); err != nil {
|
| ... | ... |
@@ -186,12 +186,6 @@ func (s *DockerSuite) TestRunStdinPipe(c *check.C) {
|
| 186 | 186 |
} |
| 187 | 187 |
|
| 188 | 188 |
out = strings.TrimSpace(out) |
| 189 |
- |
|
| 190 |
- inspectCmd := exec.Command(dockerBinary, "inspect", out) |
|
| 191 |
- if out, _, err := runCommandWithOutput(inspectCmd); err != nil {
|
|
| 192 |
- c.Fatalf("out should've been a container id: %s %v", out, err)
|
|
| 193 |
- } |
|
| 194 |
- |
|
| 195 | 189 |
waitCmd := exec.Command(dockerBinary, "wait", out) |
| 196 | 190 |
if waitOut, _, err := runCommandWithOutput(waitCmd); err != nil {
|
| 197 | 191 |
c.Fatalf("error thrown while waiting for container: %s, %v", waitOut, err)
|
| ... | ... |
@@ -224,12 +218,6 @@ func (s *DockerSuite) TestRunDetachedContainerIDPrinting(c *check.C) {
|
| 224 | 224 |
} |
| 225 | 225 |
|
| 226 | 226 |
out = strings.TrimSpace(out) |
| 227 |
- |
|
| 228 |
- inspectCmd := exec.Command(dockerBinary, "inspect", out) |
|
| 229 |
- if inspectOut, _, err := runCommandWithOutput(inspectCmd); err != nil {
|
|
| 230 |
- c.Fatalf("out should've been a container id: %s %v", inspectOut, err)
|
|
| 231 |
- } |
|
| 232 |
- |
|
| 233 | 227 |
waitCmd := exec.Command(dockerBinary, "wait", out) |
| 234 | 228 |
if waitOut, _, err := runCommandWithOutput(waitCmd); err != nil {
|
| 235 | 229 |
c.Fatalf("error thrown while waiting for container: %s, %v", waitOut, err)
|
| ... | ... |
@@ -15,29 +15,22 @@ import ( |
| 15 | 15 |
|
| 16 | 16 |
// save a repo using gz compression and try to load it using stdout |
| 17 | 17 |
func (s *DockerSuite) TestSaveXzAndLoadRepoStdout(c *check.C) {
|
| 18 |
- runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true") |
|
| 18 |
+ name := "test-save-xz-and-load-repo-stdout" |
|
| 19 |
+ runCmd := exec.Command(dockerBinary, "run", "--name", name, "busybox", "true") |
|
| 19 | 20 |
out, _, err := runCommandWithOutput(runCmd) |
| 20 | 21 |
if err != nil {
|
| 21 | 22 |
c.Fatalf("failed to create a container: %v %v", out, err)
|
| 22 | 23 |
} |
| 23 | 24 |
|
| 24 |
- cleanedContainerID := strings.TrimSpace(out) |
|
| 25 |
- |
|
| 26 | 25 |
repoName := "foobar-save-load-test-xz-gz" |
| 27 | 26 |
|
| 28 |
- inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID) |
|
| 29 |
- out, _, err = runCommandWithOutput(inspectCmd) |
|
| 30 |
- if err != nil {
|
|
| 31 |
- c.Fatalf("output should've been a container id: %v %v", cleanedContainerID, err)
|
|
| 32 |
- } |
|
| 33 |
- |
|
| 34 |
- commitCmd := exec.Command(dockerBinary, "commit", cleanedContainerID, repoName) |
|
| 27 |
+ commitCmd := exec.Command(dockerBinary, "commit", name, repoName) |
|
| 35 | 28 |
out, _, err = runCommandWithOutput(commitCmd) |
| 36 | 29 |
if err != nil {
|
| 37 | 30 |
c.Fatalf("failed to commit container: %v %v", out, err)
|
| 38 | 31 |
} |
| 39 | 32 |
|
| 40 |
- inspectCmd = exec.Command(dockerBinary, "inspect", repoName) |
|
| 33 |
+ inspectCmd := exec.Command(dockerBinary, "inspect", repoName) |
|
| 41 | 34 |
before, _, err := runCommandWithOutput(inspectCmd) |
| 42 | 35 |
if err != nil {
|
| 43 | 36 |
c.Fatalf("the repo should exist before saving it: %v %v", before, err)
|
| ... | ... |
@@ -71,29 +64,22 @@ func (s *DockerSuite) TestSaveXzAndLoadRepoStdout(c *check.C) {
|
| 71 | 71 |
|
| 72 | 72 |
// save a repo using xz+gz compression and try to load it using stdout |
| 73 | 73 |
func (s *DockerSuite) TestSaveXzGzAndLoadRepoStdout(c *check.C) {
|
| 74 |
- runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true") |
|
| 74 |
+ name := "test-save-xz-gz-and-load-repo-stdout" |
|
| 75 |
+ runCmd := exec.Command(dockerBinary, "run", "--name", name, "busybox", "true") |
|
| 75 | 76 |
out, _, err := runCommandWithOutput(runCmd) |
| 76 | 77 |
if err != nil {
|
| 77 | 78 |
c.Fatalf("failed to create a container: %v %v", out, err)
|
| 78 | 79 |
} |
| 79 | 80 |
|
| 80 |
- cleanedContainerID := strings.TrimSpace(out) |
|
| 81 |
- |
|
| 82 | 81 |
repoName := "foobar-save-load-test-xz-gz" |
| 83 | 82 |
|
| 84 |
- inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID) |
|
| 85 |
- out, _, err = runCommandWithOutput(inspectCmd) |
|
| 86 |
- if err != nil {
|
|
| 87 |
- c.Fatalf("output should've been a container id: %v %v", cleanedContainerID, err)
|
|
| 88 |
- } |
|
| 89 |
- |
|
| 90 |
- commitCmd := exec.Command(dockerBinary, "commit", cleanedContainerID, repoName) |
|
| 83 |
+ commitCmd := exec.Command(dockerBinary, "commit", name, repoName) |
|
| 91 | 84 |
out, _, err = runCommandWithOutput(commitCmd) |
| 92 | 85 |
if err != nil {
|
| 93 | 86 |
c.Fatalf("failed to commit container: %v %v", out, err)
|
| 94 | 87 |
} |
| 95 | 88 |
|
| 96 |
- inspectCmd = exec.Command(dockerBinary, "inspect", repoName) |
|
| 89 |
+ inspectCmd := exec.Command(dockerBinary, "inspect", repoName) |
|
| 97 | 90 |
before, _, err := runCommandWithOutput(inspectCmd) |
| 98 | 91 |
if err != nil {
|
| 99 | 92 |
c.Fatalf("the repo should exist before saving it: %v %v", before, err)
|
| ... | ... |
@@ -121,10 +107,6 @@ func (s *DockerSuite) TestSaveXzGzAndLoadRepoStdout(c *check.C) {
|
| 121 | 121 |
if err == nil {
|
| 122 | 122 |
c.Fatalf("the repo should not exist: %v", after)
|
| 123 | 123 |
} |
| 124 |
- |
|
| 125 |
- deleteContainer(cleanedContainerID) |
|
| 126 |
- deleteImages(repoName) |
|
| 127 |
- |
|
| 128 | 124 |
} |
| 129 | 125 |
|
| 130 | 126 |
func (s *DockerSuite) TestSaveSingleTag(c *check.C) {
|
| ... | ... |
@@ -207,28 +189,21 @@ func (s *DockerSuite) TestSaveImageId(c *check.C) {
|
| 207 | 207 |
|
| 208 | 208 |
// save a repo and try to load it using flags |
| 209 | 209 |
func (s *DockerSuite) TestSaveAndLoadRepoFlags(c *check.C) {
|
| 210 |
- runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true") |
|
| 210 |
+ name := "test-save-and-load-repo-flags" |
|
| 211 |
+ runCmd := exec.Command(dockerBinary, "run", "--name", name, "busybox", "true") |
|
| 211 | 212 |
out, _, err := runCommandWithOutput(runCmd) |
| 212 | 213 |
if err != nil {
|
| 213 | 214 |
c.Fatalf("failed to create a container: %s, %v", out, err)
|
| 214 | 215 |
} |
| 215 |
- |
|
| 216 |
- cleanedContainerID := strings.TrimSpace(out) |
|
| 217 |
- |
|
| 218 | 216 |
repoName := "foobar-save-load-test" |
| 219 | 217 |
|
| 220 |
- inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID) |
|
| 221 |
- if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
|
|
| 222 |
- c.Fatalf("output should've been a container id: %s, %v", out, err)
|
|
| 223 |
- } |
|
| 224 |
- |
|
| 225 |
- commitCmd := exec.Command(dockerBinary, "commit", cleanedContainerID, repoName) |
|
| 218 |
+ commitCmd := exec.Command(dockerBinary, "commit", name, repoName) |
|
| 226 | 219 |
deleteImages(repoName) |
| 227 | 220 |
if out, _, err = runCommandWithOutput(commitCmd); err != nil {
|
| 228 | 221 |
c.Fatalf("failed to commit container: %s, %v", out, err)
|
| 229 | 222 |
} |
| 230 | 223 |
|
| 231 |
- inspectCmd = exec.Command(dockerBinary, "inspect", repoName) |
|
| 224 |
+ inspectCmd := exec.Command(dockerBinary, "inspect", repoName) |
|
| 232 | 225 |
before, _, err := runCommandWithOutput(inspectCmd) |
| 233 | 226 |
if err != nil {
|
| 234 | 227 |
c.Fatalf("the repo should exist before saving it: %s, %v", before, err)
|
| ... | ... |
@@ -251,7 +226,6 @@ func (s *DockerSuite) TestSaveAndLoadRepoFlags(c *check.C) {
|
| 251 | 251 |
if before != after {
|
| 252 | 252 |
c.Fatalf("inspect is not the same after a save / load")
|
| 253 | 253 |
} |
| 254 |
- |
|
| 255 | 254 |
} |
| 256 | 255 |
|
| 257 | 256 |
func (s *DockerSuite) TestSaveMultipleNames(c *check.C) {
|
| ... | ... |
@@ -7,7 +7,6 @@ import ( |
| 7 | 7 |
"fmt" |
| 8 | 8 |
"os" |
| 9 | 9 |
"os/exec" |
| 10 |
- "strings" |
|
| 11 | 10 |
|
| 12 | 11 |
"github.com/docker/docker/vendor/src/github.com/kr/pty" |
| 13 | 12 |
"github.com/go-check/check" |
| ... | ... |
@@ -15,27 +14,21 @@ import ( |
| 15 | 15 |
|
| 16 | 16 |
// save a repo and try to load it using stdout |
| 17 | 17 |
func (s *DockerSuite) TestSaveAndLoadRepoStdout(c *check.C) {
|
| 18 |
- runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true") |
|
| 18 |
+ name := "test-save-and-load-repo-stdout" |
|
| 19 |
+ runCmd := exec.Command(dockerBinary, "run", "--name", name, "busybox", "true") |
|
| 19 | 20 |
out, _, err := runCommandWithOutput(runCmd) |
| 20 | 21 |
if err != nil {
|
| 21 | 22 |
c.Fatalf("failed to create a container: %s, %v", out, err)
|
| 22 | 23 |
} |
| 23 | 24 |
|
| 24 |
- cleanedContainerID := strings.TrimSpace(out) |
|
| 25 |
- |
|
| 26 | 25 |
repoName := "foobar-save-load-test" |
| 27 | 26 |
|
| 28 |
- inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID) |
|
| 29 |
- if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
|
|
| 30 |
- c.Fatalf("output should've been a container id: %s, %v", out, err)
|
|
| 31 |
- } |
|
| 32 |
- |
|
| 33 |
- commitCmd := exec.Command(dockerBinary, "commit", cleanedContainerID, repoName) |
|
| 27 |
+ commitCmd := exec.Command(dockerBinary, "commit", name, repoName) |
|
| 34 | 28 |
if out, _, err = runCommandWithOutput(commitCmd); err != nil {
|
| 35 | 29 |
c.Fatalf("failed to commit container: %s, %v", out, err)
|
| 36 | 30 |
} |
| 37 | 31 |
|
| 38 |
- inspectCmd = exec.Command(dockerBinary, "inspect", repoName) |
|
| 32 |
+ inspectCmd := exec.Command(dockerBinary, "inspect", repoName) |
|
| 39 | 33 |
before, _, err := runCommandWithOutput(inspectCmd) |
| 40 | 34 |
if err != nil {
|
| 41 | 35 |
c.Fatalf("the repo should exist before saving it: %s, %v", before, err)
|
| ... | ... |
@@ -66,7 +59,6 @@ func (s *DockerSuite) TestSaveAndLoadRepoStdout(c *check.C) {
|
| 66 | 66 |
c.Fatalf("inspect is not the same after a save / load")
|
| 67 | 67 |
} |
| 68 | 68 |
|
| 69 |
- deleteContainer(cleanedContainerID) |
|
| 70 | 69 |
deleteImages(repoName) |
| 71 | 70 |
|
| 72 | 71 |
os.Remove("/tmp/foobar-save-load-test.tar")
|