mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-04 02:37:36 +00:00
add test and fix typo in daemoncontroller
This commit is contained in:
@@ -814,7 +814,7 @@ func (dsc *DaemonSetsController) syncDaemonSet(key string) error {
|
|||||||
// summary. Returned booleans are:
|
// summary. Returned booleans are:
|
||||||
// * wantToRun:
|
// * wantToRun:
|
||||||
// Returns true when a user would expect a pod to run on this node and ignores conditions
|
// Returns true when a user would expect a pod to run on this node and ignores conditions
|
||||||
// such as OutOfDisk or insufficent resource that would cause a daemonset pod not to schedule.
|
// such as OutOfDisk or insufficient resource that would cause a daemonset pod not to schedule.
|
||||||
// This is primarily used to populate daemonset status.
|
// This is primarily used to populate daemonset status.
|
||||||
// * shouldSchedule:
|
// * shouldSchedule:
|
||||||
// Returns true when a daemonset should be scheduled to a node if a daemonset pod is not already
|
// Returns true when a daemonset should be scheduled to a node if a daemonset pod is not already
|
||||||
|
@@ -455,7 +455,7 @@ func TestInsufficientCapacityNodeDaemonDoesNotLaunchPod(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DaemonSets should not unschedule a daemonset pod from a node with insufficient free resource
|
// DaemonSets should not unschedule a daemonset pod from a node with insufficient free resource
|
||||||
func TestInsufficentCapacityNodeDaemonDoesNotUnscheduleRunningPod(t *testing.T) {
|
func TestInsufficientCapacityNodeDaemonDoesNotUnscheduleRunningPod(t *testing.T) {
|
||||||
podSpec := resourcePodSpec("too-much-mem", "75M", "75m")
|
podSpec := resourcePodSpec("too-much-mem", "75M", "75m")
|
||||||
podSpec.NodeName = "too-much-mem"
|
podSpec.NodeName = "too-much-mem"
|
||||||
ds := newDaemonSet("foo")
|
ds := newDaemonSet("foo")
|
||||||
@@ -1302,6 +1302,29 @@ func TestGetNodesToDaemonPods(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAddNode(t *testing.T) {
|
||||||
|
manager, _, _ := newTestController()
|
||||||
|
node1 := newNode("node1", nil)
|
||||||
|
ds := newDaemonSet("ds")
|
||||||
|
ds.Spec.Template.Spec.NodeSelector = simpleNodeLabel
|
||||||
|
manager.dsStore.Add(ds)
|
||||||
|
|
||||||
|
manager.addNode(node1)
|
||||||
|
if got, want := manager.queue.Len(), 0; got != want {
|
||||||
|
t.Fatalf("queue.Len() = %v, want %v", got, want)
|
||||||
|
}
|
||||||
|
|
||||||
|
node2 := newNode("node2", simpleNodeLabel)
|
||||||
|
manager.addNode(node2)
|
||||||
|
if got, want := manager.queue.Len(), 1; got != want {
|
||||||
|
t.Fatalf("queue.Len() = %v, want %v", got, want)
|
||||||
|
}
|
||||||
|
key, done := manager.queue.Get()
|
||||||
|
if key == nil || done {
|
||||||
|
t.Fatalf("failed to enqueue controller for node %v", node2.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestAddPod(t *testing.T) {
|
func TestAddPod(t *testing.T) {
|
||||||
manager, _, _ := newTestController()
|
manager, _, _ := newTestController()
|
||||||
ds1 := newDaemonSet("foo1")
|
ds1 := newDaemonSet("foo1")
|
||||||
|
Reference in New Issue
Block a user