Skip to content

Commit ea9ee6a

Browse files
committed
refactor to use aw.Name
1 parent 9ab7a79 commit ea9ee6a

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

test/e2e/instascale_app_wrapper.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
. "github.com/project-codeflare/codeflare-operator/test/support"
2828
)
2929

30-
func createInstaScaleJobAppWrapper(test Test, namespace *corev1.Namespace, config *corev1.ConfigMap) (*batchv1.Job, *mcadv1beta1.AppWrapper, error) {
30+
func instaScaleJobAppWrapper(test Test, namespace *corev1.Namespace, config *corev1.ConfigMap) *mcadv1beta1.AppWrapper {
3131
// Batch Job
3232
job := &batchv1.Job{
3333
TypeMeta: metav1.TypeMeta{
@@ -89,7 +89,7 @@ func createInstaScaleJobAppWrapper(test Test, namespace *corev1.Namespace, confi
8989
},
9090
}
9191

92-
// create an appwrapper
92+
// AppWrapper
9393
aw := &mcadv1beta1.AppWrapper{
9494
ObjectMeta: metav1.ObjectMeta{
9595
Name: "test-instascale",
@@ -136,7 +136,5 @@ func createInstaScaleJobAppWrapper(test Test, namespace *corev1.Namespace, confi
136136
},
137137
}
138138

139-
_, err := test.Client().MCAD().WorkloadV1beta1().AppWrappers(namespace.Name).Create(test.Ctx(), aw, metav1.CreateOptions{})
140-
141-
return job, aw, err
139+
return aw
142140
}

test/e2e/instascale_machinepool_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
. "github.com/onsi/gomega"
2323
mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1"
2424

25+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
26+
2527
. "github.com/project-codeflare/codeflare-operator/test/support"
2628
)
2729

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

5658
// Setup batch job and AppWrapper
57-
_, aw, err := createInstaScaleJobAppWrapper(test, namespace, cm)
59+
aw := instaScaleJobAppWrapper(test, namespace, cm)
60+
61+
// apply AppWrapper to cluster
62+
_, err := test.Client().MCAD().WorkloadV1beta1().AppWrappers(namespace.Name).Create(test.Ctx(), aw, metav1.CreateOptions{})
5863
test.Expect(err).NotTo(HaveOccurred())
5964
test.T().Logf("AppWrapper created successfully %s/%s", aw.Namespace, aw.Name)
6065

test/e2e/instascale_machineset_test.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
. "github.com/onsi/gomega"
77
mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1"
88

9+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
10+
911
. "github.com/project-codeflare/codeflare-operator/test/support"
1012
)
1113

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

34+
// // Setup batch job and AppWrapper
35+
aw := instaScaleJobAppWrapper(test, namespace, cm)
36+
3237
// look for machine set with aw name - expect to find it
33-
test.Expect(GetMachineSets(test)).Should(ContainElement(WithTransform(MachineSetId, Equal("test-instascale"))))
38+
test.Expect(GetMachineSets(test)).Should(ContainElement(WithTransform(MachineSetId, Equal(aw.Name))))
3439
// look for machine belonging to the machine set, there should be none
35-
test.Expect(GetMachines(test, "test-instascale")).Should(BeEmpty())
40+
test.Expect(GetMachines(test, aw.Name)).Should(BeEmpty())
3641

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

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

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

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

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

5560
}

0 commit comments

Comments
 (0)