From 58785c29329d993479a58ab5efc5c279975b8bf3 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 8 Nov 2023 09:45:42 +0100 Subject: [PATCH] integration/networking: fix TestBridgeICC This test broke in 98323ac114703f61d09a9e46c17201f5d1419e9a. This commit renamed WithMacAddress into WithContainerWideMacAddress. This helper sets the MacAddress field in container.Config. However, API v1.44 now ignores this field if the NetworkMode has no matching entry in EndpointsConfig. This fix uses the helper WithMacAddress and specify for which EndpointConfig the MacAddress is specified. Signed-off-by: Sebastiaan van Stijn Signed-off-by: Albin Kerouanton --- integration/networking/bridge_test.go | 36 +++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/integration/networking/bridge_test.go b/integration/networking/bridge_test.go index 8dc1cad781..f9c92909fa 100644 --- a/integration/networking/bridge_test.go +++ b/integration/networking/bridge_test.go @@ -33,11 +33,11 @@ func TestBridgeICC(t *testing.T) { defer c.Close() testcases := []struct { - name string - bridgeOpts []func(*types.NetworkCreate) - ctr1Opts []func(*container.TestContainerConfig) - linkLocal bool - pingHost string + name string + bridgeOpts []func(*types.NetworkCreate) + ctr1MacAddress string + linkLocal bool + pingHost string }{ { name: "IPv4 non-internal network", @@ -92,12 +92,10 @@ func TestBridgeICC(t *testing.T) { network.WithIPv6(), network.WithIPAM("fdf1:a844:380c:b247::/64", "fdf1:a844:380c:b247::1"), }, - ctr1Opts: []func(*container.TestContainerConfig){ - // Link-local address is derived from the MAC address, so we need to - // specify one here to hardcode the SLAAC LL address below. - container.WithMacAddress("02:42:ac:11:00:02"), - }, - pingHost: "fe80::42:acff:fe11:2%eth0", + // Link-local address is derived from the MAC address, so we need to + // specify one here to hardcode the SLAAC LL address below. + ctr1MacAddress: "02:42:ac:11:00:02", + pingHost: "fe80::42:acff:fe11:2%eth0", }, { name: "IPv6 internal network with SLAAC LL address", @@ -105,12 +103,10 @@ func TestBridgeICC(t *testing.T) { network.WithIPv6(), network.WithIPAM("fdf1:a844:380c:b247::/64", "fdf1:a844:380c:b247::1"), }, - ctr1Opts: []func(*container.TestContainerConfig){ - // Link-local address is derived from the MAC address, so we need to - // specify one here to hardcode the SLAAC LL address below. - container.WithMacAddress("02:42:ac:11:00:02"), - }, - pingHost: "fe80::42:acff:fe11:2%eth0", + // Link-local address is derived from the MAC address, so we need to + // specify one here to hardcode the SLAAC LL address below. + ctr1MacAddress: "02:42:ac:11:00:02", + pingHost: "fe80::42:acff:fe11:2%eth0", }, } @@ -125,7 +121,11 @@ func TestBridgeICC(t *testing.T) { defer network.RemoveNoError(ctx, t, c, bridgeName) ctr1Name := fmt.Sprintf("ctr-icc-%d-1", tcID) - id1 := container.Run(ctx, t, c, append(tc.ctr1Opts, + var ctr1Opts []func(config *container.TestContainerConfig) + if tc.ctr1MacAddress != "" { + ctr1Opts = append(ctr1Opts, container.WithMacAddress(bridgeName, tc.ctr1MacAddress)) + } + id1 := container.Run(ctx, t, c, append(ctr1Opts, container.WithName(ctr1Name), container.WithImage("busybox:latest"), container.WithCmd("top"),