Skip to content

Commit

Permalink
Merge pull request #1922 from bdarnell/remove-range-test
Browse files Browse the repository at this point in the history
Fix TestRaftAfterRemoveRange for #1908.
  • Loading branch information
bdarnell committed Aug 3, 2015
2 parents a373a0c + d8eb121 commit 918cf70
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions storage/client_raft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -830,23 +830,16 @@ func TestRaftAfterRemoveRange(t *testing.T) {
mtc.unreplicateRange(raftID, 0, 2)
mtc.unreplicateRange(raftID, 0, 1)

rng, err := mtc.stores[1].GetRange(raftID)
if err != nil {
t.Fatal(err)
}

// If the range removal happens before the range applies the replica config change, the group
// will be re-created when MultiRaft receives a MsgApp.
if err := util.IsTrueWithin(func() bool {
return len(rng.Desc().Replicas) == 1
}, 1*time.Second); err != nil {
t.Fatal(err)
}

// Remove the range from the second Store.
if err := mtc.stores[1].RemoveRange(rng); err != nil {
t.Fatal(err)
}
// Wait for the removal to be processed.
util.SucceedsWithin(t, time.Second, func() error {
_, err := mtc.stores[1].GetRange(raftID)
if _, ok := err.(*proto.RangeNotFoundError); ok {
return nil
} else if err != nil {
return err
}
return util.Errorf("range still exists")
})

if err := mtc.transport.Send(&multiraft.RaftMessageRequest{
GroupID: proto.RaftID(0),
Expand Down

0 comments on commit 918cf70

Please sign in to comment.