From b96a7770eaa52fa9e5157a97d33414854ef84d85 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Fri, 26 May 2023 19:20:57 +0000 Subject: [PATCH 1/2] Pass on keep_routing_rules flag value for Cancel action Signed-off-by: Matt Lord --- go/vt/vtctl/vtctl.go | 1 + 1 file changed, 1 insertion(+) diff --git a/go/vt/vtctl/vtctl.go b/go/vt/vtctl/vtctl.go index 682576b7a49..93628b4d0f5 100644 --- a/go/vt/vtctl/vtctl.go +++ b/go/vt/vtctl/vtctl.go @@ -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: From 9cb8766acdb9f7dc3dfae9668cb7f04eb5b7091b Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Mon, 29 May 2023 18:36:30 +0000 Subject: [PATCH 2/2] Add e2e test for Cancel --keep_routing_rules Signed-off-by: Matt Lord --- .../endtoend/vreplication/vreplication_test.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/go/test/endtoend/vreplication/vreplication_test.go b/go/test/endtoend/vreplication/vreplication_test.go index a16d335363e..d6a411fdb3c 100644 --- a/go/test/endtoend/vreplication/vreplication_test.go +++ b/go/test/endtoend/vreplication/vreplication_test.go @@ -34,6 +34,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/tidwall/gjson" "github.com/buger/jsonparser" @@ -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)