Skip to content

Commit

Permalink
add mem tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdeal committed Jan 31, 2024
1 parent 8b47573 commit 992a221
Showing 1 changed file with 80 additions and 5 deletions.
85 changes: 80 additions & 5 deletions test/suites/integration/scheduling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ var _ = Describe("Scheduling", Ordered, ContinueOnFailure, func() {
})

DescribeTable(
"should provision a right-sized node when a pod has InitContainers",
"should provision a right-sized node when a pod has InitContainers (cpu)",
func(expectedNodeCPU string, containerRequirements v1.ResourceRequirements, initContainers ...v1.Container) {
test.ReplaceRequirements(nodePool, v1.NodeSelectorRequirement{
Key: v1beta1.LabelInstanceCPU,
Expand Down Expand Up @@ -480,15 +480,90 @@ var _ = Describe("Scheduling", Ordered, ContinueOnFailure, func() {
}, ephemeralInitContainer(v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1250m")},
})),
Entry("container requirements + sidecar requirements > init container requirements", "1", v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("250m")},
Entry("container requirements + sidecar requirements > init container requirements", "2", v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("750m")},
}, v1.Container{
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("250m")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("750m")},
},
}, ephemeralInitContainer(v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("750m")},
})),
)

DescribeTable(
"should provision a right-sized node when a pod has InitContainers (memory)",
func(expectedNodeMemory string, containerRequirements v1.ResourceRequirements, initContainers ...v1.Container) {
test.ReplaceRequirements(nodePool, v1.NodeSelectorRequirement{
Key: v1beta1.LabelInstanceMemory,
Operator: v1.NodeSelectorOpIn,
Values: []string{"4096", "8192"},
}, v1.NodeSelectorRequirement{
Key: v1beta1.LabelInstanceCategory,
Operator: v1.NodeSelectorOpNotIn,
Values: []string{"t"},
})
pod := test.Pod(test.PodOptions{
InitContainers: initContainers,
ResourceRequirements: containerRequirements,
})
nodePool.Spec.Template.Spec.Kubelet = &corev1beta1.KubeletConfiguration{
SystemReserved: v1.ResourceList{
v1.ResourceCPU: resource.MustParse("0"),
v1.ResourceMemory: resource.MustParse("0Mi"),
},
KubeReserved: v1.ResourceList{
v1.ResourceCPU: resource.MustParse("0"),
v1.ResourceMemory: resource.MustParse("0Mi"),
},
}
env.ExpectCreated(nodePool, nodeClass, pod)
env.EventuallyExpectHealthy(pod)
node := env.ExpectCreatedNodeCount("==", 1)[0]
Expect(node.ObjectMeta.GetLabels()[v1beta1.LabelInstanceMemory]).To(Equal(expectedNodeMemory))
},
Entry("container requirements + sidecar requirements", "8192", v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceMemory: resource.MustParse("3Gi")},
}, v1.Container{
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceMemory: resource.MustParse("2Gi")},
},
}),
Entry("container requirements < init container requirements", "8192", v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceMemory: resource.MustParse("2Gi")},
}, ephemeralInitContainer(v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceMemory: resource.MustParse("1Gi")},
}), ephemeralInitContainer(v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceMemory: resource.MustParse("5Gi")},
})),
Entry("container requirements > init container requirements", "4096", v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceMemory: resource.MustParse("2Gi")},
}, ephemeralInitContainer(v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceMemory: resource.MustParse("1536Mi")},
}), ephemeralInitContainer(v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceMemory: resource.MustParse("1536Mi")},
})),
Entry("container requirements + sidecar requirements < init container requirements", "8192", v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceMemory: resource.MustParse("1Gi")},
}, v1.Container{
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceMemory: resource.MustParse("1Gi")},
},
}, ephemeralInitContainer(v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceMemory: resource.MustParse("5Gi")},
})),
Entry("container requirements + sidecar requirements > init container requirements", "4096", v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceMemory: resource.MustParse("1536Mi")},
}, v1.Container{
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceMemory: resource.MustParse("1536Mi")},
},
}, ephemeralInitContainer(v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("100m")},
Requests: v1.ResourceList{v1.ResourceMemory: resource.MustParse("2Gi")},
})),
)
})
Expand Down

0 comments on commit 992a221

Please sign in to comment.