Skip to content

Commit

Permalink
Fix e2e test
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <mattalord@gmail.com>
  • Loading branch information
mattlord committed Nov 1, 2024
1 parent 42d0a23 commit 20da402
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
13 changes: 13 additions & 0 deletions go/test/endtoend/vreplication/multi_tenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,19 @@ func TestMultiTenantSimple(t *testing.T) {
require.Zero(t, rowCount)
})

t.Run("cancel after switching reads", func(t *testing.T) {
// First let's test canceling the workflow after only switching reads
// to ensure that it properly cleans up all of the state.
createFunc()
mt.SwitchReads()
validateReadsRouteToTarget(t, "replica,rdonly")
validateTableRoutingRule(t, "customer", "replica,rdonly", sourceKs, targetKs)
validateTableRoutingRule(t, "customer", "replica,rdonly", targetKs, sourceKs)
mt.Cancel()
rowCount := getRowCount(t, vtgateConn, fmt.Sprintf("%s.%s", targetKeyspace, "t1"))
require.Zero(t, rowCount)
})

// Create again and run it to completion.
createFunc()

Expand Down
44 changes: 17 additions & 27 deletions go/test/endtoend/vreplication/vreplication_vtctldclient_cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,11 @@ func testMoveTablesFlags3(t *testing.T, sourceKeyspace, targetKeyspace string, t
catchup(t, tab, workflowName, "MoveTables")
}
mt.SwitchReads()
wf := mt.(iWorkflow)
validateReadsRouteToTarget(t, "replica,rdonly")
validateTableRoutingRule(t, "customer", "replica,rdonly", sourceKs, targetKs)
validateTableRoutingRule(t, "customer", "replica,rdonly", targetKs, sourceKs)
confirmStates(t, &wf, wrangler.WorkflowStateNotSwitched, wrangler.WorkflowStateReadsSwitched)
mt.Cancel()
confirmNoRoutingRules(t)
}
Expand Down Expand Up @@ -462,34 +467,19 @@ func splitShard(t *testing.T, keyspace, workflowName, sourceShards, targetShards
"--config-overrides", mapToCSV(overrides),
}

var rs iReshard
var wf iWorkflow
createWorkflow := func() {
rs = newReshard(vc, &reshardWorkflow{
workflowInfo: &workflowInfo{
vc: vc,
workflowName: workflowName,
targetKeyspace: keyspace,
},
sourceShards: sourceShards,
targetShards: targetShards,
createFlags: createFlags,
}, workflowFlavorVtctld)
wf = rs.(iWorkflow)
rs.Create()
}

// First test that we can create a workflow, switch ONLY reads, and then cancel it.
createWorkflow()
rs.SwitchReads()
validateReadsRouteToTarget(t, "replica")
validateTableRoutingRule(t, "customer", "replica", sourceKs, targetKs)
validateTableRoutingRule(t, "customer", "", targetKs, sourceKs)
confirmStates(t, &wf, wrangler.WorkflowStateNotSwitched, wrangler.WorkflowStateReadsSwitched)
rs.Cancel()
confirmNoRoutingRules(t)
rs := newReshard(vc, &reshardWorkflow{
workflowInfo: &workflowInfo{
vc: vc,
workflowName: workflowName,
targetKeyspace: keyspace,
},
sourceShards: sourceShards,
targetShards: targetShards,
createFlags: createFlags,
}, workflowFlavorVtctld)
wf := rs.(iWorkflow)
rs.Create()

createWorkflow()
ksWorkflow := fmt.Sprintf("%s.%s", keyspace, workflowName)
validateReshardResponse(rs)
validateOverrides(t, targetTabs, overrides)
Expand Down

0 comments on commit 20da402

Please sign in to comment.