Merge pull request #70188 from rajansandeep/ipv6tests
Extend DNS ConfigMap tests to support IPv6
This commit is contained in:
commit
0768fa5604
@ -112,14 +112,15 @@ func (t *dnsTestCommon) runDig(dnsName, target string) []string {
|
||||
cmd = append(cmd, "@"+t.dnsPod.Status.PodIP)
|
||||
case "kube-dns":
|
||||
cmd = append(cmd, "@"+t.dnsPod.Status.PodIP, "-p", "10053")
|
||||
case "ptr-record":
|
||||
cmd = append(cmd, "-x")
|
||||
case "cluster-dns":
|
||||
case "cluster-dns-ipv6":
|
||||
cmd = append(cmd, "AAAA")
|
||||
break
|
||||
default:
|
||||
panic(fmt.Errorf("invalid target: " + target))
|
||||
}
|
||||
if strings.HasSuffix(dnsName, "in-addr.arpa") || strings.HasSuffix(dnsName, "in-addr.arpa.") {
|
||||
cmd = append(cmd, []string{"-t", "ptr"}...)
|
||||
}
|
||||
cmd = append(cmd, dnsName)
|
||||
|
||||
stdout, stderr, err := t.f.ExecWithOptions(framework.ExecOptions{
|
||||
@ -327,7 +328,7 @@ func (t *dnsTestCommon) createDNSServer(aRecords map[string]string) {
|
||||
t.createDNSPodFromObj(generateDNSServerPod(aRecords))
|
||||
}
|
||||
|
||||
func (t *dnsTestCommon) createDNSServerWithPtrRecord() {
|
||||
func (t *dnsTestCommon) createDNSServerWithPtrRecord(isIPv6 bool) {
|
||||
pod := &v1.Pod{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Pod",
|
||||
@ -345,7 +346,6 @@ func (t *dnsTestCommon) createDNSServerWithPtrRecord() {
|
||||
"-u", "root",
|
||||
"-k",
|
||||
"--log-facility", "-",
|
||||
"--host-record=my.test,192.0.2.123",
|
||||
"-q",
|
||||
},
|
||||
},
|
||||
@ -354,6 +354,16 @@ func (t *dnsTestCommon) createDNSServerWithPtrRecord() {
|
||||
},
|
||||
}
|
||||
|
||||
if isIPv6 {
|
||||
pod.Spec.Containers[0].Command = append(
|
||||
pod.Spec.Containers[0].Command,
|
||||
fmt.Sprintf("--host-record=my.test,2001:db8::29"))
|
||||
} else {
|
||||
pod.Spec.Containers[0].Command = append(
|
||||
pod.Spec.Containers[0].Command,
|
||||
fmt.Sprintf("--host-record=my.test,192.0.2.123"))
|
||||
}
|
||||
|
||||
t.createDNSPodFromObj(pod)
|
||||
}
|
||||
|
||||
|
@ -64,15 +64,6 @@ func (t *dnsFederationsConfigMapTest) run() {
|
||||
|
||||
if t.name == "coredns" {
|
||||
t.labels = []string{"abc", "ghi"}
|
||||
defaultConfig := map[string]string{
|
||||
"Corefile": `.:53 {
|
||||
kubernetes cluster.local in-addr.arpa ip6.arpa {
|
||||
pods insecure
|
||||
upstream
|
||||
fallthrough in-addr.arpa ip6.arpa
|
||||
}
|
||||
}`}
|
||||
|
||||
valid1 := map[string]string{
|
||||
"Corefile": `.:53 {
|
||||
kubernetes cluster.local in-addr.arpa ip6.arpa {
|
||||
@ -112,10 +103,12 @@ func (t *dnsFederationsConfigMapTest) run() {
|
||||
t.validate()
|
||||
|
||||
By("valid2 -> default")
|
||||
t.setConfigMap(&v1.ConfigMap{Data: defaultConfig}, nil, false)
|
||||
t.setConfigMap(&v1.ConfigMap{Data: originalConfigMapData}, nil, false)
|
||||
t.deleteCoreDNSPods()
|
||||
t.validate()
|
||||
|
||||
t.restoreDNSConfigMap(originalConfigMapData)
|
||||
|
||||
} else {
|
||||
t.labels = []string{"abc", "ghi"}
|
||||
valid1 := map[string]string{"federations": t.labels[0] + "=def"}
|
||||
@ -209,7 +202,7 @@ type dnsNameserverTest struct {
|
||||
dnsTestCommon
|
||||
}
|
||||
|
||||
func (t *dnsNameserverTest) run() {
|
||||
func (t *dnsNameserverTest) run(isIPv6 bool) {
|
||||
t.init()
|
||||
|
||||
t.createUtilPodLabel("e2e-dns-configmap")
|
||||
@ -217,11 +210,19 @@ func (t *dnsNameserverTest) run() {
|
||||
originalConfigMapData := t.fetchDNSConfigMapData()
|
||||
defer t.restoreDNSConfigMap(originalConfigMapData)
|
||||
|
||||
t.createDNSServer(map[string]string{
|
||||
"abc.acme.local": "1.1.1.1",
|
||||
"def.acme.local": "2.2.2.2",
|
||||
"widget.local": "3.3.3.3",
|
||||
})
|
||||
if isIPv6 {
|
||||
t.createDNSServer(map[string]string{
|
||||
"abc.acme.local": "2606:4700:4700::1111",
|
||||
"def.acme.local": "2606:4700:4700::2222",
|
||||
"widget.local": "2606:4700:4700::3333",
|
||||
})
|
||||
} else {
|
||||
t.createDNSServer(map[string]string{
|
||||
"abc.acme.local": "1.1.1.1",
|
||||
"def.acme.local": "2.2.2.2",
|
||||
"widget.local": "3.3.3.3",
|
||||
})
|
||||
}
|
||||
defer t.deleteDNSServerPod()
|
||||
|
||||
if t.name == "coredns" {
|
||||
@ -247,21 +248,39 @@ func (t *dnsNameserverTest) run() {
|
||||
}})
|
||||
}
|
||||
|
||||
t.checkDNSRecordFrom(
|
||||
"abc.acme.local",
|
||||
func(actual []string) bool { return len(actual) == 1 && actual[0] == "1.1.1.1" },
|
||||
"cluster-dns",
|
||||
moreForeverTestTimeout)
|
||||
t.checkDNSRecordFrom(
|
||||
"def.acme.local",
|
||||
func(actual []string) bool { return len(actual) == 1 && actual[0] == "2.2.2.2" },
|
||||
"cluster-dns",
|
||||
moreForeverTestTimeout)
|
||||
t.checkDNSRecordFrom(
|
||||
"widget.local",
|
||||
func(actual []string) bool { return len(actual) == 1 && actual[0] == "3.3.3.3" },
|
||||
"cluster-dns",
|
||||
moreForeverTestTimeout)
|
||||
if isIPv6 {
|
||||
t.checkDNSRecordFrom(
|
||||
"abc.acme.local",
|
||||
func(actual []string) bool { return len(actual) == 1 && actual[0] == "2606:4700:4700::1111" },
|
||||
"cluster-dns-ipv6",
|
||||
moreForeverTestTimeout)
|
||||
t.checkDNSRecordFrom(
|
||||
"def.acme.local",
|
||||
func(actual []string) bool { return len(actual) == 1 && actual[0] == "2606:4700:4700::2222" },
|
||||
"cluster-dns-ipv6",
|
||||
moreForeverTestTimeout)
|
||||
t.checkDNSRecordFrom(
|
||||
"widget.local",
|
||||
func(actual []string) bool { return len(actual) == 1 && actual[0] == "2606:4700:4700::3333" },
|
||||
"cluster-dns-ipv6",
|
||||
moreForeverTestTimeout)
|
||||
} else {
|
||||
t.checkDNSRecordFrom(
|
||||
"abc.acme.local",
|
||||
func(actual []string) bool { return len(actual) == 1 && actual[0] == "1.1.1.1" },
|
||||
"cluster-dns",
|
||||
moreForeverTestTimeout)
|
||||
t.checkDNSRecordFrom(
|
||||
"def.acme.local",
|
||||
func(actual []string) bool { return len(actual) == 1 && actual[0] == "2.2.2.2" },
|
||||
"cluster-dns",
|
||||
moreForeverTestTimeout)
|
||||
t.checkDNSRecordFrom(
|
||||
"widget.local",
|
||||
func(actual []string) bool { return len(actual) == 1 && actual[0] == "3.3.3.3" },
|
||||
"cluster-dns",
|
||||
moreForeverTestTimeout)
|
||||
}
|
||||
|
||||
t.restoreDNSConfigMap(originalConfigMapData)
|
||||
// Wait for the deleted ConfigMap to take effect, otherwise the
|
||||
@ -277,7 +296,7 @@ type dnsPtrFwdTest struct {
|
||||
dnsTestCommon
|
||||
}
|
||||
|
||||
func (t *dnsPtrFwdTest) run() {
|
||||
func (t *dnsPtrFwdTest) run(isIPv6 bool) {
|
||||
t.init()
|
||||
|
||||
t.createUtilPodLabel("e2e-dns-configmap")
|
||||
@ -285,15 +304,23 @@ func (t *dnsPtrFwdTest) run() {
|
||||
originalConfigMapData := t.fetchDNSConfigMapData()
|
||||
defer t.restoreDNSConfigMap(originalConfigMapData)
|
||||
|
||||
t.createDNSServerWithPtrRecord()
|
||||
t.createDNSServerWithPtrRecord(isIPv6)
|
||||
defer t.deleteDNSServerPod()
|
||||
|
||||
// Should still be able to lookup public nameserver without explicit upstream nameserver set.
|
||||
t.checkDNSRecordFrom(
|
||||
"8.8.8.8.in-addr.arpa",
|
||||
func(actual []string) bool { return len(actual) == 1 && actual[0] == googleDnsHostname+"." },
|
||||
"cluster-dns",
|
||||
moreForeverTestTimeout)
|
||||
if isIPv6 {
|
||||
t.checkDNSRecordFrom(
|
||||
"2001:4860:4860::8888",
|
||||
func(actual []string) bool { return len(actual) == 1 && actual[0] == googleDnsHostname+"." },
|
||||
"ptr-record",
|
||||
moreForeverTestTimeout)
|
||||
} else {
|
||||
t.checkDNSRecordFrom(
|
||||
"8.8.8.8",
|
||||
func(actual []string) bool { return len(actual) == 1 && actual[0] == googleDnsHostname+"." },
|
||||
"ptr-record",
|
||||
moreForeverTestTimeout)
|
||||
}
|
||||
|
||||
if t.name == "coredns" {
|
||||
t.setConfigMap(&v1.ConfigMap{Data: map[string]string{
|
||||
@ -314,25 +341,41 @@ func (t *dnsPtrFwdTest) run() {
|
||||
}})
|
||||
}
|
||||
|
||||
t.checkDNSRecordFrom(
|
||||
"123.2.0.192.in-addr.arpa",
|
||||
func(actual []string) bool { return len(actual) == 1 && actual[0] == "my.test." },
|
||||
"cluster-dns",
|
||||
moreForeverTestTimeout)
|
||||
if isIPv6 {
|
||||
t.checkDNSRecordFrom(
|
||||
"2001:db8::29",
|
||||
func(actual []string) bool { return len(actual) == 1 && actual[0] == "my.test." },
|
||||
"ptr-record",
|
||||
moreForeverTestTimeout)
|
||||
|
||||
t.restoreDNSConfigMap(originalConfigMapData)
|
||||
t.checkDNSRecordFrom(
|
||||
"123.2.0.192.in-addr.arpa",
|
||||
func(actual []string) bool { return len(actual) == 0 },
|
||||
"cluster-dns",
|
||||
moreForeverTestTimeout)
|
||||
t.restoreDNSConfigMap(originalConfigMapData)
|
||||
t.checkDNSRecordFrom(
|
||||
"2001:db8::29",
|
||||
func(actual []string) bool { return len(actual) == 0 },
|
||||
"ptr-record",
|
||||
moreForeverTestTimeout)
|
||||
|
||||
} else {
|
||||
t.checkDNSRecordFrom(
|
||||
"192.0.2.123",
|
||||
func(actual []string) bool { return len(actual) == 1 && actual[0] == "my.test." },
|
||||
"ptr-record",
|
||||
moreForeverTestTimeout)
|
||||
|
||||
t.restoreDNSConfigMap(originalConfigMapData)
|
||||
t.checkDNSRecordFrom(
|
||||
"192.0.2.123",
|
||||
func(actual []string) bool { return len(actual) == 0 },
|
||||
"ptr-record",
|
||||
moreForeverTestTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
type dnsExternalNameTest struct {
|
||||
dnsTestCommon
|
||||
}
|
||||
|
||||
func (t *dnsExternalNameTest) run() {
|
||||
func (t *dnsExternalNameTest) run(isIPv6 bool) {
|
||||
t.init()
|
||||
|
||||
t.createUtilPodLabel("e2e-dns-configmap")
|
||||
@ -341,9 +384,15 @@ func (t *dnsExternalNameTest) run() {
|
||||
defer t.restoreDNSConfigMap(originalConfigMapData)
|
||||
|
||||
fooHostname := "foo.example.com"
|
||||
t.createDNSServer(map[string]string{
|
||||
fooHostname: "192.0.2.123",
|
||||
})
|
||||
if isIPv6 {
|
||||
t.createDNSServer(map[string]string{
|
||||
fooHostname: "2001:db8::29",
|
||||
})
|
||||
} else {
|
||||
t.createDNSServer(map[string]string{
|
||||
fooHostname: "192.0.2.123",
|
||||
})
|
||||
}
|
||||
defer t.deleteDNSServerPod()
|
||||
|
||||
f := t.f
|
||||
@ -364,13 +413,23 @@ func (t *dnsExternalNameTest) run() {
|
||||
f.ClientSet.CoreV1().Services(f.Namespace.Name).Delete(externalNameServiceLocal.Name, nil)
|
||||
}()
|
||||
|
||||
t.checkDNSRecordFrom(
|
||||
fmt.Sprintf("%s.%s.svc.cluster.local", serviceName, f.Namespace.Name),
|
||||
func(actual []string) bool {
|
||||
return len(actual) >= 1 && actual[0] == googleDnsHostname+"."
|
||||
},
|
||||
"cluster-dns",
|
||||
moreForeverTestTimeout)
|
||||
if isIPv6 {
|
||||
t.checkDNSRecordFrom(
|
||||
fmt.Sprintf("%s.%s.svc.cluster.local", serviceName, f.Namespace.Name),
|
||||
func(actual []string) bool {
|
||||
return len(actual) >= 1 && actual[0] == googleDnsHostname+"."
|
||||
},
|
||||
"cluster-dns-ipv6",
|
||||
moreForeverTestTimeout)
|
||||
} else {
|
||||
t.checkDNSRecordFrom(
|
||||
fmt.Sprintf("%s.%s.svc.cluster.local", serviceName, f.Namespace.Name),
|
||||
func(actual []string) bool {
|
||||
return len(actual) >= 1 && actual[0] == googleDnsHostname+"."
|
||||
},
|
||||
"cluster-dns",
|
||||
moreForeverTestTimeout)
|
||||
}
|
||||
|
||||
if t.name == "coredns" {
|
||||
t.setConfigMap(&v1.ConfigMap{Data: map[string]string{
|
||||
@ -390,26 +449,35 @@ func (t *dnsExternalNameTest) run() {
|
||||
"upstreamNameservers": fmt.Sprintf(`["%v"]`, t.dnsServerPod.Status.PodIP),
|
||||
}})
|
||||
}
|
||||
|
||||
t.checkDNSRecordFrom(
|
||||
fmt.Sprintf("%s.%s.svc.cluster.local", serviceNameLocal, f.Namespace.Name),
|
||||
func(actual []string) bool {
|
||||
return len(actual) == 2 && actual[0] == fooHostname+"." && actual[1] == "192.0.2.123"
|
||||
},
|
||||
"cluster-dns",
|
||||
moreForeverTestTimeout)
|
||||
if isIPv6 {
|
||||
t.checkDNSRecordFrom(
|
||||
fmt.Sprintf("%s.%s.svc.cluster.local", serviceNameLocal, f.Namespace.Name),
|
||||
func(actual []string) bool {
|
||||
return len(actual) >= 1 && actual[0] == fooHostname+"." && actual[1] == "2001:db8::29"
|
||||
},
|
||||
"cluster-dns-ipv6",
|
||||
moreForeverTestTimeout)
|
||||
} else {
|
||||
t.checkDNSRecordFrom(
|
||||
fmt.Sprintf("%s.%s.svc.cluster.local", serviceNameLocal, f.Namespace.Name),
|
||||
func(actual []string) bool {
|
||||
return len(actual) == 2 && actual[0] == fooHostname+"." && actual[1] == "192.0.2.123"
|
||||
},
|
||||
"cluster-dns",
|
||||
moreForeverTestTimeout)
|
||||
}
|
||||
|
||||
t.restoreDNSConfigMap(originalConfigMapData)
|
||||
}
|
||||
|
||||
var _ = SIGDescribe("DNS configMap nameserver", func() {
|
||||
var _ = SIGDescribe("DNS configMap nameserver [IPv4]", func() {
|
||||
|
||||
Context("Change stubDomain", func() {
|
||||
nsTest := &dnsNameserverTest{dnsTestCommon: newDnsTestCommon()}
|
||||
|
||||
It("should be able to change stubDomain configuration [Slow][Serial]", func() {
|
||||
nsTest.c = nsTest.f.ClientSet
|
||||
nsTest.run()
|
||||
nsTest.run(false)
|
||||
})
|
||||
})
|
||||
|
||||
@ -418,7 +486,7 @@ var _ = SIGDescribe("DNS configMap nameserver", func() {
|
||||
|
||||
It("should forward PTR records lookup to upstream nameserver [Slow][Serial]", func() {
|
||||
fwdTest.c = fwdTest.f.ClientSet
|
||||
fwdTest.run()
|
||||
fwdTest.run(false)
|
||||
})
|
||||
})
|
||||
|
||||
@ -427,7 +495,37 @@ var _ = SIGDescribe("DNS configMap nameserver", func() {
|
||||
|
||||
It("should forward externalname lookup to upstream nameserver [Slow][Serial]", func() {
|
||||
externalNameTest.c = externalNameTest.f.ClientSet
|
||||
externalNameTest.run()
|
||||
externalNameTest.run(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
var _ = SIGDescribe("DNS configMap nameserver [Feature:Networking-IPv6]", func() {
|
||||
|
||||
Context("Change stubDomain", func() {
|
||||
nsTest := &dnsNameserverTest{dnsTestCommon: newDnsTestCommon()}
|
||||
|
||||
It("should be able to change stubDomain configuration [Slow][Serial]", func() {
|
||||
nsTest.c = nsTest.f.ClientSet
|
||||
nsTest.run(true)
|
||||
})
|
||||
})
|
||||
|
||||
Context("Forward PTR lookup", func() {
|
||||
fwdTest := &dnsPtrFwdTest{dnsTestCommon: newDnsTestCommon()}
|
||||
|
||||
It("should forward PTR records lookup to upstream nameserver [Slow][Serial]", func() {
|
||||
fwdTest.c = fwdTest.f.ClientSet
|
||||
fwdTest.run(true)
|
||||
})
|
||||
})
|
||||
|
||||
Context("Forward external name lookup", func() {
|
||||
externalNameTest := &dnsExternalNameTest{dnsTestCommon: newDnsTestCommon()}
|
||||
|
||||
It("should forward externalname lookup to upstream nameserver [Slow][Serial]", func() {
|
||||
externalNameTest.c = externalNameTest.f.ClientSet
|
||||
externalNameTest.run(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user