Skip to content

Commit 58dc44b

Browse files
committed
refactored test just for machine pools
1 parent e3c8b67 commit 58dc44b

File tree

1 file changed

+22
-57
lines changed

1 file changed

+22
-57
lines changed

test/e2e/instascale_test.go renamed to test/e2e/instascale_machinepool_test.go

Lines changed: 22 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ import (
55
"time"
66

77
. "github.com/onsi/gomega"
8-
. "github.com/project-codeflare/codeflare-operator/test/support"
98
mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1"
9+
1010
batchv1 "k8s.io/api/batch/v1"
1111
corev1 "k8s.io/api/core/v1"
1212
"k8s.io/apimachinery/pkg/api/resource"
1313
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14+
15+
. "github.com/project-codeflare/codeflare-operator/test/support"
1416
)
1517

16-
func TestInstascale(t *testing.T) {
18+
func TestInstascaleMachinePool(t *testing.T) {
1719

1820
test := With(t)
1921
test.T().Parallel()
@@ -38,11 +40,12 @@ func TestInstascale(t *testing.T) {
3840
},
3941
Immutable: Ptr(true),
4042
}
43+
4144
config, err := test.Client().Core().CoreV1().ConfigMaps(namespace.Name).Create(test.Ctx(), config, metav1.CreateOptions{})
4245
test.Expect(err).NotTo(HaveOccurred())
4346
test.T().Logf("Created ConfigMap %s/%s successfully", config.Namespace, config.Name)
4447

45-
// create OCM connection
48+
//create OCM connection
4649
instascaleOCMSecret, err := test.Client().Core().CoreV1().Secrets("default").Get(test.Ctx(), "instascale-ocm-secret", metav1.GetOptions{})
4750
if err != nil {
4851
test.T().Errorf("unable to retrieve instascale-ocm-secret - Error : %v", err)
@@ -57,27 +60,10 @@ func TestInstascale(t *testing.T) {
5760
}
5861
defer connection.Close()
5962

60-
// check existing cluster resources
61-
machinePoolsExist, err := MachinePoolsExist(connection)
62-
test.Expect(err).NotTo(HaveOccurred())
63-
nodePoolsExist, err := NodePoolsExist(connection)
63+
// check existing cluster machine pool resources
64+
foundMachinePool, err := CheckMachinePools(connection, TestName)
6465
test.Expect(err).NotTo(HaveOccurred())
65-
66-
if machinePoolsExist {
67-
// look for machine pool with aw name - expect not to find it
68-
foundMachinePool, err := CheckMachinePools(connection, TestName)
69-
test.Expect(err).NotTo(HaveOccurred())
70-
test.Expect(foundMachinePool).To(BeFalse())
71-
} else if nodePoolsExist {
72-
// look for node pool with aw name - expect not to find it
73-
foundNodePool, err := CheckNodePools(connection, TestName)
74-
test.Expect(err).NotTo(HaveOccurred())
75-
test.Expect(foundNodePool).To(BeFalse())
76-
} else {
77-
foundMachineSet, err := CheckMachineSets(TestName)
78-
test.Expect(err).NotTo(HaveOccurred())
79-
test.Expect(foundMachineSet).To(BeFalse())
80-
}
66+
test.Expect(foundMachinePool).To(BeFalse())
8167

8268
// Batch Job
8369
job := &batchv1.Job{
@@ -159,10 +145,12 @@ func TestInstascale(t *testing.T) {
159145
Requests: corev1.ResourceList{
160146
corev1.ResourceCPU: resource.MustParse("250m"),
161147
corev1.ResourceMemory: resource.MustParse("512Mi"),
148+
"nvidia.com/gpu": resource.MustParse("1"),
162149
},
163150
Limits: corev1.ResourceList{
164151
corev1.ResourceCPU: resource.MustParse("500m"),
165152
corev1.ResourceMemory: resource.MustParse("1G"),
153+
"nvidia.com/gpu": resource.MustParse("1"),
166154
},
167155
},
168156
{
@@ -194,23 +182,11 @@ func TestInstascale(t *testing.T) {
194182

195183
// time.Sleep is used twice throughout the test, each for 30 seconds. Can look into using sync package waitGroup instead if that makes more sense
196184
// wait for required resources to scale up before checking them again
197-
time.Sleep(TestTimeoutThirtySeconds)
198-
199-
if machinePoolsExist {
200-
// look for machine pool with aw name - expect to find it
201-
foundMachinePool, err := CheckMachinePools(connection, TestName)
202-
test.Expect(err).NotTo(HaveOccurred())
203-
test.Expect(foundMachinePool).To(BeTrue())
204-
} else if nodePoolsExist {
205-
// look for node pool with aw name - expect to find it
206-
foundNodePool, err := CheckNodePools(connection, TestName)
207-
test.Expect(err).NotTo(HaveOccurred())
208-
test.Expect(foundNodePool).To(BeTrue())
209-
} else {
210-
foundMachineSet, err := CheckMachineSets(TestName)
211-
test.Expect(err).NotTo(HaveOccurred())
212-
test.Expect(foundMachineSet).To(BeTrue())
213-
}
185+
time.Sleep(TestTimeoutMedium)
186+
187+
foundMachinePool, err = CheckMachinePools(connection, TestName)
188+
test.Expect(err).NotTo(HaveOccurred())
189+
test.Expect(foundMachinePool).To(BeTrue())
214190

215191
// Assert that the job has completed
216192
test.T().Logf("Waiting for Job %s/%s to complete", job.Namespace, job.Name)
@@ -228,21 +204,10 @@ func TestInstascale(t *testing.T) {
228204
Should(WithTransform(AppWrapperState, Equal(mcadv1beta1.AppWrapperStateCompleted)))
229205

230206
// allow time for the resources to scale down before checking them again
231-
time.Sleep(TestTimeoutThirtySeconds)
232-
233-
if machinePoolsExist {
234-
// look for machine pool with aw name - expect to find it
235-
foundMachinePool, err := CheckMachinePools(connection, TestName)
236-
test.Expect(err).NotTo(HaveOccurred())
237-
test.Expect(foundMachinePool).To(BeFalse())
238-
} else if nodePoolsExist {
239-
// look for node pool with aw name - expect to find it
240-
foundNodePool, err := CheckNodePools(connection, TestName)
241-
test.Expect(err).NotTo(HaveOccurred())
242-
test.Expect(foundNodePool).To(BeFalse())
243-
} else {
244-
foundMachineSet, err := CheckMachineSets(TestName)
245-
test.Expect(err).NotTo(HaveOccurred())
246-
test.Expect(foundMachineSet).To(BeFalse())
247-
}
207+
time.Sleep(TestTimeoutMedium)
208+
209+
foundMachinePool, err = CheckMachinePools(connection, TestName)
210+
test.Expect(err).NotTo(HaveOccurred())
211+
test.Expect(foundMachinePool).To(BeFalse())
212+
248213
}

0 commit comments

Comments
 (0)