Clean tests from not needed inspect call

Signed-off-by: Antonio Murdaca <me@runcom.ninja>
This commit is contained in:
Antonio Murdaca 2015-05-16 16:59:53 +02:00
parent 42cfc95549
commit a268e36719
5 changed files with 24 additions and 96 deletions

View File

@ -12,18 +12,12 @@ import (
func (s *DockerSuite) TestExportContainerAndImportImage(c *check.C) { func (s *DockerSuite) TestExportContainerAndImportImage(c *check.C) {
containerID := "testexportcontainerandimportimage" containerID := "testexportcontainerandimportimage"
runCmd := exec.Command(dockerBinary, "run", "-d", "--name", containerID, "busybox", "true") runCmd := exec.Command(dockerBinary, "run", "--name", containerID, "busybox", "true")
out, _, err := runCommandWithOutput(runCmd) out, _, err := runCommandWithOutput(runCmd)
if err != nil { if err != nil {
c.Fatal("failed to create a container", out, err) c.Fatal("failed to create a container", out, err)
} }
inspectCmd := exec.Command(dockerBinary, "inspect", containerID)
out, _, err = runCommandWithOutput(inspectCmd)
if err != nil {
c.Fatalf("output should've been a container id: %s %s ", containerID, err)
}
exportCmd := exec.Command(dockerBinary, "export", containerID) exportCmd := exec.Command(dockerBinary, "export", containerID)
if out, _, err = runCommandWithOutput(exportCmd); err != nil { if out, _, err = runCommandWithOutput(exportCmd); err != nil {
c.Fatalf("failed to export container: %s, %v", out, err) c.Fatalf("failed to export container: %s, %v", out, err)
@ -37,30 +31,21 @@ func (s *DockerSuite) TestExportContainerAndImportImage(c *check.C) {
} }
cleanedImageID := strings.TrimSpace(out) cleanedImageID := strings.TrimSpace(out)
if cleanedImageID == "" {
inspectCmd = exec.Command(dockerBinary, "inspect", cleanedImageID) c.Fatalf("output should have been an image id, got: %s", out)
if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
c.Fatalf("output should've been an image id: %s, %v", out, err)
} }
} }
// Used to test output flag in the export command // Used to test output flag in the export command
func (s *DockerSuite) TestExportContainerWithOutputAndImportImage(c *check.C) { func (s *DockerSuite) TestExportContainerWithOutputAndImportImage(c *check.C) {
containerID := "testexportcontainerwithoutputandimportimage" containerID := "testexportcontainerwithoutputandimportimage"
runCmd := exec.Command(dockerBinary, "run", "-d", "--name", containerID, "busybox", "true") runCmd := exec.Command(dockerBinary, "run", "--name", containerID, "busybox", "true")
out, _, err := runCommandWithOutput(runCmd) out, _, err := runCommandWithOutput(runCmd)
if err != nil { if err != nil {
c.Fatal("failed to create a container", out, err) c.Fatal("failed to create a container", out, err)
} }
inspectCmd := exec.Command(dockerBinary, "inspect", containerID)
out, _, err = runCommandWithOutput(inspectCmd)
if err != nil {
c.Fatalf("output should've been a container id: %s %s ", containerID, err)
}
defer os.Remove("testexp.tar") defer os.Remove("testexp.tar")
exportCmd := exec.Command(dockerBinary, "export", "--output=testexp.tar", containerID) exportCmd := exec.Command(dockerBinary, "export", "--output=testexp.tar", containerID)
@ -81,10 +66,7 @@ func (s *DockerSuite) TestExportContainerWithOutputAndImportImage(c *check.C) {
} }
cleanedImageID := strings.TrimSpace(out) cleanedImageID := strings.TrimSpace(out)
if cleanedImageID == "" {
inspectCmd = exec.Command(dockerBinary, "inspect", cleanedImageID) c.Fatalf("output should have been an image id, got: %s", out)
if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
c.Fatalf("output should've been an image id: %s, %v", out, err)
} }
} }

View File

@ -15,11 +15,7 @@ func (s *DockerSuite) TestKillContainer(c *check.C) {
} }
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
c.Assert(waitRun(cleanedContainerID), check.IsNil)
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID)
if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
c.Fatalf("out should've been a container id: %s, %v", out, err)
}
killCmd := exec.Command(dockerBinary, "kill", cleanedContainerID) killCmd := exec.Command(dockerBinary, "kill", cleanedContainerID)
if out, _, err = runCommandWithOutput(killCmd); err != nil { if out, _, err = runCommandWithOutput(killCmd); err != nil {
@ -48,11 +44,7 @@ func (s *DockerSuite) TestKillDifferentUserContainer(c *check.C) {
} }
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
c.Assert(waitRun(cleanedContainerID), check.IsNil)
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID)
if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
c.Fatalf("out should've been a container id: %s, %v", out, err)
}
killCmd := exec.Command(dockerBinary, "kill", cleanedContainerID) killCmd := exec.Command(dockerBinary, "kill", cleanedContainerID)
if out, _, err = runCommandWithOutput(killCmd); err != nil { if out, _, err = runCommandWithOutput(killCmd); err != nil {

View File

@ -186,12 +186,6 @@ func (s *DockerSuite) TestRunStdinPipe(c *check.C) {
} }
out = strings.TrimSpace(out) out = strings.TrimSpace(out)
inspectCmd := exec.Command(dockerBinary, "inspect", out)
if out, _, err := runCommandWithOutput(inspectCmd); err != nil {
c.Fatalf("out should've been a container id: %s %v", out, err)
}
waitCmd := exec.Command(dockerBinary, "wait", out) waitCmd := exec.Command(dockerBinary, "wait", out)
if waitOut, _, err := runCommandWithOutput(waitCmd); err != nil { if waitOut, _, err := runCommandWithOutput(waitCmd); err != nil {
c.Fatalf("error thrown while waiting for container: %s, %v", waitOut, err) c.Fatalf("error thrown while waiting for container: %s, %v", waitOut, err)
@ -224,12 +218,6 @@ func (s *DockerSuite) TestRunDetachedContainerIDPrinting(c *check.C) {
} }
out = strings.TrimSpace(out) out = strings.TrimSpace(out)
inspectCmd := exec.Command(dockerBinary, "inspect", out)
if inspectOut, _, err := runCommandWithOutput(inspectCmd); err != nil {
c.Fatalf("out should've been a container id: %s %v", inspectOut, err)
}
waitCmd := exec.Command(dockerBinary, "wait", out) waitCmd := exec.Command(dockerBinary, "wait", out)
if waitOut, _, err := runCommandWithOutput(waitCmd); err != nil { if waitOut, _, err := runCommandWithOutput(waitCmd); err != nil {
c.Fatalf("error thrown while waiting for container: %s, %v", waitOut, err) c.Fatalf("error thrown while waiting for container: %s, %v", waitOut, err)

View File

@ -15,29 +15,22 @@ import (
// save a repo using gz compression and try to load it using stdout // save a repo using gz compression and try to load it using stdout
func (s *DockerSuite) TestSaveXzAndLoadRepoStdout(c *check.C) { func (s *DockerSuite) TestSaveXzAndLoadRepoStdout(c *check.C) {
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true") name := "test-save-xz-and-load-repo-stdout"
runCmd := exec.Command(dockerBinary, "run", "--name", name, "busybox", "true")
out, _, err := runCommandWithOutput(runCmd) out, _, err := runCommandWithOutput(runCmd)
if err != nil { if err != nil {
c.Fatalf("failed to create a container: %v %v", out, err) c.Fatalf("failed to create a container: %v %v", out, err)
} }
cleanedContainerID := strings.TrimSpace(out)
repoName := "foobar-save-load-test-xz-gz" repoName := "foobar-save-load-test-xz-gz"
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID) commitCmd := exec.Command(dockerBinary, "commit", name, repoName)
out, _, err = runCommandWithOutput(inspectCmd)
if err != nil {
c.Fatalf("output should've been a container id: %v %v", cleanedContainerID, err)
}
commitCmd := exec.Command(dockerBinary, "commit", cleanedContainerID, repoName)
out, _, err = runCommandWithOutput(commitCmd) out, _, err = runCommandWithOutput(commitCmd)
if err != nil { if err != nil {
c.Fatalf("failed to commit container: %v %v", out, err) c.Fatalf("failed to commit container: %v %v", out, err)
} }
inspectCmd = exec.Command(dockerBinary, "inspect", repoName) inspectCmd := exec.Command(dockerBinary, "inspect", repoName)
before, _, err := runCommandWithOutput(inspectCmd) before, _, err := runCommandWithOutput(inspectCmd)
if err != nil { if err != nil {
c.Fatalf("the repo should exist before saving it: %v %v", before, err) c.Fatalf("the repo should exist before saving it: %v %v", before, err)
@ -71,29 +64,22 @@ func (s *DockerSuite) TestSaveXzAndLoadRepoStdout(c *check.C) {
// save a repo using xz+gz compression and try to load it using stdout // save a repo using xz+gz compression and try to load it using stdout
func (s *DockerSuite) TestSaveXzGzAndLoadRepoStdout(c *check.C) { func (s *DockerSuite) TestSaveXzGzAndLoadRepoStdout(c *check.C) {
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true") name := "test-save-xz-gz-and-load-repo-stdout"
runCmd := exec.Command(dockerBinary, "run", "--name", name, "busybox", "true")
out, _, err := runCommandWithOutput(runCmd) out, _, err := runCommandWithOutput(runCmd)
if err != nil { if err != nil {
c.Fatalf("failed to create a container: %v %v", out, err) c.Fatalf("failed to create a container: %v %v", out, err)
} }
cleanedContainerID := strings.TrimSpace(out)
repoName := "foobar-save-load-test-xz-gz" repoName := "foobar-save-load-test-xz-gz"
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID) commitCmd := exec.Command(dockerBinary, "commit", name, repoName)
out, _, err = runCommandWithOutput(inspectCmd)
if err != nil {
c.Fatalf("output should've been a container id: %v %v", cleanedContainerID, err)
}
commitCmd := exec.Command(dockerBinary, "commit", cleanedContainerID, repoName)
out, _, err = runCommandWithOutput(commitCmd) out, _, err = runCommandWithOutput(commitCmd)
if err != nil { if err != nil {
c.Fatalf("failed to commit container: %v %v", out, err) c.Fatalf("failed to commit container: %v %v", out, err)
} }
inspectCmd = exec.Command(dockerBinary, "inspect", repoName) inspectCmd := exec.Command(dockerBinary, "inspect", repoName)
before, _, err := runCommandWithOutput(inspectCmd) before, _, err := runCommandWithOutput(inspectCmd)
if err != nil { if err != nil {
c.Fatalf("the repo should exist before saving it: %v %v", before, err) c.Fatalf("the repo should exist before saving it: %v %v", before, err)
@ -121,10 +107,6 @@ func (s *DockerSuite) TestSaveXzGzAndLoadRepoStdout(c *check.C) {
if err == nil { if err == nil {
c.Fatalf("the repo should not exist: %v", after) c.Fatalf("the repo should not exist: %v", after)
} }
deleteContainer(cleanedContainerID)
deleteImages(repoName)
} }
func (s *DockerSuite) TestSaveSingleTag(c *check.C) { func (s *DockerSuite) TestSaveSingleTag(c *check.C) {
@ -207,28 +189,21 @@ func (s *DockerSuite) TestSaveImageId(c *check.C) {
// save a repo and try to load it using flags // save a repo and try to load it using flags
func (s *DockerSuite) TestSaveAndLoadRepoFlags(c *check.C) { func (s *DockerSuite) TestSaveAndLoadRepoFlags(c *check.C) {
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true") name := "test-save-and-load-repo-flags"
runCmd := exec.Command(dockerBinary, "run", "--name", name, "busybox", "true")
out, _, err := runCommandWithOutput(runCmd) out, _, err := runCommandWithOutput(runCmd)
if err != nil { if err != nil {
c.Fatalf("failed to create a container: %s, %v", out, err) c.Fatalf("failed to create a container: %s, %v", out, err)
} }
cleanedContainerID := strings.TrimSpace(out)
repoName := "foobar-save-load-test" repoName := "foobar-save-load-test"
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID) commitCmd := exec.Command(dockerBinary, "commit", name, repoName)
if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
c.Fatalf("output should've been a container id: %s, %v", out, err)
}
commitCmd := exec.Command(dockerBinary, "commit", cleanedContainerID, repoName)
deleteImages(repoName) deleteImages(repoName)
if out, _, err = runCommandWithOutput(commitCmd); err != nil { if out, _, err = runCommandWithOutput(commitCmd); err != nil {
c.Fatalf("failed to commit container: %s, %v", out, err) c.Fatalf("failed to commit container: %s, %v", out, err)
} }
inspectCmd = exec.Command(dockerBinary, "inspect", repoName) inspectCmd := exec.Command(dockerBinary, "inspect", repoName)
before, _, err := runCommandWithOutput(inspectCmd) before, _, err := runCommandWithOutput(inspectCmd)
if err != nil { if err != nil {
c.Fatalf("the repo should exist before saving it: %s, %v", before, err) c.Fatalf("the repo should exist before saving it: %s, %v", before, err)
@ -251,7 +226,6 @@ func (s *DockerSuite) TestSaveAndLoadRepoFlags(c *check.C) {
if before != after { if before != after {
c.Fatalf("inspect is not the same after a save / load") c.Fatalf("inspect is not the same after a save / load")
} }
} }
func (s *DockerSuite) TestSaveMultipleNames(c *check.C) { func (s *DockerSuite) TestSaveMultipleNames(c *check.C) {

View File

@ -7,7 +7,6 @@ import (
"fmt" "fmt"
"os" "os"
"os/exec" "os/exec"
"strings"
"github.com/docker/docker/vendor/src/github.com/kr/pty" "github.com/docker/docker/vendor/src/github.com/kr/pty"
"github.com/go-check/check" "github.com/go-check/check"
@ -15,27 +14,21 @@ import (
// save a repo and try to load it using stdout // save a repo and try to load it using stdout
func (s *DockerSuite) TestSaveAndLoadRepoStdout(c *check.C) { func (s *DockerSuite) TestSaveAndLoadRepoStdout(c *check.C) {
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true") name := "test-save-and-load-repo-stdout"
runCmd := exec.Command(dockerBinary, "run", "--name", name, "busybox", "true")
out, _, err := runCommandWithOutput(runCmd) out, _, err := runCommandWithOutput(runCmd)
if err != nil { if err != nil {
c.Fatalf("failed to create a container: %s, %v", out, err) c.Fatalf("failed to create a container: %s, %v", out, err)
} }
cleanedContainerID := strings.TrimSpace(out)
repoName := "foobar-save-load-test" repoName := "foobar-save-load-test"
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID) commitCmd := exec.Command(dockerBinary, "commit", name, repoName)
if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
c.Fatalf("output should've been a container id: %s, %v", out, err)
}
commitCmd := exec.Command(dockerBinary, "commit", cleanedContainerID, repoName)
if out, _, err = runCommandWithOutput(commitCmd); err != nil { if out, _, err = runCommandWithOutput(commitCmd); err != nil {
c.Fatalf("failed to commit container: %s, %v", out, err) c.Fatalf("failed to commit container: %s, %v", out, err)
} }
inspectCmd = exec.Command(dockerBinary, "inspect", repoName) inspectCmd := exec.Command(dockerBinary, "inspect", repoName)
before, _, err := runCommandWithOutput(inspectCmd) before, _, err := runCommandWithOutput(inspectCmd)
if err != nil { if err != nil {
c.Fatalf("the repo should exist before saving it: %s, %v", before, err) c.Fatalf("the repo should exist before saving it: %s, %v", before, err)
@ -66,7 +59,6 @@ func (s *DockerSuite) TestSaveAndLoadRepoStdout(c *check.C) {
c.Fatalf("inspect is not the same after a save / load") c.Fatalf("inspect is not the same after a save / load")
} }
deleteContainer(cleanedContainerID)
deleteImages(repoName) deleteImages(repoName)
os.Remove("/tmp/foobar-save-load-test.tar") os.Remove("/tmp/foobar-save-load-test.tar")