mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Merge pull request #50897 from thaJeztah/move_container_options
api/types/container: move container options to client
This commit is contained in:
@@ -236,8 +236,8 @@ func TestIPRangeAt64BitLimit(t *testing.T) {
|
||||
defer network.RemoveNoError(ctx, t, c, netName)
|
||||
|
||||
id := ctr.Create(ctx, t, c, ctr.WithNetworkMode(netName))
|
||||
defer c.ContainerRemove(ctx, id, containertypes.RemoveOptions{Force: true})
|
||||
err := c.ContainerStart(ctx, id, containertypes.StartOptions{})
|
||||
defer c.ContainerRemove(ctx, id, client.ContainerRemoveOptions{Force: true})
|
||||
err := c.ContainerStart(ctx, id, client.ContainerStartOptions{})
|
||||
assert.NilError(t, err)
|
||||
})
|
||||
}
|
||||
@@ -410,7 +410,7 @@ func TestPointToPoint(t *testing.T) {
|
||||
ctr.WithNetworkMode(netName),
|
||||
ctr.WithName(ctrName),
|
||||
)
|
||||
defer apiClient.ContainerRemove(ctx, id, containertypes.RemoveOptions{Force: true})
|
||||
defer apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
attachCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
||||
defer cancel()
|
||||
@@ -418,7 +418,7 @@ func TestPointToPoint(t *testing.T) {
|
||||
ctr.WithCmd([]string{"ping", "-c1", "-W3", ctrName}...),
|
||||
ctr.WithNetworkMode(netName),
|
||||
)
|
||||
defer apiClient.ContainerRemove(ctx, res.ContainerID, containertypes.RemoveOptions{Force: true})
|
||||
defer apiClient.ContainerRemove(ctx, res.ContainerID, client.ContainerRemoveOptions{Force: true})
|
||||
assert.Check(t, is.Equal(res.ExitCode, 0))
|
||||
assert.Check(t, is.Equal(res.Stderr.Len(), 0))
|
||||
assert.Check(t, is.Contains(res.Stdout.String(), "1 packets transmitted, 1 packets received"))
|
||||
@@ -462,7 +462,7 @@ func TestIsolated(t *testing.T) {
|
||||
ctr.WithNetworkMode(netName),
|
||||
ctr.WithName(ctrName),
|
||||
)
|
||||
defer apiClient.ContainerRemove(ctx, id, containertypes.RemoveOptions{Force: true})
|
||||
defer apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
ping := func(t *testing.T, ipv string) {
|
||||
t.Helper()
|
||||
@@ -472,7 +472,7 @@ func TestIsolated(t *testing.T) {
|
||||
ctr.WithCmd([]string{"ping", "-c1", "-W3", ipv, "ctr1"}...),
|
||||
ctr.WithNetworkMode(netName),
|
||||
)
|
||||
defer apiClient.ContainerRemove(ctx, res.ContainerID, containertypes.RemoveOptions{Force: true})
|
||||
defer apiClient.ContainerRemove(ctx, res.ContainerID, client.ContainerRemoveOptions{Force: true})
|
||||
if ipv == "-6" && networking.FirewalldRunning() {
|
||||
// FIXME(robmry) - this fails due to https://github.com/moby/moby/issues/49680
|
||||
if res.ExitCode != 1 {
|
||||
@@ -502,7 +502,7 @@ func TestEndpointWithCustomIfname(t *testing.T) {
|
||||
netlabel.Ifname: "foobar",
|
||||
},
|
||||
}))
|
||||
defer ctr.Remove(ctx, t, apiClient, ctrID, containertypes.RemoveOptions{Force: true})
|
||||
defer ctr.Remove(ctx, t, apiClient, ctrID, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
out, err := ctr.Output(ctx, apiClient, ctrID)
|
||||
assert.NilError(t, err)
|
||||
@@ -522,16 +522,16 @@ func TestPublishedPortAlreadyInUse(t *testing.T) {
|
||||
ctr.WithCmd("top"),
|
||||
ctr.WithExposedPorts("80/tcp"),
|
||||
ctr.WithPortMap(containertypes.PortMap{"80/tcp": {{HostPort: "8000"}}}))
|
||||
defer ctr.Remove(ctx, t, apiClient, ctr1, containertypes.RemoveOptions{Force: true})
|
||||
defer ctr.Remove(ctx, t, apiClient, ctr1, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
ctr2 := ctr.Create(ctx, t, apiClient,
|
||||
ctr.WithCmd("top"),
|
||||
ctr.WithRestartPolicy(containertypes.RestartPolicyAlways),
|
||||
ctr.WithExposedPorts("80/tcp"),
|
||||
ctr.WithPortMap(containertypes.PortMap{"80/tcp": {{HostPort: "8000"}}}))
|
||||
defer ctr.Remove(ctx, t, apiClient, ctr2, containertypes.RemoveOptions{Force: true})
|
||||
defer ctr.Remove(ctx, t, apiClient, ctr2, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
err := apiClient.ContainerStart(ctx, ctr2, containertypes.StartOptions{})
|
||||
err := apiClient.ContainerStart(ctx, ctr2, client.ContainerStartOptions{})
|
||||
assert.Assert(t, is.ErrorContains(err, "failed to set up container networking"))
|
||||
|
||||
inspect, err := apiClient.ContainerInspect(ctx, ctr2)
|
||||
@@ -566,7 +566,7 @@ func TestAllPortMappingsAreReturned(t *testing.T) {
|
||||
ctr.WithPortMap(containertypes.PortMap{"80/tcp": {{HostPort: "8000"}}}),
|
||||
ctr.WithEndpointSettings("testnetv4", &networktypes.EndpointSettings{}),
|
||||
ctr.WithEndpointSettings("testnetv6", &networktypes.EndpointSettings{}))
|
||||
defer ctr.Remove(ctx, t, apiClient, ctrID, containertypes.RemoveOptions{Force: true})
|
||||
defer ctr.Remove(ctx, t, apiClient, ctrID, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
inspect := ctr.Inspect(ctx, t, apiClient, ctrID)
|
||||
assert.DeepEqual(t, inspect.NetworkSettings.Ports, containertypes.PortMap{
|
||||
@@ -605,7 +605,7 @@ func TestFirewalldReloadNoZombies(t *testing.T) {
|
||||
ctr.WithPortMap(containertypes.PortMap{"80/tcp": {{HostPort: "8000"}}}))
|
||||
defer func() {
|
||||
if !removed {
|
||||
ctr.Remove(ctx, t, c, cid, containertypes.RemoveOptions{Force: true})
|
||||
ctr.Remove(ctx, t, c, cid, client.ContainerRemoveOptions{Force: true})
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -620,7 +620,7 @@ func TestFirewalldReloadNoZombies(t *testing.T) {
|
||||
"With container: expected rules for %s in: %s", bridgeName, resBeforeDel.Combined())
|
||||
|
||||
// Delete the container and its network.
|
||||
ctr.Remove(ctx, t, c, cid, containertypes.RemoveOptions{Force: true})
|
||||
ctr.Remove(ctx, t, c, cid, client.ContainerRemoveOptions{Force: true})
|
||||
network.RemoveNoError(ctx, t, c, nw)
|
||||
removed = true
|
||||
|
||||
@@ -666,7 +666,7 @@ func TestLegacyLink(t *testing.T) {
|
||||
ctr.WithCmd("httpd", "-f"),
|
||||
)
|
||||
|
||||
defer ctr.Remove(ctx, t, c, cid, containertypes.RemoveOptions{Force: true})
|
||||
defer ctr.Remove(ctx, t, c, cid, client.ContainerRemoveOptions{Force: true})
|
||||
insp := ctr.Inspect(ctx, t, c, cid)
|
||||
svrAddr := insp.NetworkSettings.Networks["bridge"].IPAddress
|
||||
|
||||
@@ -741,7 +741,7 @@ func TestRemoveLegacyLink(t *testing.T) {
|
||||
ctr.WithName(svrName),
|
||||
ctr.WithCmd("httpd", "-f"),
|
||||
)
|
||||
defer ctr.Remove(ctx, t, c, svrId, containertypes.RemoveOptions{Force: true})
|
||||
defer ctr.Remove(ctx, t, c, svrId, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
// Run a container linked to the http server.
|
||||
const svrAlias = "thealias"
|
||||
@@ -750,14 +750,14 @@ func TestRemoveLegacyLink(t *testing.T) {
|
||||
ctr.WithName(clientName),
|
||||
ctr.WithLinks(svrName+":"+svrAlias),
|
||||
)
|
||||
defer ctr.Remove(ctx, t, c, clientId, containertypes.RemoveOptions{Force: true})
|
||||
defer ctr.Remove(ctx, t, c, clientId, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
// Check the link works.
|
||||
res := ctr.ExecT(ctx, t, c, clientId, []string{"wget", "-T3", "http://" + svrName})
|
||||
assert.Check(t, is.Contains(res.Stderr(), "404 Not Found"))
|
||||
|
||||
// Remove the link ("docker rm --link client/thealias").
|
||||
err := c.ContainerRemove(ctx, clientName+"/"+svrAlias, containertypes.RemoveOptions{RemoveLinks: true})
|
||||
err := c.ContainerRemove(ctx, clientName+"/"+svrAlias, client.ContainerRemoveOptions{RemoveLinks: true})
|
||||
assert.Check(t, err)
|
||||
|
||||
// Check both containers are still running.
|
||||
@@ -797,7 +797,7 @@ func TestPortMappingRestore(t *testing.T) {
|
||||
ctr.WithRestartPolicy(containertypes.RestartPolicyUnlessStopped),
|
||||
ctr.WithCmd("httpd", "-f"),
|
||||
)
|
||||
defer func() { ctr.Remove(ctx, t, c, cid, containertypes.RemoveOptions{Force: true}) }()
|
||||
defer func() { ctr.Remove(ctx, t, c, cid, client.ContainerRemoveOptions{Force: true}) }()
|
||||
|
||||
check := func() {
|
||||
t.Helper()
|
||||
@@ -968,7 +968,7 @@ func TestEmptyPortBindingsBC(t *testing.T) {
|
||||
ctr.WithPortMap(containertypes.PortMap{"80/tcp": pbs}))
|
||||
c, err := apiClient.ContainerCreate(ctx, config.Config, config.HostConfig, config.NetworkingConfig, config.Platform, config.Name)
|
||||
assert.NilError(t, err)
|
||||
defer apiClient.ContainerRemove(ctx, c.ID, containertypes.RemoveOptions{Force: true})
|
||||
defer apiClient.ContainerRemove(ctx, c.ID, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
// Inspect the container and return its port bindings, along with
|
||||
// warnings returns on container create.
|
||||
@@ -1043,7 +1043,7 @@ func TestPortBindingBackfillingForOlderContainers(t *testing.T) {
|
||||
cid := ctr.Create(ctx, t, c,
|
||||
ctr.WithExposedPorts("80/tcp"),
|
||||
ctr.WithPortMap(containertypes.PortMap{"80/tcp": {}}))
|
||||
defer c.ContainerRemove(ctx, cid, containertypes.RemoveOptions{Force: true})
|
||||
defer c.ContainerRemove(ctx, cid, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
// Stop the daemon to safely tamper with the on-disk state.
|
||||
d.Stop(t)
|
||||
|
||||
@@ -335,7 +335,7 @@ func createBridgeNetworks(ctx context.Context, t *testing.T, d *daemon.Daemon, s
|
||||
container.WithPortMap(ctr.portMappings),
|
||||
)
|
||||
t.Cleanup(func() {
|
||||
c.ContainerRemove(ctx, id, containertypes.RemoveOptions{Force: true})
|
||||
c.ContainerRemove(ctx, id, client.ContainerRemoveOptions{Force: true})
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -382,7 +382,7 @@ func createServices(ctx context.Context, t *testing.T, d *daemon.Daemon, section
|
||||
}
|
||||
|
||||
func pollService(ctx context.Context, t *testing.T, c *client.Client, host networking.Host) poll.Result {
|
||||
cl, err := c.ContainerList(ctx, containertypes.ListOptions{})
|
||||
cl, err := c.ContainerList(ctx, client.ContainerListOptions{})
|
||||
if err != nil {
|
||||
return poll.Error(fmt.Errorf("failed to list containers: %w", err))
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ func createBridgeNetworks(ctx context.Context, t *testing.T, d *daemon.Daemon, s
|
||||
container.WithPortMap(ctr.portMappings),
|
||||
)
|
||||
t.Cleanup(func() {
|
||||
c.ContainerRemove(ctx, id, containertypes.RemoveOptions{Force: true})
|
||||
c.ContainerRemove(ctx, id, client.ContainerRemoveOptions{Force: true})
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -358,7 +358,7 @@ func createServices(ctx context.Context, t *testing.T, d *daemon.Daemon, section
|
||||
|
||||
/*
|
||||
func pollService(ctx context.Context, t *testing.T, c *client.Client, host networking.Host) poll.Result {
|
||||
cl, err := c.ContainerList(ctx, containertypes.ListOptions{})
|
||||
cl, err := c.ContainerList(ctx, client.ContainerListOptions{})
|
||||
if err != nil {
|
||||
return poll.Error(fmt.Errorf("failed to list containers: %w", err))
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package network
|
||||
import (
|
||||
"testing"
|
||||
|
||||
containertypes "github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/client"
|
||||
"github.com/moby/moby/v2/integration/internal/container"
|
||||
"github.com/moby/moby/v2/integration/internal/network"
|
||||
"github.com/moby/moby/v2/testutil"
|
||||
@@ -30,7 +30,7 @@ func TestDaemonDNSFallback(t *testing.T) {
|
||||
defer c.NetworkRemove(ctx, "test")
|
||||
|
||||
cid := container.Run(ctx, t, c, container.WithNetworkMode("test"), container.WithCmd("nslookup", "docker.com"))
|
||||
defer c.ContainerRemove(ctx, cid, containertypes.RemoveOptions{Force: true})
|
||||
defer c.ContainerRemove(ctx, cid, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
poll.WaitOn(t, container.IsSuccessful(ctx, c, cid))
|
||||
}
|
||||
@@ -83,7 +83,7 @@ func TestIntDNSAsExtDNS(t *testing.T) {
|
||||
container.WithDNS(tc.extServers),
|
||||
container.WithCmd("nslookup", "docker.com"),
|
||||
)
|
||||
defer c.ContainerRemove(ctx, res.ContainerID, containertypes.RemoveOptions{Force: true})
|
||||
defer c.ContainerRemove(ctx, res.ContainerID, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
assert.Check(t, is.Equal(res.ExitCode, tc.expExitCode))
|
||||
assert.Check(t, is.Contains(res.Stdout.String(), tc.expStdout))
|
||||
@@ -120,7 +120,7 @@ func TestExtDNSInIPv6OnlyNw(t *testing.T) {
|
||||
defer network.RemoveNoError(ctx, t, c, netName)
|
||||
|
||||
ctrId := container.Run(ctx, t, c, container.WithNetworkMode(netName))
|
||||
defer c.ContainerRemove(ctx, ctrId, containertypes.RemoveOptions{Force: true})
|
||||
defer c.ContainerRemove(ctx, ctrId, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
res, err := container.Exec(ctx, c, ctrId, []string{"nslookup", "test.example"})
|
||||
assert.NilError(t, err)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
containertypes "github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/api/types/network"
|
||||
dclient "github.com/moby/moby/client"
|
||||
"github.com/moby/moby/v2/daemon/libnetwork/netlabel"
|
||||
@@ -504,7 +503,7 @@ func TestIpvlanIPAM(t *testing.T) {
|
||||
assert.Check(t, n.IsNetworkAvailable(ctx, c, netName))
|
||||
|
||||
id := container.Run(ctx, t, c, container.WithNetworkMode(netName))
|
||||
defer c.ContainerRemove(ctx, id, containertypes.RemoveOptions{Force: true})
|
||||
defer c.ContainerRemove(ctx, id, dclient.ContainerRemoveOptions{Force: true})
|
||||
|
||||
loRes := container.ExecT(ctx, t, c, id, []string{"ip", "a", "show", "dev", "lo"})
|
||||
assert.Check(t, is.Contains(loRes.Combined(), " inet "))
|
||||
@@ -601,7 +600,7 @@ func TestIPVlanDNS(t *testing.T) {
|
||||
defer c.NetworkRemove(ctx, netName)
|
||||
|
||||
ctrId := container.Run(ctx, t, c, container.WithNetworkMode(netName))
|
||||
defer c.ContainerRemove(ctx, ctrId, containertypes.RemoveOptions{Force: true})
|
||||
defer c.ContainerRemove(ctx, ctrId, dclient.ContainerRemoveOptions{Force: true})
|
||||
res, err := container.Exec(ctx, c, ctrId, []string{"nslookup", "test.example"})
|
||||
assert.NilError(t, err)
|
||||
if tc.expDNS {
|
||||
@@ -668,7 +667,7 @@ func TestPointToPoint(t *testing.T) {
|
||||
container.WithNetworkMode(netName),
|
||||
container.WithName(ctrName),
|
||||
)
|
||||
defer apiClient.ContainerRemove(ctx, id, containertypes.RemoveOptions{Force: true})
|
||||
defer apiClient.ContainerRemove(ctx, id, dclient.ContainerRemoveOptions{Force: true})
|
||||
|
||||
attachCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
||||
defer cancel()
|
||||
@@ -676,7 +675,7 @@ func TestPointToPoint(t *testing.T) {
|
||||
container.WithCmd([]string{"ping", "-c1", "-W3", ctrName}...),
|
||||
container.WithNetworkMode(netName),
|
||||
)
|
||||
defer apiClient.ContainerRemove(ctx, res.ContainerID, containertypes.RemoveOptions{Force: true})
|
||||
defer apiClient.ContainerRemove(ctx, res.ContainerID, dclient.ContainerRemoveOptions{Force: true})
|
||||
assert.Check(t, is.Equal(res.ExitCode, 0))
|
||||
assert.Check(t, is.Equal(res.Stderr.Len(), 0))
|
||||
assert.Check(t, is.Contains(res.Stdout.String(), "1 packets transmitted, 1 packets received"))
|
||||
@@ -707,7 +706,7 @@ func TestEndpointWithCustomIfname(t *testing.T) {
|
||||
netlabel.Ifname: "foobar",
|
||||
},
|
||||
}))
|
||||
defer container.Remove(ctx, t, apiClient, ctrID, containertypes.RemoveOptions{Force: true})
|
||||
defer container.Remove(ctx, t, apiClient, ctrID, dclient.ContainerRemoveOptions{Force: true})
|
||||
|
||||
out, err := container.Output(ctx, apiClient, ctrID)
|
||||
assert.NilError(t, err)
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
containertypes "github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/api/types/network"
|
||||
"github.com/moby/moby/client"
|
||||
"github.com/moby/moby/v2/daemon/libnetwork/netlabel"
|
||||
@@ -502,7 +501,7 @@ func TestMacvlanIPAM(t *testing.T) {
|
||||
assert.Check(t, n.IsNetworkAvailable(ctx, c, netName))
|
||||
|
||||
id := container.Run(ctx, t, c, container.WithNetworkMode(netName))
|
||||
defer c.ContainerRemove(ctx, id, containertypes.RemoveOptions{Force: true})
|
||||
defer c.ContainerRemove(ctx, id, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
loRes := container.ExecT(ctx, t, c, id, []string{"ip", "a", "show", "dev", "lo"})
|
||||
assert.Check(t, is.Contains(loRes.Combined(), " inet "))
|
||||
@@ -597,7 +596,7 @@ func TestMACVlanDNS(t *testing.T) {
|
||||
defer c.NetworkRemove(ctx, netName)
|
||||
|
||||
ctrId := container.Run(ctx, t, c, container.WithNetworkMode(netName))
|
||||
defer c.ContainerRemove(ctx, ctrId, containertypes.RemoveOptions{Force: true})
|
||||
defer c.ContainerRemove(ctx, ctrId, client.ContainerRemoveOptions{Force: true})
|
||||
res, err := container.Exec(ctx, c, ctrId, []string{"nslookup", "test.example"})
|
||||
assert.NilError(t, err)
|
||||
if tc.expDNS {
|
||||
@@ -629,7 +628,7 @@ func TestPointToPoint(t *testing.T) {
|
||||
container.WithNetworkMode(netName),
|
||||
container.WithName(ctrName),
|
||||
)
|
||||
defer apiClient.ContainerRemove(ctx, id, containertypes.RemoveOptions{Force: true})
|
||||
defer apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
attachCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
||||
defer cancel()
|
||||
@@ -637,7 +636,7 @@ func TestPointToPoint(t *testing.T) {
|
||||
container.WithCmd([]string{"ping", "-c1", "-W3", ctrName}...),
|
||||
container.WithNetworkMode(netName),
|
||||
)
|
||||
defer apiClient.ContainerRemove(ctx, res.ContainerID, containertypes.RemoveOptions{Force: true})
|
||||
defer apiClient.ContainerRemove(ctx, res.ContainerID, client.ContainerRemoveOptions{Force: true})
|
||||
assert.Check(t, is.Equal(res.ExitCode, 0))
|
||||
assert.Check(t, is.Equal(res.Stderr.Len(), 0))
|
||||
assert.Check(t, is.Contains(res.Stdout.String(), "1 packets transmitted, 1 packets received"))
|
||||
@@ -665,7 +664,7 @@ func TestEndpointWithCustomIfname(t *testing.T) {
|
||||
netlabel.Ifname: "foobar",
|
||||
},
|
||||
}))
|
||||
defer container.Remove(ctx, t, apiClient, ctrID, containertypes.RemoveOptions{Force: true})
|
||||
defer container.Remove(ctx, t, apiClient, ctrID, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
out, err := container.Output(ctx, apiClient, ctrID)
|
||||
assert.NilError(t, err)
|
||||
@@ -694,5 +693,5 @@ func TestParentDown(t *testing.T) {
|
||||
)
|
||||
|
||||
ctrID := container.Run(ctx, t, apiClient, container.WithNetworkMode(netName))
|
||||
defer container.Remove(ctx, t, apiClient, ctrID, containertypes.RemoveOptions{Force: true})
|
||||
defer container.Remove(ctx, t, apiClient, ctrID, client.ContainerRemoveOptions{Force: true})
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
containertypes "github.com/moby/moby/api/types/container"
|
||||
networktypes "github.com/moby/moby/api/types/network"
|
||||
"github.com/moby/moby/api/types/versions"
|
||||
"github.com/moby/moby/client"
|
||||
@@ -41,14 +40,14 @@ func TestRunContainerWithBridgeNone(t *testing.T) {
|
||||
c := d.NewClientT(t)
|
||||
|
||||
id1 := container.Run(ctx, t, c)
|
||||
defer c.ContainerRemove(ctx, id1, containertypes.RemoveOptions{Force: true})
|
||||
defer c.ContainerRemove(ctx, id1, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
result, err := container.Exec(ctx, c, id1, []string{"ip", "l"})
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(false, strings.Contains(result.Combined(), "eth0")), "There shouldn't be eth0 in container in default(bridge) mode when bridge network is disabled")
|
||||
|
||||
id2 := container.Run(ctx, t, c, container.WithNetworkMode("bridge"))
|
||||
defer c.ContainerRemove(ctx, id2, containertypes.RemoveOptions{Force: true})
|
||||
defer c.ContainerRemove(ctx, id2, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
result, err = container.Exec(ctx, c, id2, []string{"ip", "l"})
|
||||
assert.NilError(t, err)
|
||||
@@ -62,7 +61,7 @@ func TestRunContainerWithBridgeNone(t *testing.T) {
|
||||
assert.NilError(t, err, "Failed to get current process network namespace: %+v", err)
|
||||
|
||||
id3 := container.Run(ctx, t, c, container.WithNetworkMode("host"))
|
||||
defer c.ContainerRemove(ctx, id3, containertypes.RemoveOptions{Force: true})
|
||||
defer c.ContainerRemove(ctx, id3, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
result, err = container.Exec(ctx, c, id3, []string{"sh", "-c", nsCommand})
|
||||
assert.NilError(t, err)
|
||||
@@ -174,7 +173,7 @@ func TestDefaultNetworkOpts(t *testing.T) {
|
||||
|
||||
// Start a container to inspect the MTU of its network interface
|
||||
id1 := container.Run(ctx, t, c, container.WithNetworkMode(networkName))
|
||||
defer c.ContainerRemove(ctx, id1, containertypes.RemoveOptions{Force: true})
|
||||
defer c.ContainerRemove(ctx, id1, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
result, err := container.Exec(ctx, c, id1, []string{"ip", "l", "show", "eth0"})
|
||||
assert.NilError(t, err)
|
||||
@@ -260,7 +259,7 @@ func TestCreateWithPriority(t *testing.T) {
|
||||
container.WithNetworkMode("testnet1"),
|
||||
container.WithEndpointSettings("testnet1", &networktypes.EndpointSettings{GwPriority: 10}),
|
||||
container.WithEndpointSettings("testnet2", &networktypes.EndpointSettings{GwPriority: 100}))
|
||||
defer container.Remove(ctx, t, apiClient, ctrID, containertypes.RemoveOptions{Force: true})
|
||||
defer container.Remove(ctx, t, apiClient, ctrID, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
checkCtrRoutes(t, ctx, apiClient, ctrID, syscall.AF_INET, 3, "default via 10.100.30.1 dev")
|
||||
// IPv6 routing table will contain for each interface, one route for the LL
|
||||
@@ -313,7 +312,7 @@ func TestConnectWithPriority(t *testing.T) {
|
||||
container.WithCmd("sleep", "infinity"),
|
||||
container.WithNetworkMode("testnet1"),
|
||||
container.WithEndpointSettings("testnet1", &networktypes.EndpointSettings{}))
|
||||
defer container.Remove(ctx, t, apiClient, ctrID, containertypes.RemoveOptions{Force: true})
|
||||
defer container.Remove(ctx, t, apiClient, ctrID, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
checkCtrRoutes(t, ctx, apiClient, ctrID, syscall.AF_INET, 2, "default via 10.100.10.1 dev eth0")
|
||||
checkCtrRoutes(t, ctx, apiClient, ctrID, syscall.AF_INET6, 4, "default via fddd:4901:f594::1 dev eth0")
|
||||
@@ -500,7 +499,7 @@ func TestMixL3IPVlanAndBridge(t *testing.T) {
|
||||
container.WithEndpointSettings(br6NetName, &networktypes.EndpointSettings{}),
|
||||
container.WithEndpointSettings(ipvNetName, &networktypes.EndpointSettings{}),
|
||||
)
|
||||
defer container.Remove(ctx, t, c, ctrId, containertypes.RemoveOptions{Force: true})
|
||||
defer container.Remove(ctx, t, c, ctrId, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
if tc.liveRestore {
|
||||
d.Restart(t, daemonArgs...)
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
containertypes "github.com/moby/moby/api/types/container"
|
||||
networktypes "github.com/moby/moby/api/types/network"
|
||||
swarmtypes "github.com/moby/moby/api/types/swarm"
|
||||
"github.com/moby/moby/client"
|
||||
"github.com/moby/moby/v2/daemon/libnetwork/netlabel"
|
||||
"github.com/moby/moby/v2/integration/internal/container"
|
||||
"github.com/moby/moby/v2/integration/internal/network"
|
||||
@@ -48,7 +48,7 @@ func TestEndpointWithCustomIfname(t *testing.T) {
|
||||
netlabel.Ifname: "foobar",
|
||||
},
|
||||
}))
|
||||
defer container.Remove(ctx, t, apiClient, ctrID, containertypes.RemoveOptions{Force: true})
|
||||
defer container.Remove(ctx, t, apiClient, ctrID, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
out, err := container.Output(ctx, apiClient, ctrID)
|
||||
assert.NilError(t, err)
|
||||
@@ -89,7 +89,7 @@ func TestHostPortMappings(t *testing.T) {
|
||||
|
||||
poll.WaitOn(t, swarm.RunningTasksCount(ctx, apiClient, svcID, 1), swarm.ServicePoll)
|
||||
|
||||
ctrs, err := apiClient.ContainerList(ctx, containertypes.ListOptions{})
|
||||
ctrs, err := apiClient.ContainerList(ctx, client.ContainerListOptions{})
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, 1, len(ctrs))
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
containertypes "github.com/moby/moby/api/types/container"
|
||||
networktypes "github.com/moby/moby/api/types/network"
|
||||
swarmtypes "github.com/moby/moby/api/types/swarm"
|
||||
"github.com/moby/moby/client"
|
||||
@@ -489,7 +488,7 @@ func TestCustomIfnameIsPreservedOnLiveRestore(t *testing.T) {
|
||||
netlabel.Ifname: "foobar",
|
||||
},
|
||||
}))
|
||||
defer container.Remove(ctx, t, apiClient, ctrId, containertypes.RemoveOptions{Force: true})
|
||||
defer container.Remove(ctx, t, apiClient, ctrId, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
d.Restart(t, "--live-restore=true")
|
||||
|
||||
@@ -523,7 +522,7 @@ func TestCustomIfnameCollidesWithExistingIface(t *testing.T) {
|
||||
ctrId := container.Run(ctx, t, apiClient,
|
||||
container.WithCmd("top"),
|
||||
container.WithEndpointSettings("bridge", &networktypes.EndpointSettings{}))
|
||||
defer container.Remove(ctx, t, apiClient, ctrId, containertypes.RemoveOptions{Force: true})
|
||||
defer container.Remove(ctx, t, apiClient, ctrId, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
err := apiClient.NetworkConnect(ctx, testnet, ctrId, &networktypes.EndpointSettings{DriverOpts: map[string]string{
|
||||
netlabel.Ifname: "eth0",
|
||||
@@ -568,7 +567,7 @@ func TestCustomIfnameWithMatchingDynamicPrefix(t *testing.T) {
|
||||
}),
|
||||
container.WithEndpointSettings("testnet1", &networktypes.EndpointSettings{}),
|
||||
)
|
||||
defer container.Remove(ctx, t, apiClient, ctrId, containertypes.RemoveOptions{Force: true})
|
||||
defer container.Remove(ctx, t, apiClient, ctrId, client.ContainerRemoveOptions{Force: true})
|
||||
|
||||
checkIfaceAddr(t, ctx, apiClient, ctrId, "eth0", "inet 10.0.1.2/24")
|
||||
checkIfaceAddr(t, ctx, apiClient, ctrId, "eth1", "inet 10.0.0.2/24")
|
||||
|
||||
Reference in New Issue
Block a user