-
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 FakeCache to pkg/scheduler/internal… #69318
Merged
k8s-ci-robot
merged 1 commit into
kubernetes:master
from
wgliang:feature/move-fakecache
Oct 10, 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
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,28 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = ["fake_cache.go"], | ||
importpath = "k8s.io/kubernetes/pkg/scheduler/internal/cache/fake", | ||
visibility = ["//pkg/scheduler:__subpackages__"], | ||
deps = [ | ||
"//pkg/scheduler/cache:go_default_library", | ||
"//pkg/scheduler/internal/cache:go_default_library", | ||
"//staging/src/k8s.io/api/core/v1:go_default_library", | ||
"//staging/src/k8s.io/apimachinery/pkg/labels: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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and | |
limitations under the License. | ||
*/ | ||
|
||
package testing | ||
package fake | ||
|
||
import ( | ||
"k8s.io/api/core/v1" | ||
|
@@ -23,74 +23,74 @@ import ( | |
schedulerinternalcache "k8s.io/kubernetes/pkg/scheduler/internal/cache" | ||
) | ||
|
||
// FakeCache is used for testing | ||
type FakeCache struct { | ||
// Cache is used for testing | ||
type Cache struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rewrite FakeCache to Cache for
|
||
AssumeFunc func(*v1.Pod) | ||
ForgetFunc func(*v1.Pod) | ||
IsAssumedPodFunc func(*v1.Pod) bool | ||
GetPodFunc func(*v1.Pod) *v1.Pod | ||
} | ||
|
||
// AssumePod is a fake method for testing. | ||
func (f *FakeCache) AssumePod(pod *v1.Pod) error { | ||
f.AssumeFunc(pod) | ||
func (c *Cache) AssumePod(pod *v1.Pod) error { | ||
c.AssumeFunc(pod) | ||
return nil | ||
} | ||
|
||
// FinishBinding is a fake method for testing. | ||
func (f *FakeCache) FinishBinding(pod *v1.Pod) error { return nil } | ||
func (c *Cache) FinishBinding(pod *v1.Pod) error { return nil } | ||
|
||
// ForgetPod is a fake method for testing. | ||
func (f *FakeCache) ForgetPod(pod *v1.Pod) error { | ||
f.ForgetFunc(pod) | ||
func (c *Cache) ForgetPod(pod *v1.Pod) error { | ||
c.ForgetFunc(pod) | ||
return nil | ||
} | ||
|
||
// AddPod is a fake method for testing. | ||
func (f *FakeCache) AddPod(pod *v1.Pod) error { return nil } | ||
func (c *Cache) AddPod(pod *v1.Pod) error { return nil } | ||
|
||
// UpdatePod is a fake method for testing. | ||
func (f *FakeCache) UpdatePod(oldPod, newPod *v1.Pod) error { return nil } | ||
func (c *Cache) UpdatePod(oldPod, newPod *v1.Pod) error { return nil } | ||
|
||
// RemovePod is a fake method for testing. | ||
func (f *FakeCache) RemovePod(pod *v1.Pod) error { return nil } | ||
func (c *Cache) RemovePod(pod *v1.Pod) error { return nil } | ||
|
||
// IsAssumedPod is a fake method for testing. | ||
func (f *FakeCache) IsAssumedPod(pod *v1.Pod) (bool, error) { | ||
return f.IsAssumedPodFunc(pod), nil | ||
func (c *Cache) IsAssumedPod(pod *v1.Pod) (bool, error) { | ||
return c.IsAssumedPodFunc(pod), nil | ||
} | ||
|
||
// GetPod is a fake method for testing. | ||
func (f *FakeCache) GetPod(pod *v1.Pod) (*v1.Pod, error) { | ||
return f.GetPodFunc(pod), nil | ||
func (c *Cache) GetPod(pod *v1.Pod) (*v1.Pod, error) { | ||
return c.GetPodFunc(pod), nil | ||
} | ||
|
||
// AddNode is a fake method for testing. | ||
func (f *FakeCache) AddNode(node *v1.Node) error { return nil } | ||
func (c *Cache) AddNode(node *v1.Node) error { return nil } | ||
|
||
// UpdateNode is a fake method for testing. | ||
func (f *FakeCache) UpdateNode(oldNode, newNode *v1.Node) error { return nil } | ||
func (c *Cache) UpdateNode(oldNode, newNode *v1.Node) error { return nil } | ||
|
||
// RemoveNode is a fake method for testing. | ||
func (f *FakeCache) RemoveNode(node *v1.Node) error { return nil } | ||
func (c *Cache) RemoveNode(node *v1.Node) error { return nil } | ||
|
||
// UpdateNodeNameToInfoMap is a fake method for testing. | ||
func (f *FakeCache) UpdateNodeNameToInfoMap(infoMap map[string]*schedulercache.NodeInfo) error { | ||
func (c *Cache) UpdateNodeNameToInfoMap(infoMap map[string]*schedulercache.NodeInfo) error { | ||
return nil | ||
} | ||
|
||
// List is a fake method for testing. | ||
func (f *FakeCache) List(s labels.Selector) ([]*v1.Pod, error) { return nil, nil } | ||
func (c *Cache) List(s labels.Selector) ([]*v1.Pod, error) { return nil, nil } | ||
|
||
// FilteredList is a fake method for testing. | ||
func (f *FakeCache) FilteredList(filter schedulerinternalcache.PodFilter, selector labels.Selector) ([]*v1.Pod, error) { | ||
func (c *Cache) FilteredList(filter schedulerinternalcache.PodFilter, selector labels.Selector) ([]*v1.Pod, error) { | ||
return nil, nil | ||
} | ||
|
||
// Snapshot is a fake method for testing | ||
func (f *FakeCache) Snapshot() *schedulerinternalcache.Snapshot { | ||
func (c *Cache) Snapshot() *schedulerinternalcache.Snapshot { | ||
return &schedulerinternalcache.Snapshot{} | ||
} | ||
|
||
// NodeTree is a fake method for testing. | ||
func (f *FakeCache) NodeTree() *schedulerinternalcache.NodeTree { return nil } | ||
func (c *Cache) NodeTree() *schedulerinternalcache.NodeTree { return nil } |
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.
Why not putting the file in
scheduler/internal/cache
instead ofscheduler/internal/cache/fake
?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.
Since the fake is meant for unit testing, we want a way to avoid importing it into production binaries. One way would be to call the file
fake_test.go
or we could just put it in a sub-package. Incidentally, this copies the convention fromk8s.io/client-go/kubernetes/fake
.