Browse code

Fix filenames for unix only integration-cli tests

Test suffix comes after the platform/arch.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>

Tonis Tiigi authored on 2015/01/14 07:31:25
Showing 6 changed files
1 1
deleted file mode 100644
... ...
@@ -1,59 +0,0 @@
1
-// +build !windows
2
-
3
-package main
4
-
5
-import (
6
-	"bufio"
7
-	"fmt"
8
-	"io/ioutil"
9
-	"os"
10
-	"os/exec"
11
-	"testing"
12
-	"time"
13
-	"unicode"
14
-
15
-	"github.com/kr/pty"
16
-)
17
-
18
-// #5979
19
-func TestEventsRedirectStdout(t *testing.T) {
20
-
21
-	since := time.Now().Unix()
22
-
23
-	dockerCmd(t, "run", "busybox", "true")
24
-
25
-	defer deleteAllContainers()
26
-
27
-	file, err := ioutil.TempFile("", "")
28
-	if err != nil {
29
-		t.Fatalf("could not create temp file: %v", err)
30
-	}
31
-	defer os.Remove(file.Name())
32
-
33
-	command := fmt.Sprintf("%s events --since=%d --until=%d > %s", dockerBinary, since, time.Now().Unix(), file.Name())
34
-	_, tty, err := pty.Open()
35
-	if err != nil {
36
-		t.Fatalf("Could not open pty: %v", err)
37
-	}
38
-	cmd := exec.Command("sh", "-c", command)
39
-	cmd.Stdin = tty
40
-	cmd.Stdout = tty
41
-	cmd.Stderr = tty
42
-	if err := cmd.Run(); err != nil {
43
-		t.Fatalf("run err for command %q: %v", command, err)
44
-	}
45
-
46
-	scanner := bufio.NewScanner(file)
47
-	for scanner.Scan() {
48
-		for _, c := range scanner.Text() {
49
-			if unicode.IsControl(c) {
50
-				t.Fatalf("found control character %v", []byte(string(c)))
51
-			}
52
-		}
53
-	}
54
-	if err := scanner.Err(); err != nil {
55
-		t.Fatalf("Scan err for command %q: %v", command, err)
56
-	}
57
-
58
-	logDone("events - redirect stdout")
59
-}
60 1
new file mode 100644
... ...
@@ -0,0 +1,59 @@
0
+// +build !windows
1
+
2
+package main
3
+
4
+import (
5
+	"bufio"
6
+	"fmt"
7
+	"io/ioutil"
8
+	"os"
9
+	"os/exec"
10
+	"testing"
11
+	"time"
12
+	"unicode"
13
+
14
+	"github.com/kr/pty"
15
+)
16
+
17
+// #5979
18
+func TestEventsRedirectStdout(t *testing.T) {
19
+
20
+	since := time.Now().Unix()
21
+
22
+	dockerCmd(t, "run", "busybox", "true")
23
+
24
+	defer deleteAllContainers()
25
+
26
+	file, err := ioutil.TempFile("", "")
27
+	if err != nil {
28
+		t.Fatalf("could not create temp file: %v", err)
29
+	}
30
+	defer os.Remove(file.Name())
31
+
32
+	command := fmt.Sprintf("%s events --since=%d --until=%d > %s", dockerBinary, since, time.Now().Unix(), file.Name())
33
+	_, tty, err := pty.Open()
34
+	if err != nil {
35
+		t.Fatalf("Could not open pty: %v", err)
36
+	}
37
+	cmd := exec.Command("sh", "-c", command)
38
+	cmd.Stdin = tty
39
+	cmd.Stdout = tty
40
+	cmd.Stderr = tty
41
+	if err := cmd.Run(); err != nil {
42
+		t.Fatalf("run err for command %q: %v", command, err)
43
+	}
44
+
45
+	scanner := bufio.NewScanner(file)
46
+	for scanner.Scan() {
47
+		for _, c := range scanner.Text() {
48
+			if unicode.IsControl(c) {
49
+				t.Fatalf("found control character %v", []byte(string(c)))
50
+			}
51
+		}
52
+	}
53
+	if err := scanner.Err(); err != nil {
54
+		t.Fatalf("Scan err for command %q: %v", command, err)
55
+	}
56
+
57
+	logDone("events - redirect stdout")
58
+}
0 59
deleted file mode 100644
... ...
@@ -1,93 +0,0 @@
1
-// +build !windows
2
-
3
-package main
4
-
5
-import (
6
-	"fmt"
7
-	"io/ioutil"
8
-	"os"
9
-	"os/exec"
10
-	"path/filepath"
11
-	"strings"
12
-	"testing"
13
-	"time"
14
-
15
-	"github.com/docker/docker/pkg/mount"
16
-	"github.com/kr/pty"
17
-)
18
-
19
-// #6509
20
-func TestRunRedirectStdout(t *testing.T) {
21
-
22
-	defer deleteAllContainers()
23
-
24
-	checkRedirect := func(command string) {
25
-		_, tty, err := pty.Open()
26
-		if err != nil {
27
-			t.Fatalf("Could not open pty: %v", err)
28
-		}
29
-		cmd := exec.Command("sh", "-c", command)
30
-		cmd.Stdin = tty
31
-		cmd.Stdout = tty
32
-		cmd.Stderr = tty
33
-		ch := make(chan struct{})
34
-		if err := cmd.Start(); err != nil {
35
-			t.Fatalf("start err: %v", err)
36
-		}
37
-		go func() {
38
-			if err := cmd.Wait(); err != nil {
39
-				t.Fatalf("wait err=%v", err)
40
-			}
41
-			close(ch)
42
-		}()
43
-
44
-		select {
45
-		case <-time.After(10 * time.Second):
46
-			t.Fatal("command timeout")
47
-		case <-ch:
48
-		}
49
-	}
50
-
51
-	checkRedirect(dockerBinary + " run -i busybox cat /etc/passwd | grep -q root")
52
-	checkRedirect(dockerBinary + " run busybox cat /etc/passwd | grep -q root")
53
-
54
-	logDone("run - redirect stdout")
55
-}
56
-
57
-// Test recursive bind mount works by default
58
-func TestRunWithVolumesIsRecursive(t *testing.T) {
59
-	tmpDir, err := ioutil.TempDir("", "docker_recursive_mount_test")
60
-	if err != nil {
61
-		t.Fatal(err)
62
-	}
63
-
64
-	defer os.RemoveAll(tmpDir)
65
-
66
-	// Create a temporary tmpfs mount.
67
-	tmpfsDir := filepath.Join(tmpDir, "tmpfs")
68
-	if err := os.MkdirAll(tmpfsDir, 0777); err != nil {
69
-		t.Fatalf("failed to mkdir at %s - %s", tmpfsDir, err)
70
-	}
71
-	if err := mount.Mount("tmpfs", tmpfsDir, "tmpfs", ""); err != nil {
72
-		t.Fatalf("failed to create a tmpfs mount at %s - %s", tmpfsDir, err)
73
-	}
74
-
75
-	f, err := ioutil.TempFile(tmpfsDir, "touch-me")
76
-	if err != nil {
77
-		t.Fatal(err)
78
-	}
79
-	defer f.Close()
80
-
81
-	runCmd := exec.Command(dockerBinary, "run", "--name", "test-data", "--volume", fmt.Sprintf("%s:/tmp:ro", tmpDir), "busybox:latest", "ls", "/tmp/tmpfs")
82
-	out, stderr, exitCode, err := runCommandWithStdoutStderr(runCmd)
83
-	if err != nil && exitCode != 0 {
84
-		t.Fatal(out, stderr, err)
85
-	}
86
-	if !strings.Contains(out, filepath.Base(f.Name())) {
87
-		t.Fatal("Recursive bind mount test failed. Expected file not found")
88
-	}
89
-
90
-	deleteAllContainers()
91
-
92
-	logDone("run - volumes are bind mounted recursively")
93
-}
94 1
new file mode 100644
... ...
@@ -0,0 +1,93 @@
0
+// +build !windows
1
+
2
+package main
3
+
4
+import (
5
+	"fmt"
6
+	"io/ioutil"
7
+	"os"
8
+	"os/exec"
9
+	"path/filepath"
10
+	"strings"
11
+	"testing"
12
+	"time"
13
+
14
+	"github.com/docker/docker/pkg/mount"
15
+	"github.com/kr/pty"
16
+)
17
+
18
+// #6509
19
+func TestRunRedirectStdout(t *testing.T) {
20
+
21
+	defer deleteAllContainers()
22
+
23
+	checkRedirect := func(command string) {
24
+		_, tty, err := pty.Open()
25
+		if err != nil {
26
+			t.Fatalf("Could not open pty: %v", err)
27
+		}
28
+		cmd := exec.Command("sh", "-c", command)
29
+		cmd.Stdin = tty
30
+		cmd.Stdout = tty
31
+		cmd.Stderr = tty
32
+		ch := make(chan struct{})
33
+		if err := cmd.Start(); err != nil {
34
+			t.Fatalf("start err: %v", err)
35
+		}
36
+		go func() {
37
+			if err := cmd.Wait(); err != nil {
38
+				t.Fatalf("wait err=%v", err)
39
+			}
40
+			close(ch)
41
+		}()
42
+
43
+		select {
44
+		case <-time.After(10 * time.Second):
45
+			t.Fatal("command timeout")
46
+		case <-ch:
47
+		}
48
+	}
49
+
50
+	checkRedirect(dockerBinary + " run -i busybox cat /etc/passwd | grep -q root")
51
+	checkRedirect(dockerBinary + " run busybox cat /etc/passwd | grep -q root")
52
+
53
+	logDone("run - redirect stdout")
54
+}
55
+
56
+// Test recursive bind mount works by default
57
+func TestRunWithVolumesIsRecursive(t *testing.T) {
58
+	tmpDir, err := ioutil.TempDir("", "docker_recursive_mount_test")
59
+	if err != nil {
60
+		t.Fatal(err)
61
+	}
62
+
63
+	defer os.RemoveAll(tmpDir)
64
+
65
+	// Create a temporary tmpfs mount.
66
+	tmpfsDir := filepath.Join(tmpDir, "tmpfs")
67
+	if err := os.MkdirAll(tmpfsDir, 0777); err != nil {
68
+		t.Fatalf("failed to mkdir at %s - %s", tmpfsDir, err)
69
+	}
70
+	if err := mount.Mount("tmpfs", tmpfsDir, "tmpfs", ""); err != nil {
71
+		t.Fatalf("failed to create a tmpfs mount at %s - %s", tmpfsDir, err)
72
+	}
73
+
74
+	f, err := ioutil.TempFile(tmpfsDir, "touch-me")
75
+	if err != nil {
76
+		t.Fatal(err)
77
+	}
78
+	defer f.Close()
79
+
80
+	runCmd := exec.Command(dockerBinary, "run", "--name", "test-data", "--volume", fmt.Sprintf("%s:/tmp:ro", tmpDir), "busybox:latest", "ls", "/tmp/tmpfs")
81
+	out, stderr, exitCode, err := runCommandWithStdoutStderr(runCmd)
82
+	if err != nil && exitCode != 0 {
83
+		t.Fatal(out, stderr, err)
84
+	}
85
+	if !strings.Contains(out, filepath.Base(f.Name())) {
86
+		t.Fatal("Recursive bind mount test failed. Expected file not found")
87
+	}
88
+
89
+	deleteAllContainers()
90
+
91
+	logDone("run - volumes are bind mounted recursively")
92
+}
0 93
deleted file mode 100644
... ...
@@ -1,102 +0,0 @@
1
-// +build !windows
2
-
3
-package main
4
-
5
-import (
6
-	"bytes"
7
-	"fmt"
8
-	"os"
9
-	"os/exec"
10
-	"testing"
11
-
12
-	"github.com/docker/docker/vendor/src/github.com/kr/pty"
13
-)
14
-
15
-// save a repo and try to load it using stdout
16
-func TestSaveAndLoadRepoStdout(t *testing.T) {
17
-	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true")
18
-	out, _, err := runCommandWithOutput(runCmd)
19
-	if err != nil {
20
-		t.Fatalf("failed to create a container: %s, %v", out, err)
21
-	}
22
-
23
-	cleanedContainerID := stripTrailingCharacters(out)
24
-
25
-	repoName := "foobar-save-load-test"
26
-
27
-	inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID)
28
-	if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
29
-		t.Fatalf("output should've been a container id: %s, %v", out, err)
30
-	}
31
-
32
-	commitCmd := exec.Command(dockerBinary, "commit", cleanedContainerID, repoName)
33
-	if out, _, err = runCommandWithOutput(commitCmd); err != nil {
34
-		t.Fatalf("failed to commit container: %s, %v", out, err)
35
-	}
36
-
37
-	inspectCmd = exec.Command(dockerBinary, "inspect", repoName)
38
-	before, _, err := runCommandWithOutput(inspectCmd)
39
-	if err != nil {
40
-		t.Fatalf("the repo should exist before saving it: %s, %v", before, err)
41
-	}
42
-
43
-	saveCmdTemplate := `%v save %v > /tmp/foobar-save-load-test.tar`
44
-	saveCmdFinal := fmt.Sprintf(saveCmdTemplate, dockerBinary, repoName)
45
-	saveCmd := exec.Command("bash", "-c", saveCmdFinal)
46
-	if out, _, err = runCommandWithOutput(saveCmd); err != nil {
47
-		t.Fatalf("failed to save repo: %s, %v", out, err)
48
-	}
49
-
50
-	deleteImages(repoName)
51
-
52
-	loadCmdFinal := `cat /tmp/foobar-save-load-test.tar | docker load`
53
-	loadCmd := exec.Command("bash", "-c", loadCmdFinal)
54
-	if out, _, err = runCommandWithOutput(loadCmd); err != nil {
55
-		t.Fatalf("failed to load repo: %s, %v", out, err)
56
-	}
57
-
58
-	inspectCmd = exec.Command(dockerBinary, "inspect", repoName)
59
-	after, _, err := runCommandWithOutput(inspectCmd)
60
-	if err != nil {
61
-		t.Fatalf("the repo should exist after loading it: %s %v", after, err)
62
-	}
63
-
64
-	if before != after {
65
-		t.Fatalf("inspect is not the same after a save / load")
66
-	}
67
-
68
-	deleteContainer(cleanedContainerID)
69
-	deleteImages(repoName)
70
-
71
-	os.Remove("/tmp/foobar-save-load-test.tar")
72
-
73
-	logDone("save - save/load a repo using stdout")
74
-
75
-	pty, tty, err := pty.Open()
76
-	if err != nil {
77
-		t.Fatalf("Could not open pty: %v", err)
78
-	}
79
-	cmd := exec.Command(dockerBinary, "save", repoName)
80
-	cmd.Stdin = tty
81
-	cmd.Stdout = tty
82
-	cmd.Stderr = tty
83
-	if err := cmd.Start(); err != nil {
84
-		t.Fatalf("start err: %v", err)
85
-	}
86
-	if err := cmd.Wait(); err == nil {
87
-		t.Fatal("did not break writing to a TTY")
88
-	}
89
-
90
-	buf := make([]byte, 1024)
91
-
92
-	n, err := pty.Read(buf)
93
-	if err != nil {
94
-		t.Fatal("could not read tty output")
95
-	}
96
-
97
-	if !bytes.Contains(buf[:n], []byte("Cowardly refusing")) {
98
-		t.Fatal("help output is not being yielded", out)
99
-	}
100
-
101
-	logDone("save - do not save to a tty")
102
-}
103 1
new file mode 100644
... ...
@@ -0,0 +1,102 @@
0
+// +build !windows
1
+
2
+package main
3
+
4
+import (
5
+	"bytes"
6
+	"fmt"
7
+	"os"
8
+	"os/exec"
9
+	"testing"
10
+
11
+	"github.com/docker/docker/vendor/src/github.com/kr/pty"
12
+)
13
+
14
+// save a repo and try to load it using stdout
15
+func TestSaveAndLoadRepoStdout(t *testing.T) {
16
+	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true")
17
+	out, _, err := runCommandWithOutput(runCmd)
18
+	if err != nil {
19
+		t.Fatalf("failed to create a container: %s, %v", out, err)
20
+	}
21
+
22
+	cleanedContainerID := stripTrailingCharacters(out)
23
+
24
+	repoName := "foobar-save-load-test"
25
+
26
+	inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID)
27
+	if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
28
+		t.Fatalf("output should've been a container id: %s, %v", out, err)
29
+	}
30
+
31
+	commitCmd := exec.Command(dockerBinary, "commit", cleanedContainerID, repoName)
32
+	if out, _, err = runCommandWithOutput(commitCmd); err != nil {
33
+		t.Fatalf("failed to commit container: %s, %v", out, err)
34
+	}
35
+
36
+	inspectCmd = exec.Command(dockerBinary, "inspect", repoName)
37
+	before, _, err := runCommandWithOutput(inspectCmd)
38
+	if err != nil {
39
+		t.Fatalf("the repo should exist before saving it: %s, %v", before, err)
40
+	}
41
+
42
+	saveCmdTemplate := `%v save %v > /tmp/foobar-save-load-test.tar`
43
+	saveCmdFinal := fmt.Sprintf(saveCmdTemplate, dockerBinary, repoName)
44
+	saveCmd := exec.Command("bash", "-c", saveCmdFinal)
45
+	if out, _, err = runCommandWithOutput(saveCmd); err != nil {
46
+		t.Fatalf("failed to save repo: %s, %v", out, err)
47
+	}
48
+
49
+	deleteImages(repoName)
50
+
51
+	loadCmdFinal := `cat /tmp/foobar-save-load-test.tar | docker load`
52
+	loadCmd := exec.Command("bash", "-c", loadCmdFinal)
53
+	if out, _, err = runCommandWithOutput(loadCmd); err != nil {
54
+		t.Fatalf("failed to load repo: %s, %v", out, err)
55
+	}
56
+
57
+	inspectCmd = exec.Command(dockerBinary, "inspect", repoName)
58
+	after, _, err := runCommandWithOutput(inspectCmd)
59
+	if err != nil {
60
+		t.Fatalf("the repo should exist after loading it: %s %v", after, err)
61
+	}
62
+
63
+	if before != after {
64
+		t.Fatalf("inspect is not the same after a save / load")
65
+	}
66
+
67
+	deleteContainer(cleanedContainerID)
68
+	deleteImages(repoName)
69
+
70
+	os.Remove("/tmp/foobar-save-load-test.tar")
71
+
72
+	logDone("save - save/load a repo using stdout")
73
+
74
+	pty, tty, err := pty.Open()
75
+	if err != nil {
76
+		t.Fatalf("Could not open pty: %v", err)
77
+	}
78
+	cmd := exec.Command(dockerBinary, "save", repoName)
79
+	cmd.Stdin = tty
80
+	cmd.Stdout = tty
81
+	cmd.Stderr = tty
82
+	if err := cmd.Start(); err != nil {
83
+		t.Fatalf("start err: %v", err)
84
+	}
85
+	if err := cmd.Wait(); err == nil {
86
+		t.Fatal("did not break writing to a TTY")
87
+	}
88
+
89
+	buf := make([]byte, 1024)
90
+
91
+	n, err := pty.Read(buf)
92
+	if err != nil {
93
+		t.Fatal("could not read tty output")
94
+	}
95
+
96
+	if !bytes.Contains(buf[:n], []byte("Cowardly refusing")) {
97
+		t.Fatal("help output is not being yielded", out)
98
+	}
99
+
100
+	logDone("save - do not save to a tty")
101
+}