Skip to content

Commit

Permalink
CI: Lower resources used for TestVtctldMigrateSharded (#16875)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord authored Oct 2, 2024
1 parent 978c59d commit 2e47aba
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 15 deletions.
26 changes: 17 additions & 9 deletions go/test/endtoend/vreplication/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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]]
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand Down
27 changes: 21 additions & 6 deletions go/test/endtoend/vreplication/resharding_workflows_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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
}
Expand All @@ -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) {
Expand Down

0 comments on commit 2e47aba

Please sign in to comment.