func launchWebserverPod(f *e2e.Framework, podName string, nodeName string) (ip string) { containerName := fmt.Sprintf("%s-container", podName) port := 8080 pod := &api.Pod{ ObjectMeta: api.ObjectMeta{ Name: podName, }, Spec: api.PodSpec{ Containers: []api.Container{ { Name: containerName, Image: "gcr.io/google_containers/porter:59ad46ed2c56ba50fa7f1dc176c07c37", Env: []api.EnvVar{{Name: fmt.Sprintf("SERVE_PORT_%d", port), Value: "foo"}}, Ports: []api.ContainerPort{{ContainerPort: port}}, }, }, NodeName: nodeName, RestartPolicy: api.RestartPolicyNever, }, } podClient := f.Client.Pods(f.Namespace.Name) _, err := podClient.Create(pod) expectNoError(err) expectNoError(f.WaitForPodRunning(podName)) createdPod, err := podClient.Get(podName) expectNoError(err) ip = fmt.Sprintf("%s:%d", createdPod.Status.PodIP, port) e2e.Logf("Target pod IP:port is %s", ip) return }
func validateDNSResults(f *e2e.Framework, pod *api.Pod, fileNames sets.String, expect int) { By("submitting the pod to kubernetes") podClient := f.Client.Pods(f.Namespace.Name) defer func() { By("deleting the pod") defer GinkgoRecover() podClient.Delete(pod.Name, api.NewDeleteOptions(0)) }() if _, err := podClient.Create(pod); err != nil { e2e.Failf("Failed to create %s pod: %v", pod.Name, err) } Expect(f.WaitForPodRunning(pod.Name)).To(BeNil()) Expect(wait.Poll(2*time.Second, 5*time.Minute, func() (bool, error) { pod, err := podClient.Get(pod.Name) if err != nil { return false, err } switch pod.Status.Phase { case api.PodSucceeded: return true, nil case api.PodFailed: return false, fmt.Errorf("pod failed") default: return false, nil } })).To(BeNil()) By("retrieving the pod logs") r, err := podClient.GetLogs(pod.Name, &api.PodLogOptions{Container: "querier"}).Stream() if err != nil { e2e.Failf("Failed to get pod logs %s: %v", pod.Name, err) } out, err := ioutil.ReadAll(r) if err != nil { e2e.Failf("Failed to read pod logs %s: %v", pod.Name, err) } // Try to find results for each expected name. By("looking for the results for each expected name from probiers") if err := assertLinesExist(fileNames, expect, bytes.NewBuffer(out)); err != nil { e2e.Logf("Got results from pod:\n%s", out) e2e.Failf("Unexpected results: %v", err) } e2e.Logf("DNS probes using %s succeeded\n", pod.Name) }