Skip to content

Commit

Permalink
Fix cell bootstrapping
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <mattalord@gmail.com>
  • Loading branch information
mattlord committed Jan 2, 2025
1 parent f75ed39 commit d817b3c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
12 changes: 3 additions & 9 deletions go/test/endtoend/backup/vtbackup/backup_only_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,8 @@ func verifyBackupCount(t *testing.T, shardKsName string, expected int) []string
}

func listBackups(shardKsName string) ([]string, error) {
backups, err := localCluster.VtctlProcess.ExecuteCommandWithOutput(
"--backup_storage_implementation", "file",
"--file_backup_storage_root",
path.Join(os.Getenv("VTDATAROOT"), "tmp", "backupstorage"),
"ListBackups", shardKsName,
backups, err := localCluster.VtctldClientProcess.ExecuteCommandWithOutput(
"GetBackups", shardKsName,
)
if err != nil {
return nil, err
Expand All @@ -246,10 +243,7 @@ func removeBackups(t *testing.T) {
backups, err := listBackups(shardKsName)
require.NoError(t, err)
for _, backup := range backups {
_, err := localCluster.VtctlProcess.ExecuteCommandWithOutput(
"--backup_storage_implementation", "file",
"--file_backup_storage_root",
path.Join(os.Getenv("VTDATAROOT"), "tmp", "backupstorage"),
_, err := localCluster.VtctldClientProcess.ExecuteCommandWithOutput(
"RemoveBackup", shardKsName, backup,
)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion go/test/endtoend/backup/vtbackup/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestMain(m *testing.M) {
},
}
shard := &localCluster.Keyspaces[0].Shards[0]
vtctldClientProcess := cluster.VtctldClientProcessInstance("localhost", localCluster.VtctldProcess.GrpcPort, localCluster.TmpDirectory)
vtctldClientProcess := cluster.VtctldClientProcessInstance(localCluster.VtctldProcess.GrpcPort, localCluster.TopoPort, "localhost", localCluster.TmpDirectory)
_, err = vtctldClientProcess.ExecuteCommandWithOutput("CreateKeyspace", keyspaceName, "--durability-policy=semi_sync")
if err != nil {
return 1, err
Expand Down
11 changes: 10 additions & 1 deletion go/test/endtoend/cluster/cluster_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,15 @@ func (cluster *LocalProcessCluster) StartTopo() (err error) {
}

cluster.VtctldClientProcess = *cluster.NewVtctldClientProcessInstance("localhost", cluster.VtctldProcess.GrpcPort, cluster.TmpDirectory)
if !cluster.ReusingVTDATAROOT {
if err = cluster.VtctldClientProcess.AddCellInfo(cluster.Cell); err != nil {
log.Error(err)
time.Sleep(5 * time.Minute)
return
}
cluster.VtctldClientProcess.LogDir = cluster.TmpDirectory
}

return
}

Expand Down Expand Up @@ -1294,7 +1303,7 @@ func (cluster *LocalProcessCluster) NewVTOrcProcess(config VTOrcConfiguration) *
// VtctldClientProcessInstance returns a VtctldProcess handle for vtctldclient process
// configured with the given Config.
func (cluster *LocalProcessCluster) NewVtctldClientProcessInstance(hostname string, grpcPort int, tmpDirectory string) *VtctldClientProcess {
version, err := GetMajorVersion("vtctld") // `vtctldclient` does not have a --version flag, so we assume both vtctl/vtctldclient have the same version
version, err := GetMajorVersion("vtctldclient")
if err != nil {
log.Warningf("failed to get major vtctldclient version; interop with CLI changes for VEP-4 may not work: %s", err)
}
Expand Down
13 changes: 10 additions & 3 deletions go/test/endtoend/cluster/vtctldclient_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package cluster
import (
"fmt"
"os/exec"
"slices"
"strings"
"time"

Expand Down Expand Up @@ -80,7 +81,10 @@ func (vtctldclient *VtctldClientProcess) ExecuteCommandWithOutput(args ...string
var err error
retries := 10
retryDelay := 1 * time.Second
pArgs := []string{"--server", vtctldclient.Server}
var pArgs []string
if !slices.Contains(args, "--server") {
args = append(args, "--server", vtctldclient.Server)
}
if *isCoverage {
pArgs = append(pArgs, "--test.coverprofile="+getCoveragePath("vtctldclient-"+args[0]+".out"), "--test.v")
}
Expand Down Expand Up @@ -108,9 +112,12 @@ func (vtctldclient *VtctldClientProcess) ExecuteCommandWithOutput(args ...string
func (vtctldclient *VtctldClientProcess) AddCellInfo(Cell string) error {
args := []string{
"--server", "internal",
"AddCellInfo", "--",
"--topo-implementation", vtctldclient.TopoImplementation,
"--topo-global-server-address", vtctldclient.TopoGlobalAddress,
"--topo-global-root", vtctldclient.TopoGlobalRoot,
"AddCellInfo",
"--root", vtctldclient.TopoRootPath + Cell,
"--server_address", vtctldclient.TopoServerAddress,
"--server-address", vtctldclient.TopoServerAddress,
Cell,
}
_, err := vtctldclient.ExecuteCommandWithOutput(args...)
Expand Down
6 changes: 6 additions & 0 deletions go/test/endtoend/vreplication/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,12 @@ func (vc *VitessCluster) setupVtctld() {
func (vc *VitessCluster) setupVtctldClient() {
vc.VtctldClient = cluster.VtctldClientProcessInstance(vc.Vtctld.GrpcPort, mainClusterConfig.topoPort, vc.ClusterConfig.hostname, vc.ClusterConfig.tmpDir)
require.NotNil(vc.t, vc.VtctldClient)
for _, cellName := range vc.CellNames {
vc.VtctldClient.AddCellInfo(cellName)
cell, err := vc.AddCell(vc.t, cellName)
require.NoError(vc.t, err)
require.NotNil(vc.t, cell)
}
}

// CleanupDataroot deletes the vtdataroot directory. Since we run multiple tests sequentially in a single CI test shard,
Expand Down

0 comments on commit d817b3c

Please sign in to comment.