1
0
mirror of https://github.com/kubernetes-sigs/descheduler.git synced 2026-01-26 05:14:13 +01:00

run: gofumpt -w -extra .

Enable gofumpt in golangci

Signed-off-by: Furkan <furkan.turkal@trendyol.com>
This commit is contained in:
Furkan
2022-09-30 15:34:05 +03:00
parent f938ac5e87
commit 99868a41de
56 changed files with 158 additions and 117 deletions

View File

@@ -300,7 +300,6 @@ func TestDefaultEvictorPreEvictionFilter(t *testing.T) {
}
for _, test := range testCases {
t.Run(test.description, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@@ -474,7 +473,8 @@ func TestDefaultEvictorFilter(t *testing.T) {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -494,7 +494,8 @@ func TestDefaultEvictorFilter(t *testing.T) {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -515,7 +516,8 @@ func TestDefaultEvictorFilter(t *testing.T) {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -706,7 +708,6 @@ func TestDefaultEvictorFilter(t *testing.T) {
}
for _, test := range testCases {
t.Run(test.description, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@@ -758,7 +759,6 @@ func TestDefaultEvictorFilter(t *testing.T) {
if (result) != test.result {
t.Errorf("Filter should return for pod %s %t, but it returns %t", test.pods[0].Name, test.result, result)
}
})
}
}

View File

@@ -14,12 +14,13 @@ limitations under the License.
package defaultevictor
import (
"testing"
"github.com/google/go-cmp/cmp"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/utils/pointer"
"sigs.k8s.io/descheduler/pkg/api"
"testing"
)
func TestSetDefaults_DefaultEvictorArgs(t *testing.T) {

View File

@@ -14,12 +14,13 @@ limitations under the License.
package nodeutilization
import (
"testing"
"github.com/google/go-cmp/cmp"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"sigs.k8s.io/descheduler/pkg/api"
"testing"
)
func TestSetDefaults_LowNodeUtilizationArgs(t *testing.T) {

View File

@@ -105,7 +105,8 @@ func TestHighNodeUtilization(t *testing.T) {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -510,7 +511,6 @@ func TestHighNodeUtilization(t *testing.T) {
SharedInformerFactoryImpl: sharedInformerFactory,
},
)
if err != nil {
t.Fatalf("Unable to initialize the plugin: %v", err)
}
@@ -662,7 +662,6 @@ func TestHighNodeUtilizationWithTaints(t *testing.T) {
SharedInformerFactoryImpl: sharedInformerFactory,
},
)
if err != nil {
t.Fatalf("Unable to initialize the plugin: %v", err)
}

View File

@@ -90,7 +90,8 @@ func TestLowNodeUtilization(t *testing.T) {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -139,7 +140,8 @@ func TestLowNodeUtilization(t *testing.T) {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -198,7 +200,8 @@ func TestLowNodeUtilization(t *testing.T) {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -258,7 +261,8 @@ func TestLowNodeUtilization(t *testing.T) {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -312,7 +316,8 @@ func TestLowNodeUtilization(t *testing.T) {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -381,7 +386,8 @@ func TestLowNodeUtilization(t *testing.T) {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -447,7 +453,8 @@ func TestLowNodeUtilization(t *testing.T) {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -521,7 +528,8 @@ func TestLowNodeUtilization(t *testing.T) {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -602,7 +610,8 @@ func TestLowNodeUtilization(t *testing.T) {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -665,7 +674,8 @@ func TestLowNodeUtilization(t *testing.T) {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -756,7 +766,8 @@ func TestLowNodeUtilization(t *testing.T) {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -806,7 +817,8 @@ func TestLowNodeUtilization(t *testing.T) {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -901,7 +913,6 @@ func TestLowNodeUtilization(t *testing.T) {
SharedInformerFactoryImpl: sharedInformerFactory,
},
)
if err != nil {
t.Fatalf("Unable to initialize the plugin: %v", err)
}
@@ -915,7 +926,6 @@ func TestLowNodeUtilization(t *testing.T) {
}
plugin, err := NewLowNodeUtilization(&LowNodeUtilizationArgs{
Thresholds: test.thresholds,
TargetThresholds: test.targetThresholds,
UseDeviationThresholds: test.useDeviationThresholds,
@@ -1075,7 +1085,6 @@ func TestLowNodeUtilizationWithTaints(t *testing.T) {
SharedInformerFactoryImpl: sharedInformerFactory,
},
)
if err != nil {
t.Fatalf("Unable to initialize the plugin: %v", err)
}
@@ -1089,7 +1098,6 @@ func TestLowNodeUtilizationWithTaints(t *testing.T) {
}
plugin, err := NewLowNodeUtilization(&LowNodeUtilizationArgs{
Thresholds: api.ResourceThresholds{
v1.ResourcePods: 20,
},

View File

@@ -227,7 +227,7 @@ func evictPodsFromSourceNodes(
v1.ResourceMemory: {},
}
var taintsOfDestinationNodes = make(map[string][]v1.Taint, len(destinationNodes))
taintsOfDestinationNodes := make(map[string][]v1.Taint, len(destinationNodes))
for _, node := range destinationNodes {
taintsOfDestinationNodes[node.node.Name] = node.node.Spec.Taints
@@ -282,7 +282,6 @@ func evictPods(
podEvictor framework.Evictor,
continueEviction continueEvictionCond,
) {
var excludedNamespaces sets.String
if evictableNamespaces != nil {
excludedNamespaces = sets.NewString(evictableNamespaces.Exclude...)
@@ -438,7 +437,6 @@ func averageNodeBasicresources(nodes []*v1.Node, getPodsAssignedToNode podutil.G
total[resource] += api.Percentage(value.MilliValue()) / api.Percentage(nodeCapacityValue.MilliValue()) * 100.0
} else {
total[resource] += api.Percentage(value.Value()) / api.Percentage(nodeCapacityValue.Value()) * 100.0
}
}
}

View File

@@ -15,6 +15,7 @@ package nodeutilization
import (
"fmt"
"sigs.k8s.io/descheduler/pkg/api"
)

View File

@@ -18,13 +18,14 @@ package nodeutilization
import (
"fmt"
"testing"
v1 "k8s.io/api/core/v1"
"sigs.k8s.io/descheduler/pkg/api"
"testing"
)
func TestValidateLowNodeUtilizationPluginConfig(t *testing.T) {
var extendedResource = v1.ResourceName("example.com/foo")
extendedResource := v1.ResourceName("example.com/foo")
tests := []struct {
name string
thresholds api.ResourceThresholds
@@ -165,7 +166,6 @@ func TestValidateLowNodeUtilizationPluginConfig(t *testing.T) {
for _, testCase := range tests {
args := &LowNodeUtilizationArgs{
Thresholds: testCase.thresholds,
TargetThresholds: testCase.targetThresholds,
}

View File

@@ -14,13 +14,14 @@ limitations under the License.
package podlifetime
import (
"testing"
"github.com/google/go-cmp/cmp"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/utils/pointer"
"sigs.k8s.io/descheduler/pkg/api"
"testing"
)
func TestSetDefaults_PodLifeTimeArgs(t *testing.T) {

View File

@@ -371,7 +371,6 @@ func TestPodLifeTime(t *testing.T) {
SharedInformerFactoryImpl: sharedInformerFactory,
},
)
if err != nil {
t.Fatalf("Unable to initialize the plugin: %v", err)
}

View File

@@ -18,6 +18,7 @@ package podlifetime
import (
"fmt"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"

View File

@@ -17,8 +17,9 @@ limitations under the License.
package podlifetime
import (
v1 "k8s.io/api/core/v1"
"testing"
v1 "k8s.io/api/core/v1"
)
func TestValidateRemovePodLifeTimeArgs(t *testing.T) {

View File

@@ -14,11 +14,12 @@ limitations under the License.
package removeduplicates
import (
"testing"
"github.com/google/go-cmp/cmp"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"sigs.k8s.io/descheduler/pkg/api"
"testing"
)
func TestSetDefaults_RemoveDuplicatesArgs(t *testing.T) {

View File

@@ -142,7 +142,8 @@ func TestFindDuplicatePods(t *testing.T) {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -366,7 +367,6 @@ func TestFindDuplicatePods(t *testing.T) {
}
})
}
}
func TestRemoveDuplicatesUniformly(t *testing.T) {
@@ -788,7 +788,6 @@ func TestRemoveDuplicatesUniformly(t *testing.T) {
SharedInformerFactoryImpl: sharedInformerFactory,
},
)
if err != nil {
t.Fatalf("Unable to initialize the plugin: %v", err)
}

View File

@@ -14,13 +14,14 @@ limitations under the License.
package removefailedpods
import (
"testing"
"github.com/google/go-cmp/cmp"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/utils/pointer"
"sigs.k8s.io/descheduler/pkg/api"
"testing"
)
func TestSetDefaults_RemoveFailedPodsArgs(t *testing.T) {

View File

@@ -36,15 +36,14 @@ import (
"sigs.k8s.io/descheduler/test"
)
var (
OneHourInSeconds uint = 3600
)
var OneHourInSeconds uint = 3600
func TestRemoveFailedPods(t *testing.T) {
createRemoveFailedPodsArgs := func(
includingInitContainers bool,
reasons, excludeKinds []string,
minAgeSeconds *uint) RemoveFailedPodsArgs {
minAgeSeconds *uint,
) RemoveFailedPodsArgs {
return RemoveFailedPodsArgs{
IncludingInitContainers: includingInitContainers,
Reasons: reasons,
@@ -317,7 +316,6 @@ func TestRemoveFailedPods(t *testing.T) {
SharedInformerFactoryImpl: sharedInformerFactory,
},
)
if err != nil {
t.Fatalf("Unable to initialize the plugin: %v", err)
}

View File

@@ -14,12 +14,13 @@ limitations under the License.
package removepodshavingtoomanyrestarts
import (
"testing"
"github.com/google/go-cmp/cmp"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"sigs.k8s.io/descheduler/pkg/api"
"testing"
)
func TestSetDefaults_RemovePodsHavingTooManyRestartsArgs(t *testing.T) {

View File

@@ -74,7 +74,8 @@ func initPods(node *v1.Node) []*v1.Pod {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -225,7 +226,6 @@ func TestRemovePodsHavingTooManyRestarts(t *testing.T) {
for _, tc := range tests {
t.Run(tc.description, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@@ -278,7 +278,6 @@ func TestRemovePodsHavingTooManyRestarts(t *testing.T) {
SharedInformerFactoryImpl: sharedInformerFactory,
},
)
if err != nil {
t.Fatalf("Unable to initialize the plugin: %v", err)
}

View File

@@ -15,6 +15,7 @@ package removepodshavingtoomanyrestarts
import (
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

View File

@@ -14,12 +14,13 @@ limitations under the License.
package removepodsviolatinginterpodantiaffinity
import (
"testing"
"github.com/google/go-cmp/cmp"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"sigs.k8s.io/descheduler/pkg/api"
"testing"
)
func TestSetDefaults_RemovePodsViolatingInterPodAntiAffinityArgs(t *testing.T) {

View File

@@ -190,7 +190,6 @@ func TestPodAntiAffinity(t *testing.T) {
for _, test := range tests {
t.Run(test.description, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@@ -243,7 +242,6 @@ func TestPodAntiAffinity(t *testing.T) {
SharedInformerFactoryImpl: sharedInformerFactory,
},
)
if err != nil {
t.Fatalf("Unable to initialize the plugin: %v", err)
}

View File

@@ -15,6 +15,7 @@ package removepodsviolatinginterpodantiaffinity
import (
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

View File

@@ -14,12 +14,13 @@ limitations under the License.
package removepodsviolatingnodeaffinity
import (
"testing"
"github.com/google/go-cmp/cmp"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"sigs.k8s.io/descheduler/pkg/api"
"testing"
)
func TestSetDefaults_RemovePodsViolatingNodeAffinityArgs(t *testing.T) {

View File

@@ -14,13 +14,12 @@ limitations under the License.
package removepodsviolatingnodeaffinity
import (
"context"
"fmt"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets"
"context"
v1 "k8s.io/api/core/v1"
"k8s.io/klog/v2"
"sigs.k8s.io/descheduler/pkg/descheduler/evictions"

View File

@@ -242,7 +242,6 @@ func TestRemovePodsViolatingNodeAffinity(t *testing.T) {
SharedInformerFactoryImpl: sharedInformerFactory,
},
)
if err != nil {
t.Fatalf("Unable to initialize the plugin: %v", err)
}

View File

@@ -18,6 +18,7 @@ package removepodsviolatingnodeaffinity
import (
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

View File

@@ -14,12 +14,13 @@ limitations under the License.
package removepodsviolatingnodetaints
import (
"testing"
"github.com/google/go-cmp/cmp"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"sigs.k8s.io/descheduler/pkg/api"
"testing"
)
func TestSetDefaults_RemovePodsViolatingNodeTaintsArgs(t *testing.T) {

View File

@@ -139,7 +139,8 @@ func TestDeletePodsViolatingNodeTaints(t *testing.T) {
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
EmptyDir: &v1.EmptyDirVolumeSource{
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI)},
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
},
},
},
}
@@ -175,14 +176,13 @@ func TestDeletePodsViolatingNodeTaints(t *testing.T) {
includePreferNoSchedule bool
excludedTaints []string
}{
{
description: "Pods not tolerating node taint should be evicted",
pods: []*v1.Pod{p1, p2, p3},
nodes: []*v1.Node{node1},
evictLocalStoragePods: false,
evictSystemCriticalPods: false,
expectedEvictedPodCount: 1, //p2 gets evicted
expectedEvictedPodCount: 1, // p2 gets evicted
},
{
description: "Pods with tolerations but not tolerating node taint should be evicted",
@@ -190,7 +190,7 @@ func TestDeletePodsViolatingNodeTaints(t *testing.T) {
nodes: []*v1.Node{node1},
evictLocalStoragePods: false,
evictSystemCriticalPods: false,
expectedEvictedPodCount: 1, //p4 gets evicted
expectedEvictedPodCount: 1, // p4 gets evicted
},
{
description: "Only <maxPodsToEvictPerNode> number of Pods not tolerating node taint should be evicted",
@@ -199,7 +199,7 @@ func TestDeletePodsViolatingNodeTaints(t *testing.T) {
evictLocalStoragePods: false,
evictSystemCriticalPods: false,
maxPodsToEvictPerNode: &uint1,
expectedEvictedPodCount: 1, //p5 or p6 gets evicted
expectedEvictedPodCount: 1, // p5 or p6 gets evicted
},
{
description: "Only <maxNoOfPodsToEvictPerNamespace> number of Pods not tolerating node taint should be evicted",
@@ -208,7 +208,7 @@ func TestDeletePodsViolatingNodeTaints(t *testing.T) {
evictLocalStoragePods: false,
evictSystemCriticalPods: false,
maxNoOfPodsToEvictPerNamespace: &uint1,
expectedEvictedPodCount: 1, //p5 or p6 gets evicted
expectedEvictedPodCount: 1, // p5 or p6 gets evicted
},
{
description: "Critical pods not tolerating node taint should not be evicted",
@@ -216,7 +216,7 @@ func TestDeletePodsViolatingNodeTaints(t *testing.T) {
nodes: []*v1.Node{node2},
evictLocalStoragePods: false,
evictSystemCriticalPods: false,
expectedEvictedPodCount: 0, //nothing is evicted
expectedEvictedPodCount: 0, // nothing is evicted
},
{
description: "Critical pods except storage pods not tolerating node taint should not be evicted",
@@ -224,7 +224,7 @@ func TestDeletePodsViolatingNodeTaints(t *testing.T) {
nodes: []*v1.Node{node2},
evictLocalStoragePods: true,
evictSystemCriticalPods: false,
expectedEvictedPodCount: 1, //p9 gets evicted
expectedEvictedPodCount: 1, // p9 gets evicted
},
{
description: "Critical and non critical pods, only non critical pods not tolerating node taint should be evicted",
@@ -232,7 +232,7 @@ func TestDeletePodsViolatingNodeTaints(t *testing.T) {
nodes: []*v1.Node{node2},
evictLocalStoragePods: false,
evictSystemCriticalPods: false,
expectedEvictedPodCount: 1, //p11 gets evicted
expectedEvictedPodCount: 1, // p11 gets evicted
},
{
description: "Critical and non critical pods, pods not tolerating node taint should be evicted even if they are critical",
@@ -240,7 +240,7 @@ func TestDeletePodsViolatingNodeTaints(t *testing.T) {
nodes: []*v1.Node{node1, node2},
evictLocalStoragePods: false,
evictSystemCriticalPods: true,
expectedEvictedPodCount: 2, //p2 and p7 are evicted
expectedEvictedPodCount: 2, // p2 and p7 are evicted
},
{
description: "Pod p2 doesn't tolerate taint on it's node, but also doesn't tolerate taints on other nodes",
@@ -248,7 +248,7 @@ func TestDeletePodsViolatingNodeTaints(t *testing.T) {
nodes: []*v1.Node{node1, node2},
evictLocalStoragePods: false,
evictSystemCriticalPods: false,
expectedEvictedPodCount: 0, //p2 gets evicted
expectedEvictedPodCount: 0, // p2 gets evicted
nodeFit: true,
},
{
@@ -257,7 +257,7 @@ func TestDeletePodsViolatingNodeTaints(t *testing.T) {
nodes: []*v1.Node{node1, node3},
evictLocalStoragePods: false,
evictSystemCriticalPods: false,
expectedEvictedPodCount: 0, //p2 gets evicted
expectedEvictedPodCount: 0, // p2 gets evicted
nodeFit: true,
},
{
@@ -266,7 +266,7 @@ func TestDeletePodsViolatingNodeTaints(t *testing.T) {
nodes: []*v1.Node{node1, node4},
evictLocalStoragePods: false,
evictSystemCriticalPods: false,
expectedEvictedPodCount: 0, //p2 gets evicted
expectedEvictedPodCount: 0, // p2 gets evicted
nodeFit: true,
},
{
@@ -319,14 +319,13 @@ func TestDeletePodsViolatingNodeTaints(t *testing.T) {
nodes: []*v1.Node{node1, node6},
evictLocalStoragePods: false,
evictSystemCriticalPods: true,
expectedEvictedPodCount: 0, //p2 and p7 can't be evicted
expectedEvictedPodCount: 0, // p2 and p7 can't be evicted
nodeFit: true,
},
}
for _, tc := range tests {
t.Run(tc.description, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@@ -379,7 +378,6 @@ func TestDeletePodsViolatingNodeTaints(t *testing.T) {
SharedInformerFactoryImpl: sharedInformerFactory,
},
)
if err != nil {
t.Fatalf("Unable to initialize the plugin: %v", err)
}
@@ -412,7 +410,6 @@ func TestDeletePodsViolatingNodeTaints(t *testing.T) {
}
func TestToleratesTaint(t *testing.T) {
testCases := []struct {
description string
toleration v1.Toleration

View File

@@ -18,6 +18,7 @@ package removepodsviolatingnodetaints
import (
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

View File

@@ -1,9 +1,10 @@
package removepodsviolatingnodetaints
import (
"testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/descheduler/pkg/api"
"testing"
)
func TestValidateRemovePodsViolatingNodeTaintsArgs(t *testing.T) {

View File

@@ -14,12 +14,13 @@ limitations under the License.
package removepodsviolatingtopologyspreadconstraint
import (
"testing"
"github.com/google/go-cmp/cmp"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"sigs.k8s.io/descheduler/pkg/api"
"testing"
)
func TestSetDefaults_RemovePodsViolatingTopologySpreadConstraintArgs(t *testing.T) {

View File

@@ -282,8 +282,8 @@ func balanceDomains(
constraintTopologies map[topologyPair][]*v1.Pod,
sumPods float64,
isEvictable func(pod *v1.Pod) bool,
nodes []*v1.Node) {
nodes []*v1.Node,
) {
idealAvg := sumPods / float64(len(constraintTopologies))
sortedDomains := sortDomains(constraintTopologies, isEvictable)

View File

@@ -1188,7 +1188,6 @@ func TestTopologySpreadConstraint(t *testing.T) {
SharedInformerFactoryImpl: sharedInformerFactory,
},
)
if err != nil {
t.Fatalf("Unable to initialize the plugin: %v", err)
}

View File

@@ -18,6 +18,7 @@ package removepodsviolatingtopologyspreadconstraint
import (
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)