From f94b7eda83510b70f9fd3d895fe6fbf321f6ac81 Mon Sep 17 00:00:00 2001 From: "Da K. Ma" Date: Wed, 28 Feb 2018 16:11:01 +0800 Subject: [PATCH] Added unscheduable node UT for DaemonSet. Signed-off-by: Da K. Ma --- .../daemon/daemon_controller_test.go | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/controller/daemon/daemon_controller_test.go b/pkg/controller/daemon/daemon_controller_test.go index 881586c9bbf..ce4c6c5e7fb 100644 --- a/pkg/controller/daemon/daemon_controller_test.go +++ b/pkg/controller/daemon/daemon_controller_test.go @@ -1545,6 +1545,7 @@ func TestNodeShouldRunDaemonPod(t *testing.T) { predicateName string podsOnNode []*v1.Pod nodeCondition []v1.NodeCondition + nodeUnschedulable bool ds *apps.DaemonSet wantToRun, shouldSchedule, shouldContinueRunning bool err error @@ -1800,6 +1801,24 @@ func TestNodeShouldRunDaemonPod(t *testing.T) { shouldSchedule: true, shouldContinueRunning: true, }, + { + predicateName: "ShouldRunDaemonPodOnUnscheduableNode", + ds: &apps.DaemonSet{ + Spec: apps.DaemonSetSpec{ + Selector: &metav1.LabelSelector{MatchLabels: simpleDaemonSetLabel}, + Template: v1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: simpleDaemonSetLabel, + }, + Spec: resourcePodSpec("", "50M", "0.5"), + }, + }, + }, + nodeUnschedulable: true, + wantToRun: true, + shouldSchedule: true, + shouldContinueRunning: true, + }, } for i, c := range cases { @@ -1807,6 +1826,7 @@ func TestNodeShouldRunDaemonPod(t *testing.T) { node := newNode("test-node", simpleDaemonSetLabel) node.Status.Conditions = append(node.Status.Conditions, c.nodeCondition...) node.Status.Allocatable = allocatableResources("100M", "1") + node.Spec.Unschedulable = c.nodeUnschedulable manager, _, _, err := newTestController() if err != nil { t.Fatalf("error creating DaemonSets controller: %v", err)