-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
[scheduler cleanup phase 1]: Move CacheComparer to pkg/scheduler/inte… #69317
Merged
k8s-ci-robot
merged 1 commit into
kubernetes:master
from
wgliang:feature/move-cachecompare
Oct 11, 2018
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = ["comparer.go"], | ||
importpath = "k8s.io/kubernetes/pkg/scheduler/internal/cache/comparer", | ||
visibility = ["//pkg/scheduler:__subpackages__"], | ||
deps = [ | ||
"//pkg/scheduler/cache:go_default_library", | ||
"//pkg/scheduler/internal/cache:go_default_library", | ||
"//pkg/scheduler/internal/queue:go_default_library", | ||
"//staging/src/k8s.io/api/core/v1:go_default_library", | ||
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library", | ||
"//staging/src/k8s.io/client-go/listers/core/v1:go_default_library", | ||
"//vendor/github.com/golang/glog:go_default_library", | ||
], | ||
) | ||
|
||
go_test( | ||
name = "go_default_test", | ||
srcs = ["comparer_test.go"], | ||
embed = [":go_default_library"], | ||
deps = [ | ||
"//pkg/scheduler/cache:go_default_library", | ||
"//staging/src/k8s.io/api/core/v1:go_default_library", | ||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "package-srcs", | ||
srcs = glob(["**"]), | ||
tags = ["automanaged"], | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
filegroup( | ||
name = "all-srcs", | ||
srcs = [":package-srcs"], | ||
tags = ["automanaged"], | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's trivial, please change package name to
comparer_test
in this PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we should name the package as
combiner_test
? Sorry, I can't understand the benefits of doing this?But, even if we do, what should we name our file name? If we don't make any changes of files in combiner_test, we will get:
pkg/scheduler/factory/factory.go:63:2: found packages comparer (comparer.go) and comparer (comparer_test.go)
(I'm sure I have set the package name in comparer.go and comparer_test.go as comparer_test. Perhaps contrary to Go's naming rules?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is coming from my c++ background, where we try to test via public interfaces. For example, suppose one of the structs in our package has a private field protected by a private
sync.Mutex
. Nothing prevents a unit test from accessing the field without holding the mutex. (Hopefullygo test -race
would catch it.)The point is that direct access to private fields might lead us to test the wrong thing. To follow from the previous example, if we have a strong guarantee that all access to the field is protected by a mutex, we can make certain assumptions about concurrent access.
Regardless of the package name, the file name "comparer_test.go" is appropriate.
/lgtm