mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-26 13:29:11 +01:00
refactor(TestFindDuplicatePods): replace direct ownerRef assignment with test.SetRSOwnerRef
This commit is contained in:
@@ -73,19 +73,18 @@ func TestFindDuplicatePods(t *testing.T) {
|
||||
})
|
||||
node6 := test.BuildTestNode("n6", 200, 200, 10, nil)
|
||||
|
||||
ownerRef := test.GetReplicaSetOwnerRefList()
|
||||
// Three Pods in the "dev" Namespace, bound to same ReplicaSet. 2 should be evicted.
|
||||
p1 := buildTestPodForNode1("p1", func(pod *v1.Pod) {
|
||||
pod.Namespace = "dev"
|
||||
pod.ObjectMeta.OwnerReferences = ownerRef
|
||||
test.SetRSOwnerRef(pod)
|
||||
})
|
||||
p2 := buildTestPodForNode1("p2", func(pod *v1.Pod) {
|
||||
pod.Namespace = "dev"
|
||||
pod.ObjectMeta.OwnerReferences = ownerRef
|
||||
test.SetRSOwnerRef(pod)
|
||||
})
|
||||
p3 := buildTestPodForNode1("p3", func(pod *v1.Pod) {
|
||||
pod.Namespace = "dev"
|
||||
pod.ObjectMeta.OwnerReferences = ownerRef
|
||||
test.SetRSOwnerRef(pod)
|
||||
})
|
||||
// A DaemonSet.
|
||||
p4 := buildTestPodForNode1("p4", func(pod *v1.Pod) {
|
||||
@@ -119,31 +118,31 @@ func TestFindDuplicatePods(t *testing.T) {
|
||||
// Three Pods in the "test" Namespace, bound to same ReplicaSet. 2 should be evicted.
|
||||
p8 := buildTestPodForNode1("p8", func(pod *v1.Pod) {
|
||||
pod.Namespace = "test"
|
||||
pod.ObjectMeta.OwnerReferences = ownerRef
|
||||
test.SetRSOwnerRef(pod)
|
||||
})
|
||||
p9 := buildTestPodForNode1("p9", func(pod *v1.Pod) {
|
||||
pod.Namespace = "test"
|
||||
pod.ObjectMeta.OwnerReferences = ownerRef
|
||||
test.SetRSOwnerRef(pod)
|
||||
})
|
||||
p10 := buildTestPodForNode1("p10", func(pod *v1.Pod) {
|
||||
pod.Namespace = "test"
|
||||
pod.ObjectMeta.OwnerReferences = ownerRef
|
||||
test.SetRSOwnerRef(pod)
|
||||
})
|
||||
// Same owners, but different images
|
||||
p11 := buildTestPodForNode1("p11", func(pod *v1.Pod) {
|
||||
pod.Namespace = "different-images"
|
||||
pod.Spec.Containers[0].Image = "foo"
|
||||
pod.ObjectMeta.OwnerReferences = ownerRef
|
||||
test.SetRSOwnerRef(pod)
|
||||
})
|
||||
p12 := buildTestPodForNode1("p12", func(pod *v1.Pod) {
|
||||
pod.Namespace = "different-images"
|
||||
pod.Spec.Containers[0].Image = "bar"
|
||||
pod.ObjectMeta.OwnerReferences = ownerRef
|
||||
test.SetRSOwnerRef(pod)
|
||||
})
|
||||
// Multiple containers
|
||||
p13 := buildTestPodForNode1("p13", func(pod *v1.Pod) {
|
||||
pod.Namespace = "different-images"
|
||||
pod.ObjectMeta.OwnerReferences = ownerRef
|
||||
test.SetRSOwnerRef(pod)
|
||||
pod.Spec.Containers = append(pod.Spec.Containers, v1.Container{
|
||||
Name: "foo",
|
||||
Image: "foo",
|
||||
@@ -152,21 +151,21 @@ func TestFindDuplicatePods(t *testing.T) {
|
||||
// ### Pods Evictable Based On Node Fit ###
|
||||
p15 := buildTestPodForNode1("p15", func(pod *v1.Pod) {
|
||||
pod.Namespace = "node-fit"
|
||||
pod.ObjectMeta.OwnerReferences = ownerRef
|
||||
test.SetRSOwnerRef(pod)
|
||||
pod.Spec.NodeSelector = map[string]string{
|
||||
"datacenter": "west",
|
||||
}
|
||||
})
|
||||
p16 := buildTestPodForNode1("NOT1", func(pod *v1.Pod) {
|
||||
pod.Namespace = "node-fit"
|
||||
pod.ObjectMeta.OwnerReferences = ownerRef
|
||||
test.SetRSOwnerRef(pod)
|
||||
pod.Spec.NodeSelector = map[string]string{
|
||||
"datacenter": "west",
|
||||
}
|
||||
})
|
||||
p17 := buildTestPodForNode1("NOT2", func(pod *v1.Pod) {
|
||||
pod.Namespace = "node-fit"
|
||||
pod.ObjectMeta.OwnerReferences = ownerRef
|
||||
test.SetRSOwnerRef(pod)
|
||||
pod.Spec.NodeSelector = map[string]string{
|
||||
"datacenter": "west",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user