Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Commit 6c43233

Browse files
authored
enable tests based on CPU resource accounting (#83)
* remove obsolete utility function; mcad v2 doesn't manage namespaces * group related functions together * compute and log cluster capacity at start of test suite * enable tests that rely on CPU accounting to work as expected
1 parent 3ddcb4c commit 6c43233

File tree

3 files changed

+165
-468
lines changed

3 files changed

+165
-468
lines changed

test/e2e/aw_fixtures.go

Lines changed: 7 additions & 298 deletions
Original file line numberDiff line numberDiff line change
@@ -261,298 +261,6 @@ func createDeploymentAW(ctx context.Context, name string) *arbv1.AppWrapper {
261261
return aw
262262
}
263263

264-
func createDeploymentAWwith550CPU(ctx context.Context, name string) *arbv1.AppWrapper {
265-
rb := []byte(`{"apiVersion": "apps/v1",
266-
"kind": "Deployment",
267-
"metadata": {
268-
"name": "` + name + `",
269-
"namespace": "test",
270-
"labels": {
271-
"app": "` + name + `"
272-
}
273-
},
274-
"spec": {
275-
"replicas": 2,
276-
"selector": {
277-
"matchLabels": {
278-
"app": "` + name + `"
279-
}
280-
},
281-
"template": {
282-
"metadata": {
283-
"labels": {
284-
"app": "` + name + `"
285-
}
286-
},
287-
"spec": {
288-
"containers": [
289-
{
290-
"name": "` + name + `",
291-
"image": "quay.io/project-codeflare/echo-server:1.0",
292-
"resources": {
293-
"requests": {
294-
"cpu": "550m"
295-
}
296-
},
297-
"ports": [
298-
{
299-
"containerPort": 80
300-
}
301-
]
302-
}
303-
]
304-
}
305-
}
306-
}} `)
307-
var schedSpecMin int32 = 2
308-
309-
aw := &arbv1.AppWrapper{
310-
ObjectMeta: metav1.ObjectMeta{
311-
Name: name,
312-
Namespace: testNamespace,
313-
},
314-
Spec: arbv1.AppWrapperSpec{
315-
Scheduling: arbv1.SchedulingSpec{
316-
MinAvailable: schedSpecMin,
317-
},
318-
Resources: arbv1.AppWrapperResources{
319-
GenericItems: []arbv1.GenericItem{
320-
{
321-
DoNotUseReplicas: 1,
322-
GenericTemplate: runtime.RawExtension{
323-
Raw: rb,
324-
},
325-
},
326-
},
327-
},
328-
},
329-
}
330-
331-
err := getClient(ctx).Create(ctx, aw)
332-
Expect(err).NotTo(HaveOccurred())
333-
334-
return aw
335-
}
336-
337-
func createDeploymentAWwith350CPU(ctx context.Context, name string) *arbv1.AppWrapper {
338-
rb := []byte(`{"apiVersion": "apps/v1",
339-
"kind": "Deployment",
340-
"metadata": {
341-
"name": "aw-deployment-2-350cpu",
342-
"namespace": "test",
343-
"labels": {
344-
"app": "aw-deployment-2-350cpu"
345-
}
346-
},
347-
"spec": {
348-
"replicas": 2,
349-
"selector": {
350-
"matchLabels": {
351-
"app": "aw-deployment-2-350cpu"
352-
}
353-
},
354-
"template": {
355-
"metadata": {
356-
"labels": {
357-
"app": "aw-deployment-2-350cpu"
358-
}
359-
},
360-
"spec": {
361-
"containers": [
362-
{
363-
"name": "aw-deployment-2-350cpu",
364-
"image": "quay.io/project-codeflare/echo-server:1.0",
365-
"resources": {
366-
"requests": {
367-
"cpu": "350m"
368-
}
369-
},
370-
"ports": [
371-
{
372-
"containerPort": 80
373-
}
374-
]
375-
}
376-
]
377-
}
378-
}
379-
}} `)
380-
var schedSpecMin int32 = 2
381-
382-
aw := &arbv1.AppWrapper{
383-
ObjectMeta: metav1.ObjectMeta{
384-
Name: name,
385-
Namespace: testNamespace,
386-
},
387-
Spec: arbv1.AppWrapperSpec{
388-
Scheduling: arbv1.SchedulingSpec{
389-
MinAvailable: schedSpecMin,
390-
},
391-
Resources: arbv1.AppWrapperResources{
392-
GenericItems: []arbv1.GenericItem{
393-
{
394-
DoNotUseReplicas: 1,
395-
GenericTemplate: runtime.RawExtension{
396-
Raw: rb,
397-
},
398-
},
399-
},
400-
},
401-
},
402-
}
403-
404-
err := getClient(ctx).Create(ctx, aw)
405-
Expect(err).NotTo(HaveOccurred())
406-
407-
return aw
408-
}
409-
410-
func createDeploymentAWwith426CPU(ctx context.Context, name string) *arbv1.AppWrapper {
411-
rb := []byte(`{"apiVersion": "apps/v1",
412-
"kind": "Deployment",
413-
"metadata": {
414-
"name": "` + name + `",
415-
"namespace": "test",
416-
"labels": {
417-
"app": "` + name + `"
418-
}
419-
},
420-
"spec": {
421-
"replicas": 2,
422-
"selector": {
423-
"matchLabels": {
424-
"app": "` + name + `"
425-
}
426-
},
427-
"template": {
428-
"metadata": {
429-
"labels": {
430-
"app": "` + name + `"
431-
}
432-
},
433-
"spec": {
434-
"containers": [
435-
{
436-
"name": "` + name + `",
437-
"image": "quay.io/project-codeflare/echo-server:1.0",
438-
"resources": {
439-
"requests": {
440-
"cpu": "427m"
441-
}
442-
},
443-
"ports": [
444-
{
445-
"containerPort": 80
446-
}
447-
]
448-
}
449-
]
450-
}
451-
}
452-
}} `)
453-
var schedSpecMin int32 = 2
454-
455-
aw := &arbv1.AppWrapper{
456-
ObjectMeta: metav1.ObjectMeta{
457-
Name: name,
458-
Namespace: testNamespace,
459-
},
460-
Spec: arbv1.AppWrapperSpec{
461-
Scheduling: arbv1.SchedulingSpec{
462-
MinAvailable: schedSpecMin,
463-
},
464-
Resources: arbv1.AppWrapperResources{
465-
GenericItems: []arbv1.GenericItem{
466-
{
467-
DoNotUseReplicas: 1,
468-
GenericTemplate: runtime.RawExtension{
469-
Raw: rb,
470-
},
471-
},
472-
},
473-
},
474-
},
475-
}
476-
477-
err := getClient(ctx).Create(ctx, aw)
478-
Expect(err).NotTo(HaveOccurred())
479-
480-
return aw
481-
}
482-
483-
func createDeploymentAWwith425CPU(ctx context.Context, name string) *arbv1.AppWrapper {
484-
rb := []byte(`{"apiVersion": "apps/v1",
485-
"kind": "Deployment",
486-
"metadata": {
487-
"name": "aw-deployment-2-425cpu",
488-
"namespace": "test",
489-
"labels": {
490-
"app": "aw-deployment-2-425cpu"
491-
}
492-
},
493-
"spec": {
494-
"replicas": 2,
495-
"selector": {
496-
"matchLabels": {
497-
"app": "aw-deployment-2-425cpu"
498-
}
499-
},
500-
"template": {
501-
"metadata": {
502-
"labels": {
503-
"app": "aw-deployment-2-425cpu"
504-
}
505-
},
506-
"spec": {
507-
"containers": [
508-
{
509-
"name": "aw-deployment-2-425cpu",
510-
"image": "quay.io/project-codeflare/echo-server:1.0",
511-
"resources": {
512-
"requests": {
513-
"cpu": "425m"
514-
}
515-
},
516-
"ports": [
517-
{
518-
"containerPort": 80
519-
}
520-
]
521-
}
522-
]
523-
}
524-
}
525-
}} `)
526-
var schedSpecMin int32 = 2
527-
528-
aw := &arbv1.AppWrapper{
529-
ObjectMeta: metav1.ObjectMeta{
530-
Name: name,
531-
Namespace: testNamespace,
532-
},
533-
Spec: arbv1.AppWrapperSpec{
534-
Scheduling: arbv1.SchedulingSpec{
535-
MinAvailable: schedSpecMin,
536-
},
537-
Resources: arbv1.AppWrapperResources{
538-
GenericItems: []arbv1.GenericItem{
539-
{
540-
DoNotUseReplicas: 1,
541-
GenericTemplate: runtime.RawExtension{
542-
Raw: rb,
543-
},
544-
},
545-
},
546-
},
547-
},
548-
}
549-
550-
err := getClient(ctx).Create(ctx, aw)
551-
Expect(err).NotTo(HaveOccurred())
552-
553-
return aw
554-
}
555-
556264
func createGenericDeploymentAW(ctx context.Context, name string) *arbv1.AppWrapper {
557265
rb := []byte(`{"apiVersion": "apps/v1",
558266
"kind": "Deployment",
@@ -1132,7 +840,7 @@ func createGenericDeploymentAWWithMultipleItems(ctx context.Context, name string
1132840
return aw
1133841
}
1134842

1135-
func createGenericDeploymentWithCPUAW(ctx context.Context, name string, cpuDemand string, replicas int) *arbv1.AppWrapper {
843+
func createGenericDeploymentWithCPUAW(ctx context.Context, name string, cpuDemand *resource.Quantity, replicas int) *arbv1.AppWrapper {
1136844
rb := []byte(fmt.Sprintf(`{
1137845
"apiVersion": "apps/v1",
1138846
"kind": "Deployment",
@@ -1177,21 +885,22 @@ func createGenericDeploymentWithCPUAW(ctx context.Context, name string, cpuDeman
1177885
}
1178886
}} `, name, name, replicas, name, name, name, cpuDemand))
1179887

1180-
var schedSpecMin int32 = int32(replicas)
1181-
1182888
aw := &arbv1.AppWrapper{
1183889
ObjectMeta: metav1.ObjectMeta{
1184890
Name: name,
1185891
Namespace: testNamespace,
1186892
},
1187893
Spec: arbv1.AppWrapperSpec{
1188894
Scheduling: arbv1.SchedulingSpec{
1189-
MinAvailable: schedSpecMin,
895+
MinAvailable: int32(replicas),
1190896
},
1191897
Resources: arbv1.AppWrapperResources{
1192898
GenericItems: []arbv1.GenericItem{
1193-
{
1194-
DoNotUseReplicas: 1,
899+
{CustomPodResources: []arbv1.CustomPodResource{
900+
{
901+
Replicas: int32(replicas),
902+
Requests: map[v1.ResourceName]resource.Quantity{v1.ResourceCPU: *cpuDemand}},
903+
},
1195904
GenericTemplate: runtime.RawExtension{
1196905
Raw: rb,
1197906
},

0 commit comments

Comments
 (0)