Skip to content

Commit a41ed48

Browse files
authored
Flakes: Delete VTDATAROOT files in reparent test teardown within CI (#13793)
Signed-off-by: Matt Lord <mattalord@gmail.com>
1 parent 24ea6f2 commit a41ed48

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

go/test/endtoend/reparent/utils/utils.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,25 @@ func SetupRangeBasedCluster(ctx context.Context, t *testing.T) *cluster.LocalPro
7575
return setupCluster(ctx, t, ShardName, []string{cell1}, []int{2}, "semi_sync")
7676
}
7777

78-
// TeardownCluster is used to teardown the reparent cluster
78+
// TeardownCluster is used to teardown the reparent cluster. When
79+
// run in a CI environment -- which is considered true when the
80+
// "CI" env variable is set to "true" -- the teardown also removes
81+
// the VTDATAROOT directory that was used for the test/cluster.
7982
func TeardownCluster(clusterInstance *cluster.LocalProcessCluster) {
83+
usedRoot := clusterInstance.CurrentVTDATAROOT
8084
clusterInstance.Teardown()
85+
// This is always set to "true" on GitHub Actions runners:
86+
// https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
87+
ci, ok := os.LookupEnv("CI")
88+
if !ok || strings.ToLower(ci) != "true" {
89+
// Leave the directory in place to support local debugging.
90+
return
91+
}
92+
// We're running in the CI, so free up disk space for any
93+
// subsequent tests.
94+
if err := os.RemoveAll(usedRoot); err != nil {
95+
log.Errorf("Failed to remove previously used VTDATAROOT (%s): %v", usedRoot, err)
96+
}
8197
}
8298

8399
func setupCluster(ctx context.Context, t *testing.T, shardName string, cells []string, numTablets []int, durability string) *cluster.LocalProcessCluster {

0 commit comments

Comments
 (0)