@@ -5,15 +5,17 @@ import (
5
5
"time"
6
6
7
7
. "github.com/onsi/gomega"
8
- . "github.com/project-codeflare/codeflare-operator/test/support"
9
8
mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1"
9
+
10
10
batchv1 "k8s.io/api/batch/v1"
11
11
corev1 "k8s.io/api/core/v1"
12
12
"k8s.io/apimachinery/pkg/api/resource"
13
13
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14
+
15
+ . "github.com/project-codeflare/codeflare-operator/test/support"
14
16
)
15
17
16
- func TestInstascale (t * testing.T ) {
18
+ func TestInstascaleMachinePool (t * testing.T ) {
17
19
18
20
test := With (t )
19
21
test .T ().Parallel ()
@@ -38,11 +40,12 @@ func TestInstascale(t *testing.T) {
38
40
},
39
41
Immutable : Ptr (true ),
40
42
}
43
+
41
44
config , err := test .Client ().Core ().CoreV1 ().ConfigMaps (namespace .Name ).Create (test .Ctx (), config , metav1.CreateOptions {})
42
45
test .Expect (err ).NotTo (HaveOccurred ())
43
46
test .T ().Logf ("Created ConfigMap %s/%s successfully" , config .Namespace , config .Name )
44
47
45
- // create OCM connection
48
+ //create OCM connection
46
49
instascaleOCMSecret , err := test .Client ().Core ().CoreV1 ().Secrets ("default" ).Get (test .Ctx (), "instascale-ocm-secret" , metav1.GetOptions {})
47
50
if err != nil {
48
51
test .T ().Errorf ("unable to retrieve instascale-ocm-secret - Error : %v" , err )
@@ -57,27 +60,11 @@ func TestInstascale(t *testing.T) {
57
60
}
58
61
defer connection .Close ()
59
62
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 )
64
66
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 ())
81
68
82
69
// Batch Job
83
70
job := & batchv1.Job {
@@ -159,10 +146,12 @@ func TestInstascale(t *testing.T) {
159
146
Requests : corev1.ResourceList {
160
147
corev1 .ResourceCPU : resource .MustParse ("250m" ),
161
148
corev1 .ResourceMemory : resource .MustParse ("512Mi" ),
149
+ "nvidia.com/gpu" : resource .MustParse ("1" ),
162
150
},
163
151
Limits : corev1.ResourceList {
164
152
corev1 .ResourceCPU : resource .MustParse ("500m" ),
165
153
corev1 .ResourceMemory : resource .MustParse ("1G" ),
154
+ "nvidia.com/gpu" : resource .MustParse ("1" ),
166
155
},
167
156
},
168
157
{
@@ -194,23 +183,12 @@ func TestInstascale(t *testing.T) {
194
183
195
184
// 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
196
185
// 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 ())
214
192
215
193
// Assert that the job has completed
216
194
test .T ().Logf ("Waiting for Job %s/%s to complete" , job .Namespace , job .Name )
@@ -228,21 +206,11 @@ func TestInstascale(t *testing.T) {
228
206
Should (WithTransform (AppWrapperState , Equal (mcadv1beta1 .AppWrapperStateCompleted )))
229
207
230
208
// 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
+
248
216
}
0 commit comments