From 3bb5ca925733208c9a2749e186e531eef2d67595 Mon Sep 17 00:00:00 2001 From: Ismo Puustinen Date: Tue, 31 Jul 2018 10:16:31 +0300 Subject: [PATCH] cpumanager: add test for available CPUs in static policy. Test the cases where the number of CPUs available in the system is smaller or larger than the number of CPUs known in the state, which should lead to a panic. This covers both CPU onlining and offlining. The case where the number of CPUs matches is already covered by the "non-corrupted state" test. --- .../cm/cpumanager/policy_static_test.go | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/kubelet/cm/cpumanager/policy_static_test.go b/pkg/kubelet/cm/cpumanager/policy_static_test.go index a1bc3517baf..d4d84d0da19 100644 --- a/pkg/kubelet/cm/cpumanager/policy_static_test.go +++ b/pkg/kubelet/cm/cpumanager/policy_static_test.go @@ -87,6 +87,26 @@ func TestStaticPolicyStart(t *testing.T) { stDefaultCPUSet: cpuset.NewCPUSet(2, 3, 4, 5, 6, 7, 8, 9, 10, 11), expPanic: true, }, + { + description: "core 12 is not present in topology but is in state cpuset", + topo: topoDualSocketHT, + stAssignments: state.ContainerCPUAssignments{ + "0": cpuset.NewCPUSet(0, 1, 2), + "1": cpuset.NewCPUSet(3, 4), + }, + stDefaultCPUSet: cpuset.NewCPUSet(5, 6, 7, 8, 9, 10, 11, 12), + expPanic: true, + }, + { + description: "core 11 is present in topology but is not in state cpuset", + topo: topoDualSocketHT, + stAssignments: state.ContainerCPUAssignments{ + "0": cpuset.NewCPUSet(0, 1, 2), + "1": cpuset.NewCPUSet(3, 4), + }, + stDefaultCPUSet: cpuset.NewCPUSet(5, 6, 7, 8, 9, 10), + expPanic: true, + }, } for _, testCase := range testCases { t.Run(testCase.description, func(t *testing.T) {