Skip to content

Commit

Permalink
test(drain): add test for custom controller pod
Browse files Browse the repository at this point in the history
Signed-off-by: vadasambar <[email protected]>
  • Loading branch information
vadasambar committed Feb 21, 2023
1 parent 2fa357c commit 0ed6aba
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cluster-autoscaler/utils/drain/drain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,20 @@ func TestDrain(t *testing.T) {
},
}

customControllerPod := &apiv1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "bar",
Namespace: "default",
// Using names like FooController is discouraged
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions
// vadasambar: I am using it here just because `FooController`` is easier to understand than say `FooSet`
OwnerReferences: GenerateOwnerReferences("Foo", "FooController", "apps/v1", ""),
},
Spec: apiv1.PodSpec{
NodeName: "node",
},
}

nakedPod := &apiv1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "bar",
Expand Down Expand Up @@ -470,6 +484,14 @@ func TestDrain(t *testing.T) {
expectPods: []*apiv1.Pod{},
expectDaemonSetPods: []*apiv1.Pod{},
},
{
description: "Custom-controller-managed pod",
pods: []*apiv1.Pod{customControllerPod},
pdbs: []*policyv1.PodDisruptionBudget{},
expectFatal: false,
expectPods: []*apiv1.Pod{customControllerPod},
expectDaemonSetPods: []*apiv1.Pod{},
},
{
description: "naked pod",
pods: []*apiv1.Pod{nakedPod},
Expand Down

0 comments on commit 0ed6aba

Please sign in to comment.