From a402c11057e93f1235f6eb14ccd8cace66e4aad5 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Tue, 4 Dec 2018 12:46:59 -0800 Subject: [PATCH] Remove check for obsolete kube-dns label & validate kubernetes.default rather than localhost --- test/integration/cluster_dns_test.go | 30 ++++++++++------------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/test/integration/cluster_dns_test.go b/test/integration/cluster_dns_test.go index 0f6cb8afd8..d2bd6d0e57 100644 --- a/test/integration/cluster_dns_test.go +++ b/test/integration/cluster_dns_test.go @@ -25,10 +25,7 @@ import ( "time" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/kubernetes" - - commonutil "k8s.io/minikube/pkg/util" pkgutil "k8s.io/minikube/pkg/util" "k8s.io/minikube/test/integration/util" ) @@ -39,31 +36,24 @@ func testClusterDNS(t *testing.T) { if err != nil { t.Fatalf("Error getting kubernetes client %v", err) } - waitForDNS(t, client) kr := util.NewKubectlRunner(t) busybox := busyBoxPod(t, client, kr) defer kr.RunCommand([]string{"delete", "po", busybox}) - // The query result is not as important as service reachability - out, err := kr.RunCommand([]string{"exec", busybox, "nslookup", "localhost"}) - if err != nil { - t.Errorf("nslookup within busybox failed: %v", err) + out := []byte{} + + nslookup := func() error { + out, err = kr.RunCommand([]string{"exec", busybox, "nslookup", "kubernetes.default"}) + return err } + if err := util.Retry(t, nslookup, 3*time.Second, 60); err != nil { + t.Fatalf(err.Error()) + } + clusterIP := []byte("10.96.0.1") if !bytes.Contains(out, clusterIP) { - t.Errorf("nslookup did not mention %s:\n%s", clusterIP, out) - } -} - -func waitForDNS(t *testing.T, c kubernetes.Interface) { - // Implementation note: both kube-dns and coredns have k8s-app=kube-dns labels. - sel := labels.SelectorFromSet(labels.Set(map[string]string{"k8s-app": "kube-dns"})) - if err := commonutil.WaitForPodsWithLabelRunning(c, "kube-system", sel); err != nil { - t.Fatalf("Waited too long for k8s-app=kube-dns pods") - } - if err := commonutil.WaitForDeploymentToStabilize(c, "kube-system", "kube-dns", time.Minute*2); err != nil { - t.Fatalf("kube-dns deployment failed to stabilize within 2 minutes") + t.Errorf("output did not contain expected IP:\n%s", out) } }