mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Extend CPUManager e2e tests to run on MultiNUMA node with/without HT
This commit is contained in:
parent
ab97b666e2
commit
3342e4a09a
@ -145,12 +145,28 @@ func isHTEnabled() bool {
|
|||||||
return threadsPerCore > 1
|
return threadsPerCore > 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isMultiNUMA() bool {
|
||||||
|
outData, err := exec.Command("/bin/sh", "-c", "lscpu | grep \"NUMA node(s):\" | cut -d \":\" -f 2").Output()
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
|
numaNodes, err := strconv.Atoi(strings.TrimSpace(string(outData)))
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
|
return numaNodes > 1
|
||||||
|
}
|
||||||
|
|
||||||
func getCPUSiblingList(cpuRes int64) string {
|
func getCPUSiblingList(cpuRes int64) string {
|
||||||
out, err := exec.Command("/bin/sh", "-c", fmt.Sprintf("cat /sys/devices/system/cpu/cpu%d/topology/thread_siblings_list | tr -d \"\n\r\"", cpuRes)).Output()
|
out, err := exec.Command("/bin/sh", "-c", fmt.Sprintf("cat /sys/devices/system/cpu/cpu%d/topology/thread_siblings_list | tr -d \"\n\r\"", cpuRes)).Output()
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
return string(out)
|
return string(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getCoreSiblingList(cpuRes int64) string {
|
||||||
|
out, err := exec.Command("/bin/sh", "-c", fmt.Sprintf("cat /sys/devices/system/cpu/cpu%d/topology/core_siblings_list | tr -d \"\n\r\"", cpuRes)).Output()
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
return string(out)
|
||||||
|
}
|
||||||
|
|
||||||
func deleteStateFile() {
|
func deleteStateFile() {
|
||||||
err := exec.Command("/bin/sh", "-c", "rm -f /var/lib/kubelet/cpu_manager_state").Run()
|
err := exec.Command("/bin/sh", "-c", "rm -f /var/lib/kubelet/cpu_manager_state").Run()
|
||||||
framework.ExpectNoError(err, "error deleting state file")
|
framework.ExpectNoError(err, "error deleting state file")
|
||||||
@ -301,6 +317,9 @@ func runCPUManagerTests(f *framework.Framework) {
|
|||||||
if isHTEnabled() {
|
if isHTEnabled() {
|
||||||
cpuList = cpuset.MustParse(getCPUSiblingList(0)).ToSlice()
|
cpuList = cpuset.MustParse(getCPUSiblingList(0)).ToSlice()
|
||||||
cpu1 = cpuList[1]
|
cpu1 = cpuList[1]
|
||||||
|
} else if isMultiNUMA() {
|
||||||
|
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||||
|
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)
|
||||||
@ -337,6 +356,9 @@ func runCPUManagerTests(f *framework.Framework) {
|
|||||||
if isHTEnabled() {
|
if isHTEnabled() {
|
||||||
cpuList = cpuset.MustParse(getCPUSiblingList(0)).ToSlice()
|
cpuList = cpuset.MustParse(getCPUSiblingList(0)).ToSlice()
|
||||||
cpu1 = cpuList[1]
|
cpu1 = cpuList[1]
|
||||||
|
} else if isMultiNUMA() {
|
||||||
|
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||||
|
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)
|
||||||
@ -376,7 +398,15 @@ func runCPUManagerTests(f *framework.Framework) {
|
|||||||
|
|
||||||
ginkgo.By("checking if the expected cpuset was assigned")
|
ginkgo.By("checking if the expected cpuset was assigned")
|
||||||
cpuListString = "1-2"
|
cpuListString = "1-2"
|
||||||
if isHTEnabled() {
|
if isMultiNUMA() {
|
||||||
|
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||||
|
if !isHTEnabled() {
|
||||||
|
cset = cpuset.MustParse(fmt.Sprintf("%d,%d", cpuList[1], cpuList[2]))
|
||||||
|
} else {
|
||||||
|
cset = cpuset.MustParse(getCPUSiblingList(int64(cpuList[1])))
|
||||||
|
}
|
||||||
|
cpuListString = fmt.Sprintf("%s", cset)
|
||||||
|
} else if isHTEnabled() {
|
||||||
cpuListString = "2-3"
|
cpuListString = "2-3"
|
||||||
cpuList = cpuset.MustParse(getCPUSiblingList(0)).ToSlice()
|
cpuList = cpuset.MustParse(getCPUSiblingList(0)).ToSlice()
|
||||||
if cpuList[1] != 1 {
|
if cpuList[1] != 1 {
|
||||||
@ -416,8 +446,14 @@ func runCPUManagerTests(f *framework.Framework) {
|
|||||||
if cpuList[1] != 1 {
|
if cpuList[1] != 1 {
|
||||||
cpu1, cpu2 = cpuList[1], 1
|
cpu1, cpu2 = cpuList[1], 1
|
||||||
}
|
}
|
||||||
|
if isMultiNUMA() {
|
||||||
|
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||||
|
cpu2 = cpuList[1]
|
||||||
|
}
|
||||||
|
} else if isMultiNUMA() {
|
||||||
|
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||||
|
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]",
|
||||||
@ -460,8 +496,14 @@ func runCPUManagerTests(f *framework.Framework) {
|
|||||||
if cpuList[1] != 1 {
|
if cpuList[1] != 1 {
|
||||||
cpu1, cpu2 = cpuList[1], 1
|
cpu1, cpu2 = cpuList[1], 1
|
||||||
}
|
}
|
||||||
|
if isMultiNUMA() {
|
||||||
|
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||||
|
cpu2 = cpuList[1]
|
||||||
|
}
|
||||||
|
} else if isMultiNUMA() {
|
||||||
|
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||||
|
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]",
|
||||||
@ -500,6 +542,9 @@ func runCPUManagerTests(f *framework.Framework) {
|
|||||||
if isHTEnabled() {
|
if isHTEnabled() {
|
||||||
cpuList = cpuset.MustParse(getCPUSiblingList(0)).ToSlice()
|
cpuList = cpuset.MustParse(getCPUSiblingList(0)).ToSlice()
|
||||||
cpu1 = cpuList[1]
|
cpu1 = cpuList[1]
|
||||||
|
} else if isMultiNUMA() {
|
||||||
|
cpuList = cpuset.MustParse(getCoreSiblingList(0)).ToSlice()
|
||||||
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user