// Run a test container to try and contact the Kubernetes api-server from a pod, wait for it // to flip to Ready, log its output and delete it. func runKubernetesServiceTestContainer(c clientset.Interface, ns string) { path := "test/images/clusterapi-tester/pod.yaml" p, err := podFromManifest(path) if err != nil { framework.Logf("Failed to parse clusterapi-tester from manifest %v: %v", path, err) return } p.Namespace = ns if _, err := c.Core().Pods(ns).Create(p); err != nil { framework.Logf("Failed to create %v: %v", p.Name, err) return } defer func() { if err := c.Core().Pods(ns).Delete(p.Name, nil); err != nil { framework.Logf("Failed to delete pod %v: %v", p.Name, err) } }() timeout := 5 * time.Minute if err := framework.WaitForPodCondition(c, ns, p.Name, "clusterapi-tester", timeout, testutils.PodRunningReady); err != nil { framework.Logf("Pod %v took longer than %v to enter running/ready: %v", p.Name, timeout, err) return } logs, err := framework.GetPodLogs(c, ns, p.Name, p.Spec.Containers[0].Name) if err != nil { framework.Logf("Failed to retrieve logs from %v: %v", p.Name, err) } else { framework.Logf("Output of clusterapi-tester:\n%v", logs) } }
func WaitForTerminatedContainer(f *framework.Framework, pod *v1.Pod, containerName string) error { return framework.WaitForPodCondition(f.ClientSet, f.Namespace.Name, pod.Name, "container terminated", framework.PodStartTimeout, func(pod *v1.Pod) (bool, error) { if len(testutils.TerminatedContainers(pod)[containerName]) > 0 { return true, nil } return false, nil }) }