mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
e2e: fix CPU manager methods to be more flexible to different CPU topology
- fix the issue when the test runs on the node with the single CPU - fix the issue when the CPU topology has only one core per socket, it can be easily reproduced by configuring VM with multi NUMA, but when each socket has only one core Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
This commit is contained in:
parent
f6e04cd3ad
commit
d2c3f52532
@ -283,8 +283,10 @@ func runGuPodTest(f *framework.Framework) {
|
||||
cpu1 = cpuList[1]
|
||||
} else if isMultiNUMA() {
|
||||
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||
if len(cpuList) > 1 {
|
||||
cpu1 = cpuList[1]
|
||||
}
|
||||
}
|
||||
expAllowedCPUsListRegex = fmt.Sprintf("^%d\n$", cpu1)
|
||||
err = f.PodClient().MatchContainerOutput(pod.Name, pod.Spec.Containers[0].Name, expAllowedCPUsListRegex)
|
||||
framework.ExpectNoError(err, "expected log not found in container [%s] of pod [%s]",
|
||||
@ -313,6 +315,10 @@ func runNonGuPodTest(f *framework.Framework, cpuCap int64) {
|
||||
|
||||
ginkgo.By("checking if the expected cpuset was assigned")
|
||||
expAllowedCPUsListRegex = fmt.Sprintf("^0-%d\n$", cpuCap-1)
|
||||
// on the single CPU node the only possible value is 0
|
||||
if cpuCap == 1 {
|
||||
expAllowedCPUsListRegex = "^0\n$"
|
||||
}
|
||||
err = f.PodClient().MatchContainerOutput(pod.Name, pod.Spec.Containers[0].Name, expAllowedCPUsListRegex)
|
||||
framework.ExpectNoError(err, "expected log not found in container [%s] of pod [%s]",
|
||||
pod.Spec.Containers[0].Name, pod.Name)
|
||||
@ -323,7 +329,6 @@ func runNonGuPodTest(f *framework.Framework, cpuCap int64) {
|
||||
}
|
||||
|
||||
func runMultipleGuNonGuPods(f *framework.Framework, cpuCap int64, cpuAlloc int64) {
|
||||
|
||||
var cpuListString, expAllowedCPUsListRegex string
|
||||
var cpuList []int
|
||||
var cpu1 int
|
||||
@ -359,8 +364,10 @@ func runMultipleGuNonGuPods(f *framework.Framework, cpuCap int64, cpuAlloc int64
|
||||
cpu1 = cpuList[1]
|
||||
} else if isMultiNUMA() {
|
||||
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||
if len(cpuList) > 1 {
|
||||
cpu1 = cpuList[1]
|
||||
}
|
||||
}
|
||||
expAllowedCPUsListRegex = fmt.Sprintf("^%d\n$", cpu1)
|
||||
err = f.PodClient().MatchContainerOutput(pod1.Name, pod1.Spec.Containers[0].Name, expAllowedCPUsListRegex)
|
||||
framework.ExpectNoError(err, "expected log not found in container [%s] of pod [%s]",
|
||||
@ -403,12 +410,13 @@ func runMultipleCPUGuPod(f *framework.Framework) {
|
||||
cpuListString = "1-2"
|
||||
if isMultiNUMA() {
|
||||
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||
if !isHTEnabled() {
|
||||
cset = cpuset.MustParse(fmt.Sprintf("%d-%d", cpuList[1], cpuList[2]))
|
||||
} else {
|
||||
if len(cpuList) > 1 {
|
||||
cset = cpuset.MustParse(getCPUSiblingList(int64(cpuList[1])))
|
||||
if !isHTEnabled() && len(cpuList) > 2 {
|
||||
cset = cpuset.MustParse(fmt.Sprintf("%d-%d", cpuList[1], cpuList[2]))
|
||||
}
|
||||
cpuListString = fmt.Sprintf("%s", cset)
|
||||
}
|
||||
} else if isHTEnabled() {
|
||||
cpuListString = "2-3"
|
||||
cpuList = cpuset.MustParse(getCPUSiblingList(0)).ToSlice()
|
||||
@ -428,7 +436,6 @@ func runMultipleCPUGuPod(f *framework.Framework) {
|
||||
}
|
||||
|
||||
func runMultipleCPUContainersGuPod(f *framework.Framework) {
|
||||
|
||||
var expAllowedCPUsListRegex string
|
||||
var cpuList []int
|
||||
var cpu1, cpu2 int
|
||||
@ -459,12 +466,16 @@ func runMultipleCPUContainersGuPod(f *framework.Framework) {
|
||||
}
|
||||
if isMultiNUMA() {
|
||||
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||
if len(cpuList) > 1 {
|
||||
cpu2 = cpuList[1]
|
||||
}
|
||||
}
|
||||
} else if isMultiNUMA() {
|
||||
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||
if len(cpuList) > 2 {
|
||||
cpu1, cpu2 = cpuList[1], cpuList[2]
|
||||
}
|
||||
}
|
||||
expAllowedCPUsListRegex = fmt.Sprintf("^%d|%d\n$", cpu1, cpu2)
|
||||
err = f.PodClient().MatchContainerOutput(pod.Name, pod.Spec.Containers[0].Name, expAllowedCPUsListRegex)
|
||||
framework.ExpectNoError(err, "expected log not found in container [%s] of pod [%s]",
|
||||
@ -517,12 +528,16 @@ func runMultipleGuPods(f *framework.Framework) {
|
||||
}
|
||||
if isMultiNUMA() {
|
||||
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||
if len(cpuList) > 1 {
|
||||
cpu2 = cpuList[1]
|
||||
}
|
||||
}
|
||||
} else if isMultiNUMA() {
|
||||
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||
if len(cpuList) > 2 {
|
||||
cpu1, cpu2 = cpuList[1], cpuList[2]
|
||||
}
|
||||
}
|
||||
expAllowedCPUsListRegex = fmt.Sprintf("^%d\n$", cpu1)
|
||||
err = f.PodClient().MatchContainerOutput(pod1.Name, pod1.Spec.Containers[0].Name, expAllowedCPUsListRegex)
|
||||
framework.ExpectNoError(err, "expected log not found in container [%s] of pod [%s]",
|
||||
@ -607,8 +622,10 @@ func runCPUManagerTests(f *framework.Framework) {
|
||||
cpu1 = cpuList[1]
|
||||
} else if isMultiNUMA() {
|
||||
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||
if len(cpuList) > 1 {
|
||||
cpu1 = cpuList[1]
|
||||
}
|
||||
}
|
||||
expAllowedCPUsListRegex = fmt.Sprintf("^%d\n$", cpu1)
|
||||
err = f.PodClient().MatchContainerOutput(pod.Name, pod.Spec.Containers[0].Name, expAllowedCPUsListRegex)
|
||||
framework.ExpectNoError(err, "expected log not found in container [%s] of pod [%s]",
|
||||
|
Loading…
Reference in New Issue
Block a user