Преглед изворни кода

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 <github@gone.nl>
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
Sebastiaan van Stijn пре 1 година
родитељ
комит
58785c2932
1 измењених фајлова са 18 додато и 18 уклоњено
  1. 18 18
      integration/networking/bridge_test.go

+ 18 - 18
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"),