From 43fc4901eaf853ea637a9f98c40c542a6b364e47 Mon Sep 17 00:00:00 2001 From: Matej Vasek Date: Mon, 9 Oct 2023 15:18:20 +0200 Subject: [PATCH 1/3] test: sleep after cleanup Signed-off-by: Matej Vasek --- test/oncluster/scenario_runtime_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/oncluster/scenario_runtime_test.go b/test/oncluster/scenario_runtime_test.go index da270add48..0a9fce955e 100644 --- a/test/oncluster/scenario_runtime_test.go +++ b/test/oncluster/scenario_runtime_test.go @@ -8,6 +8,7 @@ import ( "path/filepath" "strings" "testing" + "time" "k8s.io/apimachinery/pkg/util/rand" common "knative.dev/func/test/common" @@ -79,7 +80,10 @@ func runtimeImpl(t *testing.T, lang string, builder string) { "--builder", builder, "--git-url", remoteRepo.ClusterCloneURL) - defer knFunc.Exec("delete", "-p", funcPath) + t.Cleanup(func() { + knFunc.Exec("delete", "-p", funcPath) + time.Sleep(time.Second * 10) + }) // -- Assertions -- result := knFunc.Exec("invoke", "-p", funcPath) From 03f9a852df43e08b92f0181879adb9e44d5eeb75 Mon Sep 17 00:00:00 2001 From: Matej Vasek Date: Mon, 9 Oct 2023 15:53:34 +0200 Subject: [PATCH 2/3] fixup: increase timeout Signed-off-by: Matej Vasek --- test/oncluster/scenario_runtime_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/oncluster/scenario_runtime_test.go b/test/oncluster/scenario_runtime_test.go index 0a9fce955e..a2d1456fee 100644 --- a/test/oncluster/scenario_runtime_test.go +++ b/test/oncluster/scenario_runtime_test.go @@ -82,7 +82,7 @@ func runtimeImpl(t *testing.T, lang string, builder string) { t.Cleanup(func() { knFunc.Exec("delete", "-p", funcPath) - time.Sleep(time.Second * 10) + time.Sleep(time.Second * 30) }) // -- Assertions -- From 6d7f95d68a9faf64a086e73115cad28d2c32aeb2 Mon Sep 17 00:00:00 2001 From: Matej Vasek Date: Mon, 9 Oct 2023 16:58:18 +0200 Subject: [PATCH 3/3] fixup: replace defers with t.Cleanup() Signed-off-by: Matej Vasek --- test/oncluster/scenario_runtime_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/oncluster/scenario_runtime_test.go b/test/oncluster/scenario_runtime_test.go index a2d1456fee..047358d0d4 100644 --- a/test/oncluster/scenario_runtime_test.go +++ b/test/oncluster/scenario_runtime_test.go @@ -64,11 +64,15 @@ func runtimeImpl(t *testing.T, lang string, builder string) { gitServer := common.GitTestServerProvider{} gitServer.Init(t) remoteRepo := gitServer.CreateRepository(gitProjectName) - defer gitServer.DeleteRepository(gitProjectName) + t.Cleanup(func() { + gitServer.DeleteRepository(gitProjectName) + }) knFunc := common.NewKnFuncShellCli(t) knFunc.Exec("create", "-l", lang, funcPath) - defer os.RemoveAll(gitProjectPath) + t.Cleanup(func() { + os.RemoveAll(gitProjectPath) + }) GitInitialCommitAndPush(t, gitProjectPath, remoteRepo.ExternalCloneURL)