@@ -27,13 +27,14 @@ import (
2727 corev1 "k8s.io/api/core/v1"
2828 "k8s.io/apimachinery/pkg/api/resource"
2929 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
30+ "k8s.io/apimachinery/pkg/types"
3031
3132 . "github.com/project-codeflare/codeflare-operator/test/e2e"
3233)
3334
3435var (
3536 namespaceName = "test-ns-olmupgrade"
36- appwrapperName = "mnist"
37+ appWrapperName = "mnist"
3738 jobName = "mnist-job"
3839)
3940
@@ -132,13 +133,14 @@ func TestMNISTCreateAppWrapper(t *testing.T) {
132133 RestartPolicy : corev1 .RestartPolicyNever ,
133134 },
134135 },
136+ Suspend : Ptr (true ),
135137 },
136138 }
137139
138140 // Create an AppWrapper resource
139141 aw := & mcadv1beta1.AppWrapper {
140142 ObjectMeta : metav1.ObjectMeta {
141- Name : appwrapperName ,
143+ Name : appWrapperName ,
142144 Namespace : namespace .Name ,
143145 },
144146 Spec : mcadv1beta1.AppWrapperSpec {
@@ -187,20 +189,27 @@ func TestMNISTCheckAppWrapperStatus(t *testing.T) {
187189 //delete the namespace after test complete
188190 defer DeleteTestNamespace (test , namespace )
189191
190- aw , err := test .Client ().MCAD ().WorkloadV1beta1 ().AppWrappers (namespace .Name ).Get (test .Ctx (), appwrapperName , metav1.GetOptions {})
192+ // Patch job to resume execution
193+ patch := []byte (`[{"op":"replace","path":"/spec/suspend","value": false}]` )
194+ job , err := test .Client ().Core ().BatchV1 ().Jobs (namespace .Name ).Patch (test .Ctx (), jobName , types .JSONPatchType , patch , metav1.PatchOptions {})
191195 test .Expect (err ).NotTo (HaveOccurred ())
192196
193- job , err := test .Client ().Core ().BatchV1 ().Jobs (namespace .Name ).Get (test .Ctx (), jobName , metav1.GetOptions {})
194- test .Expect (err ).NotTo (HaveOccurred ())
195197 test .T ().Logf ("Waiting for Job %s/%s to complete" , job .Namespace , job .Name )
196- test .Eventually (AppWrapper (test , namespace , aw .Name ), TestTimeoutLong ).Should (
198+ test .Eventually (Job (test , job .Namespace , job .Name ), TestTimeoutLong ).Should (
199+ Or (
200+ WithTransform (ConditionStatus (batchv1 .JobComplete ), Equal (corev1 .ConditionTrue )),
201+ WithTransform (ConditionStatus (batchv1 .JobFailed ), Equal (corev1 .ConditionTrue )),
202+ ))
203+
204+ test .T ().Logf ("Waiting for AppWrapper %s/%s to complete" , namespace .Name , appWrapperName )
205+ test .Eventually (AppWrapper (test , namespace , appWrapperName ), TestTimeoutShort ).Should (
197206 Or (
198207 WithTransform (AppWrapperState , Equal (mcadv1beta1 .AppWrapperStateCompleted )),
199208 WithTransform (AppWrapperState , Equal (mcadv1beta1 .AppWrapperStateFailed )),
200209 ))
201210
202- // Assert the job has completed successfully
203- test .Expect (GetAppWrapper (test , namespace , aw . Name )).
211+ // Assert the AppWrapper has completed successfully
212+ test .Expect (GetAppWrapper (test , namespace , appWrapperName )).
204213 To (WithTransform (AppWrapperState , Equal (mcadv1beta1 .AppWrapperStateCompleted )))
205214
206215}
0 commit comments