pleg: add more tests for detecting missing container/pods
This commit is contained in:
parent
719158d2c8
commit
e770f25882
@ -150,7 +150,17 @@ func TestRelisting(t *testing.T) {
|
|||||||
verifyEvents(t, expected, actual)
|
verifyEvents(t, expected, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReportMissingContainers(t *testing.T) {
|
func TestDetectingContainerDeaths(t *testing.T) {
|
||||||
|
// Vary the number of relists after the container started and before the
|
||||||
|
// container died to account for the changes in pleg's internal states.
|
||||||
|
testReportMissingContainers(t, 1)
|
||||||
|
testReportMissingPods(t, 1)
|
||||||
|
|
||||||
|
testReportMissingContainers(t, 3)
|
||||||
|
testReportMissingPods(t, 3)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testReportMissingContainers(t *testing.T, numRelists int) {
|
||||||
testPleg := newTestGenericPLEG()
|
testPleg := newTestGenericPLEG()
|
||||||
pleg, runtime := testPleg.pleg, testPleg.runtime
|
pleg, runtime := testPleg.pleg, testPleg.runtime
|
||||||
ch := pleg.Watch()
|
ch := pleg.Watch()
|
||||||
@ -164,9 +174,11 @@ func TestReportMissingContainers(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
// Drain the events from the channel
|
// Relist and drain the events from the channel.
|
||||||
|
for i := 0; i < numRelists; i++ {
|
||||||
pleg.relist()
|
pleg.relist()
|
||||||
getEventsFromChannel(ch)
|
getEventsFromChannel(ch)
|
||||||
|
}
|
||||||
|
|
||||||
// Container c2 was stopped and removed between relists. We should report
|
// Container c2 was stopped and removed between relists. We should report
|
||||||
// the event. The exited container c3 was garbage collected (i.e., removed)
|
// the event. The exited container c3 was garbage collected (i.e., removed)
|
||||||
@ -187,7 +199,7 @@ func TestReportMissingContainers(t *testing.T) {
|
|||||||
verifyEvents(t, expected, actual)
|
verifyEvents(t, expected, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReportMissingPods(t *testing.T) {
|
func testReportMissingPods(t *testing.T, numRelists int) {
|
||||||
testPleg := newTestGenericPLEG()
|
testPleg := newTestGenericPLEG()
|
||||||
pleg, runtime := testPleg.pleg, testPleg.runtime
|
pleg, runtime := testPleg.pleg, testPleg.runtime
|
||||||
ch := pleg.Watch()
|
ch := pleg.Watch()
|
||||||
@ -199,9 +211,11 @@ func TestReportMissingPods(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
// Drain the events from the channel
|
// Relist and drain the events from the channel.
|
||||||
|
for i := 0; i < numRelists; i++ {
|
||||||
pleg.relist()
|
pleg.relist()
|
||||||
getEventsFromChannel(ch)
|
getEventsFromChannel(ch)
|
||||||
|
}
|
||||||
|
|
||||||
// Container c2 was stopped and removed between relists. We should report
|
// Container c2 was stopped and removed between relists. We should report
|
||||||
// the event.
|
// the event.
|
||||||
|
Loading…
Reference in New Issue
Block a user