Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flakes: empty vtdataroot before starting a new vreplication e2e test #13803

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions go/test/endtoend/vreplication/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ func init() {
func NewVitessCluster(t *testing.T, name string, cellNames []string, clusterConfig *ClusterConfig) *VitessCluster {
vc := &VitessCluster{Name: name, Cells: make(map[string]*Cell), ClusterConfig: clusterConfig}
require.NotNil(t, vc)

vc.CleanupDataroot(t)
mattlord marked this conversation as resolved.
Show resolved Hide resolved

topo := cluster.TopoProcessInstance(vc.ClusterConfig.topoPort, vc.ClusterConfig.topoPort+1, vc.ClusterConfig.hostname, "etcd2", "global")

require.NotNil(t, topo)
Expand Down Expand Up @@ -358,6 +361,24 @@ func NewVitessCluster(t *testing.T, name string, cellNames []string, clusterConf
return vc
}

// CleanupDataroot deletes the vtdataroot directory. Since we run multiple tests sequentially in a single CI test shard,
// we can run out of disk space due to all the leftover artifacts from previous tests.
func (vc *VitessCluster) CleanupDataroot(t *testing.T) {
// 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
}
dir := vc.ClusterConfig.vtdataroot
log.Infof("Deleting vtdataroot %s", dir)
err := os.RemoveAll(dir)
require.NoError(t, err)
err = os.Mkdir(dir, 0755)
mattlord marked this conversation as resolved.
Show resolved Hide resolved
require.NoError(t, err)
}

// AddKeyspace creates a keyspace with specified shard keys and number of replica/read-only tablets.
// You can pass optional key value pairs (opts) if you want conditional behavior.
func (vc *VitessCluster) AddKeyspace(t *testing.T, cells []*Cell, ksName string, shards string, vschema string, schema string, numReplicas int, numRdonly int, tabletIDBase int, opts map[string]string) (*Keyspace, error) {
Expand Down