Skip to content

Commit 926d35d

Browse files
tenzen-yjohnugeorge
authored andcommitted
Test: Simplify and Identify pod-controller envtest (kubeflow#2084)
Signed-off-by: Yuki Iwai <[email protected]>
1 parent f2b7612 commit 926d35d

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

pkg/controller.v1/tensorflow/pod_test.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import (
1919
"fmt"
2020
"os"
2121

22+
"github.com/google/go-cmp/cmp/cmpopts"
2223
. "github.com/onsi/ginkgo/v2"
2324
. "github.com/onsi/gomega"
24-
. "github.com/onsi/gomega/gstruct"
2525
corev1 "k8s.io/api/core/v1"
2626
"k8s.io/apimachinery/pkg/api/errors"
2727
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -32,6 +32,7 @@ import (
3232
kubeflowv1 "github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v1"
3333
tftestutil "github.com/kubeflow/training-operator/pkg/controller.v1/tensorflow/testutil"
3434
"github.com/kubeflow/training-operator/pkg/core"
35+
commonutil "github.com/kubeflow/training-operator/pkg/util"
3536
"github.com/kubeflow/training-operator/pkg/util/testutil"
3637
)
3738

@@ -307,14 +308,12 @@ var _ = Describe("TFJob controller", func() {
307308
Eventually(func(g Gomega) {
308309
updatedJob := &kubeflowv1.TFJob{}
309310
g.Expect(testK8sClient.Get(ctx, types.NamespacedName{Name: tfJob.GetName(), Namespace: metav1.NamespaceDefault}, updatedJob)).Should(Succeed())
310-
expectedCondition := kubeflowv1.JobCondition{ // Make sure this type is correct
311-
Type: "Failed",
312-
Status: "True",
313-
}
314-
g.Expect(updatedJob.Status.Conditions).Should(ConsistOf(MatchFields(IgnoreExtras, Fields{
315-
"Type": Equal(expectedCondition.Type),
316-
"Status": Equal(expectedCondition.Status),
317-
})), "TFJob should be in Failed state")
311+
g.Expect(updatedJob.Status.Conditions).Should(ContainElements(BeComparableTo(kubeflowv1.JobCondition{
312+
Type: kubeflowv1.JobFailed,
313+
Status: corev1.ConditionTrue,
314+
Reason: commonutil.NewReason(kubeflowv1.TFJobKind, commonutil.JobFailedReason),
315+
Message: fmt.Sprintf("job %q is failing because %q replica(s) failed.", updatedJob.Name, kubeflowv1.TFJobReplicaTypeWorker),
316+
}, cmpopts.IgnoreFields(kubeflowv1.JobCondition{}, "LastUpdateTime", "LastTransitionTime"))), "TFJob should be in Failed state")
318317
}, testutil.Timeout, testutil.Interval).Should(Succeed())
319318

320319
})

0 commit comments

Comments
 (0)