From 67f719cb1dd8cb66135b93bfb09c3b09859d38d7 Mon Sep 17 00:00:00 2001 From: Kevin Klues Date: Tue, 23 Nov 2021 21:59:46 +0000 Subject: [PATCH] Fix unit tests following bug fix in CPUManager for map functions (1/2) This fixes two related tests to better test our "balanced" distribution algorithm. The first test originally provided an input with the following number of CPUs available on each NUMA node: Node 0: 16 Node 1: 20 Node 2: 20 Node 3: 20 It then attempted to distribute 48 CPUs across them with an expectation that each of the first 3 NUMA nodes would have 16 CPUs taken from them (leaving Node 0 with no more CPUs in the end). This would have resulted in the following amount of CPUs on each node: Node 0: 0 Node 1: 4 Node 2: 4 Node 3: 20 Which results in a standard deviation of 7.6811 However, a more balanced solution would actually be to pull 16 CPUs from NUMA nodes 1, 2, and 3, and leave 0 untouched, i.e.: Node 0: 16 Node 1: 4 Node 2: 4 Node 3: 4 Which results in a standard deviation of 5.1961524227066 To fix this test we changed the original number of available CPUs to start with 4 less CPUs on NUMA node 3, and 2 more CPUs on NUMA node 0, i.e.: Node 0: 18 Node 1: 20 Node 2: 20 Node 3: 16 So that we end up with a result of: Node 0: 2 Node 1: 4 Node 2: 4 Node 3: 16 Which pulls the CPUs from where we want and results in a standard deviation of 5.5452 For the second test, we simply reverse the number of CPUs available for Nodes 0 and 3 as: Node 0: 16 Node 1: 20 Node 2: 20 Node 3: 18 Which forces the allocation to happen just as it did for the first test, except now on NUMA nodes 1, 2, and 3 instead of NUMA nodes 0,1, and 2. Signed-off-by: Kevin Klues --- pkg/kubelet/cm/cpumanager/cpu_assignment_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/kubelet/cm/cpumanager/cpu_assignment_test.go b/pkg/kubelet/cm/cpumanager/cpu_assignment_test.go index 59059feb0cc..e57351d4890 100644 --- a/pkg/kubelet/cm/cpumanager/cpu_assignment_test.go +++ b/pkg/kubelet/cm/cpumanager/cpu_assignment_test.go @@ -721,22 +721,22 @@ func commonTakeByTopologyExtendedTestCases(t *testing.T) []takeByTopologyExtende mustParseCPUSet(t, "0-7,10-17,20-27,40-47,50-57,60-67"), }, { - "allocate 24 full cores with 8 distributed across the first 3 NUMA nodes (filling the first NUMA node)", + "allocate 24 full cores with 8 distributed across the first 3 NUMA nodes (taking all but 2 from the first NUMA node)", topoDualSocketMultiNumaPerSocketHT, - mustParseCPUSet(t, "2-39,42-79"), + mustParseCPUSet(t, "1-29,32-39,41-69,72-79"), 48, 1, "", - mustParseCPUSet(t, "2-9,10-17,20-27,42-49,50-57,60-67"), + mustParseCPUSet(t, "1-8,10-17,20-27,41-48,50-57,60-67"), }, { - "allocate 24 full cores with 8 distributed across the last 3 NUMA nodes (no room on the first NUMA node to distribute)", + "allocate 24 full cores with 8 distributed across the last 3 NUMA nodes (even though all 8 could be allocated from the first NUMA node)", topoDualSocketMultiNumaPerSocketHT, - mustParseCPUSet(t, "3-39,43-79"), + mustParseCPUSet(t, "2-29,31-39,42-69,71-79"), 48, 1, "", - mustParseCPUSet(t, "10-17,20-27,30-37,50-57,60-67,70-77"), + mustParseCPUSet(t, "10-17,20-27,31-38,50-57,60-67,71-78"), }, { "allocate 8 full cores with 2 distributed across each NUMA node",