apply comments

This commit is contained in:
gmarek
2017-02-15 11:29:04 +01:00
parent de6c9bd535
commit 3c555f2ca4

View File

@@ -87,7 +87,7 @@ func addTaintsToNode(node *v1.Node, key, value string, indices []int) *v1.Node {
} }
type timestampedPod struct { type timestampedPod struct {
name string names []string
timestamp time.Duration timestamp time.Duration
} }
@@ -503,7 +503,7 @@ func TestUpdateNode(t *testing.T) {
additionalSleep: 1500 * time.Millisecond, additionalSleep: 1500 * time.Millisecond,
}, },
{ {
description: "Pod with multiple tolerations are victed when first one runs out", description: "Pod with multiple tolerations are evicted when first one runs out",
pods: []v1.Pod{ pods: []v1.Pod{
{ {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
@@ -592,8 +592,8 @@ func TestUpdateNodeWithMultiplePods(t *testing.T) {
oldNode: testutil.NewNode("node1"), oldNode: testutil.NewNode("node1"),
newNode: addTaintsToNode(testutil.NewNode("node1"), "testTaint1", "taint1", []int{1}), newNode: addTaintsToNode(testutil.NewNode("node1"), "testTaint1", "taint1", []int{1}),
expectedDeleteTimes: durationSlice{ expectedDeleteTimes: durationSlice{
{"pod1", 0}, {[]string{"pod1"}, 0},
{"pod2", time.Second}, {[]string{"pod2"}, time.Second},
}, },
}, },
{ {
@@ -606,8 +606,7 @@ func TestUpdateNodeWithMultiplePods(t *testing.T) {
oldNode: testutil.NewNode("node1"), oldNode: testutil.NewNode("node1"),
newNode: addTaintsToNode(testutil.NewNode("node1"), "testTaint1", "taint1", []int{1, 2}), newNode: addTaintsToNode(testutil.NewNode("node1"), "testTaint1", "taint1", []int{1, 2}),
expectedDeleteTimes: durationSlice{ expectedDeleteTimes: durationSlice{
{"pod1", 0}, {[]string{"pod1", "pod2", "pod3"}, 0},
{"pod2", 0},
}, },
}, },
} }
@@ -636,20 +635,46 @@ func TestUpdateNodeWithMultiplePods(t *testing.T) {
sleptAlready = item.expectedDeleteTimes[i].timestamp + increment sleptAlready = item.expectedDeleteTimes[i].timestamp + increment
} }
podDeleted := false for delay, podName := range item.expectedDeleteTimes[i].names {
deleted := false
for _, action := range fakeClientset.Actions() {
deleteAction, ok := action.(clienttesting.DeleteActionImpl)
if !ok {
glog.Infof("Found not-delete action with verb %v. Ignoring.", action.GetVerb())
continue
}
if deleteAction.GetResource().Resource != "pods" {
continue
}
if podName == deleteAction.GetName() {
deleted = true
}
}
if !deleted {
t.Errorf("Failed to deleted pod %v after %v", podName, delay)
}
}
for _, action := range fakeClientset.Actions() { for _, action := range fakeClientset.Actions() {
deleteAction, ok := action.(clienttesting.DeleteActionImpl) deleteAction, ok := action.(clienttesting.DeleteActionImpl)
if !ok { if !ok {
glog.Infof("Found not-delete action with verb %v. Ignoring.", action.GetVerb()) glog.Infof("Found not-delete action with verb %v. Ignoring.", action.GetVerb())
continue continue
} }
if deleteAction.GetResource().Resource == "pods" && deleteAction.GetName() == item.expectedDeleteTimes[i].name { if deleteAction.GetResource().Resource != "pods" {
podDeleted = true continue
}
deletedPodName := deleteAction.GetName()
expected := false
for _, podName := range item.expectedDeleteTimes[i].names {
if podName == deletedPodName {
expected = true
}
}
if !expected {
t.Errorf("Pod %v was deleted even though it shouldn't have", deletedPodName)
} }
} }
if !podDeleted { fakeClientset.ClearActions()
t.Errorf("%v: Unexepected test result. Expected delete %v which didn't happen", item.description, item.expectedDeleteTimes[i].name)
}
} }
close(stopCh) close(stopCh)