Skip to content

Adjust upgrade e2e test to pause Job before upgrade #427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions test/upgrade/olm_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"

. "github.com/project-codeflare/codeflare-operator/test/e2e"
)

var (
namespaceName = "test-ns-olmupgrade"
appwrapperName = "mnist"
appWrapperName = "mnist"
jobName = "mnist-job"
)

Expand Down Expand Up @@ -132,13 +133,14 @@ func TestMNISTCreateAppWrapper(t *testing.T) {
RestartPolicy: corev1.RestartPolicyNever,
},
},
Suspend: Ptr(true),
},
}

// Create an AppWrapper resource
aw := &mcadv1beta1.AppWrapper{
ObjectMeta: metav1.ObjectMeta{
Name: appwrapperName,
Name: appWrapperName,
Namespace: namespace.Name,
},
Spec: mcadv1beta1.AppWrapperSpec{
Expand Down Expand Up @@ -187,20 +189,27 @@ func TestMNISTCheckAppWrapperStatus(t *testing.T) {
//delete the namespace after test complete
defer DeleteTestNamespace(test, namespace)

aw, err := test.Client().MCAD().WorkloadV1beta1().AppWrappers(namespace.Name).Get(test.Ctx(), appwrapperName, metav1.GetOptions{})
// Patch job to resume execution
patch := []byte(`[{"op":"replace","path":"/spec/suspend","value": false}]`)
job, err := test.Client().Core().BatchV1().Jobs(namespace.Name).Patch(test.Ctx(), jobName, types.JSONPatchType, patch, metav1.PatchOptions{})
test.Expect(err).NotTo(HaveOccurred())

job, err := test.Client().Core().BatchV1().Jobs(namespace.Name).Get(test.Ctx(), jobName, metav1.GetOptions{})
test.Expect(err).NotTo(HaveOccurred())
test.T().Logf("Waiting for Job %s/%s to complete", job.Namespace, job.Name)
test.Eventually(AppWrapper(test, namespace, aw.Name), TestTimeoutLong).Should(
test.Eventually(Job(test, job.Namespace, job.Name), TestTimeoutLong).Should(
Or(
WithTransform(ConditionStatus(batchv1.JobComplete), Equal(corev1.ConditionTrue)),
WithTransform(ConditionStatus(batchv1.JobFailed), Equal(corev1.ConditionTrue)),
))

test.T().Logf("Waiting for AppWrapper %s/%s to complete", namespace.Name, appWrapperName)
test.Eventually(AppWrapper(test, namespace, appWrapperName), TestTimeoutShort).Should(
Or(
WithTransform(AppWrapperState, Equal(mcadv1beta1.AppWrapperStateCompleted)),
WithTransform(AppWrapperState, Equal(mcadv1beta1.AppWrapperStateFailed)),
))

// Assert the job has completed successfully
test.Expect(GetAppWrapper(test, namespace, aw.Name)).
// Assert the AppWrapper has completed successfully
test.Expect(GetAppWrapper(test, namespace, appWrapperName)).
To(WithTransform(AppWrapperState, Equal(mcadv1beta1.AppWrapperStateCompleted)))

}