Skip to content

Commit

Permalink
Merge pull request kubernetes#4354 from DataDog/fix-expanders-tests
Browse files Browse the repository at this point in the history
fix expanders unit tests
  • Loading branch information
k8s-ci-robot authored and Evan Sheng committed Mar 24, 2022
1 parent ab8bbe2 commit 49598c6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
16 changes: 8 additions & 8 deletions cluster-autoscaler/expander/mostpods/mostpods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ import (
)

func TestMostPods(t *testing.T) {
e := NewStrategy()
e := NewFilter()

eo0 := expander.Option{Debug: "EO0"}
ret := e.BestOption([]expander.Option{eo0}, nil)
assert.Equal(t, *ret, eo0)
ret := e.BestOptions([]expander.Option{eo0}, nil)
assert.Equal(t, ret, []expander.Option{eo0})

eo1 := expander.Option{Debug: "EO1", Pods: []*apiv1.Pod{nil}}
ret = e.BestOption([]expander.Option{eo0, eo1}, nil)
assert.Equal(t, *ret, eo1)
ret = e.BestOptions([]expander.Option{eo0, eo1}, nil)
assert.Equal(t, ret, []expander.Option{eo1})

eo1b := expander.Option{Debug: "EO1b", Pods: []*apiv1.Pod{nil}}
ret = e.BestOption([]expander.Option{eo0, eo1, eo1b}, nil)
assert.NotEqual(t, *ret, eo0)
assert.True(t, assert.ObjectsAreEqual(*ret, eo1) || assert.ObjectsAreEqual(*ret, eo1b))
ret = e.BestOptions([]expander.Option{eo0, eo1, eo1b}, nil)
assert.NotEqual(t, ret, []expander.Option{eo0})
assert.ObjectsAreEqual(ret, []expander.Option{eo1, eo1b})
}
16 changes: 8 additions & 8 deletions cluster-autoscaler/expander/price/price_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestPriceExpander(t *testing.T) {
},
}
provider.SetPricingModel(pricingModel)
assert.Equal(t, optionsToDebug(NewStrategy(
assert.Equal(t, optionsToDebug(NewFilter(
provider,
&testPreferredNodeProvider{
preferred: buildNode(2000, units.GiB),
Expand All @@ -151,7 +151,7 @@ func TestPriceExpander(t *testing.T) {
},
}
provider.SetPricingModel(pricingModel)
assert.Equal(t, optionsToDebug(NewStrategy(
assert.Equal(t, optionsToDebug(NewFilter(
provider,
&testPreferredNodeProvider{
preferred: buildNode(4000, units.GiB),
Expand Down Expand Up @@ -188,7 +188,7 @@ func TestPriceExpander(t *testing.T) {
},
}
provider.SetPricingModel(pricingModel)
assert.Equal(t, optionsToDebug(NewStrategy(
assert.Equal(t, optionsToDebug(NewFilter(
provider,

&testPreferredNodeProvider{
Expand All @@ -210,7 +210,7 @@ func TestPriceExpander(t *testing.T) {
},
}
provider.SetPricingModel(pricingModel)
assert.Equal(t, optionsToDebug(NewStrategy(
assert.Equal(t, optionsToDebug(NewFilter(
provider,
&testPreferredNodeProvider{
preferred: buildNode(2000, units.GiB),
Expand Down Expand Up @@ -247,7 +247,7 @@ func TestPriceExpander(t *testing.T) {
provider.SetPricingModel(pricingModel)
// Both node groups are equally expensive. However 2
// accept two pods.
assert.Equal(t, optionsToDebug(NewStrategy(
assert.Equal(t, optionsToDebug(NewFilter(
provider,
&testPreferredNodeProvider{
preferred: buildNode(2000, units.GiB),
Expand All @@ -261,7 +261,7 @@ func TestPriceExpander(t *testing.T) {
nodePrice: map[string]float64{},
}
provider.SetPricingModel(pricingModel)
assert.Empty(t, NewStrategy(
assert.Empty(t, NewFilter(
provider,
&testPreferredNodeProvider{
preferred: buildNode(2000, units.GiB),
Expand Down Expand Up @@ -306,7 +306,7 @@ func TestPriceExpander(t *testing.T) {
},
}
provider.SetPricingModel(pricingModel)
assert.Equal(t, optionsToDebug(NewStrategy(
assert.Equal(t, optionsToDebug(NewFilter(
provider,
&testPreferredNodeProvider{
preferred: buildNode(2000, units.GiB),
Expand All @@ -328,7 +328,7 @@ func TestPriceExpander(t *testing.T) {
},
}
provider.SetPricingModel(pricingModel)
assert.Equal(t, optionsToDebug(NewStrategy(
assert.Equal(t, optionsToDebug(NewFilter(
provider,
&testPreferredNodeProvider{
preferred: buildNode(2000, units.GiB),
Expand Down
2 changes: 1 addition & 1 deletion cluster-autoscaler/expander/priority/priority_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func getFilterInstance(t *testing.T, config string) (expander.Filter, *record.Fa
lister, err := kubernetes.NewTestConfigMapLister([]*apiv1.ConfigMap{cm})
assert.Nil(t, err)
r := record.NewFakeRecorder(100)
s, err := NewStrategy(lister.ConfigMaps(testNamespace), r)
s := NewFilter(lister.ConfigMaps(testNamespace), r)
return s, r, cm, err
}

Expand Down
2 changes: 1 addition & 1 deletion cluster-autoscaler/expander/waste/waste_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func makeNodeInfo(cpu int64, memory int64, pods int64) *schedulerframework.NodeI
func TestLeastWaste(t *testing.T) {
cpuPerPod := int64(500)
memoryPerPod := int64(1000 * 1024 * 1024)
e := NewStrategy()
e := NewFilter()
balancedNodeInfo := makeNodeInfo(16*cpuPerPod, 16*memoryPerPod, 100)
nodeMap := map[string]*schedulerframework.NodeInfo{"balanced": balancedNodeInfo}
balancedOption := expander.Option{NodeGroup: &FakeNodeGroup{"balanced"}, NodeCount: 1}
Expand Down

0 comments on commit 49598c6

Please sign in to comment.