Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Wait for kube-dns before starting test #16411

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/helpers/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -4560,3 +4560,19 @@ func (kub *Kubectl) ensureKubectlVersion() error {
}
return nil
}

// NslookupInPod executes 'nslookup' in the given pod until it succeeds or times out.
func (kub *Kubectl) NslookupInPod(namespace, pod string, target string) (err error) {
err2 := WithTimeout(func() bool {
res := kub.ExecPodCmd(namespace, pod, fmt.Sprintf("nslookup %s", target))
if res.WasSuccessful() {
return true
}
err = fmt.Errorf("error looking up %s from %s/%s: %s", target, namespace, pod, res.CombineOutput().String())
return false
}, "Could not resolve target name", &TimeoutConfig{Timeout: HelperTimeout})
if err2 != nil {
return err
}
return nil
}
4 changes: 4 additions & 0 deletions test/k8sT/fqdn.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ var _ = SkipDescribeIf(helpers.RunsOn54Kernel, "K8sFQDNTest", func() {
Expect(err).Should(BeNil(), "Testapp is not ready after timeout")

appPods = helpers.GetAppPods(apps, helpers.DefaultNamespace, kubectl, "id")

// Validate that coredns is reachable from test pods
err = kubectl.NslookupInPod(helpers.DefaultNamespace, appPods[helpers.App2], "kube-dns.kube-system.svc.cluster.local")
Expect(err).Should(BeNil(), "Error reaching kube-dns before test: %s", err)
})

AfterFailed(func() {
Expand Down