mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 13:31:52 +00:00
Merge pull request #121442 from swatisehgal/topology-mgr-test-fix
node: e2e: topology-mgr: Determine threads per core to disambiguage cores from cpus
This commit is contained in:
commit
3ae4dbd45f
@ -41,7 +41,7 @@ var _ = SIGDescribe("Topology Manager Metrics [Serial] [Feature:TopologyManager]
|
|||||||
ginkgo.Context("when querying /metrics", func() {
|
ginkgo.Context("when querying /metrics", func() {
|
||||||
var oldCfg *kubeletconfig.KubeletConfiguration
|
var oldCfg *kubeletconfig.KubeletConfiguration
|
||||||
var testPod *v1.Pod
|
var testPod *v1.Pod
|
||||||
var cpusNumPerNUMA, numaNodes int
|
var cpusNumPerNUMA, coresNumPerNUMA, numaNodes, threadsPerCore int
|
||||||
|
|
||||||
ginkgo.BeforeEach(func(ctx context.Context) {
|
ginkgo.BeforeEach(func(ctx context.Context) {
|
||||||
var err error
|
var err error
|
||||||
@ -50,13 +50,16 @@ var _ = SIGDescribe("Topology Manager Metrics [Serial] [Feature:TopologyManager]
|
|||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
numaNodes, cpusNumPerNUMA = hostCheck()
|
numaNodes, coresNumPerNUMA, threadsPerCore = hostCheck()
|
||||||
|
cpusNumPerNUMA = coresNumPerNUMA * threadsPerCore
|
||||||
|
|
||||||
// It is safe to assume that the CPUs are distributed equally across
|
// It is safe to assume that the CPUs are distributed equally across
|
||||||
// NUMA nodes and therefore number of CPUs on all NUMA nodes are same
|
// NUMA nodes and therefore number of CPUs on all NUMA nodes are same
|
||||||
// so we just check the CPUs on the first NUMA node
|
// so we just check the CPUs on the first NUMA node
|
||||||
|
|
||||||
framework.Logf("numaNodes on the system %d", numaNodes)
|
framework.Logf("numaNodes on the system %d", numaNodes)
|
||||||
|
framework.Logf("Cores per NUMA on the system %d", coresNumPerNUMA)
|
||||||
|
framework.Logf("Threads per Core on the system %d", threadsPerCore)
|
||||||
framework.Logf("CPUs per NUMA on the system %d", cpusNumPerNUMA)
|
framework.Logf("CPUs per NUMA on the system %d", cpusNumPerNUMA)
|
||||||
|
|
||||||
policy := topologymanager.PolicySingleNumaNode
|
policy := topologymanager.PolicySingleNumaNode
|
||||||
@ -151,7 +154,7 @@ var _ = SIGDescribe("Topology Manager Metrics [Serial] [Feature:TopologyManager]
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
func hostCheck() (int, int) {
|
func hostCheck() (int, int, int) {
|
||||||
// this is a very rough check. We just want to rule out system that does NOT have
|
// this is a very rough check. We just want to rule out system that does NOT have
|
||||||
// multi-NUMA nodes or at least 4 cores
|
// multi-NUMA nodes or at least 4 cores
|
||||||
|
|
||||||
@ -165,7 +168,9 @@ func hostCheck() (int, int) {
|
|||||||
e2eskipper.Skipf("this test is intended to be run on a system with at least %d cores per socket", minCoreCount)
|
e2eskipper.Skipf("this test is intended to be run on a system with at least %d cores per socket", minCoreCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
return numaNodes, coreCount
|
threadsPerCore := detectThreadPerCore()
|
||||||
|
|
||||||
|
return numaNodes, coreCount, threadsPerCore
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkMetricValueGreaterThan(value interface{}) types.GomegaMatcher {
|
func checkMetricValueGreaterThan(value interface{}) types.GomegaMatcher {
|
||||||
|
@ -88,6 +88,16 @@ func detectCoresPerSocket() int {
|
|||||||
return coreCount
|
return coreCount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func detectThreadPerCore() int {
|
||||||
|
outData, err := exec.Command("/bin/sh", "-c", "lscpu | grep \"Thread(s) per core:\" | cut -d \":\" -f 2").Output()
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
|
threadCount, err := strconv.Atoi(strings.TrimSpace(string(outData)))
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
|
return threadCount
|
||||||
|
}
|
||||||
|
|
||||||
func makeContainers(ctnCmd string, ctnAttributes []tmCtnAttribute) (ctns []v1.Container) {
|
func makeContainers(ctnCmd string, ctnAttributes []tmCtnAttribute) (ctns []v1.Container) {
|
||||||
for _, ctnAttr := range ctnAttributes {
|
for _, ctnAttr := range ctnAttributes {
|
||||||
ctn := v1.Container{
|
ctn := v1.Container{
|
||||||
|
Loading…
Reference in New Issue
Block a user