1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Use suite for integration-cli

It prints test name and duration for each test.
Also performs deleteAllContainers after each test.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
Alexander Morozov 2015-04-18 09:46:47 -07:00
parent 6dcdf832a3
commit dc944ea7e4
60 changed files with 3746 additions and 4807 deletions

View file

@ -3,16 +3,17 @@ package main
import (
"os/exec"
"strings"
"testing"
"github.com/go-check/check"
)
// ensure that an added file shows up in docker diff
func TestDiffFilenameShownInOutput(t *testing.T) {
func (s *DockerSuite) TestDiffFilenameShownInOutput(c *check.C) {
containerCmd := `echo foo > /root/bar`
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", containerCmd)
out, _, err := runCommandWithOutput(runCmd)
if err != nil {
t.Fatalf("failed to start the container: %s, %v", out, err)
c.Fatalf("failed to start the container: %s, %v", out, err)
}
cleanCID := strings.TrimSpace(out)
@ -20,7 +21,7 @@ func TestDiffFilenameShownInOutput(t *testing.T) {
diffCmd := exec.Command(dockerBinary, "diff", cleanCID)
out, _, err = runCommandWithOutput(diffCmd)
if err != nil {
t.Fatalf("failed to run diff: %s %v", out, err)
c.Fatalf("failed to run diff: %s %v", out, err)
}
found := false
@ -31,15 +32,12 @@ func TestDiffFilenameShownInOutput(t *testing.T) {
}
}
if !found {
t.Errorf("couldn't find the new file in docker diff's output: %v", out)
c.Errorf("couldn't find the new file in docker diff's output: %v", out)
}
deleteContainer(cleanCID)
logDone("diff - check if created file shows up")
}
// test to ensure GH #3840 doesn't occur any more
func TestDiffEnsureDockerinitFilesAreIgnored(t *testing.T) {
func (s *DockerSuite) TestDiffEnsureDockerinitFilesAreIgnored(c *check.C) {
// this is a list of files which shouldn't show up in `docker diff`
dockerinitFiles := []string{"/etc/resolv.conf", "/etc/hostname", "/etc/hosts", "/.dockerinit", "/.dockerenv"}
@ -49,7 +47,7 @@ func TestDiffEnsureDockerinitFilesAreIgnored(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", containerCmd)
out, _, err := runCommandWithOutput(runCmd)
if err != nil {
t.Fatal(out, err)
c.Fatal(out, err)
}
cleanCID := strings.TrimSpace(out)
@ -57,26 +55,22 @@ func TestDiffEnsureDockerinitFilesAreIgnored(t *testing.T) {
diffCmd := exec.Command(dockerBinary, "diff", cleanCID)
out, _, err = runCommandWithOutput(diffCmd)
if err != nil {
t.Fatalf("failed to run diff: %s, %v", out, err)
c.Fatalf("failed to run diff: %s, %v", out, err)
}
deleteContainer(cleanCID)
for _, filename := range dockerinitFiles {
if strings.Contains(out, filename) {
t.Errorf("found file which should've been ignored %v in diff output", filename)
c.Errorf("found file which should've been ignored %v in diff output", filename)
}
}
}
logDone("diff - check if ignored files show up in diff")
}
func TestDiffEnsureOnlyKmsgAndPtmx(t *testing.T) {
func (s *DockerSuite) TestDiffEnsureOnlyKmsgAndPtmx(c *check.C) {
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sleep", "0")
out, _, err := runCommandWithOutput(runCmd)
if err != nil {
t.Fatal(out, err)
c.Fatal(out, err)
}
cleanCID := strings.TrimSpace(out)
@ -84,9 +78,8 @@ func TestDiffEnsureOnlyKmsgAndPtmx(t *testing.T) {
diffCmd := exec.Command(dockerBinary, "diff", cleanCID)
out, _, err = runCommandWithOutput(diffCmd)
if err != nil {
t.Fatalf("failed to run diff: %s, %v", out, err)
c.Fatalf("failed to run diff: %s, %v", out, err)
}
deleteContainer(cleanCID)
expected := map[string]bool{
"C /dev": true,
@ -109,9 +102,7 @@ func TestDiffEnsureOnlyKmsgAndPtmx(t *testing.T) {
for _, line := range strings.Split(out, "\n") {
if line != "" && !expected[line] {
t.Errorf("%q is shown in the diff but shouldn't", line)
c.Errorf("%q is shown in the diff but shouldn't", line)
}
}
logDone("diff - ensure that only kmsg and ptmx in diff")
}