From 5043b431b49f7ff37da8ab0d6235196a73086f56 Mon Sep 17 00:00:00 2001 From: Swati Sehgal Date: Thu, 17 Jun 2021 12:34:26 +0100 Subject: [PATCH] excludesharedpool: e2e tests: Test cases for pods with non-integral CPUs Signed-off-by: Swati Sehgal --- test/e2e_node/podresources_test.go | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/e2e_node/podresources_test.go b/test/e2e_node/podresources_test.go index 8332ee9bb87..310dfbd6d69 100644 --- a/test/e2e_node/podresources_test.go +++ b/test/e2e_node/podresources_test.go @@ -191,6 +191,9 @@ func matchPodDescWithResources(expected []podDesc, found podResMap) error { if isIntegral(podReq.cpuRequest) && len(cntInfo.CpuIds) != int(podReq.cpuRequest) { return fmt.Errorf("pod %q container %q expected %d cpus got %v", podReq.podName, podReq.cntName, podReq.cpuRequest, cntInfo.CpuIds) } + if !isIntegral(podReq.cpuRequest) && len(cntInfo.CpuIds) != 0 { + return fmt.Errorf("pod %q container %q requested %d expected to be allocated CPUs from shared pool %v", podReq.podName, podReq.cntName, podReq.cpuRequest, cntInfo.CpuIds) + } } if podReq.resourceName != "" && podReq.resourceAmount > 0 { dev := findContainerDeviceByName(cntInfo.GetDevices(), podReq.resourceName) @@ -457,6 +460,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: 1500, + }, + { + podName: "pod-01", + cntName: "cnt-00", + resourceName: sd.resourceName, + resourceAmount: 1, + cpuRequest: 1500, + }, + } + } else { + expected = []podDesc{ + { + podName: "pod-00", + cntName: "cnt-00", + cpuRequest: 1500, + }, + } + + } + 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) {