Implement check for priority

This commit is contained in:
harry
2016-02-22 15:30:31 +08:00
committed by Harry Zhang
parent f4de3ea676
commit b90550de25
2 changed files with 89 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ limitations under the License.
package priorities
import (
"os/exec"
"reflect"
"sort"
"strconv"
@@ -25,6 +26,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/util/codeinspector"
"k8s.io/kubernetes/plugin/pkg/scheduler"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
priorityutil "k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/priorities/util"
@@ -884,3 +886,30 @@ func makeImageNode(node string, status api.NodeStatus) api.Node {
Status: status,
}
}
func TestPriorityRegistered(t *testing.T) {
var functionNames []string
files := []string{"priorities.go", "node_affinity.go", "selector_spreading.go"}
for _, filePath := range files {
functions, err := codeinspector.GetPulicFunctions(filePath)
if err == nil {
functionNames = append(functionNames, functions...)
} else {
t.Errorf("unexpected error when parsing %s", filePath)
}
}
for _, funcionName := range functionNames {
err := exec.Command("grep", "-rl", funcionName, "./../../algorithmprovider/defaults/defaults.go", "./../../factory/plugins.go").Run()
if err != nil {
switch err.Error() {
case "exit status 2":
t.Errorf("unexpected error when checking %s", funcionName)
case "exit status 1":
t.Errorf("priority %s is implemented but seems not registered in any place", funcionName)
}
}
}
}