Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Nayak <[email protected]>
  • Loading branch information
rohit-nayak-ps committed Jan 14, 2021
1 parent e891283 commit dcaa521
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions go/vt/wrangler/traffic_switcher_env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,11 @@ func newTestShardMigrater(ctx context.Context, t *testing.T, sourceShards, targe
tme.wr = New(logutil.NewConsoleLogger(), tme.ts, tmclient.NewTabletManagerClient())
tme.sourceShards = sourceShards
tme.targetShards = targetShards
tme.tmeDB = fakesqldb.New(t)

tabletID := 10
for _, shard := range sourceShards {
tme.sourceMasters = append(tme.sourceMasters, newFakeTablet(t, tme.wr, "cell1", uint32(tabletID), topodatapb.TabletType_MASTER, nil, TabletKeyspaceShard(t, "ks", shard)))
tme.sourceMasters = append(tme.sourceMasters, newFakeTablet(t, tme.wr, "cell1", uint32(tabletID), topodatapb.TabletType_MASTER, tme.tmeDB, TabletKeyspaceShard(t, "ks", shard)))
tabletID += 10

_, sourceKeyRange, err := topo.ValidateShardName(shard)
Expand All @@ -261,7 +262,7 @@ func newTestShardMigrater(ctx context.Context, t *testing.T, sourceShards, targe
}

for _, shard := range targetShards {
tme.targetMasters = append(tme.targetMasters, newFakeTablet(t, tme.wr, "cell1", uint32(tabletID), topodatapb.TabletType_MASTER, nil, TabletKeyspaceShard(t, "ks", shard)))
tme.targetMasters = append(tme.targetMasters, newFakeTablet(t, tme.wr, "cell1", uint32(tabletID), topodatapb.TabletType_MASTER, tme.tmeDB, TabletKeyspaceShard(t, "ks", shard)))
tabletID += 10

_, targetKeyRange, err := topo.ValidateShardName(shard)
Expand Down
9 changes: 6 additions & 3 deletions go/vt/wrangler/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ func expectReshardQueries(t *testing.T, tme *testShardMigraterEnv) {
dbclient.addInvariant("select * from _vt.vreplication where id = 1", runningResult(1))
dbclient.addInvariant("select * from _vt.vreplication where id = 2", runningResult(2))
dbclient.addInvariant("insert into _vt.resharding_journal", noResult)

}

targetQueries := []string{
Expand All @@ -442,8 +441,10 @@ func expectReshardQueries(t *testing.T, tme *testShardMigraterEnv) {
dbclient.addInvariant("update _vt.vreplication set message = 'FROZEN'", noResult)
dbclient.addInvariant("delete from _vt.vreplication where id in (1)", noResult)
dbclient.addInvariant("delete from _vt.copy_state where vrepl_id in (1)", noResult)

}
tme.tmeDB.AddQuery("select 1 from _vt.copy_state cs, _vt.vreplication vr where vr.id = cs.vrepl_id and vr.id = 1", noResult)
tme.tmeDB.AddQuery("select 1 from _vt.copy_state cs, _vt.vreplication vr where vr.id = cs.vrepl_id and vr.id = 2", noResult)

}

func expectMoveTablesQueries(t *testing.T, tme *testMigraterEnv) {
Expand Down Expand Up @@ -474,7 +475,6 @@ func expectMoveTablesQueries(t *testing.T, tme *testMigraterEnv) {
"int64|varchar|varchar|varchar|varchar"),
""),
)
//select pos, state, message from _vt.vreplication where id=1
}

for _, dbclient := range tme.dbSourceClients {
Expand Down Expand Up @@ -517,4 +517,7 @@ func expectMoveTablesQueries(t *testing.T, tme *testMigraterEnv) {
tme.tmeDB.AddQuery("drop table vt_ks2.t1", noResult)
tme.tmeDB.AddQuery("drop table vt_ks2.t2", noResult)
tme.tmeDB.AddQuery("update _vt.vreplication set message='Picked source tablet: cell:\"cell1\" uid:10 ' where id=1", noResult)
tme.tmeDB.AddQuery("select 1 from _vt.copy_state cs, _vt.vreplication vr where vr.id = cs.vrepl_id and vr.id = 1", noResult)
tme.tmeDB.AddQuery("select 1 from _vt.copy_state cs, _vt.vreplication vr where vr.id = cs.vrepl_id and vr.id = 2", noResult)

}

0 comments on commit dcaa521

Please sign in to comment.