@@ -27,13 +27,14 @@ import (
27
27
corev1 "k8s.io/api/core/v1"
28
28
"k8s.io/apimachinery/pkg/api/resource"
29
29
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
30
+ "k8s.io/apimachinery/pkg/types"
30
31
31
32
. "github.com/project-codeflare/codeflare-operator/test/e2e"
32
33
)
33
34
34
35
var (
35
36
namespaceName = "test-ns-olmupgrade"
36
- appwrapperName = "mnist"
37
+ appWrapperName = "mnist"
37
38
jobName = "mnist-job"
38
39
)
39
40
@@ -132,13 +133,14 @@ func TestMNISTCreateAppWrapper(t *testing.T) {
132
133
RestartPolicy : corev1 .RestartPolicyNever ,
133
134
},
134
135
},
136
+ Suspend : Ptr (true ),
135
137
},
136
138
}
137
139
138
140
// Create an AppWrapper resource
139
141
aw := & mcadv1beta1.AppWrapper {
140
142
ObjectMeta : metav1.ObjectMeta {
141
- Name : appwrapperName ,
143
+ Name : appWrapperName ,
142
144
Namespace : namespace .Name ,
143
145
},
144
146
Spec : mcadv1beta1.AppWrapperSpec {
@@ -187,20 +189,27 @@ func TestMNISTCheckAppWrapperStatus(t *testing.T) {
187
189
//delete the namespace after test complete
188
190
defer DeleteTestNamespace (test , namespace )
189
191
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 {})
191
195
test .Expect (err ).NotTo (HaveOccurred ())
192
196
193
- job , err := test .Client ().Core ().BatchV1 ().Jobs (namespace .Name ).Get (test .Ctx (), jobName , metav1.GetOptions {})
194
- test .Expect (err ).NotTo (HaveOccurred ())
195
197
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 (
197
206
Or (
198
207
WithTransform (AppWrapperState , Equal (mcadv1beta1 .AppWrapperStateCompleted )),
199
208
WithTransform (AppWrapperState , Equal (mcadv1beta1 .AppWrapperStateFailed )),
200
209
))
201
210
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 )).
204
213
To (WithTransform (AppWrapperState , Equal (mcadv1beta1 .AppWrapperStateCompleted )))
205
214
206
215
}
0 commit comments