Skip to content

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
fix test exit code issue

fix pod spec
  • Loading branch information
zw0610 committed Dec 23, 2021
1 parent 4571b22 commit f7acfc6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pkg/common/util/v1/testutil/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
)

const (
DummyPortName = "dummy"
DummyPort int32 = 1221
DummyPortName string = "dummy"
DummyPort int32 = 1221
)

func NewBaseService(name string, job metav1.Object, refs []metav1.OwnerReference) *corev1.Service {
Expand Down
27 changes: 21 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,37 @@ var _ = Describe("TFJob controller", func() {
for k, v := range basicLabels {
pod.Labels[k] = v
}
pod.Spec.Containers = append(pod.Spec.Containers, corev1.Container{
Name: tfv1.DefaultContainerName,
Image: testutil.DummyContainerImage,
})
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
6 changes: 0 additions & 6 deletions pkg/controller.v1/tensorflow/tfjob_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ import (
)

var _ = Describe("TFJob controller", func() {
// Define utility constants for object names and testing timeouts/durations and intervals.
//const (
// timeout = 10 * time.Second
// interval = 1000 * time.Millisecond
//)

Context("Test Normal Path", func() {
It("should create desired Pods and Services", func() {
var (
Expand Down

0 comments on commit f7acfc6

Please sign in to comment.