Merge pull request #16363 from coolljt0725/fix_net_none_test
Fix --net none test closes #16356
This commit is contained in:
commit
7d5603e7cb
|
@ -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,
|
c.Assert(out, check.Equals, fmt.Sprintf("%s", stdout),
|
||||||
check.Commentf("There should be eth0 in container when --net=host when bridge network is disabled: %s", out))
|
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")
|
||||||
|
|
Loading…
Reference in New Issue