@@ -25,7 +25,6 @@ import (
2525 corev1 "k8s.io/api/core/v1"
2626 "k8s.io/apimachinery/pkg/api/resource"
2727 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28- "k8s.io/apimachinery/pkg/labels"
2928
3029 . "github.com/project-codeflare/codeflare-operator/test/support"
3130 mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1"
@@ -179,22 +178,17 @@ torchvision==0.12.0
179178 test .Eventually (AppWrapper (test , namespace , aw .Name ), TestTimeoutMedium ).
180179 Should (WithTransform (AppWrapperState , Equal (mcadv1beta1 .AppWrapperStateActive )))
181180
182- defer JobTroubleshooting (test , job )
183-
184- test .T ().Logf ("Waiting for Job %s/%s to complete successfully" , job .Namespace , job .Name )
185- test .Eventually (Job (test , job .Namespace , job .Name ), TestTimeoutLong ).
186- Should (WithTransform (ConditionStatus (batchv1 .JobComplete ), Equal (corev1 .ConditionTrue )))
187-
188- // Refresh the job to get the generated pod selector
189- job = GetJob (test , job .Namespace , job .Name )
190-
191- // Get the job Pod
192- pods := GetPods (test , job .Namespace , metav1.ListOptions {
193- LabelSelector : labels .FormatLabels (job .Spec .Selector .MatchLabels )},
194- )
195- test .Expect (pods ).To (HaveLen (1 ))
181+ test .T ().Logf ("Waiting for Job %s/%s to complete" , job .Namespace , job .Name )
182+ test .Eventually (Job (test , job .Namespace , job .Name ), TestTimeoutLong ).Should (
183+ Or (
184+ WithTransform (ConditionStatus (batchv1 .JobComplete ), Equal (corev1 .ConditionTrue )),
185+ WithTransform (ConditionStatus (batchv1 .JobFailed ), Equal (corev1 .ConditionTrue )),
186+ ))
196187
197188 // Print the job logs
198- test .T ().Logf ("Printing Job %s/%s logs" , job .Namespace , job .Name )
199- test .T ().Log (GetPodLogs (test , & pods [0 ], corev1.PodLogOptions {}))
189+ PrintJobLogs (test , job .Namespace , job .Name )
190+
191+ // Assert the job has completed successfully
192+ test .Expect (GetJob (test , job .Namespace , job .Name )).
193+ To (WithTransform (ConditionStatus (batchv1 .JobComplete ), Equal (corev1 .ConditionTrue )))
200194}
0 commit comments