Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
test: get pod network info if dns validation fails (#2778)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfrancis authored Feb 25, 2020
1 parent dc25b0d commit c841ebc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
29 changes: 17 additions & 12 deletions test/e2e/kubernetes/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1018,16 +1018,26 @@ var _ = Describe("Azure Container Cluster using the Kubernetes Orchestrator", fu

It("should have functional container networking DNS", func() {
By("Ensuring that we have functional DNS resolution from a linux container")
j, err := job.CreateJobFromFileDeleteIfExists(filepath.Join(WorkloadDir, "validate-dns-linux.yaml"), "validate-dns-linux", "default", 3*time.Second, cfg.Timeout)
validateDNSLinuxName := "validate-dns-linux"
validateDNSLinuxNamespace := "default"
j, err := job.CreateJobFromFileDeleteIfExists(filepath.Join(WorkloadDir, fmt.Sprintf("%s.yaml", validateDNSLinuxName)), validateDNSLinuxName, validateDNSLinuxNamespace, 3*time.Second, cfg.Timeout)
Expect(err).NotTo(HaveOccurred())
ready, err := j.WaitOnSucceeded(sleepBetweenRetriesWhenWaitingForPodReady, validateDNSTimeout)
if err != nil {
pod.PrintPodsLogs("validate-dns-linux", "default", 5*time.Second, 1*time.Minute)
}
delErr := j.Delete(util.DefaultDeleteRetries)
if delErr != nil {
fmt.Printf("could not delete job %s\n", j.Metadata.Name)
fmt.Println(delErr)
pod.PrintPodsLogs(validateDNSLinuxName, validateDNSLinuxNamespace, 5*time.Second, 1*time.Minute)
pods, err := pod.GetAllByPrefixWithRetry(validateDNSLinuxName, validateDNSLinuxNamespace, 3*time.Second, cfg.Timeout)
Expect(err).NotTo(HaveOccurred())
for _, p := range pods {
out, err := p.Exec("--", "cat", "/etc/resolv.conf")
log.Printf("%s\n", string(out))
Expect(err).NotTo(HaveOccurred())
out, err = p.Exec("--", "ifconfig")
log.Printf("%s\n", string(out))
Expect(err).NotTo(HaveOccurred())
out, err = p.Exec("--", "nc", "-vz", eng.ExpandedDefinition.Properties.OrchestratorProfile.KubernetesConfig.DNSServiceIP, "53")
log.Printf("%s\n", string(out))
Expect(err).NotTo(HaveOccurred())
}
}
Expect(err).NotTo(HaveOccurred())
Expect(ready).To(Equal(true))
Expand All @@ -1042,11 +1052,6 @@ var _ = Describe("Azure Container Cluster using the Kubernetes Orchestrator", fu
if err != nil {
pod.PrintPodsLogs("validate-dns-windows", "default", 5*time.Second, 1*time.Minute)
}
delErr = j.Delete(util.DefaultDeleteRetries)
if delErr != nil {
fmt.Printf("could not delete job %s\n", j.Metadata.Name)
fmt.Println(delErr)
}
Expect(err).NotTo(HaveOccurred())
Expect(ready).To(Equal(true))
}
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/kubernetes/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func GetAll(namespace string) (*List, error) {
}

// GetWithRetry gets a pod, allowing for retries
func GetWithRetry(podPrefix, namespace string, sleep, timeout time.Duration) (*Pod, error) {
func GetWithRetry(podName, namespace string, sleep, timeout time.Duration) (*Pod, error) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
ch := make(chan GetResult)
Expand All @@ -306,7 +306,7 @@ func GetWithRetry(podPrefix, namespace string, sleep, timeout time.Duration) (*P
case <-ctx.Done():
return
default:
ch <- GetAsync(podPrefix, namespace)
ch <- GetAsync(podName, namespace)
time.Sleep(sleep)
}
}
Expand Down

0 comments on commit c841ebc

Please sign in to comment.