Skip to content

Commit

Permalink
isexclusive: e2e tests: Test cases for pods with non-integral CPUs
Browse files Browse the repository at this point in the history
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
  • Loading branch information
swatisehgal committed Jun 17, 2021
1 parent 5eee8a9 commit 4837b35
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion test/e2e_node/podresources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,18 @@ func matchPodDescWithResources(expected []podDesc, found podResMap) error {

cpuRequest := getCpuRequest(podReq.cpuRequest)
if cpuRequest > 0 && cpuRequest == float32(int(cpuRequest)) {
if !cntInfo.IsExclusive {
return fmt.Errorf("pod %q container %q requested %f expected to be allocated exclusive CPUs %v", podReq.podName, podReq.cntName, cpuRequest, cntInfo.CpuIds)
}
if len(cntInfo.CpuIds) != int(cpuRequest) {
return fmt.Errorf("pod %q container %q expected %f cpus got %v", podReq.podName, podReq.cntName, cpuRequest, cntInfo.CpuIds)
}
}

if cpuRequest > 0 && cpuRequest != float32(int(cpuRequest)) {
if cntInfo.IsExclusive {
return fmt.Errorf("pod %q container %q requested %f expected to be allocated CPUs from shared pool %v", podReq.podName, podReq.cntName, cpuRequest, cntInfo.CpuIds)
}
}
if podReq.resourceName != "" && podReq.resourceAmount > 0 {
dev := findContainerDeviceByName(cntInfo.GetDevices(), podReq.resourceName)
if dev == nil {
Expand Down Expand Up @@ -449,6 +456,38 @@ func podresourcesListTests(f *framework.Framework, cli kubeletpodresourcesv1.Pod
expectedPostDelete := filterOutDesc(expected, "pod-01")
expectPodResources(1, cli, expectedPostDelete)
tpd.deletePodsForTest(f)

tpd = newTestPodData()
ginkgo.By("checking the output when pods request non integral CPUs")
if sd != nil {
expected = []podDesc{
{
podName: "pod-00",
cntName: "cnt-00",
cpuRequest: "1500m",
},
{
podName: "pod-01",
cntName: "cnt-00",
resourceName: sd.resourceName,
resourceAmount: 1,
cpuRequest: "1500m",
},
}
} else {
expected = []podDesc{
{
podName: "pod-00",
cntName: "cnt-00",
cpuRequest: "1500m",
},
}

}
tpd.createPodsForTest(f, expected)
expectPodResources(1, cli, expected)
tpd.deletePodsForTest(f)

}

func podresourcesGetAllocatableResourcesTests(f *framework.Framework, cli kubeletpodresourcesv1.PodResourcesListerClient, sd *sriovData, onlineCPUs, reservedSystemCPUs cpuset.CPUSet) {
Expand Down

0 comments on commit 4837b35

Please sign in to comment.