@@ -19,9 +19,9 @@ import (
19
19
"fmt"
20
20
"os"
21
21
22
+ "github.com/google/go-cmp/cmp/cmpopts"
22
23
. "github.com/onsi/ginkgo/v2"
23
24
. "github.com/onsi/gomega"
24
- . "github.com/onsi/gomega/gstruct"
25
25
corev1 "k8s.io/api/core/v1"
26
26
"k8s.io/apimachinery/pkg/api/errors"
27
27
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -32,6 +32,7 @@ import (
32
32
kubeflowv1 "github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v1"
33
33
tftestutil "github.com/kubeflow/training-operator/pkg/controller.v1/tensorflow/testutil"
34
34
"github.com/kubeflow/training-operator/pkg/core"
35
+ commonutil "github.com/kubeflow/training-operator/pkg/util"
35
36
"github.com/kubeflow/training-operator/pkg/util/testutil"
36
37
)
37
38
@@ -307,14 +308,12 @@ var _ = Describe("TFJob controller", func() {
307
308
Eventually (func (g Gomega ) {
308
309
updatedJob := & kubeflowv1.TFJob {}
309
310
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" )
318
317
}, testutil .Timeout , testutil .Interval ).Should (Succeed ())
319
318
320
319
})
0 commit comments