From ca6e54890cfb56f74b584dff259fff53cb9a1d11 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 20 Aug 2015 12:38:48 +0100 Subject: [PATCH 1/2] Fix Transfer() when removing a peer, so we actually target the other peer. --- ipam/ring/ring_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipam/ring/ring_test.go b/ipam/ring/ring_test.go index 7c23ccdd48..94b5c77c21 100644 --- a/ipam/ring/ring_test.go +++ b/ipam/ring/ring_test.go @@ -650,7 +650,7 @@ func TestFuzzRingHard(t *testing.T) { } common.Debug.Printf("%s: transferring from peer %s", otherPeername, peername) - otherRing.Transfer(peername, peername) + otherRing.Transfer(peername, otherPeername) // And now tell everyone about the transfer - rmpeer is // not partition safe From 135c34a45aac85489b7f5f5238f3bb4d9c0ce128 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 20 Aug 2015 13:07:16 +0100 Subject: [PATCH 2/2] Don't remove peer from table until after we've copied its entries out --- ipam/ring/ring_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ipam/ring/ring_test.go b/ipam/ring/ring_test.go index 94b5c77c21..89a766bc56 100644 --- a/ipam/ring/ring_test.go +++ b/ipam/ring/ring_test.go @@ -588,7 +588,7 @@ func TestFuzzRing(t *testing.T) { } func TestFuzzRingHard(t *testing.T) { - //common.InitDefaultLogging(true) + //common.SetLogLevel("debug") var ( numPeers = 100 iterations = 3000 @@ -635,13 +635,8 @@ func TestFuzzRingHard(t *testing.T) { return } + // Pick one peer to remove, and a different one to transfer to peerIndex, peername, _ := randomPeer(-1) - // Remove peer from our state - peers = append(peers[:peerIndex], peers[peerIndex+1:]...) - rings = append(rings[:peerIndex], rings[peerIndex+1:]...) - theRanges = make(map[int][]address.Range) - - // Transfer the space for this peer on another peer, but not this one _, otherPeername, otherRing := randomPeer(peerIndex) // We need to be in a ~converged ring to rmpeer @@ -652,6 +647,11 @@ func TestFuzzRingHard(t *testing.T) { common.Debug.Printf("%s: transferring from peer %s", otherPeername, peername) otherRing.Transfer(peername, otherPeername) + // Remove peer from our state + peers = append(peers[:peerIndex], peers[peerIndex+1:]...) + rings = append(rings[:peerIndex], rings[peerIndex+1:]...) + theRanges = make(map[int][]address.Range) + // And now tell everyone about the transfer - rmpeer is // not partition safe for i, ring := range rings {