Fix bug in CPUManager with setting topology for policies

Also add a check in the unit tests to avoid regressions
This commit is contained in:
Kevin Klues 2019-08-28 17:32:25 -05:00
parent d7ecc85239
commit ddfd9ac0ca
2 changed files with 11 additions and 1 deletions

View File

@ -113,7 +113,7 @@ func NewManager(cpuPolicyName string, reconcilePeriod time.Duration, machineInfo
case PolicyStatic: case PolicyStatic:
var err error var err error
topo, err := topology.Discover(machineInfo, numaNodeInfo) topo, err = topology.Discover(machineInfo, numaNodeInfo)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -353,6 +353,16 @@ func TestCPUManagerGenerate(t *testing.T) {
if rawMgr.policy.Name() != testCase.expectedPolicy { if rawMgr.policy.Name() != testCase.expectedPolicy {
t.Errorf("Unexpected policy name. Have: %q wants %q", rawMgr.policy.Name(), testCase.expectedPolicy) t.Errorf("Unexpected policy name. Have: %q wants %q", rawMgr.policy.Name(), testCase.expectedPolicy)
} }
if rawMgr.policy.Name() == string(PolicyNone) {
if rawMgr.topology != nil {
t.Errorf("Expected topology to be nil for 'none' policy. Have: %q", rawMgr.topology)
}
}
if rawMgr.policy.Name() != string(PolicyNone) {
if rawMgr.topology == nil {
t.Errorf("Expected topology to be non-nil for policy '%v'. Have: %q", rawMgr.policy.Name(), rawMgr.topology)
}
}
} }
}) })