Browse Source

Fix --net none test closes #16356

Signed-off-by: Lei Jitang <leijitang@huawei.com>
Lei Jitang 9 years ago
parent
commit
0b2091132a
1 changed files with 12 additions and 4 deletions
  1. 12 4
      integration-cli/docker_cli_daemon_test.go

+ 12 - 4
integration-cli/docker_cli_daemon_test.go

@@ -3,6 +3,7 @@
 package main
 package main
 
 
 import (
 import (
+	"bytes"
 	"encoding/json"
 	"encoding/json"
 	"fmt"
 	"fmt"
 	"io/ioutil"
 	"io/ioutil"
@@ -1492,11 +1493,16 @@ func (s *DockerDaemonSuite) TestRunContainerWithBridgeNone(c *check.C) {
 	c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
 	c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
 	c.Assert(strings.Contains(out, "eth0"), check.Equals, false,
 	c.Assert(strings.Contains(out, "eth0"), check.Equals, false,
 		check.Commentf("There shouldn't be eth0 in container in bridge mode when bridge network is disabled: %s", out))
 		check.Commentf("There shouldn't be eth0 in container in bridge mode when bridge network is disabled: %s", out))
-
+	cmd := exec.Command("ip", "l")
+	stdout := bytes.NewBuffer(nil)
+	cmd.Stdout = stdout
+	if err := cmd.Run(); err != nil {
+		c.Fatal("Failed to get host network interface")
+	}
 	out, err = s.d.Cmd("run", "--rm", "--net=host", "busybox", "ip", "l")
 	out, err = s.d.Cmd("run", "--rm", "--net=host", "busybox", "ip", "l")
 	c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
 	c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
-	c.Assert(strings.Contains(out, "eth0"), check.Equals, true,
-		check.Commentf("There should be eth0 in container when --net=host when bridge network is disabled: %s", out))
+	c.Assert(out, check.Equals, fmt.Sprintf("%s", stdout),
+		check.Commentf("The network interfaces in container should be the same with host when --net=host when bridge network is disabled: %s", out))
 }
 }
 
 
 func (s *DockerDaemonSuite) TestDaemonRestartWithContainerRunning(t *check.C) {
 func (s *DockerDaemonSuite) TestDaemonRestartWithContainerRunning(t *check.C) {
@@ -1618,7 +1624,9 @@ func (s *DockerDaemonSuite) TestDaemonCorruptedSyslogAddress(c *check.C) {
 }
 }
 
 
 func (s *DockerDaemonSuite) TestDaemonWideLogConfig(c *check.C) {
 func (s *DockerDaemonSuite) TestDaemonWideLogConfig(c *check.C) {
-	c.Assert(s.d.Start("--log-driver=json-file", "--log-opt=max-size=1k"), check.IsNil)
+	if err := s.d.StartWithBusybox("--log-driver=json-file", "--log-opt=max-size=1k"); err != nil {
+		c.Fatal(err)
+	}
 	out, err := s.d.Cmd("run", "-d", "--name=logtest", "busybox", "top")
 	out, err := s.d.Cmd("run", "-d", "--name=logtest", "busybox", "top")
 	c.Assert(err, check.IsNil, check.Commentf("Output: %s, err: %v", out, err))
 	c.Assert(err, check.IsNil, check.Commentf("Output: %s, err: %v", out, err))
 	out, err = s.d.Cmd("inspect", "-f", "{{ .HostConfig.LogConfig.Config }}", "logtest")
 	out, err = s.d.Cmd("inspect", "-f", "{{ .HostConfig.LogConfig.Config }}", "logtest")