Add a new TestTakeByTopologyNUMADistributed() test to the CPUManager
As part of this, pull out all of the existing "TakeByTopology" tests and have them be called by the original TestTakeByTopologyNUMAPacked() as well as the new TestTakeByTopologyNUMADistributed() test. In a subsequent commit, we will add some tests that should differ between these two algorithms. Signed-off-by: Kevin Klues <kklues@nvidia.com>
This commit is contained in:
@@ -506,15 +506,17 @@ func TestCPUAccumulatorTake(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTakeByTopologyNUMAPacked(t *testing.T) {
|
||||
testCases := []struct {
|
||||
description string
|
||||
topo *topology.CPUTopology
|
||||
availableCPUs cpuset.CPUSet
|
||||
numCPUs int
|
||||
expErr string
|
||||
expResult cpuset.CPUSet
|
||||
}{
|
||||
type takeByTopologyTestCase struct {
|
||||
description string
|
||||
topo *topology.CPUTopology
|
||||
availableCPUs cpuset.CPUSet
|
||||
numCPUs int
|
||||
expErr string
|
||||
expResult cpuset.CPUSet
|
||||
}
|
||||
|
||||
func commonTakeByTopologyTestCases(t *testing.T) []takeByTopologyTestCase {
|
||||
return []takeByTopologyTestCase{
|
||||
{
|
||||
"take more cpus than are available from single socket with HT",
|
||||
topoSingleSocketHT,
|
||||
@@ -628,7 +630,10 @@ func TestTakeByTopologyNUMAPacked(t *testing.T) {
|
||||
mustParseCPUSet(t, "10-39,50-79"),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func TestTakeByTopologyNUMAPacked(t *testing.T) {
|
||||
testCases := commonTakeByTopologyTestCases(t)
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.description, func(t *testing.T) {
|
||||
result, err := takeByTopologyNUMAPacked(tc.topo, tc.availableCPUs, tc.numCPUs)
|
||||
@@ -642,6 +647,21 @@ func TestTakeByTopologyNUMAPacked(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTakeByTopologyNUMADistributed(t *testing.T) {
|
||||
testCases := commonTakeByTopologyTestCases(t)
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.description, func(t *testing.T) {
|
||||
result, err := takeByTopologyNUMADistributed(tc.topo, tc.availableCPUs, tc.numCPUs)
|
||||
if tc.expErr != "" && err.Error() != tc.expErr {
|
||||
t.Errorf("expected error to be [%v] but it was [%v]", tc.expErr, err)
|
||||
}
|
||||
if !result.Equals(tc.expResult) {
|
||||
t.Errorf("expected result [%s] to equal [%s]", result, tc.expResult)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func mustParseCPUSet(t *testing.T, s string) cpuset.CPUSet {
|
||||
cpus, err := cpuset.Parse(s)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user