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).
This commit is contained in:
Claudiu Belu 2019-08-11 10:51:27 -07:00
parent 77fca12f66
commit a8c63d132b

View File

@ -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)