Skip to content

Commit

Permalink
Get more stuff...
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord committed Dec 27, 2024
1 parent 9858b8f commit b2a120f
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 147 deletions.
6 changes: 3 additions & 3 deletions go/test/endtoend/throttler/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func GetThrottlerStatusRaw(vtctldProcess *cluster.VtctldClientProcess, tablet *c
return result, err
}

// UpdateThrottlerTopoConfig runs vtctlclient UpdateThrottlerConfig.
// UpdateThrottlerTopoConfig runs vtctldclient UpdateThrottlerConfig.
// This retries the command until it succeeds or times out as the
// SrvKeyspace record may not yet exist for a newly created
// Keyspace that is still initializing before it becomes serving.
Expand Down Expand Up @@ -218,7 +218,7 @@ func GetThrottlerStatus(vtctldProcess *cluster.VtctldClientProcess, tablet *clus
return resp.Status, err
}

// UpdateThrottlerTopoConfig runs vtctlclient UpdateThrottlerConfig.
// UpdateThrottlerTopoConfig runs vtctldclient UpdateThrottlerConfig.
// This retries the command until it succeeds or times out as the
// SrvKeyspace record may not yet exist for a newly created
// Keyspace that is still initializing before it becomes serving.
Expand Down Expand Up @@ -272,7 +272,7 @@ func WaitForSrvKeyspace(clusterInstance *cluster.LocalProcessCluster, cell, keys
}
}

// throttleAppRaw runs vtctlclient UpdateThrottlerConfig with --throttle-app flags
// throttleAppRaw runs vtctldclient UpdateThrottlerConfig with --throttle-app flags
// This retries the command until it succeeds or times out as the
// SrvKeyspace record may not yet exist for a newly created
// Keyspace that is still initializing before it becomes serving.
Expand Down
2 changes: 1 addition & 1 deletion go/test/endtoend/vreplication/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
// 1. Composite or multi-column primary keys
// 2. PKs that contain an ENUM column
// 3. That we properly handle tables with auto_increment columns (which are stripped by default when
// moving the table to a sharded keyspace with vtctldclient and left in place when using vtctlclient)
// moving the table to a sharded keyspace)
//
// The Lead and Lead-1 tables also allows us to test several things:
// 1. Mixed case identifiers
Expand Down
2 changes: 1 addition & 1 deletion go/test/endtoend/vreplication/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ func validateDryRunResults(t *testing.T, output string, want []string) {
gotDryRun := strings.Split(output, "\n")
require.True(t, len(gotDryRun) > 3)
var startRow int
if strings.HasPrefix(gotDryRun[1], "Parameters:") { // vtctlclient
if strings.HasPrefix(gotDryRun[1], "Parameters:") { // vtctldclient
startRow = 3
} else if strings.Contains(gotDryRun[0], "deprecated") {
startRow = 4
Expand Down
131 changes: 2 additions & 129 deletions go/test/endtoend/vreplication/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,140 +41,13 @@ func insertInitialDataIntoExternalCluster(t *testing.T, conn *mysql.Conn) {
})
}

// TestVtctlMigrate runs an e2e test for importing from an external cluster using the vtctl Mount and Migrate commands.
// TestMigrate runs an e2e test for importing from an external cluster using the vtctld Mount and Migrate commands.
// We have an anti-pattern in Vitess: vt executables look for an environment variable VTDATAROOT for certain cluster parameters
// like the log directory when they are created. Until this test we just needed a single cluster for e2e tests.
// However now we need to create an external Vitess cluster. For this we need a different VTDATAROOT and
// hence the VTDATAROOT env variable gets overwritten.
// Each time we need to create vt processes in the "other" cluster we need to set the appropriate VTDATAROOT
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]]
_, err := vc.AddKeyspace(t, []*Cell{defaultCell}, "product", "0", initialProductVSchema, initialProductSchema, defaultReplicas, defaultRdonly, 100, nil)
require.NoError(t, err, "failed to create product keyspace")
vtgate := defaultCell.Vtgates[0]
require.NotNil(t, vtgate, "failed to get vtgate")

vtgateConn := getConnection(t, vc.ClusterConfig.hostname, vc.ClusterConfig.vtgateMySQLPort)
defer vtgateConn.Close()
verifyClusterHealth(t, vc)
insertInitialData(t)
t.Run("VStreamFrom", func(t *testing.T) {
testVStreamFrom(t, vtgate, "product", 2)
})

// create external cluster
extCell := "extcell1"
extVc := NewVitessCluster(t, &clusterOptions{cells: []string{"extcell1"}, clusterConfig: externalClusterConfig})
defer extVc.TearDown()

extCell2 := extVc.Cells[extCell]
extVc.AddKeyspace(t, []*Cell{extCell2}, "rating", "0", initialExternalVSchema, initialExternalSchema, 0, 0, 1000, nil)
extVtgate := extCell2.Vtgates[0]
require.NotNil(t, extVtgate)

verifyClusterHealth(t, extVc)
extVtgateConn := getConnection(t, extVc.ClusterConfig.hostname, extVc.ClusterConfig.vtgateMySQLPort)
insertInitialDataIntoExternalCluster(t, extVtgateConn)

var output, expected string
ksWorkflow := "product.e1"

t.Run("mount external cluster", func(t *testing.T) {
if output, err = vc.VtctlClient.ExecuteCommandWithOutput("Mount", "--", "--type=vitess", "--topo_type=etcd2",
fmt.Sprintf("--topo_server=localhost:%d", extVc.ClusterConfig.topoPort), "--topo_root=/vitess/global", "ext1"); err != nil {
t.Fatalf("Mount command failed with %+v : %s\n", err, output)
}
if output, err = vc.VtctlClient.ExecuteCommandWithOutput("Mount", "--", "--type=vitess", "--list"); err != nil {
t.Fatalf("Mount command failed with %+v : %s\n", err, output)
}
expected = "ext1\n"
require.Equal(t, expected, output)
if output, err = vc.VtctlClient.ExecuteCommandWithOutput("Mount", "--", "--type=vitess", "--show", "ext1"); err != nil {
t.Fatalf("Mount command failed with %+v : %s\n", err, output)
}
expected = `{"ClusterName":"ext1","topo_config":{"topo_type":"etcd2","server":"localhost:12379","root":"/vitess/global"}}` + "\n"
require.Equal(t, expected, output)
})

t.Run("migrate from external cluster", func(t *testing.T) {
if output, err = vc.VtctlClient.ExecuteCommandWithOutput("Migrate", "--", "--all", "--cells=extcell1",
"--source=ext1.rating", "create", ksWorkflow); err != nil {
t.Fatalf("Migrate command failed with %+v : %s\n", err, output)
}
waitForWorkflowState(t, vc, ksWorkflow, binlogdatapb.VReplicationWorkflowState_Running.String())
expectNumberOfStreams(t, vtgateConn, "migrate", "e1", "product:0", 1)
waitForRowCount(t, vtgateConn, "product:0", "rating", 2)
waitForRowCount(t, vtgateConn, "product:0", "review", 3)
execVtgateQuery(t, extVtgateConn, "rating", "insert into review(rid, pid, review) values(4, 1, 'review4');")
execVtgateQuery(t, extVtgateConn, "rating", "insert into rating(gid, pid, rating) values(3, 1, 3);")
waitForRowCount(t, vtgateConn, "product:0", "rating", 3)
waitForRowCount(t, vtgateConn, "product:0", "review", 4)
doVDiff(t, ksWorkflow, "extcell1")

if output, err = vc.VtctlClient.ExecuteCommandWithOutput("Migrate", "complete", ksWorkflow); err != nil {
t.Fatalf("Migrate command failed with %+v : %s\n", err, output)
}

expectNumberOfStreams(t, vtgateConn, "migrate", "e1", "product:0", 0)
})
t.Run("cancel migrate workflow", func(t *testing.T) {
execVtgateQuery(t, vtgateConn, "product", "drop table review,rating")

if output, err = vc.VtctlClient.ExecuteCommandWithOutput("Migrate", "--", "--all", "--auto_start=false", "--cells=extcell1",
"--source=ext1.rating", "create", ksWorkflow); err != nil {
t.Fatalf("Migrate command failed with %+v : %s\n", err, output)
}
expectNumberOfStreams(t, vtgateConn, "migrate", "e1", "product:0", 1, binlogdatapb.VReplicationWorkflowState_Stopped.String())
waitForRowCount(t, vtgateConn, "product:0", "rating", 0)
waitForRowCount(t, vtgateConn, "product:0", "review", 0)
if output, err = vc.VtctlClient.ExecuteCommandWithOutput("Migrate", "cancel", ksWorkflow); err != nil {
t.Fatalf("Migrate command failed with %+v : %s\n", err, output)
}
expectNumberOfStreams(t, vtgateConn, "migrate", "e1", "product:0", 0)
var found bool
found, err = checkIfTableExists(t, vc, "zone1-100", "review")
require.NoError(t, err)
require.False(t, found)
found, err = checkIfTableExists(t, vc, "zone1-100", "rating")
require.NoError(t, err)
require.False(t, found)
})
t.Run("unmount external cluster", func(t *testing.T) {
if output, err = vc.VtctlClient.ExecuteCommandWithOutput("Mount", "--", "--type=vitess", "--unmount", "ext1"); err != nil {
t.Fatalf("Mount command failed with %+v : %s\n", err, output)
}

if output, err = vc.VtctlClient.ExecuteCommandWithOutput("Mount", "--", "--type=vitess", "--list"); err != nil {
t.Fatalf("Mount command failed with %+v : %s\n", err, output)
}
expected = "\n"
require.Equal(t, expected, output)

output, err = vc.VtctlClient.ExecuteCommandWithOutput("Mount", "--", "--type=vitess", "--show", "ext1")
require.Errorf(t, err, "there is no vitess cluster named ext1")
})
}

// TestVtctldMigrate runs an e2e test for importing from an external cluster using the vtctld Mount and Migrate commands.
// We have an anti-pattern in Vitess: vt executables look for an environment variable VTDATAROOT for certain cluster parameters
// like the log directory when they are created. Until this test we just needed a single cluster for e2e tests.
// However now we need to create an external Vitess cluster. For this we need a different VTDATAROOT and
// hence the VTDATAROOT env variable gets overwritten.
// Each time we need to create vt processes in the "other" cluster we need to set the appropriate VTDATAROOT
func TestVtctldMigrateUnsharded(t *testing.T) {
func TestMigrateUnsharded(t *testing.T) {
vc = NewVitessCluster(t, nil)

oldDefaultReplicas := defaultReplicas
Expand Down
2 changes: 1 addition & 1 deletion go/test/endtoend/vreplication/time_zone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func TestMoveTablesTZ(t *testing.T) {
require.Equal(t, row.AsString("dt2", ""), qrTargetUSPacific.Named().Rows[i].AsString("dt2", ""))
require.Equal(t, row.AsString("ts1", ""), qrTargetUSPacific.Named().Rows[i].AsString("ts1", ""))
}
output, err = vc.VtctlClient.ExecuteCommandWithOutput("MoveTables", "--", "SwitchTraffic", ksWorkflow)
output, err = vc.VtctldClient.ExecuteCommandWithOutput("MoveTables", "--target-keyspace", targetKs, "SwitchTraffic", "--workflow", workflow)
require.NoError(t, err, output)

qr, err := productTab.QueryTablet(sqlparser.BuildParsedQuery("select * from %s.vreplication where workflow='%s_reverse'",
Expand Down
1 change: 0 additions & 1 deletion go/test/endtoend/vreplication/vstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/stretchr/testify/require"

"vitess.io/vitess/go/vt/log"
_ "vitess.io/vitess/go/vt/vtctl/grpcvtctlclient"
_ "vitess.io/vitess/go/vt/vtgate/grpcvtgateconn"
"vitess.io/vitess/go/vt/vtgate/vtgateconn"

Expand Down
13 changes: 2 additions & 11 deletions test/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1346,18 +1346,9 @@
"RetryMax": 1,
"Tags": []
},
"vreplication_vtctl_migrate": {
"vreplication_migrate": {
"File": "unused.go",
"Args": ["vitess.io/vitess/go/test/endtoend/vreplication", "-run", "TestVtctlMigrate", "-timeout", "30m"],
"Command": [],
"Manual": false,
"Shard": "vreplication_migrate",
"RetryMax": 1,
"Tags": []
},
"vreplication_vtctld_migrate": {
"File": "unused.go",
"Args": ["vitess.io/vitess/go/test/endtoend/vreplication", "-run", "TestVtctldMigrate", "-timeout", "30m"],
"Args": ["vitess.io/vitess/go/test/endtoend/vreplication", "-run", "TestMigrate", "-timeout", "30m"],
"Command": [],
"Manual": false,
"Shard": "vreplication_migrate",
Expand Down

0 comments on commit b2a120f

Please sign in to comment.