Skip to content

Commit

Permalink
test: add extra test cases for predicate checker
Browse files Browse the repository at this point in the history
- where the predicate checker uses custom scheduler config
Signed-off-by: vadasambar <surajrbanakar@gmail.com>
  • Loading branch information
vadasambar committed May 17, 2023
1 parent 3cbce28 commit 07313a7
Show file tree
Hide file tree
Showing 8 changed files with 250 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func TestFilterOutSchedulable(t *testing.T) {
for tn, tc := range testCases {
t.Run(tn, func(t *testing.T) {
clusterSnapshot := clustersnapshot.NewBasicClusterSnapshot()
predicateChecker, err := predicatechecker.NewTestPredicateChecker()
predicateChecker, err := predicatechecker.NewTestPredicateChecker(nil)
assert.NoError(t, err)

var allExpectedScheduledPods []*apiv1.Pod
Expand Down Expand Up @@ -262,7 +262,7 @@ func BenchmarkFilterOutSchedulable(b *testing.B) {
}
}

predicateChecker, err := predicatechecker.NewTestPredicateChecker()
predicateChecker, err := predicatechecker.NewTestPredicateChecker(nil)
assert.NoError(b, err)

clusterSnapshot := snapshotFactory()
Expand Down
2 changes: 1 addition & 1 deletion cluster-autoscaler/core/test/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func NewScaleTestAutoscalingContext(
// Ignoring error here is safe - if a test doesn't specify valid estimatorName,
// it either doesn't need one, or should fail when it turns out to be nil.
estimatorBuilder, _ := estimator.NewEstimatorBuilder(options.EstimatorName, estimator.NewThresholdBasedEstimationLimiter(0, 0))
predicateChecker, err := predicatechecker.NewTestPredicateChecker()
predicateChecker, err := predicatechecker.NewTestPredicateChecker(nil)
if err != nil {
return context.AutoscalingContext{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion cluster-autoscaler/estimator/binpacking_estimator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func TestBinpackingEstimate(t *testing.T) {
// Add one node in different zone to trigger topology spread constraints
clusterSnapshot.AddNode(makeNode(100, 100, "oldnode", "zone-jupiter"))

predicateChecker, err := predicatechecker.NewTestPredicateChecker()
predicateChecker, err := predicatechecker.NewTestPredicateChecker(nil)
assert.NoError(t, err)
limiter := NewThresholdBasedEstimationLimiter(tc.maxNodes, time.Duration(0))
estimator := NewBinpackingNodeEstimator(predicateChecker, clusterSnapshot, limiter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestGetNodeInfosForGroups(t *testing.T) {
podLister := kube_util.NewTestPodLister([]*apiv1.Pod{})
registry := kube_util.NewListerRegistry(nil, nil, podLister, nil, nil, nil, nil, nil, nil, nil)

predicateChecker, err := predicatechecker.NewTestPredicateChecker()
predicateChecker, err := predicatechecker.NewTestPredicateChecker(nil)
assert.NoError(t, err)

ctx := context.AutoscalingContext{
Expand Down Expand Up @@ -161,7 +161,7 @@ func TestGetNodeInfosForGroupsCache(t *testing.T) {
podLister := kube_util.NewTestPodLister([]*apiv1.Pod{})
registry := kube_util.NewListerRegistry(nil, nil, podLister, nil, nil, nil, nil, nil, nil, nil)

predicateChecker, err := predicatechecker.NewTestPredicateChecker()
predicateChecker, err := predicatechecker.NewTestPredicateChecker(nil)
assert.NoError(t, err)

// Fill cache
Expand Down Expand Up @@ -250,7 +250,7 @@ func TestGetNodeInfosCacheExpired(t *testing.T) {
provider := testprovider.NewTestAutoprovisioningCloudProvider(nil, nil, nil, nil, nil, nil)
podLister := kube_util.NewTestPodLister([]*apiv1.Pod{})
registry := kube_util.NewListerRegistry(nil, nil, podLister, nil, nil, nil, nil, nil, nil, nil)
predicateChecker, err := predicatechecker.NewTestPredicateChecker()
predicateChecker, err := predicatechecker.NewTestPredicateChecker(nil)
assert.NoError(t, err)

ctx := context.AutoscalingContext{
Expand Down
2 changes: 1 addition & 1 deletion cluster-autoscaler/simulator/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func TestFindNodesToRemove(t *testing.T) {
}

clusterSnapshot := clustersnapshot.NewBasicClusterSnapshot()
predicateChecker, err := predicatechecker.NewTestPredicateChecker()
predicateChecker, err := predicatechecker.NewTestPredicateChecker(nil)
assert.NoError(t, err)
tracker := NewUsageTracker()

Expand Down
Loading

0 comments on commit 07313a7

Please sign in to comment.