浏览代码

Merge pull request #10455 from ashahab-altiscale/9875-lxc-symlink

Fixes symlink, container size, and kmsg tests
Michael Crosby 10 年之前
父节点
当前提交
382f187b1a

+ 16 - 4
integration-cli/docker_cli_diff_test.go

@@ -89,10 +89,22 @@ func TestDiffEnsureOnlyKmsgAndPtmx(t *testing.T) {
 	deleteContainer(cleanCID)
 
 	expected := map[string]bool{
-		"C /dev":      true,
-		"A /dev/full": true, // busybox
-		"C /dev/ptmx": true, // libcontainer
-		"A /dev/kmsg": true, // lxc
+		"C /dev":         true,
+		"A /dev/full":    true, // busybox
+		"C /dev/ptmx":    true, // libcontainer
+		"A /dev/kmsg":    true, // lxc
+		"A /dev/fd":      true,
+		"A /dev/fuse":    true,
+		"A /dev/ptmx":    true,
+		"A /dev/null":    true,
+		"A /dev/random":  true,
+		"A /dev/stdout":  true,
+		"A /dev/stderr":  true,
+		"A /dev/tty1":    true,
+		"A /dev/stdin":   true,
+		"A /dev/tty":     true,
+		"A /dev/urandom": true,
+		"A /dev/zero":    true,
 	}
 
 	for _, line := range strings.Split(out, "\n") {

+ 15 - 1
integration-cli/docker_cli_ps_test.go

@@ -1,7 +1,9 @@
 package main
 
 import (
+	"fmt"
 	"os/exec"
+	"strconv"
 	"strings"
 	"testing"
 	"time"
@@ -243,6 +245,18 @@ func assertContainerList(out string, expected []string) bool {
 }
 
 func TestPsListContainersSize(t *testing.T) {
+	cmd := exec.Command(dockerBinary, "run", "-d", "busybox", "echo", "hello")
+	runCommandWithOutput(cmd)
+	cmd = exec.Command(dockerBinary, "ps", "-s", "-n=1")
+	base_out, _, err := runCommandWithOutput(cmd)
+	base_lines := strings.Split(strings.Trim(base_out, "\n "), "\n")
+	base_sizeIndex := strings.Index(base_lines[0], "SIZE")
+	base_foundSize := base_lines[1][base_sizeIndex:]
+	base_bytes, err := strconv.Atoi(strings.Split(base_foundSize, " ")[0])
+	if err != nil {
+		t.Fatal(err)
+	}
+
 	name := "test_size"
 	runCmd := exec.Command(dockerBinary, "run", "--name", name, "busybox", "sh", "-c", "echo 1 > test")
 	out, _, err := runCommandWithOutput(runCmd)
@@ -275,7 +289,7 @@ func TestPsListContainersSize(t *testing.T) {
 	if foundID != id[:12] {
 		t.Fatalf("Expected id %s, got %s", id[:12], foundID)
 	}
-	expectedSize := "2 B"
+	expectedSize := fmt.Sprintf("%d B", (2 + base_bytes))
 	foundSize := lines[1][sizeIndex:]
 	if foundSize != expectedSize {
 		t.Fatalf("Expected size %q, got %q", expectedSize, foundSize)

+ 3 - 3
integration-cli/docker_cli_run_test.go

@@ -572,14 +572,14 @@ func TestRunCreateVolume(t *testing.T) {
 func TestRunCreateVolumeWithSymlink(t *testing.T) {
 	buildCmd := exec.Command(dockerBinary, "build", "-t", "docker-test-createvolumewithsymlink", "-")
 	buildCmd.Stdin = strings.NewReader(`FROM busybox
-		RUN mkdir /foo && ln -s /foo /bar`)
+		RUN ln -s home /bar`)
 	buildCmd.Dir = workingDirectory
 	err := buildCmd.Run()
 	if err != nil {
 		t.Fatalf("could not build 'docker-test-createvolumewithsymlink': %v", err)
 	}
 
-	cmd := exec.Command(dockerBinary, "run", "-v", "/bar/foo", "--name", "test-createvolumewithsymlink", "docker-test-createvolumewithsymlink", "sh", "-c", "mount | grep -q /foo/foo")
+	cmd := exec.Command(dockerBinary, "run", "-v", "/bar/foo", "--name", "test-createvolumewithsymlink", "docker-test-createvolumewithsymlink", "sh", "-c", "mount | grep -q /home/foo")
 	exitCode, err := runCommand(cmd)
 	if err != nil || exitCode != 0 {
 		t.Fatalf("[run] err: %v, exitcode: %d", err, exitCode)
@@ -615,7 +615,7 @@ func TestRunVolumesFromSymlinkPath(t *testing.T) {
 	name := "docker-test-volumesfromsymlinkpath"
 	buildCmd := exec.Command(dockerBinary, "build", "-t", name, "-")
 	buildCmd.Stdin = strings.NewReader(`FROM busybox
-		RUN mkdir /baz && ln -s /baz /foo
+		RUN ln -s home /foo
 		VOLUME ["/foo/bar"]`)
 	buildCmd.Dir = workingDirectory
 	err := buildCmd.Run()