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

enable tests based on CPU resource accounting #83

Merged
merged 4 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
305 changes: 7 additions & 298 deletions test/e2e/aw_fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,298 +261,6 @@ func createDeploymentAW(ctx context.Context, name string) *arbv1.AppWrapper {
return aw
}

func createDeploymentAWwith550CPU(ctx context.Context, name string) *arbv1.AppWrapper {
rb := []byte(`{"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": "` + name + `",
"namespace": "test",
"labels": {
"app": "` + name + `"
}
},
"spec": {
"replicas": 2,
"selector": {
"matchLabels": {
"app": "` + name + `"
}
},
"template": {
"metadata": {
"labels": {
"app": "` + name + `"
}
},
"spec": {
"containers": [
{
"name": "` + name + `",
"image": "quay.io/project-codeflare/echo-server:1.0",
"resources": {
"requests": {
"cpu": "550m"
}
},
"ports": [
{
"containerPort": 80
}
]
}
]
}
}
}} `)
var schedSpecMin int32 = 2

aw := &arbv1.AppWrapper{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: testNamespace,
},
Spec: arbv1.AppWrapperSpec{
Scheduling: arbv1.SchedulingSpec{
MinAvailable: schedSpecMin,
},
Resources: arbv1.AppWrapperResources{
GenericItems: []arbv1.GenericItem{
{
DoNotUseReplicas: 1,
GenericTemplate: runtime.RawExtension{
Raw: rb,
},
},
},
},
},
}

err := getClient(ctx).Create(ctx, aw)
Expect(err).NotTo(HaveOccurred())

return aw
}

func createDeploymentAWwith350CPU(ctx context.Context, name string) *arbv1.AppWrapper {
rb := []byte(`{"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": "aw-deployment-2-350cpu",
"namespace": "test",
"labels": {
"app": "aw-deployment-2-350cpu"
}
},
"spec": {
"replicas": 2,
"selector": {
"matchLabels": {
"app": "aw-deployment-2-350cpu"
}
},
"template": {
"metadata": {
"labels": {
"app": "aw-deployment-2-350cpu"
}
},
"spec": {
"containers": [
{
"name": "aw-deployment-2-350cpu",
"image": "quay.io/project-codeflare/echo-server:1.0",
"resources": {
"requests": {
"cpu": "350m"
}
},
"ports": [
{
"containerPort": 80
}
]
}
]
}
}
}} `)
var schedSpecMin int32 = 2

aw := &arbv1.AppWrapper{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: testNamespace,
},
Spec: arbv1.AppWrapperSpec{
Scheduling: arbv1.SchedulingSpec{
MinAvailable: schedSpecMin,
},
Resources: arbv1.AppWrapperResources{
GenericItems: []arbv1.GenericItem{
{
DoNotUseReplicas: 1,
GenericTemplate: runtime.RawExtension{
Raw: rb,
},
},
},
},
},
}

err := getClient(ctx).Create(ctx, aw)
Expect(err).NotTo(HaveOccurred())

return aw
}

func createDeploymentAWwith426CPU(ctx context.Context, name string) *arbv1.AppWrapper {
rb := []byte(`{"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": "` + name + `",
"namespace": "test",
"labels": {
"app": "` + name + `"
}
},
"spec": {
"replicas": 2,
"selector": {
"matchLabels": {
"app": "` + name + `"
}
},
"template": {
"metadata": {
"labels": {
"app": "` + name + `"
}
},
"spec": {
"containers": [
{
"name": "` + name + `",
"image": "quay.io/project-codeflare/echo-server:1.0",
"resources": {
"requests": {
"cpu": "427m"
}
},
"ports": [
{
"containerPort": 80
}
]
}
]
}
}
}} `)
var schedSpecMin int32 = 2

aw := &arbv1.AppWrapper{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: testNamespace,
},
Spec: arbv1.AppWrapperSpec{
Scheduling: arbv1.SchedulingSpec{
MinAvailable: schedSpecMin,
},
Resources: arbv1.AppWrapperResources{
GenericItems: []arbv1.GenericItem{
{
DoNotUseReplicas: 1,
GenericTemplate: runtime.RawExtension{
Raw: rb,
},
},
},
},
},
}

err := getClient(ctx).Create(ctx, aw)
Expect(err).NotTo(HaveOccurred())

return aw
}

func createDeploymentAWwith425CPU(ctx context.Context, name string) *arbv1.AppWrapper {
rb := []byte(`{"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": "aw-deployment-2-425cpu",
"namespace": "test",
"labels": {
"app": "aw-deployment-2-425cpu"
}
},
"spec": {
"replicas": 2,
"selector": {
"matchLabels": {
"app": "aw-deployment-2-425cpu"
}
},
"template": {
"metadata": {
"labels": {
"app": "aw-deployment-2-425cpu"
}
},
"spec": {
"containers": [
{
"name": "aw-deployment-2-425cpu",
"image": "quay.io/project-codeflare/echo-server:1.0",
"resources": {
"requests": {
"cpu": "425m"
}
},
"ports": [
{
"containerPort": 80
}
]
}
]
}
}
}} `)
var schedSpecMin int32 = 2

aw := &arbv1.AppWrapper{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: testNamespace,
},
Spec: arbv1.AppWrapperSpec{
Scheduling: arbv1.SchedulingSpec{
MinAvailable: schedSpecMin,
},
Resources: arbv1.AppWrapperResources{
GenericItems: []arbv1.GenericItem{
{
DoNotUseReplicas: 1,
GenericTemplate: runtime.RawExtension{
Raw: rb,
},
},
},
},
},
}

err := getClient(ctx).Create(ctx, aw)
Expect(err).NotTo(HaveOccurred())

return aw
}

func createGenericDeploymentAW(ctx context.Context, name string) *arbv1.AppWrapper {
rb := []byte(`{"apiVersion": "apps/v1",
"kind": "Deployment",
Expand Down Expand Up @@ -1132,7 +840,7 @@ func createGenericDeploymentAWWithMultipleItems(ctx context.Context, name string
return aw
}

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

var schedSpecMin int32 = int32(replicas)

aw := &arbv1.AppWrapper{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: testNamespace,
},
Spec: arbv1.AppWrapperSpec{
Scheduling: arbv1.SchedulingSpec{
MinAvailable: schedSpecMin,
MinAvailable: int32(replicas),
},
Resources: arbv1.AppWrapperResources{
GenericItems: []arbv1.GenericItem{
{
DoNotUseReplicas: 1,
{CustomPodResources: []arbv1.CustomPodResource{
{
Replicas: int32(replicas),
Requests: map[v1.ResourceName]resource.Quantity{v1.ResourceCPU: *cpuDemand}},
},
GenericTemplate: runtime.RawExtension{
Raw: rb,
},
Expand Down
Loading