hivedscheduler
hivedscheduler copied to clipboard
Refactor test cases
Motivation
-
Current test cases are mainly located in https://github.com/microsoft/hivedscheduler/blob/v0.3.4/pkg/algorithm/hived_algorithm_test.go . There are a lot of global variables and the code uses a lot of functions to reference them, which causes poor readability.
-
As we are going to use the v2 schema, old test cases will be out-dated. It is a good time to refactor them.
Proposal
Define a hivedAlgorithmTester interface as follows:
type hivedAlgorithmTester interface {
SchedulePod(podName string, pgsr v2.PodGroupSchedulingRequest, isDryRun bool)
AssertPodScheduleSucceed(podName string, psr internal.PodScheduleResult)
AssertPodScheduleFail(podName string)
SetAllNodesToHealthy()
SetAllNodesToBad()
SetNodeToBad(nodeName string)
SetAllNodesToHealthy(nodeName string)
ExecuteCasesFromYaml(yamlFilename string)
}
func NewHivedAlgorithmTester (t *testing.T, configFilePath string) *hivedAlgorithmTester{
}
After this tester is implemented, we will be able to express test cases within a yaml file, e.g.
- method: SchedulePod
parameters:
- pod1
- vc: vc1
pinnedCellId: "",
chain: "DGX2-V100-Node"
priority: 0
podRootGroup:
Name: "pod1-group"
WithinOneCell: ""
Pods:
PodMinNumber: 1
PodMaxNumber: 1
CellsPerPod:
CellType: "DGX2-V100-gpu"
CellNumber: 1
ContainsCurrentPod: true
- false
- method: AssertPodScheduleSucceed
parameters:
- pod1
- psr:
PodWaitInfo:
PodPreemptInfo:
PodWaitInfo: