From cdefdd8db9a264bacbe05f3bf0290247fe40ec06 Mon Sep 17 00:00:00 2001 From: Florent Poinsard <35779988+frouioui@users.noreply.github.com> Date: Thu, 28 Sep 2023 17:48:12 -0500 Subject: [PATCH] [release-15.0] Flakes: Delete VTDATAROOT files in reparent test teardown within CI (#13793) (#14118) Co-authored-by: Matt Lord --- go/test/endtoend/reparent/utils/utils.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/go/test/endtoend/reparent/utils/utils.go b/go/test/endtoend/reparent/utils/utils.go index 3ea2dc04e38..ca1cec15bd1 100644 --- a/go/test/endtoend/reparent/utils/utils.go +++ b/go/test/endtoend/reparent/utils/utils.go @@ -75,9 +75,25 @@ func SetupRangeBasedCluster(ctx context.Context, t *testing.T) *cluster.LocalPro return setupCluster(ctx, t, ShardName, []string{cell1}, []int{2}, "semi_sync") } -// TeardownCluster is used to teardown the reparent cluster +// TeardownCluster is used to teardown the reparent cluster. When +// run in a CI environment -- which is considered true when the +// "CI" env variable is set to "true" -- the teardown also removes +// the VTDATAROOT directory that was used for the test/cluster. func TeardownCluster(clusterInstance *cluster.LocalProcessCluster) { + usedRoot := clusterInstance.CurrentVTDATAROOT clusterInstance.Teardown() + // This is always set to "true" on GitHub Actions runners: + // https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables + ci, ok := os.LookupEnv("CI") + if !ok || strings.ToLower(ci) != "true" { + // Leave the directory in place to support local debugging. + return + } + // We're running in the CI, so free up disk space for any + // subsequent tests. + if err := os.RemoveAll(usedRoot); err != nil { + log.Errorf("Failed to remove previously used VTDATAROOT (%s): %v", usedRoot, err) + } } func setupCluster(ctx context.Context, t *testing.T, shardName string, cells []string, numTablets []int, durability string) *cluster.LocalProcessCluster {