kubelet: Make the test fail if (*FakeRuntime).Assert fails

This commit is contained in:
Geonju Kim
2021-02-11 16:37:07 +09:00
parent c198632a12
commit fc4a29da2c
3 changed files with 26 additions and 22 deletions

View File

@@ -144,16 +144,18 @@ func newTestKubeletWithImageList(
imageList []kubecontainer.Image,
controllerAttachDetachEnabled bool,
initFakeVolumePlugin bool) *TestKubelet {
fakeRuntime := &containertest.FakeRuntime{}
fakeRuntime.RuntimeType = "test"
fakeRuntime.VersionInfo = "1.5.0"
fakeRuntime.ImageList = imageList
// Set ready conditions by default.
fakeRuntime.RuntimeStatus = &kubecontainer.RuntimeStatus{
Conditions: []kubecontainer.RuntimeCondition{
{Type: "RuntimeReady", Status: true},
{Type: "NetworkReady", Status: true},
fakeRuntime := &containertest.FakeRuntime{
ImageList: imageList,
// Set ready conditions by default.
RuntimeStatus: &kubecontainer.RuntimeStatus{
Conditions: []kubecontainer.RuntimeCondition{
{Type: "RuntimeReady", Status: true},
{Type: "NetworkReady", Status: true},
},
},
VersionInfo: "1.5.0",
RuntimeType: "test",
T: t,
}
fakeRecorder := &record.FakeRecorder{}
@@ -658,7 +660,7 @@ func TestKillPodFollwedByIsPodPendingTermination(t *testing.T) {
RunningPod: pod,
})
if !(kl.podKiller.IsPodPendingTerminationByUID(pod.ID) || fakeRuntime.AssertKilledPods([]string{"12345678"}) == nil) {
if !(kl.podKiller.IsPodPendingTerminationByUID(pod.ID) || fakeRuntime.AssertKilledPods([]string{"12345678"})) {
t.Fatal("Race condition: When KillPod is complete, the pod should be pending termination or be killed")
}
}