@@ -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,11 @@ 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+ // look for machine pool with aw name - expect not to find it
65+ foundMachinePool , err := CheckMachinePools (connection , TestName )
6466 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- }
67+ test .Expect (foundMachinePool ).To (BeFalse ())
8168
8269 // Batch Job
8370 job := & batchv1.Job {
@@ -159,10 +146,12 @@ func TestInstascale(t *testing.T) {
159146 Requests : corev1.ResourceList {
160147 corev1 .ResourceCPU : resource .MustParse ("250m" ),
161148 corev1 .ResourceMemory : resource .MustParse ("512Mi" ),
149+ "nvidia.com/gpu" : resource .MustParse ("1" ),
162150 },
163151 Limits : corev1.ResourceList {
164152 corev1 .ResourceCPU : resource .MustParse ("500m" ),
165153 corev1 .ResourceMemory : resource .MustParse ("1G" ),
154+ "nvidia.com/gpu" : resource .MustParse ("1" ),
166155 },
167156 },
168157 {
@@ -194,23 +183,12 @@ func TestInstascale(t *testing.T) {
194183
195184 // 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
196185 // 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- }
186+ time .Sleep (TestTimeoutMedium )
187+
188+ // look for machine pool with aw name - expect to find it
189+ foundMachinePool , err = CheckMachinePools (connection , TestName )
190+ test .Expect (err ).NotTo (HaveOccurred ())
191+ test .Expect (foundMachinePool ).To (BeTrue ())
214192
215193 // Assert that the job has completed
216194 test .T ().Logf ("Waiting for Job %s/%s to complete" , job .Namespace , job .Name )
@@ -228,21 +206,11 @@ func TestInstascale(t *testing.T) {
228206 Should (WithTransform (AppWrapperState , Equal (mcadv1beta1 .AppWrapperStateCompleted )))
229207
230208 // 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- }
209+ time .Sleep (TestTimeoutMedium )
210+
211+ // look for machine pool with aw name - expect not to find it
212+ foundMachinePool , err = CheckMachinePools (connection , TestName )
213+ test .Expect (err ).NotTo (HaveOccurred ())
214+ test .Expect (foundMachinePool ).To (BeFalse ())
215+
248216}
0 commit comments