Skip to content

Commit

Permalink
[release-16.0] VReplication: Pass on --keep_routing_rules flag value …
Browse files Browse the repository at this point in the history
…for Cancel action (#13171) (#13194)

* Pass on keep_routing_rules flag value for Cancel action

Signed-off-by: Matt Lord <[email protected]>

* Add e2e test for Cancel --keep_routing_rules

Signed-off-by: Matt Lord <[email protected]>

---------

Signed-off-by: Matt Lord <[email protected]>
Co-authored-by: Matt Lord <[email protected]>
  • Loading branch information
vitess-bot[bot] and mattlord authored May 30, 2023
1 parent 88269ad commit 28c9dce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion go/test/endtoend/vreplication/vreplication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tidwall/gjson"

"github.com/buger/jsonparser"

Expand Down Expand Up @@ -173,7 +174,19 @@ func TestVReplicationDDLHandling(t *testing.T) {
waitForQueryResult(t, vtgateConn, targetKs, checkColQueryTarget, "[[INT64(0)]]")
// Confirm new col does exist on source
waitForQueryResult(t, vtgateConn, sourceKs, checkColQuerySource, "[[INT64(1)]]")
moveTablesAction(t, "Cancel", defaultCellName, workflow, sourceKs, targetKs, table)
// Also test Cancel --keep_routing_rules
moveTablesAction(t, "Cancel", defaultCellName, workflow, sourceKs, targetKs, table, "--keep_routing_rules")
// Confirm that the routing rules were NOT cleared
rr, err := vc.VtctldClient.ExecuteCommandWithOutput("GetRoutingRules")
require.NoError(t, err)
require.Greater(t, len(gjson.Get(rr, "rules").Array()), 0)
// Manually clear the routing rules
err = vc.VtctldClient.ExecuteCommand("ApplyRoutingRules", "--rules", "{}")
require.NoError(t, err)
// Confirm that the routing rules are gone
rr, err = vc.VtctldClient.ExecuteCommandWithOutput("GetRoutingRules")
require.NoError(t, err)
require.Equal(t, len(gjson.Get(rr, "rules").Array()), 0)
// Drop the column on source to start fresh again
_, err = vtgateConn.ExecuteFetch(dropColDDL, 1, false)
require.NoError(t, err, "error executing %q: %v", dropColDDL, err)
Expand Down
1 change: 1 addition & 0 deletions go/vt/vtctl/vtctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2294,6 +2294,7 @@ func commandVRWorkflow(ctx context.Context, wr *wrangler.Wrangler, subFlags *pfl
vrwp.MaxAllowedTransactionLagSeconds = int64(math.Ceil(maxReplicationLagAllowed.Seconds()))
case vReplicationWorkflowActionCancel:
vrwp.KeepData = *keepData
vrwp.KeepRoutingRules = *keepRoutingRules
case vReplicationWorkflowActionComplete:
switch workflowType {
case wrangler.MoveTablesWorkflow:
Expand Down

0 comments on commit 28c9dce

Please sign in to comment.