Browse code

Merge pull request #14765 from runcom/fix-dockerCmd-refactor

Refactor missed dockerCmd changes

Brian Goff authored on 2015/07/22 00:53:28
Showing 1 changed files
... ...
@@ -33,12 +33,7 @@ func (s *DockerSuite) TestRunEchoStdout(c *check.C) {
33 33
 
34 34
 // "test" should be printed
35 35
 func (s *DockerSuite) TestRunEchoStdoutWithMemoryLimit(c *check.C) {
36
-	runCmd := exec.Command(dockerBinary, "run", "-m", "16m", "busybox", "echo", "test")
37
-	out, _, _, err := runCommandWithStdoutStderr(runCmd)
38
-	if err != nil {
39
-		c.Fatalf("failed to run container: %v, output: %q", err, out)
40
-	}
41
-
36
+	out, _, _ := dockerCmdWithStdoutStderr(c, "run", "-m", "16m", "busybox", "echo", "test")
42 37
 	out = strings.Trim(out, "\r\n")
43 38
 
44 39
 	if expected := "test"; out != expected {
... ...
@@ -73,12 +68,7 @@ func (s *DockerSuite) TestRunEchoStdoutWitCPULimit(c *check.C) {
73 73
 
74 74
 // "test" should be printed
75 75
 func (s *DockerSuite) TestRunEchoStdoutWithCPUAndMemoryLimit(c *check.C) {
76
-	runCmd := exec.Command(dockerBinary, "run", "-c", "1000", "-m", "16m", "busybox", "echo", "test")
77
-	out, _, _, err := runCommandWithStdoutStderr(runCmd)
78
-	if err != nil {
79
-		c.Fatalf("failed to run container: %v, output: %q", err, out)
80
-	}
81
-
76
+	out, _, _ := dockerCmdWithStdoutStderr(c, "run", "-c", "1000", "-m", "16m", "busybox", "echo", "test")
82 77
 	if out != "test\n" {
83 78
 		c.Errorf("container should've printed 'test', got %q instead", out)
84 79
 	}
... ...
@@ -931,12 +921,7 @@ func (s *DockerSuite) TestRunDnsDefaultOptions(c *check.C) {
931 931
 }
932 932
 
933 933
 func (s *DockerSuite) TestRunDnsOptions(c *check.C) {
934
-	cmd := exec.Command(dockerBinary, "run", "--dns=127.0.0.1", "--dns-search=mydomain", "busybox", "cat", "/etc/resolv.conf")
935
-
936
-	out, stderr, _, err := runCommandWithStdoutStderr(cmd)
937
-	if err != nil {
938
-		c.Fatal(err, out)
939
-	}
934
+	out, stderr, _ := dockerCmdWithStdoutStderr(c, "run", "--dns=127.0.0.1", "--dns-search=mydomain", "busybox", "cat", "/etc/resolv.conf")
940 935
 
941 936
 	// The client will get a warning on stderr when setting DNS to a localhost address; verify this:
942 937
 	if !strings.Contains(stderr, "Localhost DNS setting") {
... ...
@@ -948,12 +933,7 @@ func (s *DockerSuite) TestRunDnsOptions(c *check.C) {
948 948
 		c.Fatalf("expected 'nameserver 127.0.0.1 search mydomain', but says: %q", actual)
949 949
 	}
950 950
 
951
-	cmd = exec.Command(dockerBinary, "run", "--dns=127.0.0.1", "--dns-search=.", "busybox", "cat", "/etc/resolv.conf")
952
-
953
-	out, _, _, err = runCommandWithStdoutStderr(cmd)
954
-	if err != nil {
955
-		c.Fatal(err, out)
956
-	}
951
+	out, stderr, _ = dockerCmdWithStdoutStderr(c, "run", "--dns=127.0.0.1", "--dns-search=.", "busybox", "cat", "/etc/resolv.conf")
957 952
 
958 953
 	actual = strings.Replace(strings.Trim(strings.Trim(out, "\r\n"), " "), "\n", " ", -1)
959 954
 	if actual != "nameserver 127.0.0.1" {
... ...
@@ -1923,15 +1903,11 @@ func (s *DockerSuite) TestRunExposePort(c *check.C) {
1923 1923
 
1924 1924
 func (s *DockerSuite) TestRunUnknownCommand(c *check.C) {
1925 1925
 	testRequires(c, NativeExecDriver)
1926
-	runCmd := exec.Command(dockerBinary, "create", "busybox", "/bin/nada")
1927
-	cID, _, _, err := runCommandWithStdoutStderr(runCmd)
1928
-	if err != nil {
1929
-		c.Fatalf("Failed to create container: %v, output: %q", err, cID)
1930
-	}
1931
-	cID = strings.TrimSpace(cID)
1926
+	out, _, _ := dockerCmdWithStdoutStderr(c, "create", "busybox", "/bin/nada")
1932 1927
 
1933
-	runCmd = exec.Command(dockerBinary, "start", cID)
1934
-	_, _, _, _ = runCommandWithStdoutStderr(runCmd)
1928
+	cID := strings.TrimSpace(out)
1929
+	_, _, err := dockerCmdWithError(c, "start", cID)
1930
+	c.Assert(err, check.NotNil)
1935 1931
 
1936 1932
 	rc, err := inspectField(cID, "State.ExitCode")
1937 1933
 	c.Assert(err, check.IsNil)