From 7a525542dbf69191a8af7b236ceb4c3acbc81261 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Wed, 13 Sep 2023 15:50:54 -0400 Subject: [PATCH 1/5] Fix TestLeftJoinUsingUnsharded Signed-off-by: Florent Poinsard --- go/test/endtoend/cluster/cluster_process.go | 3 +-- go/test/endtoend/cluster/vttablet_process.go | 9 +++++---- go/test/endtoend/vtgate/queries/misc/misc_test.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/go/test/endtoend/cluster/cluster_process.go b/go/test/endtoend/cluster/cluster_process.go index e111e4325f3..6f1b00c53ff 100644 --- a/go/test/endtoend/cluster/cluster_process.go +++ b/go/test/endtoend/cluster/cluster_process.go @@ -334,13 +334,12 @@ func (cluster *LocalProcessCluster) startKeyspace(keyspace Keyspace, shardNames } // Create the keyspace if it doesn't already exist. _ = cluster.VtctlProcess.CreateKeyspace(keyspace.Name, keyspace.SidecarDBName) - var mysqlctlProcessList []*exec.Cmd for _, shardName := range shardNames { shard := &Shard{ Name: shardName, } log.Infof("Starting shard: %v", shardName) - mysqlctlProcessList = []*exec.Cmd{} + var mysqlctlProcessList []*exec.Cmd for i := 0; i < totalTabletsRequired; i++ { // instantiate vttablet object with reserved ports tabletUID := cluster.GetAndReserveTabletUID() diff --git a/go/test/endtoend/cluster/vttablet_process.go b/go/test/endtoend/cluster/vttablet_process.go index 9f5e513c7a0..96b972aef2d 100644 --- a/go/test/endtoend/cluster/vttablet_process.go +++ b/go/test/endtoend/cluster/vttablet_process.go @@ -79,7 +79,7 @@ type VttabletProcess struct { Charset string ConsolidationsURL string - //Extra Args to be set before starting the vttablet process + // Extra Args to be set before starting the vttablet process ExtraArgs []string proc *exec.Cmd @@ -149,8 +149,9 @@ func (vttablet *VttabletProcess) Setup() (err error) { } }() + time.Sleep(10 * time.Second) if vttablet.ServingStatus != "" { - if err = vttablet.WaitForTabletStatus(vttablet.ServingStatus); err != nil { + if err = vttablet.WaitForTabletStatus(vttablet.ServingStatus, "SERVING"); err != nil { errFileContent, _ := os.ReadFile(fname) if errFileContent != nil { log.Infof("vttablet error:\n%s\n", string(errFileContent)) @@ -273,8 +274,8 @@ func (vttablet *VttabletProcess) GetTabletType() string { } // WaitForTabletStatus waits for one of the expected statuses to be reached -func (vttablet *VttabletProcess) WaitForTabletStatus(expectedStatus string) error { - return vttablet.WaitForTabletStatusesForTimeout([]string{expectedStatus}, vttabletStateTimeout) +func (vttablet *VttabletProcess) WaitForTabletStatus(expectedStatus ...string) error { + return vttablet.WaitForTabletStatusesForTimeout(expectedStatus, vttabletStateTimeout) } // WaitForTabletStatuses waits for one of expected statuses is reached diff --git a/go/test/endtoend/vtgate/queries/misc/misc_test.go b/go/test/endtoend/vtgate/queries/misc/misc_test.go index 77cb1784c43..559fcaa9b6e 100644 --- a/go/test/endtoend/vtgate/queries/misc/misc_test.go +++ b/go/test/endtoend/vtgate/queries/misc/misc_test.go @@ -301,6 +301,6 @@ func TestLeftJoinUsingUnsharded(t *testing.T) { mcmp, closer := start(t) defer closer() - utils.Exec(t, mcmp.VtConn, "insert into uks.unsharded(id1) values (1),(2),(3),(4),(5)") - utils.Exec(t, mcmp.VtConn, "select * from uks.unsharded as A left join uks.unsharded as B using(id1)") + utils.Exec(t, mcmp.VtConn, "insert /*vt+ QUERY_TIMEOUT_MS=1000 */ into uks.unsharded(id1) values (1),(2),(3),(4),(5)") + utils.Exec(t, mcmp.VtConn, "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from uks.unsharded as A left join uks.unsharded as B using(id1)") } From 50b2a37d47ced9e9e97817b318e4325f2ebb44c2 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Wed, 13 Sep 2023 16:04:40 -0400 Subject: [PATCH 2/5] increase vttabletStateTimeout Signed-off-by: Florent Poinsard --- go/test/endtoend/cluster/vttablet_process.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/go/test/endtoend/cluster/vttablet_process.go b/go/test/endtoend/cluster/vttablet_process.go index 96b972aef2d..44f46925ad6 100644 --- a/go/test/endtoend/cluster/vttablet_process.go +++ b/go/test/endtoend/cluster/vttablet_process.go @@ -42,7 +42,7 @@ import ( "vitess.io/vitess/go/vt/sqlparser" ) -const vttabletStateTimeout = 30 * time.Second +const vttabletStateTimeout = 60 * time.Second // VttabletProcess is a generic handle for a running vttablet . // It can be spawned manually @@ -149,7 +149,6 @@ func (vttablet *VttabletProcess) Setup() (err error) { } }() - time.Sleep(10 * time.Second) if vttablet.ServingStatus != "" { if err = vttablet.WaitForTabletStatus(vttablet.ServingStatus, "SERVING"); err != nil { errFileContent, _ := os.ReadFile(fname) From b8ef6962bbafb7583eb2fe7e825b3b5c798c0298 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Wed, 13 Sep 2023 16:22:13 -0400 Subject: [PATCH 3/5] use WaitForTabletStatuses Signed-off-by: Florent Poinsard --- go/test/endtoend/cluster/vttablet_process.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/go/test/endtoend/cluster/vttablet_process.go b/go/test/endtoend/cluster/vttablet_process.go index 44f46925ad6..43cca09f9f7 100644 --- a/go/test/endtoend/cluster/vttablet_process.go +++ b/go/test/endtoend/cluster/vttablet_process.go @@ -150,7 +150,7 @@ func (vttablet *VttabletProcess) Setup() (err error) { }() if vttablet.ServingStatus != "" { - if err = vttablet.WaitForTabletStatus(vttablet.ServingStatus, "SERVING"); err != nil { + if err = vttablet.WaitForTabletStatuses([]string{"SERVING", "NOT_SERVING"}); err != nil { errFileContent, _ := os.ReadFile(fname) if errFileContent != nil { log.Infof("vttablet error:\n%s\n", string(errFileContent)) @@ -273,8 +273,8 @@ func (vttablet *VttabletProcess) GetTabletType() string { } // WaitForTabletStatus waits for one of the expected statuses to be reached -func (vttablet *VttabletProcess) WaitForTabletStatus(expectedStatus ...string) error { - return vttablet.WaitForTabletStatusesForTimeout(expectedStatus, vttabletStateTimeout) +func (vttablet *VttabletProcess) WaitForTabletStatus(expectedStatus string) error { + return vttablet.WaitForTabletStatusesForTimeout([]string{expectedStatus}, vttabletStateTimeout) } // WaitForTabletStatuses waits for one of expected statuses is reached From 80e18b668f00f2b09b49d1e7826010033879a6a5 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Wed, 13 Sep 2023 16:28:43 -0400 Subject: [PATCH 4/5] add comment Signed-off-by: Florent Poinsard --- go/test/endtoend/cluster/vttablet_process.go | 1 + 1 file changed, 1 insertion(+) diff --git a/go/test/endtoend/cluster/vttablet_process.go b/go/test/endtoend/cluster/vttablet_process.go index 43cca09f9f7..808f93dc0a1 100644 --- a/go/test/endtoend/cluster/vttablet_process.go +++ b/go/test/endtoend/cluster/vttablet_process.go @@ -150,6 +150,7 @@ 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 { errFileContent, _ := os.ReadFile(fname) if errFileContent != nil { From 5a8b78c0bd9d9f3393eb4bbab4319c81bfa4026f Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 18 Sep 2023 13:09:49 -0400 Subject: [PATCH 5/5] add explicit serving status to vttablet process Signed-off-by: Florent Poinsard --- go/test/endtoend/cluster/cluster_process.go | 13 +++++++++++-- go/test/endtoend/cluster/vttablet_process.go | 12 ++++++++++-- .../endtoend/tabletmanager/custom_rule_topo_test.go | 2 +- .../endtoend/tabletmanager/primary/tablet_test.go | 2 +- .../endtoend/tabletmanager/tablet_health_test.go | 8 ++++---- .../tabletmanager/tablet_security_policy_test.go | 6 +++--- go/test/endtoend/tabletmanager/tablet_test.go | 4 ++-- 7 files changed, 32 insertions(+), 15 deletions(-) diff --git a/go/test/endtoend/cluster/cluster_process.go b/go/test/endtoend/cluster/cluster_process.go index 6f1b00c53ff..46efd8dc974 100644 --- a/go/test/endtoend/cluster/cluster_process.go +++ b/go/test/endtoend/cluster/cluster_process.go @@ -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, @@ -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() } diff --git a/go/test/endtoend/cluster/vttablet_process.go b/go/test/endtoend/cluster/vttablet_process.go index 808f93dc0a1..3bacb71b154 100644 --- a/go/test/endtoend/cluster/vttablet_process.go +++ b/go/test/endtoend/cluster/vttablet_process.go @@ -71,6 +71,7 @@ type VttabletProcess struct { QueryzURL string StatusDetailsURL string SupportsBackup bool + ExplicitServingStatus bool ServingStatus string DbPassword string DbPort int @@ -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)) diff --git a/go/test/endtoend/tabletmanager/custom_rule_topo_test.go b/go/test/endtoend/tabletmanager/custom_rule_topo_test.go index fb6a64efef3..aa09a99e0fe 100644 --- a/go/test/endtoend/tabletmanager/custom_rule_topo_test.go +++ b/go/test/endtoend/tabletmanager/custom_rule_topo_test.go @@ -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") diff --git a/go/test/endtoend/tabletmanager/primary/tablet_test.go b/go/test/endtoend/tabletmanager/primary/tablet_test.go index 678f3bf3d42..f6255b1f71a 100644 --- a/go/test/endtoend/tabletmanager/primary/tablet_test.go +++ b/go/test/endtoend/tabletmanager/primary/tablet_test.go @@ -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 diff --git a/go/test/endtoend/tabletmanager/tablet_health_test.go b/go/test/endtoend/tabletmanager/tablet_health_test.go index f54a3d285ef..83a3ce08cfb 100644 --- a/go/test/endtoend/tabletmanager/tablet_health_test.go +++ b/go/test/endtoend/tabletmanager/tablet_health_test.go @@ -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" @@ -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) @@ -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() { @@ -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) diff --git a/go/test/endtoend/tabletmanager/tablet_security_policy_test.go b/go/test/endtoend/tabletmanager/tablet_security_policy_test.go index 2ad907ec7b8..b3b11405abb 100644 --- a/go/test/endtoend/tabletmanager/tablet_security_policy_test.go +++ b/go/test/endtoend/tabletmanager/tablet_security_policy_test.go @@ -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. @@ -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. @@ -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. diff --git a/go/test/endtoend/tabletmanager/tablet_test.go b/go/test/endtoend/tabletmanager/tablet_test.go index 97715d39a58..4fe5a70d125 100644 --- a/go/test/endtoend/tabletmanager/tablet_test.go +++ b/go/test/endtoend/tabletmanager/tablet_test.go @@ -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. @@ -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