Skip to content

Commit

Permalink
vreplication: fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Vicent Marti <[email protected]>
  • Loading branch information
vmg committed Oct 4, 2023
1 parent 444ab9a commit 02f428f
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions go/vt/vttablet/tabletmanager/vreplication/vreplicator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,47 +286,47 @@ func TestDeferSecondaryKeys(t *testing.T) {
tableName: "t1",
initialDDL: "create table t1 (id int not null, c1 int default null, primary key (id), key c1 (c1))",
strippedDDL: "create table t1 (id int not null, c1 int default null, primary key (id))",
actionDDL: "alter table %s.t1 add key c1 (c1)",
actionDDL: "alter table %s.t1 add index c1 (c1)",
WorkflowType: int32(binlogdatapb.VReplicationWorkflowType_Reshard),
},
{
name: "2SK",
tableName: "t1",
initialDDL: "create table t1 (id int not null, c1 int default null, c2 int default null, primary key (id), key c1 (c1), key c2 (c2))",
strippedDDL: "create table t1 (id int not null, c1 int default null, c2 int default null, primary key (id))",
actionDDL: "alter table %s.t1 add key c1 (c1), add key c2 (c2)",
actionDDL: "alter table %s.t1 add index c1 (c1), add index c2 (c2)",
WorkflowType: int32(binlogdatapb.VReplicationWorkflowType_MoveTables),
},
{
name: "2tSK",
tableName: "t1",
initialDDL: "create table t1 (id int not null, c1 varchar(10) default null, c2 varchar(10) default null, primary key (id), key c1_c2 (c1,c2), key c2 (c2))",
strippedDDL: "create table t1 (id int not null, c1 varchar(10) default null, c2 varchar(10) default null, primary key (id))",
actionDDL: "alter table %s.t1 add key c1_c2 (c1, c2), add key c2 (c2)",
actionDDL: "alter table %s.t1 add index c1_c2 (c1, c2), add index c2 (c2)",
WorkflowType: int32(binlogdatapb.VReplicationWorkflowType_MoveTables),
},
{
name: "2FPK2SK",
tableName: "t1",
initialDDL: "create table t1 (id int not null, c1 varchar(10) not null, c2 varchar(10) default null, primary key (id,c1), key c1_c2 (c1,c2), key c2 (c2))",
strippedDDL: "create table t1 (id int not null, c1 varchar(10) not null, c2 varchar(10) default null, primary key (id,c1))",
actionDDL: "alter table %s.t1 add key c1_c2 (c1, c2), add key c2 (c2)",
actionDDL: "alter table %s.t1 add index c1_c2 (c1, c2), add index c2 (c2)",
WorkflowType: int32(binlogdatapb.VReplicationWorkflowType_MoveTables),
},
{
name: "3FPK1SK",
tableName: "t1",
initialDDL: "create table t1 (id int not null, c1 varchar(10) not null, c2 varchar(10) not null, primary key (id,c1,c2), key c2 (c2))",
strippedDDL: "create table t1 (id int not null, c1 varchar(10) not null, c2 varchar(10) not null, primary key (id,c1,c2))",
actionDDL: "alter table %s.t1 add key c2 (c2)",
actionDDL: "alter table %s.t1 add index c2 (c2)",
WorkflowType: int32(binlogdatapb.VReplicationWorkflowType_Reshard),
},
{
name: "3FPK1SK_ShardMerge",
tableName: "t1",
initialDDL: "create table t1 (id int not null, c1 varchar(10) not null, c2 varchar(10) not null, primary key (id,c1,c2), key c2 (c2))",
strippedDDL: "create table t1 (id int not null, c1 varchar(10) not null, c2 varchar(10) not null, primary key (id,c1,c2))",
actionDDL: "alter table %s.t1 add key c2 (c2)",
actionDDL: "alter table %s.t1 add index c2 (c2)",
postStashHook: func() error {
myid := id + 1000
// Insert second vreplication record to simulate a second controller/vreplicator
Expand All @@ -343,7 +343,7 @@ func TestDeferSecondaryKeys(t *testing.T) {
// when this is called there's no secondary keys to stash anymore.
addlAction, err := json.Marshal(PostCopyAction{
Type: PostCopyActionSQL,
Task: fmt.Sprintf("alter table %s.t1 add key c2 (c2)", dbName),
Task: fmt.Sprintf("alter table %s.t1 add index c2 (c2)", dbName),
})
if err != nil {
return err
Expand All @@ -366,34 +366,34 @@ func TestDeferSecondaryKeys(t *testing.T) {
tableName: "t1",
initialDDL: "create table t1 (id int not null, c1 varchar(10) default null, c2 varchar(10) default null, key c1_c2 (c1,c2), key c2 (c2))",
strippedDDL: "create table t1 (id int not null, c1 varchar(10) default null, c2 varchar(10) default null)",
actionDDL: "alter table %s.t1 add key c1_c2 (c1, c2), add key c2 (c2)",
actionDDL: "alter table %s.t1 add index c1_c2 (c1, c2), add index c2 (c2)",
WorkflowType: int32(binlogdatapb.VReplicationWorkflowType_MoveTables),
},
{
name: "2SKRetryNoErr",
tableName: "t1",
initialDDL: "create table t1 (id int not null, c1 int default null, c2 int default null, primary key (id), key c1 (c1), key c2 (c2))",
strippedDDL: "create table t1 (id int not null, c1 int default null, c2 int default null, primary key (id))",
intermediateDDL: "alter table %s.t1 add key c1 (c1), add key c2 (c2)",
actionDDL: "alter table %s.t1 add key c1 (c1), add key c2 (c2)",
intermediateDDL: "alter table %s.t1 add index c1 (c1), add index c2 (c2)",
actionDDL: "alter table %s.t1 add index c1 (c1), add index c2 (c2)",
WorkflowType: int32(binlogdatapb.VReplicationWorkflowType_MoveTables),
},
{
name: "2SKRetryNoErr2",
tableName: "t1",
initialDDL: "create table t1 (id int not null, c1 int default null, c2 int default null, primary key (id), key c1 (c1), key c2 (c2))",
strippedDDL: "create table t1 (id int not null, c1 int default null, c2 int default null, primary key (id))",
intermediateDDL: "alter table %s.t1 add key c2 (c2), add key c1 (c1)",
actionDDL: "alter table %s.t1 add key c1 (c1), add key c2 (c2)",
intermediateDDL: "alter table %s.t1 add index c2 (c2), add index c1 (c1)",
actionDDL: "alter table %s.t1 add index c1 (c1), add index c2 (c2)",
WorkflowType: int32(binlogdatapb.VReplicationWorkflowType_MoveTables),
},
{
name: "SKSuperSetNoErr", // a superset of the original keys is allowed
tableName: "t1",
initialDDL: "create table t1 (id int not null, c1 int default null, c2 int default null, primary key (id), key c1 (c1), key c2 (c2))",
strippedDDL: "create table t1 (id int not null, c1 int default null, c2 int default null, primary key (id))",
intermediateDDL: "alter table %s.t1 add unique key c1_c2 (c1,c2), add key c2 (c2), add key c1 (c1)",
actionDDL: "alter table %s.t1 add key c1 (c1), add key c2 (c2)",
intermediateDDL: "alter table %s.t1 add unique index c1_c2 (c1,c2), add index c2 (c2), add index c1 (c1)",
actionDDL: "alter table %s.t1 add index c1 (c1), add index c2 (c2)",
WorkflowType: int32(binlogdatapb.VReplicationWorkflowType_MoveTables),
expectFinalSchemaDiff: true,
},
Expand All @@ -402,8 +402,8 @@ func TestDeferSecondaryKeys(t *testing.T) {
tableName: "t1",
initialDDL: "create table t1 (id int not null, c1 int default null, c2 int default null, primary key (id), key c1 (c1), key c2 (c2))",
strippedDDL: "create table t1 (id int not null, c1 int default null, c2 int default null, primary key (id))",
intermediateDDL: "alter table %s.t1 add key c2 (c2)",
actionDDL: "alter table %s.t1 add key c1 (c1), add key c2 (c2)",
intermediateDDL: "alter table %s.t1 add index c2 (c2)",
actionDDL: "alter table %s.t1 add index c1 (c1), add index c2 (c2)",
WorkflowType: int32(binlogdatapb.VReplicationWorkflowType_MoveTables),
wantExecErr: "Duplicate key name 'c2' (errno 1061) (sqlstate 42000)",
},
Expand All @@ -412,8 +412,8 @@ func TestDeferSecondaryKeys(t *testing.T) {
tableName: "t1",
initialDDL: "create table t1 (id int not null, c1 int default null, c2 int default null, primary key (id), key c1 (c1), key c2 (c2))",
strippedDDL: "create table t1 (id int not null, c1 int default null, c2 int default null, primary key (id))",
intermediateDDL: "alter table %s.t1 add key c1 (c1)",
actionDDL: "alter table %s.t1 add key c1 (c1), add key c2 (c2)",
intermediateDDL: "alter table %s.t1 add index c1 (c1)",
actionDDL: "alter table %s.t1 add index c1 (c1), add index c2 (c2)",
WorkflowType: int32(binlogdatapb.VReplicationWorkflowType_MoveTables),
wantExecErr: "Duplicate key name 'c1' (errno 1061) (sqlstate 42000)",
},
Expand Down Expand Up @@ -578,9 +578,9 @@ func TestCancelledDeferSecondaryKeys(t *testing.T) {
getActionsSQLf := "select action from _vt.post_copy_action where vrepl_id=%d and table_name='%s'"

tableName := "t1"
ddl := fmt.Sprintf("create table %s.t1 (id int not null, c1 int default null, c2 int default null, primary key(id), key c1 (c1), key c2 (c2))", dbName)
ddl := fmt.Sprintf("create table %s.t1 (id int not null, c1 int default null, c2 int default null, primary key(id), index c1 (c1), index c2 (c2))", dbName)
withoutPKs := "create table t1 (id int not null, c1 int default null, c2 int default null, primary key(id))"
alter := fmt.Sprintf("alter table %s.t1 add key c1 (c1), add key c2 (c2)", dbName)
alter := fmt.Sprintf("alter table %s.t1 add index c1 (c1), add index c2 (c2)", dbName)

// Create the table.
_, err = dbClient.ExecuteFetch(ddl, 1)
Expand Down

0 comments on commit 02f428f

Please sign in to comment.