diff --git a/go/test/endtoend/vreplication/migrate_test.go b/go/test/endtoend/vreplication/migrate_test.go index c6518f0fdec..2ccb3158fd9 100644 --- a/go/test/endtoend/vreplication/migrate_test.go +++ b/go/test/endtoend/vreplication/migrate_test.go @@ -21,13 +21,12 @@ import ( "strings" "testing" + "github.com/stretchr/testify/require" "github.com/tidwall/gjson" + "vitess.io/vitess/go/mysql" "vitess.io/vitess/go/test/endtoend/cluster" - "github.com/stretchr/testify/require" - - "vitess.io/vitess/go/mysql" binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata" ) @@ -51,8 +50,15 @@ func insertInitialDataIntoExternalCluster(t *testing.T, conn *mysql.Conn) { func TestVtctlMigrate(t *testing.T) { vc = NewVitessCluster(t, nil) + oldDefaultReplicas := defaultReplicas + oldDefaultRdonly := defaultRdonly defaultReplicas = 0 defaultRdonly = 0 + defer func() { + defaultReplicas = oldDefaultReplicas + defaultRdonly = oldDefaultRdonly + }() + defer vc.TearDown() defaultCell := vc.Cells[vc.CellNames[0]] @@ -314,21 +320,23 @@ func TestVtctldMigrateUnsharded(t *testing.T) { // doesn't match that of the source cluster. The test migrates from a cluster with keyspace customer to an "external" // cluster with keyspace rating. func TestVtctldMigrateSharded(t *testing.T) { + setSidecarDBName("_vt") + currentWorkflowType = binlogdatapb.VReplicationWorkflowType_MoveTables oldDefaultReplicas := defaultReplicas oldDefaultRdonly := defaultRdonly - defaultReplicas = 1 - defaultRdonly = 1 + defaultReplicas = 0 + defaultRdonly = 0 defer func() { defaultReplicas = oldDefaultReplicas defaultRdonly = oldDefaultRdonly }() - setSidecarDBName("_vt") - currentWorkflowType = binlogdatapb.VReplicationWorkflowType_MoveTables vc = setupCluster(t) + defer vc.TearDown() + vtgateConn := getConnection(t, vc.ClusterConfig.hostname, vc.ClusterConfig.vtgateMySQLPort) defer vtgateConn.Close() - defer vc.TearDown() + setupCustomerKeyspace(t) createMoveTablesWorkflow(t, "customer,Lead,datze,customer2") tstWorkflowSwitchReadsAndWrites(t) @@ -363,7 +371,7 @@ func TestVtctldMigrateSharded(t *testing.T) { if output, err = extVc.VtctldClient.ExecuteCommandWithOutput("Migrate", "--target-keyspace", "rating", "--workflow", "e1", "create", "--source-keyspace", "customer", "--mount-name", "external", "--all-tables", "--cells=zone1", - "--tablet-types=primary,replica"); err != nil { + "--tablet-types=primary"); err != nil { require.FailNow(t, "Migrate command failed with %+v : %s\n", err, output) } waitForWorkflowState(t, extVc, ksWorkflow, binlogdatapb.VReplicationWorkflowState_Running.String()) diff --git a/go/test/endtoend/vreplication/resharding_workflows_v2_test.go b/go/test/endtoend/vreplication/resharding_workflows_v2_test.go index 1e93a54b850..4c6dea61912 100644 --- a/go/test/endtoend/vreplication/resharding_workflows_v2_test.go +++ b/go/test/endtoend/vreplication/resharding_workflows_v2_test.go @@ -335,6 +335,9 @@ func tstWorkflowCancel(t *testing.T) error { } func validateReadsRoute(t *testing.T, tabletTypes string, tablet *cluster.VttabletProcess) { + if tablet == nil { + return + } if tabletTypes == "" { tabletTypes = "replica,rdonly" } @@ -350,11 +353,15 @@ func validateReadsRoute(t *testing.T, tabletTypes string, tablet *cluster.Vttabl } func validateReadsRouteToSource(t *testing.T, tabletTypes string) { - validateReadsRoute(t, tabletTypes, sourceReplicaTab) + if sourceReplicaTab != nil { + validateReadsRoute(t, tabletTypes, sourceReplicaTab) + } } func validateReadsRouteToTarget(t *testing.T, tabletTypes string) { - validateReadsRoute(t, tabletTypes, targetReplicaTab1) + if targetReplicaTab1 != nil { + validateReadsRoute(t, tabletTypes, targetReplicaTab1) + } } func validateWritesRouteToSource(t *testing.T) { @@ -849,8 +856,12 @@ func setupCluster(t *testing.T) *VitessCluster { insertInitialData(t) defaultCell := vc.Cells[vc.CellNames[0]] sourceTab = vc.Cells[defaultCell.Name].Keyspaces["product"].Shards["0"].Tablets["zone1-100"].Vttablet - sourceReplicaTab = vc.Cells[defaultCell.Name].Keyspaces["product"].Shards["0"].Tablets["zone1-101"].Vttablet - sourceRdonlyTab = vc.Cells[defaultCell.Name].Keyspaces["product"].Shards["0"].Tablets["zone1-102"].Vttablet + if defaultReplicas > 0 { + sourceReplicaTab = vc.Cells[defaultCell.Name].Keyspaces["product"].Shards["0"].Tablets["zone1-101"].Vttablet + } + if defaultRdonly > 0 { + sourceRdonlyTab = vc.Cells[defaultCell.Name].Keyspaces["product"].Shards["0"].Tablets["zone1-102"].Vttablet + } return vc } @@ -864,8 +875,12 @@ func setupCustomerKeyspace(t *testing.T) { custKs := vc.Cells[defaultCell.Name].Keyspaces["customer"] targetTab1 = custKs.Shards["-80"].Tablets["zone1-200"].Vttablet targetTab2 = custKs.Shards["80-"].Tablets["zone1-300"].Vttablet - targetReplicaTab1 = custKs.Shards["-80"].Tablets["zone1-201"].Vttablet - targetRdonlyTab1 = custKs.Shards["-80"].Tablets["zone1-202"].Vttablet + if defaultReplicas > 0 { + targetReplicaTab1 = custKs.Shards["-80"].Tablets["zone1-201"].Vttablet + } + if defaultRdonly > 0 { + targetRdonlyTab1 = custKs.Shards["-80"].Tablets["zone1-202"].Vttablet + } } func setupCustomer2Keyspace(t *testing.T) {