From a8c63d132b0279b296189a22fa3e2f0f7da03475 Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Sun, 11 Aug 2019 10:51:27 -0700 Subject: [PATCH] tests: Fixes DNS tests for Windows A previous commit replaced the usage of hostname -i with getent hosts in DNS probe commands (for testing IPv6), which breaks the Windows tests (getent hosts is a Linux-specific command that looks into the /etc/hosts file, which, on Windows, is not managed by Kubelet). This commit addresses this issue by executing getent hosts on IPv6 clusters and hostname -i on IPv4 clusters (Windows does not support IPv6 at this moment). --- test/e2e/network/dns_common.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/e2e/network/dns_common.go b/test/e2e/network/dns_common.go index 5981f6517d5..44aabc20061 100644 --- a/test/e2e/network/dns_common.go +++ b/test/e2e/network/dns_common.go @@ -474,7 +474,12 @@ func createProbeCommand(namesToResolve []string, hostEntries []string, ptrLookup podARecByUDPFileName := fmt.Sprintf("%s_udp@PodARecord", fileNamePrefix) podARecByTCPFileName := fmt.Sprintf("%s_tcp@PodARecord", fileNamePrefix) - probeCmd += fmt.Sprintf(`podARec=$$(getent hosts $$(hostname | awk '{print $1}') | tr ":." "-" | awk '{print $$1".%s.pod.%s"}');`, namespace, dnsDomain) + + if framework.TestContext.IPFamily == "ipv6" { + probeCmd += fmt.Sprintf(`podARec=$$(getent hosts $$(hostname | awk '{print $1}') | tr ":." "-" | awk '{print $$1".%s.pod.%s"}');`, namespace, dnsDomain) + } else { + probeCmd += fmt.Sprintf(`podARec=$$(hostname -i| awk -F. '{print $$1"-"$$2"-"$$3"-"$$4".%s.pod.%s"}');`, namespace, dnsDomain) + } probeCmd += fmt.Sprintf(`check="$$(dig +notcp +noall +answer +search $${podARec} A $${podARec} AAAA)" && test -n "$$check" && echo OK > /results/%s;`, podARecByUDPFileName) probeCmd += fmt.Sprintf(`check="$$(dig +tcp +noall +answer +search $${podARec} A $${podARec} AAAA)" && test -n "$$check" && echo OK > /results/%s;`, podARecByTCPFileName) fileNames = append(fileNames, podARecByUDPFileName)