Skip to content

Commit

Permalink
add explicit serving status to vttablet process
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
  • Loading branch information
frouioui committed Sep 18, 2023
1 parent 54e41ae commit 5a8b78c
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 15 deletions.
13 changes: 11 additions & 2 deletions go/test/endtoend/cluster/cluster_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -1262,8 +1262,16 @@ func (cluster *LocalProcessCluster) VtprocessInstanceFromVttablet(tablet *Vttabl
}

// StartVttablet starts a new tablet
func (cluster *LocalProcessCluster) StartVttablet(tablet *Vttablet, servingStatus string,
supportBackup bool, cell string, keyspaceName string, hostname string, shardName string) error {
func (cluster *LocalProcessCluster) StartVttablet(
tablet *Vttablet,
explicitServingStatus bool,
servingStatus string,
supportBackup bool,
cell string,
keyspaceName string,
hostname string,
shardName string,
) error {
tablet.VttabletProcess = VttabletProcessInstance(
tablet.HTTPPort,
tablet.GrpcPort,
Expand All @@ -1281,6 +1289,7 @@ func (cluster *LocalProcessCluster) StartVttablet(tablet *Vttablet, servingStatu

tablet.VttabletProcess.SupportsBackup = supportBackup
tablet.VttabletProcess.ServingStatus = servingStatus
tablet.VttabletProcess.ExplicitServingStatus = explicitServingStatus
return tablet.VttabletProcess.Setup()
}

Expand Down
12 changes: 10 additions & 2 deletions go/test/endtoend/cluster/vttablet_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type VttabletProcess struct {
QueryzURL string
StatusDetailsURL string
SupportsBackup bool
ExplicitServingStatus bool
ServingStatus string
DbPassword string
DbPort int
Expand Down Expand Up @@ -150,8 +151,15 @@ func (vttablet *VttabletProcess) Setup() (err error) {
}()

if vttablet.ServingStatus != "" {
// We wait for any valid status to indicate that the tablet server is running.
if err = vttablet.WaitForTabletStatuses([]string{"SERVING", "NOT_SERVING"}); err != nil {
// If the tablet has an explicit serving status we use the serving status
// otherwise we wait for any serving status to show up in the healthcheck.
var servingStatus []string
if vttablet.ExplicitServingStatus {
servingStatus = append(servingStatus, vttablet.ServingStatus)
} else {
servingStatus = append(servingStatus, "SERVING", "NOT_SERVING")
}
if err = vttablet.WaitForTabletStatuses(servingStatus); err != nil {
errFileContent, _ := os.ReadFile(fname)
if errFileContent != nil {
log.Infof("vttablet error:\n%s\n", string(errFileContent))
Expand Down
2 changes: 1 addition & 1 deletion go/test/endtoend/tabletmanager/custom_rule_topo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestTopoCustomRule(t *testing.T) {
require.Nil(t, err, "error should be Nil")

// Start Vttablet
err = clusterInstance.StartVttablet(rTablet, "SERVING", false, cell, keyspaceName, hostname, shardName)
err = clusterInstance.StartVttablet(rTablet, false, "SERVING", false, cell, keyspaceName, hostname, shardName)
require.Nil(t, err, "error should be Nil")

err = clusterInstance.VtctlclientProcess.ExecuteCommand("Validate")
Expand Down
2 changes: 1 addition & 1 deletion go/test/endtoend/tabletmanager/primary/tablet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func TestPrimaryRestartSetsPTSTimestamp(t *testing.T) {
require.NoError(t, err)

// Start Vttablet
err = clusterInstance.StartVttablet(&replicaTablet, "SERVING", false, cell, keyspaceName, hostname, shardName)
err = clusterInstance.StartVttablet(&replicaTablet, false, "SERVING", false, cell, keyspaceName, hostname, shardName)
require.NoError(t, err)

// Make sure that the PTS did not change
Expand Down
8 changes: 4 additions & 4 deletions go/test/endtoend/tabletmanager/tablet_health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestTabletReshuffle(t *testing.T) {

// SupportsBackup=False prevents vttablet from trying to restore
// Start vttablet process
err = clusterInstance.StartVttablet(rTablet, "SERVING", false, cell, keyspaceName, hostname, shardName)
err = clusterInstance.StartVttablet(rTablet, false, "SERVING", false, cell, keyspaceName, hostname, shardName)
require.NoError(t, err)

sql := "select value from t1"
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestHealthCheck(t *testing.T) {
defer replicaConn.Close()

// start vttablet process, should be in SERVING state as we already have a primary
err = clusterInstance.StartVttablet(rTablet, "SERVING", false, cell, keyspaceName, hostname, shardName)
err = clusterInstance.StartVttablet(rTablet, true, "SERVING", false, cell, keyspaceName, hostname, shardName)
require.NoError(t, err)

conn, err := mysql.Connect(ctx, &primaryTabletParams)
Expand Down Expand Up @@ -227,7 +227,7 @@ func TestHealthCheckSchemaChangeSignal(t *testing.T) {
clusterInstance.VtTabletExtraArgs = oldArgs
}()
// start vttablet process, should be in SERVING state as we already have a primary.
err = clusterInstance.StartVttablet(tempTablet, "SERVING", false, cell, keyspaceName, hostname, shardName)
err = clusterInstance.StartVttablet(tempTablet, false, "SERVING", false, cell, keyspaceName, hostname, shardName)
require.NoError(t, err)

defer func() {
Expand Down Expand Up @@ -381,7 +381,7 @@ func TestHealthCheckDrainedStateDoesNotShutdownQueryService(t *testing.T) {
// - the second tablet will be set to 'drained' and we expect that
// - the query service won't be shutdown

//Wait if tablet is not in service state
// Wait if tablet is not in service state
defer cluster.PanicHandler(t)
clusterInstance.DisableVTOrcRecoveries(t)
defer clusterInstance.EnableVTOrcRecoveries(t)
Expand Down
6 changes: 3 additions & 3 deletions go/test/endtoend/tabletmanager/tablet_security_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestFallbackSecurityPolicy(t *testing.T) {

// Requesting an unregistered security_policy should fallback to deny-all.
clusterInstance.VtTabletExtraArgs = []string{"--security_policy", "bogus"}
err = clusterInstance.StartVttablet(mTablet, "SERVING", false, cell, keyspaceName, hostname, shardName)
err = clusterInstance.StartVttablet(mTablet, false, "SERVING", false, cell, keyspaceName, hostname, shardName)
require.NoError(t, err)

// It should deny ADMIN role.
Expand Down Expand Up @@ -94,7 +94,7 @@ func TestDenyAllSecurityPolicy(t *testing.T) {

// Requesting a deny-all security_policy.
clusterInstance.VtTabletExtraArgs = []string{"--security_policy", "deny-all"}
err = clusterInstance.StartVttablet(mTablet, "SERVING", false, cell, keyspaceName, hostname, shardName)
err = clusterInstance.StartVttablet(mTablet, false, "SERVING", false, cell, keyspaceName, hostname, shardName)
require.NoError(t, err)

// It should deny ADMIN role.
Expand Down Expand Up @@ -126,7 +126,7 @@ func TestReadOnlySecurityPolicy(t *testing.T) {

// Requesting a read-only security_policy.
clusterInstance.VtTabletExtraArgs = []string{"--security_policy", "read-only"}
err = clusterInstance.StartVttablet(mTablet, "SERVING", false, cell, keyspaceName, hostname, shardName)
err = clusterInstance.StartVttablet(mTablet, false, "SERVING", false, cell, keyspaceName, hostname, shardName)
require.NoError(t, err)

// It should deny ADMIN role.
Expand Down
4 changes: 2 additions & 2 deletions go/test/endtoend/tabletmanager/tablet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestEnsureDB(t *testing.T) {

log.Info(fmt.Sprintf("Started vttablet %v", tablet))
// Start vttablet process as replica. It won't be able to serve because there's no db.
err = clusterInstance.StartVttablet(tablet, "NOT_SERVING", false, cell, "dbtest", hostname, "0")
err = clusterInstance.StartVttablet(tablet, false, "NOT_SERVING", false, cell, "dbtest", hostname, "0")
require.NoError(t, err)

// Make it the primary.
Expand Down Expand Up @@ -78,7 +78,7 @@ func TestResetReplicationParameters(t *testing.T) {

log.Info(fmt.Sprintf("Started vttablet %v", tablet))
// Start vttablet process as replica. It won't be able to serve because there's no db.
err = clusterInstance.StartVttablet(tablet, "NOT_SERVING", false, cell, "dbtest", hostname, "0")
err = clusterInstance.StartVttablet(tablet, false, "NOT_SERVING", false, cell, "dbtest", hostname, "0")
require.NoError(t, err)

// Set a replication source on the tablet and start replication
Expand Down

0 comments on commit 5a8b78c

Please sign in to comment.