Skip to content

Commit

Permalink
refactor to use aw.Name
Browse files Browse the repository at this point in the history
  • Loading branch information
Fiona-Waters committed Oct 16, 2023
1 parent 9ab7a79 commit ea9ee6a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
8 changes: 3 additions & 5 deletions test/e2e/instascale_app_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
. "github.com/project-codeflare/codeflare-operator/test/support"
)

func createInstaScaleJobAppWrapper(test Test, namespace *corev1.Namespace, config *corev1.ConfigMap) (*batchv1.Job, *mcadv1beta1.AppWrapper, error) {
func instaScaleJobAppWrapper(test Test, namespace *corev1.Namespace, config *corev1.ConfigMap) *mcadv1beta1.AppWrapper {
// Batch Job
job := &batchv1.Job{
TypeMeta: metav1.TypeMeta{
Expand Down Expand Up @@ -89,7 +89,7 @@ func createInstaScaleJobAppWrapper(test Test, namespace *corev1.Namespace, confi
},
}

// create an appwrapper
// AppWrapper
aw := &mcadv1beta1.AppWrapper{
ObjectMeta: metav1.ObjectMeta{
Name: "test-instascale",
Expand Down Expand Up @@ -136,7 +136,5 @@ func createInstaScaleJobAppWrapper(test Test, namespace *corev1.Namespace, confi
},
}

_, err := test.Client().MCAD().WorkloadV1beta1().AppWrappers(namespace.Name).Create(test.Ctx(), aw, metav1.CreateOptions{})

return job, aw, err
return aw
}
7 changes: 6 additions & 1 deletion test/e2e/instascale_machinepool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
. "github.com/onsi/gomega"
mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

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

Expand Down Expand Up @@ -54,7 +56,10 @@ func TestInstascaleMachinePool(t *testing.T) {
ShouldNot(ContainElement(WithTransform(MachinePoolId, Equal("test-instascale-g4dn-xlarge"))))

// Setup batch job and AppWrapper
_, aw, err := createInstaScaleJobAppWrapper(test, namespace, cm)
aw := instaScaleJobAppWrapper(test, namespace, cm)

// apply AppWrapper to cluster
_, err := test.Client().MCAD().WorkloadV1beta1().AppWrappers(namespace.Name).Create(test.Ctx(), aw, metav1.CreateOptions{})
test.Expect(err).NotTo(HaveOccurred())
test.T().Logf("AppWrapper created successfully %s/%s", aw.Namespace, aw.Name)

Expand Down
17 changes: 11 additions & 6 deletions test/e2e/instascale_machineset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
. "github.com/onsi/gomega"
mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

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

Expand All @@ -29,27 +31,30 @@ func TestInstascaleMachineSet(t *testing.T) {
"mnist.py": ReadFile(test, "mnist.py"),
})

// // Setup batch job and AppWrapper
aw := instaScaleJobAppWrapper(test, namespace, cm)

// look for machine set with aw name - expect to find it
test.Expect(GetMachineSets(test)).Should(ContainElement(WithTransform(MachineSetId, Equal("test-instascale"))))
test.Expect(GetMachineSets(test)).Should(ContainElement(WithTransform(MachineSetId, Equal(aw.Name))))
// look for machine belonging to the machine set, there should be none
test.Expect(GetMachines(test, "test-instascale")).Should(BeEmpty())
test.Expect(GetMachines(test, aw.Name)).Should(BeEmpty())

// // Setup batch job and AppWrapper
_, aw, err := createInstaScaleJobAppWrapper(test, namespace, cm)
// apply AppWrapper to cluster
_, err := test.Client().MCAD().WorkloadV1beta1().AppWrappers(namespace.Name).Create(test.Ctx(), aw, metav1.CreateOptions{})
test.Expect(err).NotTo(HaveOccurred())

// assert that AppWrapper goes to "Running" state
test.Eventually(AppWrapper(test, namespace, aw.Name), TestTimeoutGpuProvisioning).
Should(WithTransform(AppWrapperState, Equal(mcadv1beta1.AppWrapperStateActive)))

// look for machine belonging to the machine set - expect to find it
test.Eventually(Machines(test, "test-instascale"), TestTimeoutLong).Should(HaveLen(1))
test.Eventually(Machines(test, aw.Name), TestTimeoutLong).Should(HaveLen(1))

// assert that the AppWrapper goes to "Completed" state
test.Eventually(AppWrapper(test, namespace, aw.Name), TestTimeoutMedium).
Should(WithTransform(AppWrapperState, Equal(mcadv1beta1.AppWrapperStateCompleted)))

// look for machine belonging to the machine set - there should be none
test.Eventually(Machines(test, "test-instascale"), TestTimeoutLong).Should(BeEmpty())
test.Eventually(Machines(test, aw.Name), TestTimeoutLong).Should(BeEmpty())

}

0 comments on commit ea9ee6a

Please sign in to comment.