@@ -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.
7982func 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
8399func setupCluster (ctx context.Context , t * testing.T , shardName string , cells []string , numTablets []int , durability string ) * cluster.LocalProcessCluster {
0 commit comments