feat(scheduler): move node info snapshot out of internal package
This commit is contained in:
12
pkg/scheduler/internal/cache/cache_test.go
vendored
12
pkg/scheduler/internal/cache/cache_test.go
vendored
@@ -23,7 +23,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
@@ -1077,7 +1077,7 @@ func TestNodeOperators(t *testing.T) {
|
||||
}
|
||||
|
||||
// Case 2: dump cached nodes successfully.
|
||||
cachedNodes := NewNodeInfoSnapshot()
|
||||
cachedNodes := schedulernodeinfo.NewSnapshot()
|
||||
cache.UpdateNodeInfoSnapshot(cachedNodes)
|
||||
newNode, found := cachedNodes.NodeInfoMap[node.Name]
|
||||
if !found || len(cachedNodes.NodeInfoMap) != 1 {
|
||||
@@ -1180,7 +1180,7 @@ func TestSchedulerCache_UpdateNodeInfoSnapshot(t *testing.T) {
|
||||
}
|
||||
|
||||
var cache *schedulerCache
|
||||
var snapshot *NodeInfoSnapshot
|
||||
var snapshot *schedulernodeinfo.Snapshot
|
||||
type operation = func()
|
||||
|
||||
addNode := func(i int) operation {
|
||||
@@ -1333,7 +1333,7 @@ func TestSchedulerCache_UpdateNodeInfoSnapshot(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
cache = newSchedulerCache(time.Second, time.Second, nil)
|
||||
snapshot = NewNodeInfoSnapshot()
|
||||
snapshot = schedulernodeinfo.NewSnapshot()
|
||||
|
||||
for _, op := range test.operations {
|
||||
op()
|
||||
@@ -1364,7 +1364,7 @@ func TestSchedulerCache_UpdateNodeInfoSnapshot(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func compareCacheWithNodeInfoSnapshot(cache *schedulerCache, snapshot *NodeInfoSnapshot) error {
|
||||
func compareCacheWithNodeInfoSnapshot(cache *schedulerCache, snapshot *schedulernodeinfo.Snapshot) error {
|
||||
if len(snapshot.NodeInfoMap) != len(cache.nodes) {
|
||||
return fmt.Errorf("unexpected number of nodes in the snapshot. Expected: %v, got: %v", len(cache.nodes), len(snapshot.NodeInfoMap))
|
||||
}
|
||||
@@ -1390,7 +1390,7 @@ func BenchmarkUpdate1kNodes30kPods(b *testing.B) {
|
||||
cache := setupCacheOf1kNodes30kPods(b)
|
||||
b.ResetTimer()
|
||||
for n := 0; n < b.N; n++ {
|
||||
cachedNodes := NewNodeInfoSnapshot()
|
||||
cachedNodes := schedulernodeinfo.NewSnapshot()
|
||||
cache.UpdateNodeInfoSnapshot(cachedNodes)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user