Modify e2e test for init containers in stable

This commit is contained in:
Dominika Hodovska 2017-01-24 12:53:19 +01:00
parent a856188b96
commit 6c0191b31d

View File

@ -78,9 +78,16 @@ var _ = framework.KubeDescribe("InitContainer", func() {
},
},
}
stable := true
for i := 0; i < 2; i++ {
if !stable {
framework.Logf("PodSpec: initContainers in metadata.annotation")
if err := podutil.SetInitContainersAnnotations(pod); err != nil {
Expect(err).To(BeNil())
}
} else {
framework.Logf("PodSpec: initContainers in spec.initContainers")
}
startedPod := podClient.Create(pod)
w, err := podClient.Watch(metav1.SingleObject(startedPod.ObjectMeta))
Expect(err).NotTo(HaveOccurred(), "error watching a pod")
@ -104,6 +111,10 @@ var _ = framework.KubeDescribe("InitContainer", func() {
Expect(status.State.Terminated).NotTo(BeNil())
Expect(status.State.Terminated.ExitCode).To(BeZero())
}
stable = false
name := "pod-init-" + string(uuid.NewUUID())
pod.Name = name
}
})
It("should invoke init containers on a RestartAlways pod", func() {
@ -147,9 +158,16 @@ var _ = framework.KubeDescribe("InitContainer", func() {
},
},
}
stable := true
for i := 0; i < 2; i++ {
if !stable {
framework.Logf("PodSpec: initContainers in metadata.annotation")
if err := podutil.SetInitContainersAnnotations(pod); err != nil {
Expect(err).To(BeNil())
}
} else {
framework.Logf("PodSpec: initContainers in spec.initContainers")
}
startedPod := podClient.Create(pod)
w, err := podClient.Watch(metav1.SingleObject(startedPod.ObjectMeta))
Expect(err).NotTo(HaveOccurred(), "error watching a pod")
@ -173,6 +191,10 @@ var _ = framework.KubeDescribe("InitContainer", func() {
Expect(status.State.Terminated).NotTo(BeNil())
Expect(status.State.Terminated.ExitCode).To(BeZero())
}
stable = false
name := "pod-init-" + string(uuid.NewUUID())
pod.Name = name
}
})
It("should not start app containers if init containers fail on a RestartAlways pod", func() {
@ -217,9 +239,16 @@ var _ = framework.KubeDescribe("InitContainer", func() {
},
},
}
stable := true
for i := 0; i < 2; i++ {
if !stable {
framework.Logf("PodSpec: initContainers in metadata.annotation")
if err := podutil.SetInitContainersAnnotations(pod); err != nil {
Expect(err).To(BeNil())
}
} else {
framework.Logf("PodSpec: initContainers in spec.initContainers")
}
startedPod := podClient.Create(pod)
w, err := podClient.Watch(metav1.SingleObject(startedPod.ObjectMeta))
Expect(err).NotTo(HaveOccurred(), "error watching a pod")
@ -295,6 +324,10 @@ var _ = framework.KubeDescribe("InitContainer", func() {
Expect(init.Reason).To(Equal("ContainersNotInitialized"))
Expect(init.Message).To(Equal("containers with incomplete status: [init1 init2]"))
Expect(len(endPod.Status.InitContainerStatuses)).To(Equal(2))
stable = false
name := "pod-init-" + string(uuid.NewUUID())
pod.Name = name
}
})
It("should not start app containers and fail the pod if init containers fail on a RestartNever pod", func() {
@ -340,9 +373,16 @@ var _ = framework.KubeDescribe("InitContainer", func() {
},
},
}
stable := true
for i := 0; i < 2; i++ {
if !stable {
framework.Logf("PodSpec: initContainers in metadata.annotation")
if err := podutil.SetInitContainersAnnotations(pod); err != nil {
Expect(err).To(BeNil())
}
} else {
framework.Logf("PodSpec: initContainers in spec.initContainers")
}
startedPod := podClient.Create(pod)
w, err := podClient.Watch(metav1.SingleObject(startedPod.ObjectMeta))
@ -405,5 +445,9 @@ var _ = framework.KubeDescribe("InitContainer", func() {
Expect(init.Message).To(Equal("containers with incomplete status: [init2]"))
Expect(len(endPod.Status.InitContainerStatuses)).To(Equal(2))
Expect(endPod.Status.ContainerStatuses[0].State.Waiting).ToNot(BeNil())
stable = false
name := "pod-init-" + string(uuid.NewUUID())
pod.Name = name
}
})
})