11package checkpoint
22
33import (
4- "flag"
54 "reflect"
65 "testing"
76 "time"
@@ -11,9 +10,6 @@ import (
1110)
1211
1312func TestProcess (t * testing.T ) {
14- flag .Set ("logtostderr" , "true" )
15- flag .Parse ()
16-
1713 type testCase struct {
1814 desc string
1915 localRunning map [string ]* v1.Pod
@@ -59,6 +55,13 @@ func TestProcess(t *testing.T) {
5955 apiParents : map [string ]* v1.Pod {"AA" : {}},
6056 expectStart : []string {"AA" },
6157 },
58+ {
59+ desc : "Inactive checkpoint and only api and kubelet parents: should start" ,
60+ inactiveCheckpoints : map [string ]* v1.Pod {"AA" : {}},
61+ apiParents : map [string ]* v1.Pod {"AA" : {}},
62+ localParents : map [string ]* v1.Pod {"AA" : {}},
63+ expectStart : []string {"AA" },
64+ },
6265 {
6366 desc : "Active checkpoint and no local running: no change" ,
6467 activeCheckpoints : map [string ]* v1.Pod {"AA" : {}},
@@ -170,8 +173,9 @@ func TestProcess(t *testing.T) {
170173 },
171174 "AA" : {},
172175 },
173- expectStop : []string {"AA" , "kube-system/pod-checkpointer" },
174- expectGraceRemove : []string {"AA" , "kube-system/pod-checkpointer" },
176+ expectStart : []string {"kube-system/pod-checkpointer" },
177+ expectStop : []string {"BB" },
178+ expectGraceRemove : []string {"AA" , "BB" , "kube-system/pod-checkpointer" },
175179 },
176180 {
177181 desc : "Inactive pod-checkpointer, no local parent, no api parent: should remove all" ,
@@ -187,7 +191,7 @@ func TestProcess(t *testing.T) {
187191 },
188192 "AA" : {},
189193 },
190- expectStop : []string {"AA" , "kube-system/pod-checkpointer" },
194+ expectStart : []string {"kube-system/pod-checkpointer" },
191195 expectGraceRemove : []string {"AA" , "kube-system/pod-checkpointer" },
192196 },
193197 {
@@ -204,7 +208,8 @@ func TestProcess(t *testing.T) {
204208 },
205209 "AA" : {},
206210 },
207- expectStop : []string {"AA" , "kube-system/pod-checkpointer" },
211+ expectStart : []string {"kube-system/pod-checkpointer" },
212+ expectStop : []string {"AA" },
208213 expectGraceRemove : []string {"AA" , "kube-system/pod-checkpointer" },
209214 },
210215 {
@@ -268,8 +273,8 @@ func TestProcess(t *testing.T) {
268273 },
269274 "AA" : {},
270275 },
271- expectStop : []string {"AA" , " kube-system/pod-checkpointer" },
272- expectGraceRemove : []string {"AA" , "kube-system/pod-checkpointer" },
276+ expectStart : []string {"kube-system/pod-checkpointer" , "BB " },
277+ expectGraceRemove : []string {"AA" , "BB" , " kube-system/pod-checkpointer" },
273278 },
274279 {
275280 desc : "Running as an on-disk checkpointer: Inactive pod-checkpointer, no local parent, no api parent: should remove all" ,
@@ -286,7 +291,7 @@ func TestProcess(t *testing.T) {
286291 },
287292 "AA" : {},
288293 },
289- expectStop : []string {"AA" , "kube-system/pod-checkpointer" },
294+ expectStart : []string {"kube-system/pod-checkpointer" },
290295 expectGraceRemove : []string {"AA" , "kube-system/pod-checkpointer" },
291296 },
292297 {
@@ -304,7 +309,8 @@ func TestProcess(t *testing.T) {
304309 },
305310 "AA" : {},
306311 },
307- expectStop : []string {"AA" , "kube-system/pod-checkpointer" },
312+ expectStart : []string {"kube-system/pod-checkpointer" },
313+ expectStop : []string {"AA" },
308314 expectGraceRemove : []string {"AA" , "kube-system/pod-checkpointer" },
309315 },
310316 }
0 commit comments