diff --git a/test/e2e_node/topology_manager_metrics_test.go b/test/e2e_node/topology_manager_metrics_test.go index 8e6480ec123..fe17ad9c9fc 100644 --- a/test/e2e_node/topology_manager_metrics_test.go +++ b/test/e2e_node/topology_manager_metrics_test.go @@ -41,7 +41,7 @@ var _ = SIGDescribe("Topology Manager Metrics [Serial] [Feature:TopologyManager] ginkgo.Context("when querying /metrics", func() { var oldCfg *kubeletconfig.KubeletConfiguration var testPod *v1.Pod - var cpusNumPerNUMA, numaNodes int + var cpusNumPerNUMA, coresNumPerNUMA, numaNodes, threadsPerCore int ginkgo.BeforeEach(func(ctx context.Context) { var err error @@ -50,13 +50,16 @@ var _ = SIGDescribe("Topology Manager Metrics [Serial] [Feature:TopologyManager] 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 // NUMA nodes and therefore number of CPUs on all NUMA nodes are same // so we just check the CPUs on the first NUMA node 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) 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 // 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) } - return numaNodes, coreCount + threadsPerCore := detectThreadPerCore() + + return numaNodes, coreCount, threadsPerCore } func checkMetricValueGreaterThan(value interface{}) types.GomegaMatcher { diff --git a/test/e2e_node/topology_manager_test.go b/test/e2e_node/topology_manager_test.go index 65c643168af..eddf264aa2b 100644 --- a/test/e2e_node/topology_manager_test.go +++ b/test/e2e_node/topology_manager_test.go @@ -88,6 +88,16 @@ func detectCoresPerSocket() int { 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) { for _, ctnAttr := range ctnAttributes { ctn := v1.Container{