test(kuberuntime): deflake TestRemoveContainer

Signed-off-by: knight42 <anonymousknight96@gmail.com>
This commit is contained in:
knight42 2020-08-24 02:32:27 +08:00
parent 14a11060a0
commit cfeddcf654
No known key found for this signature in database
GPG Key ID: 1040B69865E7D86C

View File

@ -79,9 +79,12 @@ func TestRemoveContainer(t *testing.T) {
err = m.removeContainer(containerID)
assert.NoError(t, err)
// Verify container log is removed
assert.Equal(t, []string{expectedContainerLogPath, expectedContainerLogPathRotated, expectedContainerLogSymlink}, fakeOS.Removes)
// Verify container log is removed.
// We could not predict the order of `fakeOS.Removes`, so we use `assert.ElementsMatch` here.
assert.ElementsMatch(t,
[]string{expectedContainerLogSymlink, expectedContainerLogPath, expectedContainerLogPathRotated},
fakeOS.Removes)
// Verify container is removed
assert.Contains(t, fakeRuntime.Called, "RemoveContainer")
containers, err := fakeRuntime.ListContainers(&runtimeapi.ContainerFilter{Id: containerID})