Skip to content

Commit

Permalink
Update vexec unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord committed Sep 9, 2024
1 parent 5e3054b commit 6323ffa
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions go/vt/wrangler/vexec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"vitess.io/vitess/go/ptr"
"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/textutil"
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/vtenv"

binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata"
tabletmanagerdatapb "vitess.io/vitess/go/vt/proto/tabletmanagerdata"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
"vitess.io/vitess/go/vt/vtenv"
)

var (
Expand Down Expand Up @@ -397,18 +399,18 @@ func TestWorkflowUpdate(t *testing.T) {
defer env.close()
logger := logutil.NewMemoryLogger()
wr := New(vtenv.NewTestEnv(), logger, env.topoServ, env.tmc)
nullSlice := textutil.SimulatedNullStringSlice // Used to represent a non-provided value

tests := []struct {
name string
cells []string
tabletTypes []topodatapb.TabletType
onDDL binlogdatapb.OnDDLAction
onDDL *binlogdatapb.OnDDLAction
output string
wantErr string
}{
{
name: "no flags",
cells: nullSlice,
cells: textutil.SimulatedNullStringSlice,
tabletTypes: textutil.SimulatedNullTabletTypeSlice,
wantErr: "no updates were provided; use --cells, --tablet-types, or --on-ddl to specify new values",
},
Expand All @@ -420,22 +422,22 @@ func TestWorkflowUpdate(t *testing.T) {
},
{
name: "only tablet types",
cells: nullSlice,
cells: textutil.SimulatedNullStringSlice,
tabletTypes: []topodatapb.TabletType{topodatapb.TabletType_PRIMARY, topodatapb.TabletType_REPLICA},
output: "The following workflow fields will be updated:\n tablet_types=\"primary,replica\"\nOn the following tablets in the target keyspace for workflow wrWorkflow:\n zone1-0000000200 (target/-80)\n zone1-0000000210 (target/80-)\n",
},
{
name: "only on-ddl",
cells: nullSlice,
cells: textutil.SimulatedNullStringSlice,
tabletTypes: textutil.SimulatedNullTabletTypeSlice,
onDDL: binlogdatapb.OnDDLAction_EXEC_IGNORE,
onDDL: ptr.Of(binlogdatapb.OnDDLAction_EXEC_IGNORE),
output: "The following workflow fields will be updated:\n on_ddl=\"EXEC_IGNORE\"\nOn the following tablets in the target keyspace for workflow wrWorkflow:\n zone1-0000000200 (target/-80)\n zone1-0000000210 (target/80-)\n",
},
{
name: "all flags",
cells: []string{"zone1", "zone2"},
tabletTypes: []topodatapb.TabletType{topodatapb.TabletType_RDONLY, topodatapb.TabletType_SPARE},
onDDL: binlogdatapb.OnDDLAction_EXEC,
onDDL: ptr.Of(binlogdatapb.OnDDLAction_EXEC),
output: "The following workflow fields will be updated:\n cells=\"zone1,zone2\"\n tablet_types=\"rdonly,spare\"\n on_ddl=\"EXEC\"\nOn the following tablets in the target keyspace for workflow wrWorkflow:\n zone1-0000000200 (target/-80)\n zone1-0000000210 (target/80-)\n",
},
}
Expand All @@ -445,7 +447,7 @@ func TestWorkflowUpdate(t *testing.T) {
rpcReq := &tabletmanagerdatapb.UpdateVReplicationWorkflowRequest{
Cells: tcase.cells,
TabletTypes: tcase.tabletTypes,
OnDdl: &tcase.onDDL,
OnDdl: tcase.onDDL,
}

_, err := wr.WorkflowAction(ctx, workflow, keyspace, "update", true, rpcReq, nil)
Expand Down

0 comments on commit 6323ffa

Please sign in to comment.