mirror of
https://github.com/moby/moby.git
synced 2025-07-29 07:21:35 +03:00
Clean integration-cli/utils.go from most of its content
Most of the code is now on pkg/integration. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
@ -21,6 +21,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/integration-cli/daemon"
|
||||
"github.com/docker/docker/pkg/integration"
|
||||
"github.com/docker/docker/pkg/integration/checker"
|
||||
icmd "github.com/docker/docker/pkg/integration/cmd"
|
||||
"github.com/docker/docker/pkg/mount"
|
||||
@ -235,11 +236,7 @@ func (s *DockerDaemonSuite) TestDaemonStartBridgeWithoutIPAssociation(c *check.C
|
||||
s.d.Stop(c)
|
||||
|
||||
// now we will remove the ip from docker0 and then try starting the daemon
|
||||
ipCmd := exec.Command("ip", "addr", "flush", "dev", "docker0")
|
||||
stdout, stderr, _, err := runCommandWithStdoutStderr(ipCmd)
|
||||
if err != nil {
|
||||
c.Fatalf("failed to remove docker0 IP association: %v, stdout: %q, stderr: %q", err, stdout, stderr)
|
||||
}
|
||||
icmd.RunCommand("ip", "addr", "flush", "dev", "docker0").Assert(c, icmd.Success)
|
||||
|
||||
if err := s.d.StartWithError(); err != nil {
|
||||
warning := "**WARNING: Docker bridge network in bad state--delete docker0 bridge interface to fix"
|
||||
@ -668,24 +665,16 @@ func (s *DockerDaemonSuite) TestDaemonBridgeIP(c *check.C) {
|
||||
defer d.Restart(c)
|
||||
|
||||
ifconfigSearchString := ip.String()
|
||||
ifconfigCmd := exec.Command("ifconfig", defaultNetworkBridge)
|
||||
out, _, _, err := runCommandWithStdoutStderr(ifconfigCmd)
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
c.Assert(strings.Contains(out, ifconfigSearchString), check.Equals, true,
|
||||
check.Commentf("ifconfig output should have contained %q, but was %q",
|
||||
ifconfigSearchString, out))
|
||||
icmd.RunCommand("ifconfig", defaultNetworkBridge).Assert(c, icmd.Expected{
|
||||
Out: ifconfigSearchString,
|
||||
})
|
||||
|
||||
ipTablesSearchString := bridgeIPNet.String()
|
||||
ipTablesCmd := exec.Command("iptables", "-t", "nat", "-nvL")
|
||||
out, _, err = runCommandWithOutput(ipTablesCmd)
|
||||
c.Assert(err, check.IsNil)
|
||||
icmd.RunCommand("iptables", "-t", "nat", "-nvL").Assert(c, icmd.Expected{
|
||||
Out: ipTablesSearchString,
|
||||
})
|
||||
|
||||
c.Assert(strings.Contains(out, ipTablesSearchString), check.Equals, true,
|
||||
check.Commentf("iptables output should have contained %q, but was %q",
|
||||
ipTablesSearchString, out))
|
||||
|
||||
out, err = d.Cmd("run", "-d", "--name", "test", "busybox", "top")
|
||||
_, err := d.Cmd("run", "-d", "--name", "test", "busybox", "top")
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
containerIP, err := d.FindContainerIP("test")
|
||||
@ -706,24 +695,15 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithBridgeIPChange(c *check.C) {
|
||||
bridgeIP := "192.169.100.1/24"
|
||||
_, bridgeIPNet, _ := net.ParseCIDR(bridgeIP)
|
||||
|
||||
ipCmd := exec.Command("ifconfig", "docker0", bridgeIP)
|
||||
stdout, stderr, _, err := runCommandWithStdoutStderr(ipCmd)
|
||||
if err != nil {
|
||||
c.Fatalf("failed to change docker0's IP association: %v, stdout: %q, stderr: %q", err, stdout, stderr)
|
||||
}
|
||||
icmd.RunCommand("ifconfig", "docker0", bridgeIP).Assert(c, icmd.Success)
|
||||
|
||||
s.d.Start(c, "--bip", bridgeIP)
|
||||
|
||||
//check if the iptables contains new bridgeIP MASQUERADE rule
|
||||
ipTablesSearchString := bridgeIPNet.String()
|
||||
ipTablesCmd := exec.Command("iptables", "-t", "nat", "-nvL")
|
||||
out, _, err := runCommandWithOutput(ipTablesCmd)
|
||||
if err != nil {
|
||||
c.Fatalf("Could not run iptables -nvL: %s, %v", out, err)
|
||||
}
|
||||
if !strings.Contains(out, ipTablesSearchString) {
|
||||
c.Fatalf("iptables output should have contained new MASQUERADE rule with IP %q, but was %q", ipTablesSearchString, out)
|
||||
}
|
||||
icmd.RunCommand("iptables", "-t", "nat", "-nvL").Assert(c, icmd.Expected{
|
||||
Out: ipTablesSearchString,
|
||||
})
|
||||
}
|
||||
|
||||
func (s *DockerDaemonSuite) TestDaemonBridgeFixedCidr(c *check.C) {
|
||||
@ -1908,7 +1888,7 @@ func (s *DockerDaemonSuite) TestDaemonCgroupParent(c *check.C) {
|
||||
|
||||
out, err := s.d.Cmd("run", "--name", name, "busybox", "cat", "/proc/self/cgroup")
|
||||
c.Assert(err, checker.IsNil)
|
||||
cgroupPaths := parseCgroupPaths(string(out))
|
||||
cgroupPaths := integration.ParseCgroupPaths(string(out))
|
||||
c.Assert(len(cgroupPaths), checker.Not(checker.Equals), 0, check.Commentf("unexpected output - %q", string(out)))
|
||||
out, err = s.d.Cmd("inspect", "-f", "{{.Id}}", name)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
Reference in New Issue
Block a user