diff --git a/integration/daemon/daemon_linux_test.go b/integration/daemon/daemon_linux_test.go new file mode 100644 index 0000000000..591cba531d --- /dev/null +++ b/integration/daemon/daemon_linux_test.go @@ -0,0 +1,36 @@ +package daemon // import "github.com/docker/docker/integration/daemon" + +import ( + "testing" + + "github.com/docker/docker/testutil" + "github.com/docker/docker/testutil/daemon" + "gotest.tools/v3/icmd" +) + +func TestDaemonDefaultBridgeWithFixedCidrButNoBip(t *testing.T) { + ctx := testutil.StartSpan(baseContext, t) + + bridgeName := "ext-bridge1" + d := daemon.New(t, daemon.WithEnvVars("DOCKER_TEST_CREATE_DEFAULT_BRIDGE="+bridgeName)) + defer func() { + d.Stop(t) + d.Cleanup(t) + }() + + defer func() { + // No need to clean up when running this test in rootless mode, as the + // interface is deleted when the daemon is stopped and the netns + // reclaimed by the kernel. + if !testEnv.IsRootless() { + deleteInterface(t, bridgeName) + } + }() + d.StartWithBusybox(ctx, t, "--bridge", bridgeName, "--fixed-cidr", "192.168.130.0/24") +} + +func deleteInterface(t *testing.T, ifName string) { + icmd.RunCommand("ip", "link", "delete", ifName).Assert(t, icmd.Success) + icmd.RunCommand("iptables", "-t", "nat", "--flush").Assert(t, icmd.Success) + icmd.RunCommand("iptables", "--flush").Assert(t, icmd.Success) +} diff --git a/integration/daemon/daemon_test.go b/integration/daemon/daemon_test.go index 608f8176ad..8f15776fa4 100644 --- a/integration/daemon/daemon_test.go +++ b/integration/daemon/daemon_test.go @@ -699,32 +699,3 @@ func testLiveRestoreUserChainsSetup(t *testing.T) { assert.Check(t, is.Equal(strings.TrimSpace(result.Stdout()), "-A FORWARD -j DOCKER-USER"), "the jump to DOCKER-USER should be the first rule in the FORWARD chain") }) } - -func TestDaemonDefaultBridgeWithFixedCidrButNoBip(t *testing.T) { - skip.If(t, runtime.GOOS == "windows") - - ctx := testutil.StartSpan(baseContext, t) - - bridgeName := "ext-bridge1" - d := daemon.New(t, daemon.WithEnvVars("DOCKER_TEST_CREATE_DEFAULT_BRIDGE="+bridgeName)) - defer func() { - d.Stop(t) - d.Cleanup(t) - }() - - defer func() { - // No need to clean up when running this test in rootless mode, as the - // interface is deleted when the daemon is stopped and the netns - // reclaimed by the kernel. - if !testEnv.IsRootless() { - deleteInterface(t, bridgeName) - } - }() - d.StartWithBusybox(ctx, t, "--bridge", bridgeName, "--fixed-cidr", "192.168.130.0/24") -} - -func deleteInterface(t *testing.T, ifName string) { - icmd.RunCommand("ip", "link", "delete", ifName).Assert(t, icmd.Success) - icmd.RunCommand("iptables", "-t", "nat", "--flush").Assert(t, icmd.Success) - icmd.RunCommand("iptables", "--flush").Assert(t, icmd.Success) -}