Skip to content

Commit

Permalink
Fix vtctldclient creation
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord committed Jan 2, 2025
1 parent efdefd7 commit 4ec0dc1
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go/test/endtoend/backup/vtctlbackup/backup_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func LaunchCluster(setupType int, streamMode string, stripes int, cDetails *Comp
if err := localCluster.InitTablet(replica2, keyspaceName, shard.Name); err != nil {
return 1, err
}
vtctldClientProcess := cluster.VtctldClientProcessInstance("localhost", localCluster.VtctldProcess.GrpcPort, localCluster.TmpDirectory)
vtctldClientProcess := cluster.VtctldClientProcessInstance(localCluster.VtctldProcess.GrpcPort, localCluster.TopoPort, "localhost", localCluster.TmpDirectory)
_, err = vtctldClientProcess.ExecuteCommandWithOutput("SetKeyspaceDurabilityPolicy", keyspaceName, "--durability-policy=semi_sync")
if err != nil {
return 1, err
Expand Down
4 changes: 2 additions & 2 deletions go/test/endtoend/docker/vttestserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ func TestVtctldCommands(t *testing.T) {
err = vtest.waitUntilDockerHealthy(10)
require.NoError(t, err)

vtctldClient := cluster.VtctldClientProcessInstance("localhost", vtest.basePort+1, os.TempDir())
res, err := vtctldClient.ExecuteCommandWithOutput("GetKeyspaces")
vtctldClient := cluster.VtctldClientProcessInstance(vtest.basePort+1, 0, "localhost", os.TempDir())
res, err := vtctldClient.ExecuteCommandWithOutput("--server", "internal", "GetKeyspaces")
require.NoError(t, err)
// We verify that the command succeeds, and the keyspace name is present in the output.
require.Contains(t, res, "long_ks_name")
Expand Down
2 changes: 1 addition & 1 deletion go/test/endtoend/recovery/unshardedrecovery/recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func TestMainImpl(m *testing.M) {
}
}

vtctldClientProcess := cluster.VtctldClientProcessInstance("localhost", localCluster.VtctldProcess.GrpcPort, localCluster.TmpDirectory)
vtctldClientProcess := cluster.VtctldClientProcessInstance(localCluster.VtctldProcess.GrpcPort, localCluster.TopoPort, "localhost", localCluster.TmpDirectory)
_, err = vtctldClientProcess.ExecuteCommandWithOutput("SetKeyspaceDurabilityPolicy", keyspaceName, "--durability-policy=semi_sync")
if err != nil {
return 1, err
Expand Down
6 changes: 3 additions & 3 deletions go/test/endtoend/reparent/emergencyreparent/ers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func TestTrivialERS(t *testing.T) {
}
// We should do the same for vtctl binary
for i := 1; i <= 4; i++ {
out, err := utils.ErsWithVtctl(clusterInstance)
log.Infof("ERS-vtctl loop %d. EmergencyReparentShard Output: %v", i, out)
out, err := utils.ErsWithVtctldClient(clusterInstance)
log.Infof("ERS-vtctldclient loop %d. EmergencyReparentShard Output: %v", i, out)
require.NoError(t, err)
time.Sleep(5 * time.Second)
}
Expand Down Expand Up @@ -395,7 +395,7 @@ func TestERSForInitialization(t *testing.T) {
err = clusterInstance.SetupCluster(keyspace, []cluster.Shard{*shard})
require.NoError(t, err)
if clusterInstance.VtctlMajorVersion >= 14 {
vtctldClientProcess := cluster.VtctldClientProcessInstance("localhost", clusterInstance.VtctldProcess.GrpcPort, clusterInstance.TmpDirectory)
vtctldClientProcess := cluster.VtctldClientProcessInstance(clusterInstance.VtctldProcess.GrpcPort, clusterInstance.TopoPort, "localhost", clusterInstance.TmpDirectory)
out, err := vtctldClientProcess.ExecuteCommandWithOutput("SetKeyspaceDurabilityPolicy", keyspace.Name, "--durability-policy=semi_sync")
require.NoError(t, err, out)
}
Expand Down
6 changes: 6 additions & 0 deletions go/test/endtoend/reparent/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,12 @@ func ErsIgnoreTablet(clusterInstance *cluster.LocalProcessCluster, tab *cluster.
return clusterInstance.VtctldClientProcess.ExecuteCommandWithOutput(args...)
}

// ErsWithVtctldClient runs ERS via vtctldclient binary
func ErsWithVtctldClient(clusterInstance *cluster.LocalProcessCluster) (string, error) {
args := []string{"EmergencyReparentShard", "--keyspace-shard", fmt.Sprintf("%s/%s", KeyspaceName, ShardName)}
return clusterInstance.VtctldClientProcess.ExecuteCommandWithOutput(args...)
}

// endregion

// region validations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func TestMain(m *testing.M) {
Host: clusterInstance.Hostname,
Port: clusterInstance.VtgateMySQLPort,
}
clusterInstance.VtctldClientProcess = *cluster.VtctldClientProcessInstance("localhost", clusterInstance.VtctldProcess.GrpcPort, clusterInstance.TmpDirectory)
clusterInstance.VtctldClientProcess = *cluster.VtctldClientProcessInstance(clusterInstance.VtctldProcess.GrpcPort, clusterInstance.TopoPort, "localhost", clusterInstance.TmpDirectory)

return m.Run()
}()
Expand Down
2 changes: 1 addition & 1 deletion go/test/endtoend/vault/vault_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func initializeClusterLate(t *testing.T) {

err := clusterInstance.SetupCluster(keyspace, []cluster.Shard{*shard})
require.NoError(t, err)
vtctldClientProcess := cluster.VtctldClientProcessInstance("localhost", clusterInstance.VtctldProcess.GrpcPort, clusterInstance.TmpDirectory)
vtctldClientProcess := cluster.VtctldClientProcessInstance(clusterInstance.VtctldProcess.GrpcPort, clusterInstance.TopoPort, "localhost", clusterInstance.TmpDirectory)
out, err := vtctldClientProcess.ExecuteCommandWithOutput("SetKeyspaceDurabilityPolicy", keyspaceName, "--durability-policy=semi_sync")
require.NoError(t, err, out)

Expand Down

0 comments on commit 4ec0dc1

Please sign in to comment.