From 8cdf83ed1e0e03451f4db4d46faf9e05e3feca0e Mon Sep 17 00:00:00 2001 From: "Bobby (Babak) Salamat" Date: Mon, 11 Jun 2018 16:39:39 -0700 Subject: [PATCH] Add tests to cover newly added unresolvable failures --- pkg/scheduler/core/generic_scheduler_test.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pkg/scheduler/core/generic_scheduler_test.go b/pkg/scheduler/core/generic_scheduler_test.go index d0611c55a59..6a6a1ee27a5 100644 --- a/pkg/scheduler/core/generic_scheduler_test.go +++ b/pkg/scheduler/core/generic_scheduler_test.go @@ -1112,7 +1112,7 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) { expected: map[string]bool{}, }, { - name: "pod affinity should be tried", + name: "ErrPodAffinityNotMatch should be tried as it indicates that the pod is unschedulable due to inter-pod affinity or anti-affinity", failedPredMap: FailedPredicateMap{ "machine1": []algorithm.PredicateFailureReason{algorithmpredicates.ErrPodAffinityNotMatch}, "machine2": []algorithm.PredicateFailureReason{algorithmpredicates.ErrPodNotMatchHostName}, @@ -1128,6 +1128,14 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) { }, expected: map[string]bool{"machine1": true, "machine3": true, "machine4": true}, }, + { + name: "ErrPodAffinityRulesNotMatch should not be tried as it indicates that the pod is unschedulable due to inter-pod affinity, but ErrPodAffinityNotMatch should be tried as it indicates that the pod is unschedulable due to inter-pod affinity or anti-affinity", + failedPredMap: FailedPredicateMap{ + "machine1": []algorithm.PredicateFailureReason{algorithmpredicates.ErrPodAffinityRulesNotMatch}, + "machine2": []algorithm.PredicateFailureReason{algorithmpredicates.ErrPodAffinityNotMatch}, + }, + expected: map[string]bool{"machine2": true, "machine3": true, "machine4": true}, + }, { name: "Mix of failed predicates works fine", failedPredMap: FailedPredicateMap{ @@ -1138,6 +1146,16 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) { }, expected: map[string]bool{"machine3": true, "machine4": true}, }, + { + name: "Node condition errors should be considered unresolvable", + failedPredMap: FailedPredicateMap{ + "machine1": []algorithm.PredicateFailureReason{algorithmpredicates.ErrNodeUnderDiskPressure}, + "machine2": []algorithm.PredicateFailureReason{algorithmpredicates.ErrNodeUnderPIDPressure}, + "machine3": []algorithm.PredicateFailureReason{algorithmpredicates.ErrNodeUnderMemoryPressure}, + "machine4": []algorithm.PredicateFailureReason{algorithmpredicates.ErrNodeOutOfDisk}, + }, + expected: map[string]bool{}, + }, } for _, test := range tests {