From 53bdea6acd3f686ff498af5fab24acb9beabe1c3 Mon Sep 17 00:00:00 2001 From: David Cheung Date: Wed, 15 Nov 2023 08:38:08 +0000 Subject: [PATCH] Run cleanup-all after all tests when running in prow. * We want to make sure the resources always get properly cleanup. For a given test, cleanup.sh is not run if there is failure in preceding script(setup.sh or cleanup.sh). --- test/main_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/main_test.go b/test/main_test.go index ba8b37e9..cf20ed53 100644 --- a/test/main_test.go +++ b/test/main_test.go @@ -49,6 +49,11 @@ func TestMain(m *testing.M) { } project := ph.AcquireOrDie(flags.boskosResourceType) defer func() { + out, err := exec.Command("bash", "test/cleanup-all.sh").CombinedOutput() + if err != nil { + // Fail now because we shouldn't continue testing if any step fails. + klog.Errorf("failed to run ./test/cleanup-all.sh: %q, err: %v", out, err) + } ph.Release() }() @@ -79,7 +84,3 @@ func TestMain(m *testing.M) { m.Run() } - -func TestHelloWorld(t *testing.T) { - klog.Info("Hello world") -}