-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'kubernetes-sigs:master' into feat-return-node-fit-error
- Loading branch information
Showing
17 changed files
with
243 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package removeduplicates | ||
|
||
import ( | ||
"testing" | ||
|
||
"sigs.k8s.io/descheduler/pkg/api" | ||
) | ||
|
||
func TestValidateRemovePodsViolatingNodeTaintsArgs(t *testing.T) { | ||
testCases := []struct { | ||
description string | ||
args *RemoveDuplicatesArgs | ||
expectError bool | ||
}{ | ||
{ | ||
description: "valid namespace args, no errors", | ||
args: &RemoveDuplicatesArgs{ | ||
ExcludeOwnerKinds: []string{"Job"}, | ||
Namespaces: &api.Namespaces{ | ||
Include: []string{"default"}, | ||
}, | ||
}, | ||
expectError: false, | ||
}, | ||
{ | ||
description: "invalid namespaces args, expects error", | ||
args: &RemoveDuplicatesArgs{ | ||
ExcludeOwnerKinds: []string{"Job"}, | ||
Namespaces: &api.Namespaces{ | ||
Include: []string{"default"}, | ||
Exclude: []string{"kube-system"}, | ||
}, | ||
}, | ||
expectError: true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.description, func(t *testing.T) { | ||
err := ValidateRemoveDuplicatesArgs(tc.args) | ||
|
||
hasError := err != nil | ||
if tc.expectError != hasError { | ||
t.Error("unexpected arg validation behavior") | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package removefailedpods | ||
|
||
import ( | ||
"testing" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"sigs.k8s.io/descheduler/pkg/api" | ||
) | ||
|
||
func TestValidateRemoveFailedPodsArgs(t *testing.T) { | ||
var oneHourPodLifetimeSeconds uint = 3600 | ||
testCases := []struct { | ||
description string | ||
args *RemoveFailedPodsArgs | ||
expectError bool | ||
}{ | ||
{ | ||
description: "valid namespace args, no errors", | ||
args: &RemoveFailedPodsArgs{ | ||
Namespaces: &api.Namespaces{ | ||
Include: []string{"default"}, | ||
}, | ||
ExcludeOwnerKinds: []string{"Job"}, | ||
Reasons: []string{"ReasonDoesNotMatch"}, | ||
MinPodLifetimeSeconds: &oneHourPodLifetimeSeconds, | ||
}, | ||
expectError: false, | ||
}, | ||
{ | ||
description: "invalid namespaces args, expects error", | ||
args: &RemoveFailedPodsArgs{ | ||
Namespaces: &api.Namespaces{ | ||
Include: []string{"default"}, | ||
Exclude: []string{"kube-system"}, | ||
}, | ||
}, | ||
expectError: true, | ||
}, | ||
{ | ||
description: "valid label selector args, no errors", | ||
args: &RemoveFailedPodsArgs{ | ||
LabelSelector: &metav1.LabelSelector{ | ||
MatchLabels: map[string]string{"role.kubernetes.io/node": ""}, | ||
}, | ||
}, | ||
expectError: false, | ||
}, | ||
{ | ||
description: "invalid label selector args, expects errors", | ||
args: &RemoveFailedPodsArgs{ | ||
LabelSelector: &metav1.LabelSelector{ | ||
MatchExpressions: []metav1.LabelSelectorRequirement{ | ||
{ | ||
Operator: metav1.LabelSelectorOpIn, | ||
}, | ||
}, | ||
}, | ||
}, | ||
expectError: true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.description, func(t *testing.T) { | ||
err := ValidateRemoveFailedPodsArgs(tc.args) | ||
hasError := err != nil | ||
if tc.expectError != hasError { | ||
t.Error("unexpected arg validation behavior") | ||
} | ||
}) | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/validation_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package removepodsviolatinginterpodantiaffinity | ||
|
||
import ( | ||
"testing" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"sigs.k8s.io/descheduler/pkg/api" | ||
) | ||
|
||
func TestValidateRemovePodsViolatingInterPodAntiAffinityArgs(t *testing.T) { | ||
testCases := []struct { | ||
description string | ||
args *RemovePodsViolatingInterPodAntiAffinityArgs | ||
expectError bool | ||
}{ | ||
{ | ||
description: "valid namespace args, no errors", | ||
args: &RemovePodsViolatingInterPodAntiAffinityArgs{ | ||
Namespaces: &api.Namespaces{ | ||
Include: []string{"default"}, | ||
}, | ||
}, | ||
expectError: false, | ||
}, | ||
{ | ||
description: "invalid namespaces args, expects error", | ||
args: &RemovePodsViolatingInterPodAntiAffinityArgs{ | ||
Namespaces: &api.Namespaces{ | ||
Include: []string{"default"}, | ||
Exclude: []string{"kube-system"}, | ||
}, | ||
}, | ||
expectError: true, | ||
}, | ||
{ | ||
description: "valid label selector args, no errors", | ||
args: &RemovePodsViolatingInterPodAntiAffinityArgs{ | ||
LabelSelector: &metav1.LabelSelector{ | ||
MatchLabels: map[string]string{"role.kubernetes.io/node": ""}, | ||
}, | ||
}, | ||
expectError: false, | ||
}, | ||
{ | ||
description: "invalid label selector args, expects errors", | ||
args: &RemovePodsViolatingInterPodAntiAffinityArgs{ | ||
LabelSelector: &metav1.LabelSelector{ | ||
MatchExpressions: []metav1.LabelSelectorRequirement{ | ||
{ | ||
Operator: metav1.LabelSelectorOpIn, | ||
}, | ||
}, | ||
}, | ||
}, | ||
expectError: true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.description, func(t *testing.T) { | ||
err := ValidateRemovePodsViolatingInterPodAntiAffinityArgs(tc.args) | ||
hasError := err != nil | ||
if tc.expectError != hasError { | ||
t.Error("unexpected arg validation behavior") | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.