mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-26 05:14:13 +01:00
refactor(TestRemovePodsHavingTooManyRestarts): inline node1
This commit is contained in:
@@ -130,7 +130,6 @@ func initPods(apply func(pod *v1.Pod)) []*v1.Pod {
|
||||
}
|
||||
|
||||
func TestRemovePodsHavingTooManyRestarts(t *testing.T) {
|
||||
node1 := buildTestNode(nodeName1, nil)
|
||||
node2 := buildTestNode(nodeName2, func(node *v1.Node) {
|
||||
node.Spec.Taints = []v1.Taint{
|
||||
{
|
||||
@@ -174,56 +173,72 @@ func TestRemovePodsHavingTooManyRestarts(t *testing.T) {
|
||||
description: "All pods have total restarts under threshold, no pod evictions",
|
||||
args: createRemovePodsHavingTooManyRestartsAgrs(10000, true),
|
||||
pods: initPods(nil),
|
||||
nodes: []*v1.Node{node1},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
},
|
||||
expectedEvictedPodCount: 0,
|
||||
},
|
||||
{
|
||||
description: "Some pods have total restarts bigger than threshold",
|
||||
args: createRemovePodsHavingTooManyRestartsAgrs(1, true),
|
||||
pods: initPods(nil),
|
||||
nodes: []*v1.Node{node1},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
},
|
||||
expectedEvictedPodCount: 6,
|
||||
},
|
||||
{
|
||||
description: "Nine pods have total restarts equals threshold(includingInitContainers=true), 6 pod evictions",
|
||||
args: createRemovePodsHavingTooManyRestartsAgrs(1*25, true),
|
||||
pods: initPods(nil),
|
||||
nodes: []*v1.Node{node1},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
},
|
||||
expectedEvictedPodCount: 6,
|
||||
},
|
||||
{
|
||||
description: "Nine pods have total restarts equals threshold(includingInitContainers=false), 5 pod evictions",
|
||||
args: createRemovePodsHavingTooManyRestartsAgrs(1*25, false),
|
||||
pods: initPods(nil),
|
||||
nodes: []*v1.Node{node1},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
},
|
||||
expectedEvictedPodCount: 5,
|
||||
},
|
||||
{
|
||||
description: "All pods have total restarts equals threshold(includingInitContainers=true), 6 pod evictions",
|
||||
args: createRemovePodsHavingTooManyRestartsAgrs(1*20, true),
|
||||
pods: initPods(nil),
|
||||
nodes: []*v1.Node{node1},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
},
|
||||
expectedEvictedPodCount: 6,
|
||||
},
|
||||
{
|
||||
description: "Nine pods have total restarts equals threshold(includingInitContainers=false), 6 pod evictions",
|
||||
args: createRemovePodsHavingTooManyRestartsAgrs(1*20, false),
|
||||
pods: initPods(nil),
|
||||
nodes: []*v1.Node{node1},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
},
|
||||
expectedEvictedPodCount: 6,
|
||||
},
|
||||
{
|
||||
description: "Five pods have total restarts bigger than threshold(includingInitContainers=true), but only 1 pod eviction",
|
||||
args: createRemovePodsHavingTooManyRestartsAgrs(5*25+1, true),
|
||||
pods: initPods(nil),
|
||||
nodes: []*v1.Node{node1},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
},
|
||||
expectedEvictedPodCount: 1,
|
||||
},
|
||||
{
|
||||
description: "Five pods have total restarts bigger than threshold(includingInitContainers=false), but only 1 pod eviction",
|
||||
args: createRemovePodsHavingTooManyRestartsAgrs(5*20+1, false),
|
||||
pods: initPods(nil),
|
||||
nodes: []*v1.Node{node1},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
},
|
||||
expectedEvictedPodCount: 1,
|
||||
nodeFit: false,
|
||||
},
|
||||
@@ -231,7 +246,9 @@ func TestRemovePodsHavingTooManyRestarts(t *testing.T) {
|
||||
description: "All pods have total restarts equals threshold(maxPodsToEvictPerNode=3), 3 pod evictions",
|
||||
args: createRemovePodsHavingTooManyRestartsAgrs(1, true),
|
||||
pods: initPods(nil),
|
||||
nodes: []*v1.Node{node1},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
},
|
||||
expectedEvictedPodCount: 3,
|
||||
maxPodsToEvictPerNode: &uint3,
|
||||
},
|
||||
@@ -239,7 +256,9 @@ func TestRemovePodsHavingTooManyRestarts(t *testing.T) {
|
||||
description: "All pods have total restarts equals threshold(maxNoOfPodsToEvictPerNamespace=3), 3 pod evictions",
|
||||
args: createRemovePodsHavingTooManyRestartsAgrs(1, true),
|
||||
pods: initPods(nil),
|
||||
nodes: []*v1.Node{node1},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
},
|
||||
expectedEvictedPodCount: 3,
|
||||
maxNoOfPodsToEvictPerNamespace: &uint3,
|
||||
},
|
||||
@@ -247,7 +266,10 @@ func TestRemovePodsHavingTooManyRestarts(t *testing.T) {
|
||||
description: "All pods have total restarts equals threshold(maxPodsToEvictPerNode=3) but the only other node is tainted, 0 pod evictions",
|
||||
args: createRemovePodsHavingTooManyRestartsAgrs(1, true),
|
||||
pods: initPods(nil),
|
||||
nodes: []*v1.Node{node1, node2},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
node2,
|
||||
},
|
||||
expectedEvictedPodCount: 0,
|
||||
maxPodsToEvictPerNode: &uint3,
|
||||
nodeFit: true,
|
||||
@@ -256,7 +278,10 @@ func TestRemovePodsHavingTooManyRestarts(t *testing.T) {
|
||||
description: "All pods have total restarts equals threshold(maxPodsToEvictPerNode=3) but the only other node is not schedulable, 0 pod evictions",
|
||||
args: createRemovePodsHavingTooManyRestartsAgrs(1, true),
|
||||
pods: initPods(nil),
|
||||
nodes: []*v1.Node{node1, node3},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
node3,
|
||||
},
|
||||
expectedEvictedPodCount: 0,
|
||||
maxPodsToEvictPerNode: &uint3,
|
||||
nodeFit: true,
|
||||
@@ -265,7 +290,10 @@ func TestRemovePodsHavingTooManyRestarts(t *testing.T) {
|
||||
description: "All pods have total restarts equals threshold(maxPodsToEvictPerNode=3) but the only other node does not have enough CPU, 0 pod evictions",
|
||||
args: createRemovePodsHavingTooManyRestartsAgrs(1, true),
|
||||
pods: initPods(nil),
|
||||
nodes: []*v1.Node{node1, node4},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
node4,
|
||||
},
|
||||
expectedEvictedPodCount: 0,
|
||||
maxPodsToEvictPerNode: &uint3,
|
||||
nodeFit: true,
|
||||
@@ -274,7 +302,10 @@ func TestRemovePodsHavingTooManyRestarts(t *testing.T) {
|
||||
description: "All pods have total restarts equals threshold(maxPodsToEvictPerNode=3) but the only other node has enough CPU, 3 pod evictions",
|
||||
args: createRemovePodsHavingTooManyRestartsAgrs(1, true),
|
||||
pods: initPods(nil),
|
||||
nodes: []*v1.Node{node1, node5},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
node5,
|
||||
},
|
||||
expectedEvictedPodCount: 3,
|
||||
maxPodsToEvictPerNode: &uint3,
|
||||
nodeFit: true,
|
||||
@@ -289,7 +320,10 @@ func TestRemovePodsHavingTooManyRestarts(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}),
|
||||
nodes: []*v1.Node{node1, node5},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
node5,
|
||||
},
|
||||
expectedEvictedPodCount: 3,
|
||||
maxPodsToEvictPerNode: &uint3,
|
||||
nodeFit: true,
|
||||
@@ -298,7 +332,10 @@ func TestRemovePodsHavingTooManyRestarts(t *testing.T) {
|
||||
description: "pods without CrashLoopBackOff with states=CrashLoopBackOff, 0 pod evictions",
|
||||
args: RemovePodsHavingTooManyRestartsArgs{PodRestartThreshold: 1, States: []string{"CrashLoopBackOff"}},
|
||||
pods: initPods(nil),
|
||||
nodes: []*v1.Node{node1, node5},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
node5,
|
||||
},
|
||||
expectedEvictedPodCount: 0,
|
||||
maxPodsToEvictPerNode: &uint3,
|
||||
nodeFit: true,
|
||||
@@ -309,7 +346,9 @@ func TestRemovePodsHavingTooManyRestarts(t *testing.T) {
|
||||
pods: initPods(func(pod *v1.Pod) {
|
||||
pod.Status.Phase = v1.PodRunning
|
||||
}),
|
||||
nodes: []*v1.Node{node1},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
},
|
||||
expectedEvictedPodCount: 3,
|
||||
maxPodsToEvictPerNode: &uint3,
|
||||
},
|
||||
@@ -319,7 +358,9 @@ func TestRemovePodsHavingTooManyRestarts(t *testing.T) {
|
||||
pods: initPods(func(pod *v1.Pod) {
|
||||
pod.Status.Phase = v1.PodPending
|
||||
}),
|
||||
nodes: []*v1.Node{node1},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
},
|
||||
expectedEvictedPodCount: 0,
|
||||
maxPodsToEvictPerNode: &uint3,
|
||||
},
|
||||
@@ -335,7 +376,9 @@ func TestRemovePodsHavingTooManyRestarts(t *testing.T) {
|
||||
},
|
||||
}
|
||||
}),
|
||||
nodes: []*v1.Node{node1},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
},
|
||||
expectedEvictedPodCount: 3,
|
||||
maxPodsToEvictPerNode: &uint3,
|
||||
},
|
||||
@@ -351,7 +394,9 @@ func TestRemovePodsHavingTooManyRestarts(t *testing.T) {
|
||||
},
|
||||
}
|
||||
}),
|
||||
nodes: []*v1.Node{node1},
|
||||
nodes: []*v1.Node{
|
||||
buildTestNode(nodeName1, nil),
|
||||
},
|
||||
expectedEvictedPodCount: 0,
|
||||
maxPodsToEvictPerNode: &uint3,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user