From d8eb121f03f59c797807d68e4c044ffc014c458e Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Mon, 3 Aug 2015 17:40:06 -0400 Subject: [PATCH] Fix TestRaftAfterRemoveRange for #1908. Now that the range removes itself we don't need to call RemoveRange again in this test. Fixes #1921. --- storage/client_raft_test.go | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/storage/client_raft_test.go b/storage/client_raft_test.go index db772f489697..f68463aa9e7a 100644 --- a/storage/client_raft_test.go +++ b/storage/client_raft_test.go @@ -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),