From ee73270915bc3271fa0f5a760515bf96bcaf2505 Mon Sep 17 00:00:00 2001 From: Nathan Gieseker Date: Fri, 19 Oct 2018 19:01:56 -0700 Subject: [PATCH 1/3] Removes PQDNs from conformance tests and places them in their own tests --- test/e2e/network/dns.go | 79 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 2 deletions(-) diff --git a/test/e2e/network/dns.go b/test/e2e/network/dns.go index 8af7177b922..11d56a9549a 100644 --- a/test/e2e/network/dns.go +++ b/test/e2e/network/dns.go @@ -44,9 +44,8 @@ var _ = SIGDescribe("DNS", func() { framework.ConformanceIt("should provide DNS for the cluster ", func() { // All the names we need to be able to resolve. // TODO: Spin up a separate test service and test that dns works for that service. + // NOTE: This only contains the FQDN and the Host name, for testing partial name, see the test below namesToResolve := []string{ - "kubernetes.default", - "kubernetes.default.svc", fmt.Sprintf("kubernetes.default.svc.%s", framework.TestContext.ClusterDNSDomain), } // Added due to #8512. This is critical for GCE and GKE deployments. @@ -67,12 +66,40 @@ var _ = SIGDescribe("DNS", func() { validateDNSResults(f, pod, append(wheezyFileNames, jessieFileNames...)) }) + + It("should resolve DNS of partial qualified names for the cluster ", func() { + // All the names we need to be able to resolve. + // TODO: Spin up a separate test service and test that dns works for that service. + namesToResolve := []string{ + "kubernetes.default", + "kubernetes.default.svc", + "kubernetes.default.svc.cluster", + } + // Added due to #8512. This is critical for GCE and GKE deployments. + if framework.ProviderIs("gce", "gke") { + namesToResolve = append(namesToResolve, "google.com") + namesToResolve = append(namesToResolve, "metadata") + } + hostFQDN := fmt.Sprintf("%s.%s.%s.svc.cluster.local", dnsTestPodHostName, dnsTestServiceName, f.Namespace.Name) + hostEntries := []string{hostFQDN, dnsTestPodHostName} + wheezyProbeCmd, wheezyFileNames := createProbeCommand(namesToResolve, hostEntries, "", "wheezy", f.Namespace.Name) + jessieProbeCmd, jessieFileNames := createProbeCommand(namesToResolve, hostEntries, "", "jessie", f.Namespace.Name) + By("Running these commands on wheezy: " + wheezyProbeCmd + "\n") + By("Running these commands on jessie: " + jessieProbeCmd + "\n") + + // Run a pod which probes DNS and exposes the results by HTTP. + By("creating a pod to probe DNS") + pod := createDNSPod(f.Namespace.Name, wheezyProbeCmd, jessieProbeCmd, dnsTestPodHostName, dnsTestServiceName) + validateDNSResults(f, pod, append(wheezyFileNames, jessieFileNames...)) + }) + /* Release : v1.9 Testname: DNS, services Description: When a headless service is created, the service MUST be able to resolve all the required service endpoints. When the service is created, any pod in the same namespace must be able to resolve the service by all of the expected DNS names. */ framework.ConformanceIt("should provide DNS for services ", func() { + // NOTE: This only contains the FQDN and the Host name, for testing partial name, see the test below // Create a test headless service. By("Creating a test headless service") testServiceSelector := map[string]string{ @@ -103,6 +130,53 @@ var _ = SIGDescribe("DNS", func() { // for headless service. namesToResolve := []string{ fmt.Sprintf("%s", headlessService.Name), + fmt.Sprintf("%s.%s.svc.cluster.local", headlessService.Name, f.Namespace.Name), + fmt.Sprintf("_http._tcp.%s.%s.svc.cluster.local", headlessService.Name, f.Namespace.Name), + fmt.Sprintf("_http._tcp.%s.%s.svc.cluster.local", regularService.Name, f.Namespace.Name), + } + + wheezyProbeCmd, wheezyFileNames := createProbeCommand(namesToResolve, nil, regularService.Spec.ClusterIP, "wheezy", f.Namespace.Name) + jessieProbeCmd, jessieFileNames := createProbeCommand(namesToResolve, nil, regularService.Spec.ClusterIP, "jessie", f.Namespace.Name) + By("Running these commands on wheezy: " + wheezyProbeCmd + "\n") + By("Running these commands on jessie: " + jessieProbeCmd + "\n") + + // Run a pod which probes DNS and exposes the results by HTTP. + By("creating a pod to probe DNS") + pod := createDNSPod(f.Namespace.Name, wheezyProbeCmd, jessieProbeCmd, dnsTestPodHostName, dnsTestServiceName) + pod.ObjectMeta.Labels = testServiceSelector + + validateDNSResults(f, pod, append(wheezyFileNames, jessieFileNames...)) + }) + + It("should resolve DNS of partial qualified names for services ", func() { + // Create a test headless service. + By("Creating a test headless service") + testServiceSelector := map[string]string{ + "dns-test": "true", + } + headlessService := framework.CreateServiceSpec(dnsTestServiceName, "", true, testServiceSelector) + _, err := f.ClientSet.CoreV1().Services(f.Namespace.Name).Create(headlessService) + Expect(err).NotTo(HaveOccurred(), "failed to create headless service: %s", dnsTestServiceName) + defer func() { + By("deleting the test headless service") + defer GinkgoRecover() + f.ClientSet.CoreV1().Services(f.Namespace.Name).Delete(headlessService.Name, nil) + }() + + regularServiceName := "test-service-2" + regularService := framework.CreateServiceSpec(regularServiceName, "", false, testServiceSelector) + regularService, err = f.ClientSet.CoreV1().Services(f.Namespace.Name).Create(regularService) + Expect(err).NotTo(HaveOccurred(), "failed to create regular service: %s", regularServiceName) + defer func() { + By("deleting the test service") + defer GinkgoRecover() + f.ClientSet.CoreV1().Services(f.Namespace.Name).Delete(regularService.Name, nil) + }() + + // All the names we need to be able to resolve. + // TODO: Create more endpoints and ensure that multiple A records are returned + // for headless service. + namesToResolve := []string{ fmt.Sprintf("%s.%s", headlessService.Name, f.Namespace.Name), fmt.Sprintf("%s.%s.svc", headlessService.Name, f.Namespace.Name), fmt.Sprintf("_http._tcp.%s.%s.svc", headlessService.Name, f.Namespace.Name), @@ -122,6 +196,7 @@ var _ = SIGDescribe("DNS", func() { validateDNSResults(f, pod, append(wheezyFileNames, jessieFileNames...)) }) + It("should provide DNS for pods for Hostname and Subdomain", func() { // Create a test headless service. By("Creating a test headless service") From 1a7e07b6187b7230e62c79854ff2848e0e4e8f63 Mon Sep 17 00:00:00 2001 From: Nathan Gieseker Date: Tue, 13 Nov 2018 14:15:05 -0800 Subject: [PATCH 2/3] Rebase, fixes format error, removes a host name from confomance test --- test/e2e/network/dns.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/e2e/network/dns.go b/test/e2e/network/dns.go index 11d56a9549a..e5e630aa55c 100644 --- a/test/e2e/network/dns.go +++ b/test/e2e/network/dns.go @@ -66,7 +66,6 @@ var _ = SIGDescribe("DNS", func() { validateDNSResults(f, pod, append(wheezyFileNames, jessieFileNames...)) }) - It("should resolve DNS of partial qualified names for the cluster ", func() { // All the names we need to be able to resolve. // TODO: Spin up a separate test service and test that dns works for that service. @@ -82,8 +81,8 @@ var _ = SIGDescribe("DNS", func() { } hostFQDN := fmt.Sprintf("%s.%s.%s.svc.cluster.local", dnsTestPodHostName, dnsTestServiceName, f.Namespace.Name) hostEntries := []string{hostFQDN, dnsTestPodHostName} - wheezyProbeCmd, wheezyFileNames := createProbeCommand(namesToResolve, hostEntries, "", "wheezy", f.Namespace.Name) - jessieProbeCmd, jessieFileNames := createProbeCommand(namesToResolve, hostEntries, "", "jessie", f.Namespace.Name) + wheezyProbeCmd, wheezyFileNames := createProbeCommand(namesToResolve, hostEntries, "", "wheezy", f.Namespace.Name, framework.TestContext.ClusterDNSDomain) + jessieProbeCmd, jessieFileNames := createProbeCommand(namesToResolve, hostEntries, "", "jessie", f.Namespace.Name, framework.TestContext.ClusterDNSDomain) By("Running these commands on wheezy: " + wheezyProbeCmd + "\n") By("Running these commands on jessie: " + jessieProbeCmd + "\n") @@ -92,7 +91,7 @@ var _ = SIGDescribe("DNS", func() { pod := createDNSPod(f.Namespace.Name, wheezyProbeCmd, jessieProbeCmd, dnsTestPodHostName, dnsTestServiceName) validateDNSResults(f, pod, append(wheezyFileNames, jessieFileNames...)) }) - + /* Release : v1.9 Testname: DNS, services @@ -129,14 +128,13 @@ var _ = SIGDescribe("DNS", func() { // TODO: Create more endpoints and ensure that multiple A records are returned // for headless service. namesToResolve := []string{ - fmt.Sprintf("%s", headlessService.Name), fmt.Sprintf("%s.%s.svc.cluster.local", headlessService.Name, f.Namespace.Name), fmt.Sprintf("_http._tcp.%s.%s.svc.cluster.local", headlessService.Name, f.Namespace.Name), fmt.Sprintf("_http._tcp.%s.%s.svc.cluster.local", regularService.Name, f.Namespace.Name), } - wheezyProbeCmd, wheezyFileNames := createProbeCommand(namesToResolve, nil, regularService.Spec.ClusterIP, "wheezy", f.Namespace.Name) - jessieProbeCmd, jessieFileNames := createProbeCommand(namesToResolve, nil, regularService.Spec.ClusterIP, "jessie", f.Namespace.Name) + wheezyProbeCmd, wheezyFileNames := createProbeCommand(namesToResolve, nil, regularService.Spec.ClusterIP, "wheezy", f.Namespace.Name, framework.TestContext.ClusterDNSDomain) + jessieProbeCmd, jessieFileNames := createProbeCommand(namesToResolve, nil, regularService.Spec.ClusterIP, "jessie", f.Namespace.Name, framework.TestContext.ClusterDNSDomain) By("Running these commands on wheezy: " + wheezyProbeCmd + "\n") By("Running these commands on jessie: " + jessieProbeCmd + "\n") @@ -177,6 +175,7 @@ var _ = SIGDescribe("DNS", func() { // TODO: Create more endpoints and ensure that multiple A records are returned // for headless service. namesToResolve := []string{ + fmt.Sprintf("%s", headlessService.Name), fmt.Sprintf("%s.%s", headlessService.Name, f.Namespace.Name), fmt.Sprintf("%s.%s.svc", headlessService.Name, f.Namespace.Name), fmt.Sprintf("_http._tcp.%s.%s.svc", headlessService.Name, f.Namespace.Name), @@ -196,7 +195,6 @@ var _ = SIGDescribe("DNS", func() { validateDNSResults(f, pod, append(wheezyFileNames, jessieFileNames...)) }) - It("should provide DNS for pods for Hostname and Subdomain", func() { // Create a test headless service. By("Creating a test headless service") From 689db1b4cb5cde66f6d6c804f719090cc0c53338 Mon Sep 17 00:00:00 2001 From: Nathan Gieseker Date: Fri, 1 Feb 2019 13:35:33 -0800 Subject: [PATCH 3/3] removes incorrect dns name to resolve in dns test --- test/e2e/network/dns.go | 1 - 1 file changed, 1 deletion(-) diff --git a/test/e2e/network/dns.go b/test/e2e/network/dns.go index e5e630aa55c..0acd30efed2 100644 --- a/test/e2e/network/dns.go +++ b/test/e2e/network/dns.go @@ -72,7 +72,6 @@ var _ = SIGDescribe("DNS", func() { namesToResolve := []string{ "kubernetes.default", "kubernetes.default.svc", - "kubernetes.default.svc.cluster", } // Added due to #8512. This is critical for GCE and GKE deployments. if framework.ProviderIs("gce", "gke") {