瀏覽代碼

Merge pull request #47505 from akerouanton/fix-TestBridgeICC-ipv6

inte/networking:  ping with -6 specified when needed
Sebastiaan van Stijn 1 年之前
父節點
當前提交
0fb845858d
共有 1 個文件被更改,包括 20 次插入6 次删除
  1. 20 6
      integration/networking/bridge_test.go

+ 20 - 6
integration/networking/bridge_test.go

@@ -38,7 +38,8 @@ func TestBridgeICC(t *testing.T) {
 		name           string
 		name           string
 		bridgeOpts     []func(*types.NetworkCreate)
 		bridgeOpts     []func(*types.NetworkCreate)
 		ctr1MacAddress string
 		ctr1MacAddress string
-		linkLocal      bool
+		isIPv6         bool
+		isLinkLocal    bool
 		pingHost       string
 		pingHost       string
 	}{
 	}{
 		{
 		{
@@ -57,6 +58,7 @@ func TestBridgeICC(t *testing.T) {
 				network.WithIPv6(),
 				network.WithIPv6(),
 				network.WithIPAM("fdf1:a844:380c:b200::/64", "fdf1:a844:380c:b200::1"),
 				network.WithIPAM("fdf1:a844:380c:b200::/64", "fdf1:a844:380c:b200::1"),
 			},
 			},
+			isIPv6: true,
 		},
 		},
 		{
 		{
 			name: "IPv6 ULA on internal network",
 			name: "IPv6 ULA on internal network",
@@ -65,6 +67,7 @@ func TestBridgeICC(t *testing.T) {
 				network.WithInternal(),
 				network.WithInternal(),
 				network.WithIPAM("fdf1:a844:380c:b247::/64", "fdf1:a844:380c:b247::1"),
 				network.WithIPAM("fdf1:a844:380c:b247::/64", "fdf1:a844:380c:b247::1"),
 			},
 			},
+			isIPv6: true,
 		},
 		},
 		{
 		{
 			name: "IPv6 link-local address on non-internal network",
 			name: "IPv6 link-local address on non-internal network",
@@ -76,7 +79,8 @@ func TestBridgeICC(t *testing.T) {
 				// 2. the one dynamically assigned by the IPAM driver.
 				// 2. the one dynamically assigned by the IPAM driver.
 				network.WithIPAM("fe80::/64", "fe80::1"),
 				network.WithIPAM("fe80::/64", "fe80::1"),
 			},
 			},
-			linkLocal: true,
+			isLinkLocal: true,
+			isIPv6:      true,
 		},
 		},
 		{
 		{
 			name: "IPv6 link-local address on internal network",
 			name: "IPv6 link-local address on internal network",
@@ -86,10 +90,11 @@ func TestBridgeICC(t *testing.T) {
 				// See the note above about link-local addresses.
 				// See the note above about link-local addresses.
 				network.WithIPAM("fe80::/64", "fe80::1"),
 				network.WithIPAM("fe80::/64", "fe80::1"),
 			},
 			},
-			linkLocal: true,
+			isLinkLocal: true,
+			isIPv6:      true,
 		},
 		},
 		{
 		{
-			// As for 'LL non-internal', but ping the container by name instead of by address
+			// As for 'LL non-internal', ping the container by name instead of by address
 			// - the busybox test containers only have one interface with a link local
 			// - the busybox test containers only have one interface with a link local
 			// address, so the zone index is not required:
 			// address, so the zone index is not required:
 			//   RFC-4007, section 6: "[...] for nodes with only a single non-loopback
 			//   RFC-4007, section 6: "[...] for nodes with only a single non-loopback
@@ -101,6 +106,7 @@ func TestBridgeICC(t *testing.T) {
 				network.WithIPv6(),
 				network.WithIPv6(),
 				network.WithIPAM("fe80::/64", "fe80::1"),
 				network.WithIPAM("fe80::/64", "fe80::1"),
 			},
 			},
+			isIPv6: true,
 		},
 		},
 		{
 		{
 			name: "IPv6 nonstandard link-local subnet on non-internal network ping by name",
 			name: "IPv6 nonstandard link-local subnet on non-internal network ping by name",
@@ -113,6 +119,7 @@ func TestBridgeICC(t *testing.T) {
 				network.WithIPv6(),
 				network.WithIPv6(),
 				network.WithIPAM("fe80:1234::/64", "fe80:1234::1"),
 				network.WithIPAM("fe80:1234::/64", "fe80:1234::1"),
 			},
 			},
+			isIPv6: true,
 		},
 		},
 		{
 		{
 			name: "IPv6 non-internal network with SLAAC LL address",
 			name: "IPv6 non-internal network with SLAAC LL address",
@@ -124,6 +131,7 @@ func TestBridgeICC(t *testing.T) {
 			// specify one here to hardcode the SLAAC LL address below.
 			// specify one here to hardcode the SLAAC LL address below.
 			ctr1MacAddress: "02:42:ac:11:00:02",
 			ctr1MacAddress: "02:42:ac:11:00:02",
 			pingHost:       "fe80::42:acff:fe11:2%eth0",
 			pingHost:       "fe80::42:acff:fe11:2%eth0",
+			isIPv6:         true,
 		},
 		},
 		{
 		{
 			name: "IPv6 internal network with SLAAC LL address",
 			name: "IPv6 internal network with SLAAC LL address",
@@ -135,6 +143,7 @@ func TestBridgeICC(t *testing.T) {
 			// specify one here to hardcode the SLAAC LL address below.
 			// specify one here to hardcode the SLAAC LL address below.
 			ctr1MacAddress: "02:42:ac:11:00:02",
 			ctr1MacAddress: "02:42:ac:11:00:02",
 			pingHost:       "fe80::42:acff:fe11:2%eth0",
 			pingHost:       "fe80::42:acff:fe11:2%eth0",
+			isIPv6:         true,
 		},
 		},
 	}
 	}
 
 
@@ -164,7 +173,7 @@ func TestBridgeICC(t *testing.T) {
 
 
 			pingHost := tc.pingHost
 			pingHost := tc.pingHost
 			if pingHost == "" {
 			if pingHost == "" {
-				if tc.linkLocal {
+				if tc.isLinkLocal {
 					inspect := container.Inspect(ctx, t, c, id1)
 					inspect := container.Inspect(ctx, t, c, id1)
 					pingHost = inspect.NetworkSettings.Networks[bridgeName].GlobalIPv6Address + "%eth0"
 					pingHost = inspect.NetworkSettings.Networks[bridgeName].GlobalIPv6Address + "%eth0"
 				} else {
 				} else {
@@ -172,7 +181,12 @@ func TestBridgeICC(t *testing.T) {
 				}
 				}
 			}
 			}
 
 
-			pingCmd := []string{"ping", "-c1", "-W3", pingHost}
+			ipv := "-4"
+			if tc.isIPv6 {
+				ipv = "-6"
+			}
+
+			pingCmd := []string{"ping", "-c1", "-W3", ipv, pingHost}
 
 
 			ctr2Name := fmt.Sprintf("ctr-icc-%d-2", tcID)
 			ctr2Name := fmt.Sprintf("ctr-icc-%d-2", tcID)
 			attachCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
 			attachCtx, cancel := context.WithTimeout(ctx, 5*time.Second)