}, }, }, } By("setting up watch") selector := labels.SelectorFromSet(labels.Set(map[string]string{"time": value})) options := v1.ListOptions{LabelSelector: selector.String()} pods, err := podClient.List(options) Expect(err).NotTo(HaveOccurred(), "failed to query for pods") Expect(len(pods.Items)).To(Equal(0)) options = v1.ListOptions{ LabelSelector: selector.String(), ResourceVersion: pods.ListMeta.ResourceVersion, } w, err := podClient.Watch(options) Expect(err).NotTo(HaveOccurred(), "failed to set up watch") By("submitting the pod to kubernetes") podClient.Create(pod) By("verifying the pod is in kubernetes") selector = labels.SelectorFromSet(labels.Set(map[string]string{"time": value})) options = v1.ListOptions{LabelSelector: selector.String()} pods, err = podClient.List(options) Expect(err).NotTo(HaveOccurred(), "failed to query for pods") Expect(len(pods.Items)).To(Equal(1)) By("verifying pod creation was observed") select { case event, _ := <-w.ResultChan():
}, }, Containers: []v1.Container{ { Name: "run1", Image: "gcr.io/google_containers/busybox:1.24", Command: []string{"/bin/true"}, }, }, }, } if err := podutil.SetInitContainersAnnotations(pod); err != nil { Expect(err).To(BeNil()) } startedPod := podClient.Create(pod) w, err := podClient.Watch(v1.SingleObject(startedPod.ObjectMeta)) Expect(err).NotTo(HaveOccurred(), "error watching a pod") wr := watch.NewRecorder(w) event, err := watch.Until(framework.PodStartTimeout, wr, conditions.PodCompleted) Expect(err).To(BeNil()) framework.CheckInvariants(wr.Events(), framework.ContainerInitInvariant) endPod := event.Object.(*v1.Pod) if err := podutil.SetInitContainersAndStatuses(endPod); err != nil { Expect(err).To(BeNil()) } Expect(endPod.Status.Phase).To(Equal(v1.PodSucceeded)) _, init := v1.GetPodCondition(&endPod.Status, v1.PodInitialized) Expect(init).NotTo(BeNil()) Expect(init.Status).To(Equal(v1.ConditionTrue))