Skip to content

Commit d5d4cd6

Browse files
committed
reset resharding test
1 parent 515df35 commit d5d4cd6

File tree

1 file changed

+19
-65
lines changed

1 file changed

+19
-65
lines changed

go/test/endtoend/vreplication/resharding_workflows_v2_test.go

Lines changed: 19 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ func tstWorkflowExec(t *testing.T, cells, workflow, sourceKs, targetKs, tables,
163163
args = append(args, "--tablet-types", tabletTypes)
164164
}
165165
args = append(args, "--action_timeout=10m") // At this point something is up so fail the test
166-
t.Logf("Executing workflow command: vtctldclient %s", strings.Join(args, " "))
166+
if debugMode {
167+
t.Logf("Executing workflow command: vtctldclient %v", strings.Join(args, " "))
168+
}
167169
output, err := vc.VtctldClient.ExecuteCommandWithOutput(args...)
168170
lastOutput = output
169171
if err != nil {
@@ -335,7 +337,6 @@ func validateReadsRoute(t *testing.T, tabletTypes string, tablet *cluster.Vttabl
335337
if strings.Contains(tabletTypes, tt) {
336338
readQuery := "select * from customer"
337339
assertQueryExecutesOnTablet(t, vtgateConn, tablet, destination, readQuery, readQuery)
338-
339340
}
340341
}
341342
}
@@ -395,13 +396,6 @@ func getCurrentStatus(t *testing.T) string {
395396
// but CI currently fails on creating multiple clusters even after the previous ones are torn down
396397

397398
func TestBasicV2Workflows(t *testing.T) {
398-
ogReplicas := defaultReplicas
399-
ogRdOnly := defaultRdonly
400-
defer func() {
401-
defaultReplicas = ogReplicas
402-
defaultRdonly = ogRdOnly
403-
}()
404-
defaultReplicas = 1
405399
defaultRdonly = 1
406400
extraVTTabletArgs = []string{
407401
parallelInsertWorkers,
@@ -639,12 +633,6 @@ func testPartialSwitches(t *testing.T) {
639633
tstWorkflowSwitchReads(t, "", "")
640634
checkStates(t, nextState, nextState) // idempotency
641635

642-
tstWorkflowReverseReads(t, "replica,rdonly", "")
643-
checkStates(t, wrangler.WorkflowStateReadsSwitched, wrangler.WorkflowStateNotSwitched)
644-
645-
tstWorkflowSwitchReads(t, "", "")
646-
checkStates(t, wrangler.WorkflowStateNotSwitched, wrangler.WorkflowStateReadsSwitched)
647-
648636
tstWorkflowSwitchWrites(t)
649637
currentState = nextState
650638
nextState = wrangler.WorkflowStateAllSwitched
@@ -681,12 +669,12 @@ func testRestOfWorkflow(t *testing.T) {
681669
waitForLowLag(t, "customer", "wf1")
682670
tstWorkflowSwitchReads(t, "", "")
683671
checkStates(t, wrangler.WorkflowStateNotSwitched, wrangler.WorkflowStateReadsSwitched)
684-
validateReadsRouteToTarget(t, "replica,rdonly")
672+
validateReadsRouteToTarget(t, "replica")
685673
validateWritesRouteToSource(t)
686674

687675
tstWorkflowSwitchWrites(t)
688676
checkStates(t, wrangler.WorkflowStateReadsSwitched, wrangler.WorkflowStateAllSwitched)
689-
validateReadsRouteToTarget(t, "replica,rdonly")
677+
validateReadsRouteToTarget(t, "replica")
690678
validateWritesRouteToTarget(t)
691679

692680
// this function is called for both MoveTables and Reshard, so the reverse workflows exist in different keyspaces
@@ -697,45 +685,42 @@ func testRestOfWorkflow(t *testing.T) {
697685
waitForLowLag(t, keyspace, "wf1_reverse")
698686
tstWorkflowReverseReads(t, "", "")
699687
checkStates(t, wrangler.WorkflowStateAllSwitched, wrangler.WorkflowStateWritesSwitched)
700-
validateReadsRouteToSource(t, "replica,rdonly")
688+
validateReadsRouteToSource(t, "replica")
701689
validateWritesRouteToTarget(t)
702690

703691
tstWorkflowReverseWrites(t)
704692
checkStates(t, wrangler.WorkflowStateWritesSwitched, wrangler.WorkflowStateNotSwitched)
705-
validateReadsRouteToSource(t, "replica,rdonly")
693+
validateReadsRouteToSource(t, "replica")
706694
validateWritesRouteToSource(t)
707695

708696
waitForLowLag(t, "customer", "wf1")
709697
tstWorkflowSwitchWrites(t)
710698
checkStates(t, wrangler.WorkflowStateNotSwitched, wrangler.WorkflowStateWritesSwitched)
711-
validateReadsRouteToSource(t, "replica,rdonly")
699+
validateReadsRouteToSource(t, "replica")
712700
validateWritesRouteToTarget(t)
713701

714702
waitForLowLag(t, keyspace, "wf1_reverse")
715703
tstWorkflowReverseWrites(t)
716-
checkStates(t, wrangler.WorkflowStateWritesSwitched, wrangler.WorkflowStateNotSwitched)
717-
validateReadsRouteToSource(t, "replica,rdonly")
704+
validateReadsRouteToSource(t, "replica")
718705
validateWritesRouteToSource(t)
719706

720707
waitForLowLag(t, "customer", "wf1")
721708
tstWorkflowSwitchReads(t, "", "")
722-
checkStates(t, wrangler.WorkflowStateNotSwitched, wrangler.WorkflowStateReadsSwitched)
723-
validateReadsRouteToTarget(t, "replica,rdonly")
709+
validateReadsRouteToTarget(t, "replica")
724710
validateWritesRouteToSource(t)
725711

726712
tstWorkflowReverseReads(t, "", "")
727-
checkStates(t, wrangler.WorkflowStateReadsSwitched, wrangler.WorkflowStateNotSwitched)
728-
validateReadsRouteToSource(t, "replica,rdonly")
713+
validateReadsRouteToSource(t, "replica")
729714
validateWritesRouteToSource(t)
730715

731716
tstWorkflowSwitchReadsAndWrites(t)
732-
checkStates(t, wrangler.WorkflowStateNotSwitched, wrangler.WorkflowStateAllSwitched)
733-
validateReadsRouteToTarget(t, "replica,rdonly")
717+
validateReadsRouteToTarget(t, "replica")
718+
validateReadsRoute(t, "rdonly", targetRdonlyTab1)
734719
validateWritesRouteToTarget(t)
735720
waitForLowLag(t, keyspace, "wf1_reverse")
736721
tstWorkflowReverseReadsAndWrites(t)
737-
checkStates(t, wrangler.WorkflowStateAllSwitched, wrangler.WorkflowStateNotSwitched)
738-
validateReadsRouteToSource(t, "replica,rdonly")
722+
validateReadsRoute(t, "rdonly", sourceRdonlyTab)
723+
validateReadsRouteToSource(t, "replica")
739724
validateWritesRouteToSource(t)
740725

741726
// trying to complete an unswitched workflow should error
@@ -746,7 +731,8 @@ func testRestOfWorkflow(t *testing.T) {
746731
// fully switch and complete
747732
waitForLowLag(t, "customer", "wf1")
748733
tstWorkflowSwitchReadsAndWrites(t)
749-
validateReadsRouteToTarget(t, "replica,rdonly")
734+
validateReadsRoute(t, "rdonly", targetRdonlyTab1)
735+
validateReadsRouteToTarget(t, "replica")
750736
validateWritesRouteToTarget(t)
751737

752738
err = tstWorkflowComplete(t)
@@ -801,7 +787,7 @@ func setupMinimalCluster(t *testing.T) *VitessCluster {
801787

802788
zone1 := vc.Cells["zone1"]
803789

804-
vc.AddKeyspace(t, []*Cell{zone1}, "product", "0", initialProductVSchema, initialProductSchema, defaultReplicas, defaultRdonly, 100, nil)
790+
vc.AddKeyspace(t, []*Cell{zone1}, "product", "0", initialProductVSchema, initialProductSchema, 0, 0, 100, nil)
805791

806792
verifyClusterHealth(t, vc)
807793
insertInitialData(t)
@@ -814,7 +800,7 @@ func setupMinimalCluster(t *testing.T) *VitessCluster {
814800
func setupMinimalCustomerKeyspace(t *testing.T) map[string]*cluster.VttabletProcess {
815801
tablets := make(map[string]*cluster.VttabletProcess)
816802
if _, err := vc.AddKeyspace(t, []*Cell{vc.Cells["zone1"]}, "customer", "-80,80-",
817-
customerVSchema, customerSchema, defaultReplicas, defaultRdonly, 200, nil); err != nil {
803+
customerVSchema, customerSchema, 0, 0, 200, nil); err != nil {
818804
t.Fatal(err)
819805
}
820806
defaultCell := vc.Cells[vc.CellNames[0]]
@@ -950,7 +936,6 @@ func createAdditionalCustomerShards(t *testing.T, shards string) {
950936
targetTab2 = custKs.Shards["80-c0"].Tablets["zone1-600"].Vttablet
951937
targetTab1 = custKs.Shards["40-80"].Tablets["zone1-500"].Vttablet
952938
targetReplicaTab1 = custKs.Shards["-40"].Tablets["zone1-401"].Vttablet
953-
targetRdonlyTab1 = custKs.Shards["-40"].Tablets["zone1-402"].Vttablet
954939

955940
sourceTab = custKs.Shards["-80"].Tablets["zone1-200"].Vttablet
956941
sourceReplicaTab = custKs.Shards["-80"].Tablets["zone1-201"].Vttablet
@@ -962,34 +947,3 @@ func tstApplySchemaOnlineDDL(t *testing.T, sql string, keyspace string) {
962947
"--sql", sql, keyspace)
963948
require.NoError(t, err, fmt.Sprintf("ApplySchema Error: %s", err))
964949
}
965-
966-
func validateTableRoutingRule(t *testing.T, table, tabletType, fromKeyspace, toKeyspace string) {
967-
tabletType = strings.ToLower(strings.TrimSpace(tabletType))
968-
rr := getRoutingRules(t)
969-
// We set matched = true by default because it is possible, if --no-routing-rules is set while creating
970-
// a workflow, that the routing rules are empty when the workflow starts.
971-
// We set it to false below when the rule is found, but before matching the routed keyspace.
972-
matched := true
973-
for _, r := range rr.GetRules() {
974-
fromRule := fmt.Sprintf("%s.%s", fromKeyspace, table)
975-
if tabletType != "" && tabletType != "primary" {
976-
fromRule = fmt.Sprintf("%s@%s", fromRule, tabletType)
977-
}
978-
if r.FromTable == fromRule {
979-
// We found the rule, so we can set matched to false here and check for the routed keyspace below.
980-
matched = false
981-
require.NotEmpty(t, r.ToTables)
982-
toTable := r.ToTables[0]
983-
// The ToTables value is of the form "routedKeyspace.table".
984-
routedKeyspace, routedTable, ok := strings.Cut(toTable, ".")
985-
require.True(t, ok)
986-
require.Equal(t, table, routedTable)
987-
if routedKeyspace == toKeyspace {
988-
// We found the rule, the table and keyspace matches, so our search is done.
989-
matched = true
990-
break
991-
}
992-
}
993-
}
994-
require.Truef(t, matched, "routing rule for %s.%s from %s to %s not found", fromKeyspace, table, tabletType, toKeyspace)
995-
}

0 commit comments

Comments
 (0)