From d5a18173b98cabdaae082f42a4dc3f84b3821821 Mon Sep 17 00:00:00 2001 From: Amulyam24 Date: Thu, 28 Oct 2021 11:44:09 +0530 Subject: [PATCH] virtcontainers: fix failing template test on ppc64le If a file/directory doesn't exist, os.Stat() returns an error. Assert the returned value with os.IsNotExist() to prevent it from failing. Fixes: #2920 Signed-off-by: Amulyam24 --- .../factory/template/template_test.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/runtime/virtcontainers/factory/template/template_test.go b/src/runtime/virtcontainers/factory/template/template_test.go index cc289e79cc..9c8d5805a5 100644 --- a/src/runtime/virtcontainers/factory/template/template_test.go +++ b/src/runtime/virtcontainers/factory/template/template_test.go @@ -129,7 +129,16 @@ func TestTemplateFactory(t *testing.T) { // CloseFactory, there is no need to call tt.CloseFactory(ctx) f.CloseFactory(ctx) - // expect tt.statePath not exist, if exist, it means this case failed. - _, err = os.Stat(tt.statePath) - assert.Nil(err) + //umount may take more time. Check periodically if the mount exists + waitTime, delay := 20, 1*time.Second + for check := waitTime; check > 0; { + // expect tt.statePath not exist, if exist, it means this case failed. + _, err = os.Stat(tt.statePath) + if err != nil { + break + } + check -= 1 + time.Sleep(delay) + } + assert.True(os.IsNotExist(err), fmt.Sprintf("mount still present after waiting %d seconds", waitTime)) }