Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove two zany unit tests. #38908

Merged
merged 1 commit into from
Dec 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 0 additions & 18 deletions pkg/util/codeinspector/BUILD

This file was deleted.

96 changes: 0 additions & 96 deletions pkg/util/codeinspector/codeinspector.go

This file was deleted.

8 changes: 1 addition & 7 deletions plugin/pkg/scheduler/algorithm/predicates/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,13 @@ go_test(
"utils_test.go",
],
library = "go_default_library",
tags = [
"automanaged",
"skip",
],
tags = ["automanaged"],
deps = [
"//pkg/api/resource:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/labels:go_default_library",
"//pkg/util/codeinspector:go_default_library",
"//plugin/pkg/scheduler/algorithm:go_default_library",
"//plugin/pkg/scheduler/algorithm/priorities/util:go_default_library",
"//plugin/pkg/scheduler/schedulercache:go_default_library",
"//vendor:k8s.io/gengo/parser",
"//vendor:k8s.io/gengo/types",
],
)
83 changes: 0 additions & 83 deletions plugin/pkg/scheduler/algorithm/predicates/predicates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,12 @@ package predicates

import (
"fmt"
"os/exec"
"path/filepath"
"reflect"
"strings"
"testing"

"k8s.io/gengo/parser"
"k8s.io/gengo/types"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/util/codeinspector"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
priorityutil "k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/priorities/util"
"k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache"
Expand Down Expand Up @@ -1849,84 +1844,6 @@ func TestEBSVolumeCountConflicts(t *testing.T) {
}
}

func getPredicateSignature() (*types.Signature, error) {
filePath := "./../types.go"
pkgName := filepath.Dir(filePath)
builder := parser.New()
if err := builder.AddDir(pkgName); err != nil {
return nil, err
}
universe, err := builder.FindTypes()
if err != nil {
return nil, err
}
result, ok := universe[pkgName].Types["FitPredicate"]
if !ok {
return nil, fmt.Errorf("FitPredicate type not defined")
}
return result.Signature, nil
}

func TestPredicatesRegistered(t *testing.T) {
var functions []*types.Type

// Files and directories which predicates may be referenced
targetFiles := []string{
"./../../algorithmprovider/defaults/defaults.go", // Default algorithm
"./../../factory/plugins.go", // Registered in init()
"./../../../../../pkg/", // kubernetes/pkg, often used by kubelet or controller
}

// List all golang source files under ./predicates/, excluding test files and sub-directories.
files, err := codeinspector.GetSourceCodeFiles(".")

if err != nil {
t.Errorf("unexpected error: %v when listing files in current directory", err)
}

// Get all public predicates in files.
for _, filePath := range files {
fileFunctions, err := codeinspector.GetPublicFunctions("k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/predicates", filePath)
if err == nil {
functions = append(functions, fileFunctions...)
} else {
t.Errorf("unexpected error %s when parsing %s", err, filePath)
}
}

predSignature, err := getPredicateSignature()
if err != nil {
t.Fatalf("Couldn't get predicates signature")
}

// Check if all public predicates are referenced in target files.
for _, function := range functions {
// Ignore functions that don't match FitPredicate signature.
signature := function.Underlying.Signature
if len(predSignature.Parameters) != len(signature.Parameters) {
continue
}
if len(predSignature.Results) != len(signature.Results) {
continue
}
// TODO: Check exact types of parameters and results.

args := []string{"-rl", function.Name.Name}
args = append(args, targetFiles...)

err := exec.Command("grep", args...).Run()
if err != nil {
switch err.Error() {
case "exit status 2":
t.Errorf("unexpected error when checking %s", function.Name)
case "exit status 1":
t.Errorf("predicate %s is implemented as public but seems not registered or used in any other place",
function.Name)
}
}
}
}

func newPodWithPort(hostPorts ...int) *v1.Pod {
networkPorts := []v1.ContainerPort{}
for _, port := range hostPorts {
Expand Down
9 changes: 1 addition & 8 deletions plugin/pkg/scheduler/algorithm/priorities/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,19 @@ go_test(
"node_affinity_test.go",
"node_label_test.go",
"node_prefer_avoid_pods_test.go",
"priorities_test.go",
"selector_spreading_test.go",
"taint_toleration_test.go",
],
library = "go_default_library",
tags = [
"automanaged",
"skip",
],
tags = ["automanaged"],
deps = [
"//pkg/api/resource:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/apis/extensions/v1beta1:go_default_library",
"//pkg/apis/meta/v1:go_default_library",
"//pkg/util/codeinspector:go_default_library",
"//plugin/pkg/scheduler/algorithm:go_default_library",
"//plugin/pkg/scheduler/algorithm/priorities/util:go_default_library",
"//plugin/pkg/scheduler/api:go_default_library",
"//plugin/pkg/scheduler/schedulercache:go_default_library",
"//vendor:k8s.io/gengo/parser",
"//vendor:k8s.io/gengo/types",
],
)
117 changes: 0 additions & 117 deletions plugin/pkg/scheduler/algorithm/priorities/priorities_test.go

This file was deleted.