2019-10-19 08:49:05 -04:00
/ *
Copyright 2019 The Kubernetes Authors .
Licensed under the Apache License , Version 2.0 ( the "License" ) ;
you may not use this file except in compliance with the License .
You may obtain a copy of the License at
http : //www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing , software
distributed under the License is distributed on an "AS IS" BASIS ,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
See the License for the specific language governing permissions and
limitations under the License .
* /
package noderesources
import (
"context"
"reflect"
"testing"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2021-05-12 06:47:59 -04:00
"k8s.io/kubernetes/pkg/scheduler/apis/config"
2020-10-09 10:41:44 -04:00
"k8s.io/kubernetes/pkg/scheduler/framework"
2021-01-29 16:35:38 -05:00
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/feature"
2020-06-19 05:05:45 -04:00
"k8s.io/kubernetes/pkg/scheduler/framework/runtime"
2020-01-13 15:49:57 -05:00
"k8s.io/kubernetes/pkg/scheduler/internal/cache"
2019-10-19 08:49:05 -04:00
)
func TestNodeResourcesBalancedAllocation ( t * testing . T ) {
2021-05-12 06:47:59 -04:00
cpuAndMemoryAndGPU := v1 . PodSpec {
Containers : [ ] v1 . Container {
{
Resources : v1 . ResourceRequirements {
Requests : v1 . ResourceList {
v1 . ResourceCPU : resource . MustParse ( "1000m" ) ,
v1 . ResourceMemory : resource . MustParse ( "2000" ) ,
} ,
} ,
} ,
{
Resources : v1 . ResourceRequirements {
Requests : v1 . ResourceList {
v1 . ResourceCPU : resource . MustParse ( "2000m" ) ,
v1 . ResourceMemory : resource . MustParse ( "3000" ) ,
"nvidia.com/gpu" : resource . MustParse ( "3" ) ,
} ,
} ,
} ,
} ,
NodeName : "machine1" ,
}
2019-10-19 08:49:05 -04:00
labels1 := map [ string ] string {
"foo" : "bar" ,
"baz" : "blah" ,
}
labels2 := map [ string ] string {
"bar" : "foo" ,
"baz" : "blah" ,
}
machine1Spec := v1 . PodSpec {
NodeName : "machine1" ,
}
machine2Spec := v1 . PodSpec {
NodeName : "machine2" ,
}
noResources := v1 . PodSpec {
Containers : [ ] v1 . Container { } ,
}
cpuOnly := v1 . PodSpec {
NodeName : "machine1" ,
Containers : [ ] v1 . Container {
{
Resources : v1 . ResourceRequirements {
Requests : v1 . ResourceList {
v1 . ResourceCPU : resource . MustParse ( "1000m" ) ,
v1 . ResourceMemory : resource . MustParse ( "0" ) ,
} ,
} ,
} ,
{
Resources : v1 . ResourceRequirements {
Requests : v1 . ResourceList {
v1 . ResourceCPU : resource . MustParse ( "2000m" ) ,
v1 . ResourceMemory : resource . MustParse ( "0" ) ,
} ,
} ,
} ,
} ,
}
cpuOnly2 := cpuOnly
cpuOnly2 . NodeName = "machine2"
cpuAndMemory := v1 . PodSpec {
NodeName : "machine2" ,
Containers : [ ] v1 . Container {
{
Resources : v1 . ResourceRequirements {
Requests : v1 . ResourceList {
v1 . ResourceCPU : resource . MustParse ( "1000m" ) ,
v1 . ResourceMemory : resource . MustParse ( "2000" ) ,
} ,
} ,
} ,
{
Resources : v1 . ResourceRequirements {
Requests : v1 . ResourceList {
v1 . ResourceCPU : resource . MustParse ( "2000m" ) ,
v1 . ResourceMemory : resource . MustParse ( "3000" ) ,
} ,
} ,
} ,
} ,
}
2021-06-16 13:46:05 -04:00
nonZeroContainer := v1 . PodSpec {
Containers : [ ] v1 . Container { { } } ,
}
nonZeroContainer1 := v1 . PodSpec {
NodeName : "machine1" ,
Containers : [ ] v1 . Container { { } } ,
}
2021-05-12 06:47:59 -04:00
defaultResourceBalancedAllocationSet := [ ] config . ResourceSpec {
{ Name : string ( v1 . ResourceCPU ) , Weight : 1 } ,
{ Name : string ( v1 . ResourceMemory ) , Weight : 1 } ,
}
scalarResource := map [ string ] int64 {
"nvidia.com/gpu" : 8 ,
}
2019-10-19 08:49:05 -04:00
tests := [ ] struct {
pod * v1 . Pod
pods [ ] * v1 . Pod
nodes [ ] * v1 . Node
expectedList framework . NodeScoreList
name string
2021-05-12 06:47:59 -04:00
args config . NodeResourcesBalancedAllocationArgs
2019-10-19 08:49:05 -04:00
} {
{
2020-05-12 05:44:41 -04:00
// Node1 scores (remaining resources) on 0-MaxNodeScore scale
2019-10-19 08:49:05 -04:00
// CPU Fraction: 0 / 4000 = 0%
// Memory Fraction: 0 / 10000 = 0%
2021-05-12 06:47:59 -04:00
// Node1 Score: (1-0) * MaxNodeScore = MaxNodeScore
2020-05-12 05:44:41 -04:00
// Node2 scores (remaining resources) on 0-MaxNodeScore scale
2019-10-19 08:49:05 -04:00
// CPU Fraction: 0 / 4000 = 0 %
// Memory Fraction: 0 / 10000 = 0%
2021-05-12 06:47:59 -04:00
// Node2 Score: (1-0) * MaxNodeScore = MaxNodeScore
2019-10-19 08:49:05 -04:00
pod : & v1 . Pod { Spec : noResources } ,
nodes : [ ] * v1 . Node { makeNode ( "machine1" , 4000 , 10000 ) , makeNode ( "machine2" , 4000 , 10000 ) } ,
expectedList : [ ] framework . NodeScore { { Name : "machine1" , Score : framework . MaxNodeScore } , { Name : "machine2" , Score : framework . MaxNodeScore } } ,
name : "nothing scheduled, nothing requested" ,
2021-05-12 06:47:59 -04:00
args : config . NodeResourcesBalancedAllocationArgs { Resources : defaultResourceBalancedAllocationSet } ,
2019-10-19 08:49:05 -04:00
} ,
{
2020-05-12 05:44:41 -04:00
// Node1 scores on 0-MaxNodeScore scale
2019-10-19 08:49:05 -04:00
// CPU Fraction: 3000 / 4000= 75%
// Memory Fraction: 5000 / 10000 = 50%
2021-05-12 06:47:59 -04:00
// Node1 std: (0.75 - 0.5) / 2 = 0.125
// Node1 Score: (1 - 0.125)*MaxNodeScore = 87
2020-05-12 05:44:41 -04:00
// Node2 scores on 0-MaxNodeScore scale
2019-10-19 08:49:05 -04:00
// CPU Fraction: 3000 / 6000= 50%
// Memory Fraction: 5000/10000 = 50%
2021-05-12 06:47:59 -04:00
// Node2 std: 0
// Node2 Score: (1-0) * MaxNodeScore = MaxNodeScore
2019-10-19 08:49:05 -04:00
pod : & v1 . Pod { Spec : cpuAndMemory } ,
nodes : [ ] * v1 . Node { makeNode ( "machine1" , 4000 , 10000 ) , makeNode ( "machine2" , 6000 , 10000 ) } ,
2021-05-12 06:47:59 -04:00
expectedList : [ ] framework . NodeScore { { Name : "machine1" , Score : 87 } , { Name : "machine2" , Score : framework . MaxNodeScore } } ,
2019-10-19 08:49:05 -04:00
name : "nothing scheduled, resources requested, differently sized machines" ,
2021-05-12 06:47:59 -04:00
args : config . NodeResourcesBalancedAllocationArgs { Resources : defaultResourceBalancedAllocationSet } ,
2019-10-19 08:49:05 -04:00
} ,
{
2020-05-12 05:44:41 -04:00
// Node1 scores on 0-MaxNodeScore scale
2019-10-19 08:49:05 -04:00
// CPU Fraction: 0 / 4000= 0%
// Memory Fraction: 0 / 10000 = 0%
2021-05-12 06:47:59 -04:00
// Node1 std: 0
// Node1 Score: (1-0) * MaxNodeScore = MaxNodeScore
2020-05-12 05:44:41 -04:00
// Node2 scores on 0-MaxNodeScore scale
2019-10-19 08:49:05 -04:00
// CPU Fraction: 0 / 4000= 0%
// Memory Fraction: 0 / 10000 = 0%
2021-05-12 06:47:59 -04:00
// Node2 std: 0
// Node2 Score: (1-0) * MaxNodeScore = MaxNodeScore
2019-10-19 08:49:05 -04:00
pod : & v1 . Pod { Spec : noResources } ,
nodes : [ ] * v1 . Node { makeNode ( "machine1" , 4000 , 10000 ) , makeNode ( "machine2" , 4000 , 10000 ) } ,
expectedList : [ ] framework . NodeScore { { Name : "machine1" , Score : framework . MaxNodeScore } , { Name : "machine2" , Score : framework . MaxNodeScore } } ,
2021-05-12 06:47:59 -04:00
name : "no resources requested, pods without container scheduled" ,
2019-10-19 08:49:05 -04:00
pods : [ ] * v1 . Pod {
{ Spec : machine1Spec , ObjectMeta : metav1 . ObjectMeta { Labels : labels2 } } ,
{ Spec : machine1Spec , ObjectMeta : metav1 . ObjectMeta { Labels : labels1 } } ,
{ Spec : machine2Spec , ObjectMeta : metav1 . ObjectMeta { Labels : labels1 } } ,
{ Spec : machine2Spec , ObjectMeta : metav1 . ObjectMeta { Labels : labels1 } } ,
} ,
2021-05-12 06:47:59 -04:00
args : config . NodeResourcesBalancedAllocationArgs { Resources : defaultResourceBalancedAllocationSet } ,
2019-10-19 08:49:05 -04:00
} ,
2021-06-16 13:46:05 -04:00
{
// Node1 scores on 0-MaxNodeScore scale
2021-10-29 22:04:14 -04:00
// CPU Fraction: 0 / 250 = 0%
// Memory Fraction: 0 / 1000 = 0%
// Node1 std: (0 - 0) / 2 = 0
// Node1 Score: (1 - 0)*MaxNodeScore = 100
2021-06-16 13:46:05 -04:00
// Node2 scores on 0-MaxNodeScore scale
2021-10-29 22:04:14 -04:00
// CPU Fraction: 0 / 250 = 0%
// Memory Fraction: 0 / 1000 = 0%
// Node2 std: (0 - 0) / 2 = 0
// Node2 Score: (1 - 0)*MaxNodeScore = 100
2021-06-16 13:46:05 -04:00
pod : & v1 . Pod { Spec : nonZeroContainer } ,
nodes : [ ] * v1 . Node { makeNode ( "machine1" , 250 , 1000 * 1024 * 1024 ) , makeNode ( "machine2" , 250 , 1000 * 1024 * 1024 ) } ,
2021-10-29 22:04:14 -04:00
expectedList : [ ] framework . NodeScore { { Name : "machine1" , Score : 100 } , { Name : "machine2" , Score : 100 } } ,
2021-05-12 06:47:59 -04:00
name : "no resources requested, pods with container scheduled" ,
2021-06-16 13:46:05 -04:00
pods : [ ] * v1 . Pod {
{ Spec : nonZeroContainer1 } ,
{ Spec : nonZeroContainer1 } ,
} ,
2021-05-12 06:47:59 -04:00
args : config . NodeResourcesBalancedAllocationArgs { Resources : defaultResourceBalancedAllocationSet } ,
2021-06-16 13:46:05 -04:00
} ,
2019-10-19 08:49:05 -04:00
{
2020-05-12 05:44:41 -04:00
// Node1 scores on 0-MaxNodeScore scale
2019-10-19 08:49:05 -04:00
// CPU Fraction: 6000 / 10000 = 60%
// Memory Fraction: 0 / 20000 = 0%
2021-05-12 06:47:59 -04:00
// Node1 std: (0.6 - 0) / 2 = 0.3
// Node1 Score: (1 - 0.3)*MaxNodeScore = 70
2020-05-12 05:44:41 -04:00
// Node2 scores on 0-MaxNodeScore scale
2019-10-19 08:49:05 -04:00
// CPU Fraction: 6000 / 10000 = 60%
// Memory Fraction: 5000 / 20000 = 25%
2021-05-12 06:47:59 -04:00
// Node2 std: (0.6 - 0.25) / 2 = 0.175
// Node2 Score: (1 - 0.175)*MaxNodeScore = 82
2019-10-19 08:49:05 -04:00
pod : & v1 . Pod { Spec : noResources } ,
nodes : [ ] * v1 . Node { makeNode ( "machine1" , 10000 , 20000 ) , makeNode ( "machine2" , 10000 , 20000 ) } ,
2021-05-12 06:47:59 -04:00
expectedList : [ ] framework . NodeScore { { Name : "machine1" , Score : 70 } , { Name : "machine2" , Score : 82 } } ,
2019-10-19 08:49:05 -04:00
name : "no resources requested, pods scheduled with resources" ,
pods : [ ] * v1 . Pod {
{ Spec : cpuOnly , ObjectMeta : metav1 . ObjectMeta { Labels : labels2 } } ,
{ Spec : cpuOnly , ObjectMeta : metav1 . ObjectMeta { Labels : labels1 } } ,
{ Spec : cpuOnly2 , ObjectMeta : metav1 . ObjectMeta { Labels : labels1 } } ,
{ Spec : cpuAndMemory , ObjectMeta : metav1 . ObjectMeta { Labels : labels1 } } ,
} ,
2021-05-12 06:47:59 -04:00
args : config . NodeResourcesBalancedAllocationArgs { Resources : defaultResourceBalancedAllocationSet } ,
2019-10-19 08:49:05 -04:00
} ,
{
2020-05-12 05:44:41 -04:00
// Node1 scores on 0-MaxNodeScore scale
2019-10-19 08:49:05 -04:00
// CPU Fraction: 6000 / 10000 = 60%
// Memory Fraction: 5000 / 20000 = 25%
2021-05-12 06:47:59 -04:00
// Node1 std: (0.6 - 0.25) / 2 = 0.175
// Node1 Score: (1 - 0.175)*MaxNodeScore = 82
2020-05-12 05:44:41 -04:00
// Node2 scores on 0-MaxNodeScore scale
2019-10-19 08:49:05 -04:00
// CPU Fraction: 6000 / 10000 = 60%
// Memory Fraction: 10000 / 20000 = 50%
2021-05-12 06:47:59 -04:00
// Node2 std: (0.6 - 0.5) / 2 = 0.05
// Node2 Score: (1 - 0.05)*MaxNodeScore = 95
2019-10-19 08:49:05 -04:00
pod : & v1 . Pod { Spec : cpuAndMemory } ,
nodes : [ ] * v1 . Node { makeNode ( "machine1" , 10000 , 20000 ) , makeNode ( "machine2" , 10000 , 20000 ) } ,
2021-05-12 06:47:59 -04:00
expectedList : [ ] framework . NodeScore { { Name : "machine1" , Score : 82 } , { Name : "machine2" , Score : 95 } } ,
2019-10-19 08:49:05 -04:00
name : "resources requested, pods scheduled with resources" ,
pods : [ ] * v1 . Pod {
{ Spec : cpuOnly } ,
{ Spec : cpuAndMemory } ,
} ,
2021-05-12 06:47:59 -04:00
args : config . NodeResourcesBalancedAllocationArgs { Resources : defaultResourceBalancedAllocationSet } ,
2019-10-19 08:49:05 -04:00
} ,
{
2020-05-12 05:44:41 -04:00
// Node1 scores on 0-MaxNodeScore scale
2019-10-19 08:49:05 -04:00
// CPU Fraction: 6000 / 10000 = 60%
// Memory Fraction: 5000 / 20000 = 25%
2021-05-12 06:47:59 -04:00
// Node1 std: (0.6 - 0.25) / 2 = 0.175
// Node1 Score: (1 - 0.175)*MaxNodeScore = 82
2020-05-12 05:44:41 -04:00
// Node2 scores on 0-MaxNodeScore scale
2019-10-19 08:49:05 -04:00
// CPU Fraction: 6000 / 10000 = 60%
// Memory Fraction: 10000 / 50000 = 20%
2021-05-12 06:47:59 -04:00
// Node2 std: (0.6 - 0.2) / 2 = 0.2
// Node2 Score: (1 - 0.2)*MaxNodeScore = 80
2019-10-19 08:49:05 -04:00
pod : & v1 . Pod { Spec : cpuAndMemory } ,
nodes : [ ] * v1 . Node { makeNode ( "machine1" , 10000 , 20000 ) , makeNode ( "machine2" , 10000 , 50000 ) } ,
2021-05-12 06:47:59 -04:00
expectedList : [ ] framework . NodeScore { { Name : "machine1" , Score : 82 } , { Name : "machine2" , Score : 80 } } ,
2019-10-19 08:49:05 -04:00
name : "resources requested, pods scheduled with resources, differently sized machines" ,
pods : [ ] * v1 . Pod {
{ Spec : cpuOnly } ,
{ Spec : cpuAndMemory } ,
} ,
2021-05-12 06:47:59 -04:00
args : config . NodeResourcesBalancedAllocationArgs { Resources : defaultResourceBalancedAllocationSet } ,
2019-10-19 08:49:05 -04:00
} ,
{
2020-05-12 05:44:41 -04:00
// Node1 scores on 0-MaxNodeScore scale
2021-06-16 13:46:05 -04:00
// CPU Fraction: 6000 / 6000 = 1
2019-10-19 08:49:05 -04:00
// Memory Fraction: 0 / 10000 = 0
2021-05-12 06:47:59 -04:00
// Node1 std: (1 - 0) / 2 = 0.5
// Node1 Score: (1 - 0.5)*MaxNodeScore = 50
2021-06-16 13:46:05 -04:00
// Node1 Score: MaxNodeScore - (1 - 0) * MaxNodeScore = 0
2020-05-12 05:44:41 -04:00
// Node2 scores on 0-MaxNodeScore scale
2021-06-16 13:46:05 -04:00
// CPU Fraction: 6000 / 6000 = 1
2019-10-19 08:49:05 -04:00
// Memory Fraction 5000 / 10000 = 50%
2021-05-12 06:47:59 -04:00
// Node2 std: (1 - 0.5) / 2 = 0.25
// Node2 Score: (1 - 0.25)*MaxNodeScore = 75
2019-10-19 08:49:05 -04:00
pod : & v1 . Pod { Spec : cpuOnly } ,
2021-06-16 13:46:05 -04:00
nodes : [ ] * v1 . Node { makeNode ( "machine1" , 6000 , 10000 ) , makeNode ( "machine2" , 6000 , 10000 ) } ,
2021-05-12 06:47:59 -04:00
expectedList : [ ] framework . NodeScore { { Name : "machine1" , Score : 50 } , { Name : "machine2" , Score : 75 } } ,
2021-06-16 13:46:05 -04:00
name : "requested resources at node capacity" ,
2019-10-19 08:49:05 -04:00
pods : [ ] * v1 . Pod {
{ Spec : cpuOnly } ,
{ Spec : cpuAndMemory } ,
} ,
2021-05-12 06:47:59 -04:00
args : config . NodeResourcesBalancedAllocationArgs { Resources : defaultResourceBalancedAllocationSet } ,
} ,
{
pod : & v1 . Pod { Spec : noResources } ,
nodes : [ ] * v1 . Node { makeNode ( "machine1" , 0 , 0 ) , makeNode ( "machine2" , 0 , 0 ) } ,
expectedList : [ ] framework . NodeScore { { Name : "machine1" , Score : 100 } , { Name : "machine2" , Score : 100 } } ,
name : "zero node resources, pods scheduled with resources" ,
pods : [ ] * v1 . Pod {
{ Spec : cpuOnly } ,
{ Spec : cpuAndMemory } ,
} ,
args : config . NodeResourcesBalancedAllocationArgs { Resources : defaultResourceBalancedAllocationSet } ,
} ,
// Node1 scores on 0-MaxNodeScore scale
2021-10-29 22:04:14 -04:00
// CPU Fraction: 3000 / 3500 = 85.71%
2021-05-12 06:47:59 -04:00
// Memory Fraction: 5000 / 40000 = 12.5%
// GPU Fraction: 4 / 8 = 0.5%
2021-10-29 22:04:14 -04:00
// Node1 std: sqrt(((0.8571 - 0.503) * (0.8571 - 0.503) + (0.503 - 0.125) * (0.503 - 0.125) + (0.503 - 0.5) * (0.503 - 0.5)) / 3) = 0.3002
// Node1 Score: (1 - 0.3002)*MaxNodeScore = 70
2021-05-12 06:47:59 -04:00
// Node2 scores on 0-MaxNodeScore scale
2021-10-29 22:04:14 -04:00
// CPU Fraction: 3000 / 3500 = 85.71%
2021-05-12 06:47:59 -04:00
// Memory Fraction: 5000 / 40000 = 12.5%
// GPU Fraction: 1 / 8 = 12.5%
2021-10-29 22:04:14 -04:00
// Node2 std: sqrt(((0.8571 - 0.378) * (0.8571 - 0.378) + (0.378 - 0.125) * (0.378 - 0.125)) + (0.378 - 0.125) * (0.378 - 0.125)) / 3) = 0.345
// Node2 Score: (1 - 0.358)*MaxNodeScore = 65
2021-05-12 06:47:59 -04:00
{
pod : & v1 . Pod {
Spec : v1 . PodSpec {
Containers : [ ] v1 . Container {
{
Resources : v1 . ResourceRequirements {
Requests : v1 . ResourceList {
v1 . ResourceMemory : resource . MustParse ( "0" ) ,
"nvidia.com/gpu" : resource . MustParse ( "1" ) ,
} ,
} ,
} ,
} ,
} ,
} ,
nodes : [ ] * v1 . Node { makeNodeWithExtendedResource ( "machine1" , 3500 , 40000 , scalarResource ) , makeNodeWithExtendedResource ( "machine2" , 3500 , 40000 , scalarResource ) } ,
2021-10-29 22:04:14 -04:00
expectedList : [ ] framework . NodeScore { { Name : "machine1" , Score : 70 } , { Name : "machine2" , Score : 65 } } ,
2021-05-12 06:47:59 -04:00
name : "include scalar resource on a node for balanced resource allocation" ,
pods : [ ] * v1 . Pod {
{ Spec : cpuAndMemory } ,
{ Spec : cpuAndMemoryAndGPU } ,
} ,
args : config . NodeResourcesBalancedAllocationArgs { Resources : [ ] config . ResourceSpec {
{ Name : string ( v1 . ResourceCPU ) , Weight : 1 } ,
{ Name : string ( v1 . ResourceMemory ) , Weight : 1 } ,
{ Name : "nvidia.com/gpu" , Weight : 1 } ,
} } ,
} ,
// Only one node (machine1) has the scalar resource, pod doesn't request the scalar resource and the scalar resource should be skipped for consideration.
// Node1: std = 0, score = 100
// Node2: std = 0, score = 100
{
pod : & v1 . Pod { Spec : v1 . PodSpec { Containers : [ ] v1 . Container { { } } } } ,
nodes : [ ] * v1 . Node { makeNodeWithExtendedResource ( "machine1" , 3500 , 40000 , scalarResource ) , makeNode ( "machine2" , 3500 , 40000 ) } ,
expectedList : [ ] framework . NodeScore { { Name : "machine1" , Score : 100 } , { Name : "machine2" , Score : 100 } } ,
name : "node without the scalar resource results to a higher score" ,
pods : [ ] * v1 . Pod {
{ Spec : cpuOnly } ,
{ Spec : cpuOnly2 } ,
} ,
args : config . NodeResourcesBalancedAllocationArgs { Resources : [ ] config . ResourceSpec {
{ Name : string ( v1 . ResourceCPU ) , Weight : 1 } ,
{ Name : "nvidia.com/gpu" , Weight : 1 } ,
} } ,
2019-10-19 08:49:05 -04:00
} ,
}
for _ , test := range tests {
t . Run ( test . name , func ( t * testing . T ) {
2020-01-13 15:49:57 -05:00
snapshot := cache . NewSnapshot ( test . pods , test . nodes )
2021-03-03 16:44:25 -05:00
fh , _ := runtime . NewFramework ( nil , nil , runtime . WithSnapshotSharedLister ( snapshot ) )
2021-05-12 06:47:59 -04:00
p , _ := NewBalancedAllocation ( & test . args , fh , feature . Features { EnablePodOverhead : true } )
2019-10-19 08:49:05 -04:00
for i := range test . nodes {
hostResult , err := p . ( framework . ScorePlugin ) . Score ( context . Background ( ) , nil , test . pod , test . nodes [ i ] . Name )
if err != nil {
t . Errorf ( "unexpected error: %v" , err )
}
if ! reflect . DeepEqual ( test . expectedList [ i ] . Score , hostResult ) {
2021-06-16 13:46:05 -04:00
t . Errorf ( "got score %v for host %v, expected %v" , hostResult , test . nodes [ i ] . Name , test . expectedList [ i ] . Score )
2019-10-19 08:49:05 -04:00
}
}
} )
}
}