Skip to content

Commit

Permalink
fix test exit code issue
Browse files Browse the repository at this point in the history
  • Loading branch information
zw0610 committed Dec 23, 2021
1 parent 69c8147 commit 6ef54e3
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions pkg/controller.v1/tensorflow/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,22 +236,34 @@ var _ = Describe("TFJob controller", func() {
for k, v := range basicLabels {
pod.Labels[k] = v
}
pod.Spec.Containers = append(pod.Spec.Containers, corev1.Container{})
Expect(testK8sClient.Create(ctx, pod)).Should(Succeed())

po := &corev1.Pod{}
created := &corev1.Pod{}
key := types.NamespacedName{Namespace: metav1.NamespaceDefault, Name: pod.GetName()}
Expect(testK8sClient.Get(ctx, key, po)).Should(Succeed())
po.Status.Phase = corev1.PodFailed
po.Spec.Containers = append(po.Spec.Containers, corev1.Container{})
po.Status.ContainerStatuses = append(po.Status.ContainerStatuses, corev1.ContainerStatus{
Expect(testK8sClient.Get(ctx, key, created)).Should(Succeed())
created.Status.Phase = corev1.PodFailed
created.Status.ContainerStatuses = append(created.Status.ContainerStatuses, corev1.ContainerStatus{
Name: tfv1.DefaultContainerName,
State: corev1.ContainerState{
Terminated: &corev1.ContainerStateTerminated{
ExitCode: 130,
},
},
})
Expect(testK8sClient.Status().Update(ctx, po))
Expect(testK8sClient.Status().Update(ctx, created))

// Make sure the version of pod created is updated with desired status
Eventually(func() error {
updated := &corev1.Pod{}
if err := testK8sClient.Get(ctx, key, updated); err != nil {
return err
}
if updated.Status.Phase != corev1.PodFailed {
return fmt.Errorf("pod status is not Failed")
}
return nil
}, timeout, interval).Should(BeNil())

_ = reconciler.ReconcileJobs(tfJob, tfJob.Spec.TFReplicaSpecs, tfJob.Status, &tfJob.Spec.RunPolicy)

Expand Down

0 comments on commit 6ef54e3

Please sign in to comment.