mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fixes symlink, container size, and kmsg tests
Changes symlink, container size and kmsg tests to account for lxc driver. Signed-off-by: Abin Shahab <ashahab@altiscale.com> (github: ashahab-altiscale) Docker-DCO-1.1-Signed-off-by: Abin Shahab <ashahab@altiscale.com> (github: ashahab-altiscale)
This commit is contained in:
parent
c12fb48a8a
commit
29ac29a436
3 changed files with 34 additions and 8 deletions
|
@ -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") {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue