Skip to content

Commit

Permalink
Derive sourceKs and targetKs from input tablets
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord committed Jan 24, 2025
1 parent 76396de commit 6cbcc8a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions go/test/endtoend/vreplication/vreplication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,9 +828,9 @@ func shardCustomer(t *testing.T, testReverse bool, cells []*Cell, sourceCellOrAl
testSwitchTrafficPermissionChecks(t, workflowType, sourceKs, shardNames, targetKs, workflow)

testSwitchWritesErrorHandling(t, []*cluster.VttabletProcess{productTab}, []*cluster.VttabletProcess{customerTab1, customerTab2},
sourceKs, targetKs, workflow, workflowType)
workflow, workflowType)

// Now let's confirm that it now works as expected.
// Now let's confirm that it works as expected with an error.
switchWrites(t, workflowType, ksWorkflow, false)

checkThatVDiffFails(t, targetKs, workflow)
Expand Down Expand Up @@ -1094,8 +1094,9 @@ func reshard(t *testing.T, ksName string, tableName string, workflow string, sou
reshardAction(t, "SwitchTraffic", workflow, ksName, "", "", callNames, "primary", "--dry-run")
}
if tableName == "customer" {
testSwitchWritesErrorHandling(t, sourceTablets, targetTablets, ksName, ksName, workflow, "reshard")
testSwitchWritesErrorHandling(t, sourceTablets, targetTablets, workflow, "reshard")
}
// Now let's confirm that it works as expected with an error.
reshardAction(t, "SwitchTraffic", workflow, ksName, "", "", callNames, "primary")
reshardAction(t, "Complete", workflow, ksName, "", "", "", "")
for tabletName, count := range counts {
Expand Down Expand Up @@ -1673,12 +1674,14 @@ func testSwitchTrafficPermissionChecks(t *testing.T, workflowType, sourceKeyspac
// The workflow MUST be migrating the customer table from the source to the
// target keyspace AND the workflow must currently have reads switched but not
// writes.
func testSwitchWritesErrorHandling(t *testing.T, sourceTablets, targetTablets []*cluster.VttabletProcess, sourceKs, targetKs, workflow, workflowType string) {
func testSwitchWritesErrorHandling(t *testing.T, sourceTablets, targetTablets []*cluster.VttabletProcess, workflow, workflowType string) {
t.Run("validate switch writes error handling", func(t *testing.T) {
ksWorkflow := fmt.Sprintf("%s.%s", targetKs, workflow)
vtgateConn := getConnection(t, vc.ClusterConfig.hostname, vc.ClusterConfig.vtgateMySQLPort)
require.NotZero(t, len(sourceTablets), "no source tablets provided for keyspace %s", sourceKs)
require.NotZero(t, len(targetTablets), "no target tablets provided for keyspace %s", targetKs)
sourceKs := sourceTablets[0].Keyspace
targetKs := targetTablets[0].Keyspace
ksWorkflow := fmt.Sprintf("%s.%s", targetKs, workflow)
var err error
sourceConns := make([]*mysql.Conn, len(sourceTablets))
for i, tablet := range sourceTablets {
Expand Down

0 comments on commit 6cbcc8a

Please sign in to comment.