Skip to content

Commit 850f4bb

Browse files
committed
modify random failure
1 parent 123d1a9 commit 850f4bb

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

pkg/kubelet/pleg/generic_test.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,23 +211,17 @@ func TestEventChannelFull(t *testing.T) {
211211
}},
212212
}
213213
pleg.relist()
214-
// event channel is full, discard events
215-
expected = []*PodLifecycleEvent{
214+
allEvents := []*PodLifecycleEvent{
216215
{ID: "1234", Type: ContainerRemoved, Data: "c1"},
217216
{ID: "1234", Type: ContainerDied, Data: "c2"},
218217
{ID: "1234", Type: ContainerStarted, Data: "c3"},
219218
{ID: "4567", Type: ContainerRemoved, Data: "c1"},
220219
{ID: "4567", Type: ContainerStarted, Data: "c4"},
221220
}
221+
// event channel is full, discard events
222222
actual = getEventsFromChannel(ch)
223223
assert.True(t, len(actual) == 4, "channel length should be 4")
224-
for _, actualEvent := range actual {
225-
for _, expectedEvent := range expected {
226-
if actualEvent.ID == expectedEvent.ID && actualEvent.Data == expectedEvent.Data {
227-
assert.True(t, actualEvent.Type == expectedEvent.Type, "event type should be equal")
228-
}
229-
}
230-
}
224+
assert.Subsetf(t, allEvents, actual, "actual events should in all events")
231225
}
232226

233227
func TestDetectingContainerDeaths(t *testing.T) {

0 commit comments

Comments
 (0)