From ae4ccc91b2812460ec8b839c7b51850626cb999a Mon Sep 17 00:00:00 2001 From: aojeagarcia Date: Sat, 9 Mar 2019 13:24:13 +0100 Subject: [PATCH 1/2] Add IPv6 support to the Downward e2e API test Current regex used in the Downward e2e API tests is matching only IPv4 addresses, consequently those tests fails with IPv6 clusters. This patch modifies the regex to match ipv4 and ipv6 addresses. Ref: https://github.com/kubernetes/kubernetes/issues/70248 --- test/e2e/common/downward_api.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/common/downward_api.go b/test/e2e/common/downward_api.go index bd7ac61205c..0055af21423 100644 --- a/test/e2e/common/downward_api.go +++ b/test/e2e/common/downward_api.go @@ -78,7 +78,7 @@ var _ = Describe("[sig-node] Downward API", func() { expectations := []string{ fmt.Sprintf("POD_NAME=%v", podName), fmt.Sprintf("POD_NAMESPACE=%v", f.Namespace.Name), - "POD_IP=(?:\\d+)\\.(?:\\d+)\\.(?:\\d+)\\.(?:\\d+)", + "POD_IP=(?:\\d+\\.\\d+\\.\\d+\\.\\d+|[a-fA-F0-9:]+)", } testDownwardAPI(f, podName, env, expectations) @@ -105,7 +105,7 @@ var _ = Describe("[sig-node] Downward API", func() { } expectations := []string{ - "HOST_IP=(?:\\d+)\\.(?:\\d+)\\.(?:\\d+)\\.(?:\\d+)", + "HOST_IP=(?:\\d+\\.\\d+\\.\\d+\\.\\d+|[a-fA-F0-9:]+)", } testDownwardAPI(f, podName, env, expectations) From d528944a0398518f35794c36f8be24d8bcc78f21 Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Wed, 24 Apr 2019 23:37:24 +0200 Subject: [PATCH 2/2] Add more strict IPv6 regex Previous IPv6 regex was too loose, this patchs adds a better and more strict regex for IPv6 addresses and makes the IPv4 and IPv6 regex availables as constants inside the framework pkg --- test/e2e/common/downward_api.go | 4 ++-- test/e2e/framework/networking_utils.go | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/e2e/common/downward_api.go b/test/e2e/common/downward_api.go index 0055af21423..d1169ed21f8 100644 --- a/test/e2e/common/downward_api.go +++ b/test/e2e/common/downward_api.go @@ -78,7 +78,7 @@ var _ = Describe("[sig-node] Downward API", func() { expectations := []string{ fmt.Sprintf("POD_NAME=%v", podName), fmt.Sprintf("POD_NAMESPACE=%v", f.Namespace.Name), - "POD_IP=(?:\\d+\\.\\d+\\.\\d+\\.\\d+|[a-fA-F0-9:]+)", + fmt.Sprintf("POD_IP=%v|%v", framework.RegexIPv4, framework.RegexIPv6), } testDownwardAPI(f, podName, env, expectations) @@ -105,7 +105,7 @@ var _ = Describe("[sig-node] Downward API", func() { } expectations := []string{ - "HOST_IP=(?:\\d+\\.\\d+\\.\\d+\\.\\d+|[a-fA-F0-9:]+)", + fmt.Sprintf("HOST_IP=%v|%v", framework.RegexIPv4, framework.RegexIPv6), } testDownwardAPI(f, podName, env, expectations) diff --git a/test/e2e/framework/networking_utils.go b/test/e2e/framework/networking_utils.go index 7d43570aa9c..a07fdab7e28 100644 --- a/test/e2e/framework/networking_utils.go +++ b/test/e2e/framework/networking_utils.go @@ -62,6 +62,10 @@ const ( maxNetProxyPodsCount = 10 // Number of checks to hit a given set of endpoints when enable session affinity. SessionAffinityChecks = 10 + // Regex to match IPv4 addresses + RegexIPv4 = "(?:\\d+)\\.(?:\\d+)\\.(?:\\d+)\\.(?:\\d+)" + // Regex to match IPv6 addresses + RegexIPv6 = "(?:(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){6})(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:::(?:(?:(?:[0-9a-fA-F]{1,4})):){5})(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?: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3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,4}(?:(?:[0-9a-fA-F]{1,4})))?::)(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,5}(?:(?:[0-9a-fA-F]{1,4})))?::)(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,6}(?:(?:[0-9a-fA-F]{1,4})))?::))))" ) var NetexecImageName = imageutils.GetE2EImage(imageutils.Netexec)