mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 03:03:59 +00:00
Merge pull request #98373 from cynepco3hahue/e2e_fix_cpus_assumptions
e2e: fix CPU manager methods to be more flexible to different CPU topology
This commit is contained in:
commit
6235ad8c74
@ -283,8 +283,10 @@ func runGuPodTest(f *framework.Framework) {
|
|||||||
cpu1 = cpuList[1]
|
cpu1 = cpuList[1]
|
||||||
} else if isMultiNUMA() {
|
} else if isMultiNUMA() {
|
||||||
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||||
|
if len(cpuList) > 1 {
|
||||||
cpu1 = cpuList[1]
|
cpu1 = cpuList[1]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
expAllowedCPUsListRegex = fmt.Sprintf("^%d\n$", cpu1)
|
expAllowedCPUsListRegex = fmt.Sprintf("^%d\n$", cpu1)
|
||||||
err = f.PodClient().MatchContainerOutput(pod.Name, pod.Spec.Containers[0].Name, expAllowedCPUsListRegex)
|
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]",
|
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")
|
ginkgo.By("checking if the expected cpuset was assigned")
|
||||||
expAllowedCPUsListRegex = fmt.Sprintf("^0-%d\n$", cpuCap-1)
|
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)
|
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]",
|
framework.ExpectNoError(err, "expected log not found in container [%s] of pod [%s]",
|
||||||
pod.Spec.Containers[0].Name, pod.Name)
|
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) {
|
func runMultipleGuNonGuPods(f *framework.Framework, cpuCap int64, cpuAlloc int64) {
|
||||||
|
|
||||||
var cpuListString, expAllowedCPUsListRegex string
|
var cpuListString, expAllowedCPUsListRegex string
|
||||||
var cpuList []int
|
var cpuList []int
|
||||||
var cpu1 int
|
var cpu1 int
|
||||||
@ -359,8 +364,10 @@ func runMultipleGuNonGuPods(f *framework.Framework, cpuCap int64, cpuAlloc int64
|
|||||||
cpu1 = cpuList[1]
|
cpu1 = cpuList[1]
|
||||||
} else if isMultiNUMA() {
|
} else if isMultiNUMA() {
|
||||||
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||||
|
if len(cpuList) > 1 {
|
||||||
cpu1 = cpuList[1]
|
cpu1 = cpuList[1]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
expAllowedCPUsListRegex = fmt.Sprintf("^%d\n$", cpu1)
|
expAllowedCPUsListRegex = fmt.Sprintf("^%d\n$", cpu1)
|
||||||
err = f.PodClient().MatchContainerOutput(pod1.Name, pod1.Spec.Containers[0].Name, expAllowedCPUsListRegex)
|
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]",
|
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"
|
cpuListString = "1-2"
|
||||||
if isMultiNUMA() {
|
if isMultiNUMA() {
|
||||||
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||||
if !isHTEnabled() {
|
if len(cpuList) > 1 {
|
||||||
cset = cpuset.MustParse(fmt.Sprintf("%d-%d", cpuList[1], cpuList[2]))
|
|
||||||
} else {
|
|
||||||
cset = cpuset.MustParse(getCPUSiblingList(int64(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)
|
cpuListString = fmt.Sprintf("%s", cset)
|
||||||
|
}
|
||||||
} else if isHTEnabled() {
|
} else if isHTEnabled() {
|
||||||
cpuListString = "2-3"
|
cpuListString = "2-3"
|
||||||
cpuList = cpuset.MustParse(getCPUSiblingList(0)).ToSlice()
|
cpuList = cpuset.MustParse(getCPUSiblingList(0)).ToSlice()
|
||||||
@ -428,7 +436,6 @@ func runMultipleCPUGuPod(f *framework.Framework) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runMultipleCPUContainersGuPod(f *framework.Framework) {
|
func runMultipleCPUContainersGuPod(f *framework.Framework) {
|
||||||
|
|
||||||
var expAllowedCPUsListRegex string
|
var expAllowedCPUsListRegex string
|
||||||
var cpuList []int
|
var cpuList []int
|
||||||
var cpu1, cpu2 int
|
var cpu1, cpu2 int
|
||||||
@ -459,12 +466,16 @@ func runMultipleCPUContainersGuPod(f *framework.Framework) {
|
|||||||
}
|
}
|
||||||
if isMultiNUMA() {
|
if isMultiNUMA() {
|
||||||
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||||
|
if len(cpuList) > 1 {
|
||||||
cpu2 = cpuList[1]
|
cpu2 = cpuList[1]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if isMultiNUMA() {
|
} else if isMultiNUMA() {
|
||||||
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||||
|
if len(cpuList) > 2 {
|
||||||
cpu1, cpu2 = cpuList[1], cpuList[2]
|
cpu1, cpu2 = cpuList[1], cpuList[2]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
expAllowedCPUsListRegex = fmt.Sprintf("^%d|%d\n$", cpu1, cpu2)
|
expAllowedCPUsListRegex = fmt.Sprintf("^%d|%d\n$", cpu1, cpu2)
|
||||||
err = f.PodClient().MatchContainerOutput(pod.Name, pod.Spec.Containers[0].Name, expAllowedCPUsListRegex)
|
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]",
|
framework.ExpectNoError(err, "expected log not found in container [%s] of pod [%s]",
|
||||||
@ -517,12 +528,16 @@ func runMultipleGuPods(f *framework.Framework) {
|
|||||||
}
|
}
|
||||||
if isMultiNUMA() {
|
if isMultiNUMA() {
|
||||||
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||||
|
if len(cpuList) > 1 {
|
||||||
cpu2 = cpuList[1]
|
cpu2 = cpuList[1]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if isMultiNUMA() {
|
} else if isMultiNUMA() {
|
||||||
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||||
|
if len(cpuList) > 2 {
|
||||||
cpu1, cpu2 = cpuList[1], cpuList[2]
|
cpu1, cpu2 = cpuList[1], cpuList[2]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
expAllowedCPUsListRegex = fmt.Sprintf("^%d\n$", cpu1)
|
expAllowedCPUsListRegex = fmt.Sprintf("^%d\n$", cpu1)
|
||||||
err = f.PodClient().MatchContainerOutput(pod1.Name, pod1.Spec.Containers[0].Name, expAllowedCPUsListRegex)
|
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]",
|
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]
|
cpu1 = cpuList[1]
|
||||||
} else if isMultiNUMA() {
|
} else if isMultiNUMA() {
|
||||||
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||||
|
if len(cpuList) > 1 {
|
||||||
cpu1 = cpuList[1]
|
cpu1 = cpuList[1]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
expAllowedCPUsListRegex = fmt.Sprintf("^%d\n$", cpu1)
|
expAllowedCPUsListRegex = fmt.Sprintf("^%d\n$", cpu1)
|
||||||
err = f.PodClient().MatchContainerOutput(pod.Name, pod.Spec.Containers[0].Name, expAllowedCPUsListRegex)
|
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]",
|
framework.ExpectNoError(err, "expected log not found in container [%s] of pod [%s]",
|
||||||
|
Loading…
Reference in New Issue
Block a user