mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-26 05:14:13 +01:00
refactor(TestDefaultEvictor): add setPodLocalStorage helper function
This commit is contained in:
@@ -276,6 +276,20 @@ func TestDefaultEvictorFilter(t *testing.T) {
|
|||||||
pod.Annotations = map[string]string{evictPodAnnotationKey: "true"}
|
pod.Annotations = map[string]string{evictPodAnnotationKey: "true"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setPodLocalStorage := func(pod *v1.Pod) {
|
||||||
|
pod.Spec.Volumes = []v1.Volume{
|
||||||
|
{
|
||||||
|
Name: "sample",
|
||||||
|
VolumeSource: v1.VolumeSource{
|
||||||
|
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
|
||||||
|
EmptyDir: &v1.EmptyDirVolumeSource{
|
||||||
|
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ownerRefUUID := uuid.NewUUID()
|
ownerRefUUID := uuid.NewUUID()
|
||||||
|
|
||||||
testCases := []testCase{
|
testCases := []testCase{
|
||||||
@@ -383,17 +397,7 @@ func TestDefaultEvictorFilter(t *testing.T) {
|
|||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPod("p5", n1.Name, func(pod *v1.Pod) {
|
buildTestPod("p5", n1.Name, func(pod *v1.Pod) {
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
pod.Spec.Volumes = []v1.Volume{
|
setPodLocalStorage(pod)
|
||||||
{
|
|
||||||
Name: "sample",
|
|
||||||
VolumeSource: v1.VolumeSource{
|
|
||||||
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
|
|
||||||
EmptyDir: &v1.EmptyDirVolumeSource{
|
|
||||||
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -402,17 +406,7 @@ func TestDefaultEvictorFilter(t *testing.T) {
|
|||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPod("p6", n1.Name, func(pod *v1.Pod) {
|
buildTestPod("p6", n1.Name, func(pod *v1.Pod) {
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
pod.Spec.Volumes = []v1.Volume{
|
setPodLocalStorage(pod)
|
||||||
{
|
|
||||||
Name: "sample",
|
|
||||||
VolumeSource: v1.VolumeSource{
|
|
||||||
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
|
|
||||||
EmptyDir: &v1.EmptyDirVolumeSource{
|
|
||||||
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
evictLocalStoragePods: true,
|
evictLocalStoragePods: true,
|
||||||
@@ -424,17 +418,7 @@ func TestDefaultEvictorFilter(t *testing.T) {
|
|||||||
buildTestPod("p7", n1.Name, func(pod *v1.Pod) {
|
buildTestPod("p7", n1.Name, func(pod *v1.Pod) {
|
||||||
setPodEvictAnnotation(pod)
|
setPodEvictAnnotation(pod)
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
pod.Spec.Volumes = []v1.Volume{
|
setPodLocalStorage(pod)
|
||||||
{
|
|
||||||
Name: "sample",
|
|
||||||
VolumeSource: v1.VolumeSource{
|
|
||||||
HostPath: &v1.HostPathVolumeSource{Path: "somePath"},
|
|
||||||
EmptyDir: &v1.EmptyDirVolumeSource{
|
|
||||||
SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
result: true,
|
result: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user