Skip to content

Commit

Permalink
topo: Add a test for full coverage of the ShardInfo.CheckServedTypesM…
Browse files Browse the repository at this point in the history
…igration method.
  • Loading branch information
michael-berlin committed Oct 4, 2016
1 parent df0f735 commit f6ed050
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go/vt/topo/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ func (si *ShardInfo) CheckServedTypesMigration(tabletType topodatapb.TabletType,
// master is a special case with a few extra checks
if tabletType == topodatapb.TabletType_MASTER {
if len(cells) > 0 {
return fmt.Errorf("cannot migrate only some cells for master in shard %v/%v", si.keyspace, si.shardName)
return fmt.Errorf("cannot migrate only some cells for MASTER in shard %v/%v. Do not specify a list of cells", si.keyspace, si.shardName)
}
if remove && len(si.ServedTypes) > 1 {
// Log which types must be migrated first.
Expand Down
4 changes: 4 additions & 0 deletions go/vt/topo/shard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ func TestUpdateServedTypesMap(t *testing.T) {
t.Fatalf("remove master failed: %v", err)
}
// MASTER
// Migration fails if a list of cells is specified.
if err := si.UpdateServedTypesMap(topodatapb.TabletType_MASTER, []string{"first", "third"}, true); err == nil || err.Error() != "cannot migrate only some cells for MASTER in shard ks/sh. Do not specify a list of cells" {
t.Fatalf("remove master failed: %v", err)
}
if err := si.UpdateServedTypesMap(topodatapb.TabletType_MASTER, nil, true); err != nil {
t.Fatalf("remove master failed: %v", err)
}
Expand Down

0 comments on commit f6ed050

Please sign in to comment.