Remove check for obsolete kube-dns label & validate kubernetes.default rather than localhost
parent
bc67a32a7b
commit
a402c11057
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue