GEODE-3052 Restarting 2 locators together causes potential locator split brain
The fix for this issue introduced different timing in GMSJoinLeave's discovery process that affected one of the unit tests for that class, causing periodic failures. I've added an Awaitility.await() to stabilize the test. Project: http://git-wip-us.apache.org/repos/asf/geode/repo Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/0254a60f Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/0254a60f Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/0254a60f Branch: refs/heads/feature/GEODE-3109 Commit: 0254a60f5939b537284aba4a59a7cff4da5f3fc4 Parents: d08a75b Author: Bruce Schuchardt <[email protected]> Authored: Wed Jun 28 10:39:58 2017 -0700 Committer: Bruce Schuchardt <[email protected]> Committed: Wed Jun 28 10:39:58 2017 -0700 ---------------------------------------------------------------------- .../gms/membership/GMSJoinLeaveJUnitTest.java | 43 +++++++++----------- 1 file changed, 20 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode/blob/0254a60f/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java index a31fa8d..2c7f9d9 100644 --- a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java @@ -1196,29 +1196,26 @@ public class GMSJoinLeaveJUnitTest { @Test public void testCoordinatorFindRequestSuccess() throws Exception { - try { - initMocks(false); - HashSet<InternalDistributedMember> registrants = new HashSet<>(); - registrants.add(mockMembers[0]); - FindCoordinatorResponse fcr = new FindCoordinatorResponse(mockMembers[0], mockMembers[0], - false, null, registrants, false, true, null); - NetView view = createView(); - JoinResponseMessage jrm = new JoinResponseMessage(mockMembers[0], view, 0); - - TcpClientWrapper tcpClientWrapper = mock(TcpClientWrapper.class); - gmsJoinLeave.setTcpClientWrapper(tcpClientWrapper); - FindCoordinatorRequest fcreq = - new FindCoordinatorRequest(gmsJoinLeaveMemberId, new HashSet<>(), -1, null, 0, ""); - int connectTimeout = (int) services.getConfig().getMemberTimeout() * 2; - when(tcpClientWrapper.sendCoordinatorFindRequest(new InetSocketAddress("localhost", 12345), - fcreq, connectTimeout)).thenReturn(fcr); - callAsnyc(() -> { - gmsJoinLeave.installView(view); - }); - assertTrue("Should be able to join ", gmsJoinLeave.join()); - } finally { - - } + initMocks(false); + HashSet<InternalDistributedMember> registrants = new HashSet<>(); + registrants.add(mockMembers[0]); + FindCoordinatorResponse fcr = new FindCoordinatorResponse(mockMembers[0], mockMembers[0], + false, null, registrants, false, true, null); + NetView view = createView(); + JoinResponseMessage jrm = new JoinResponseMessage(mockMembers[0], view, 0); + + TcpClientWrapper tcpClientWrapper = mock(TcpClientWrapper.class); + gmsJoinLeave.setTcpClientWrapper(tcpClientWrapper); + FindCoordinatorRequest fcreq = + new FindCoordinatorRequest(gmsJoinLeaveMemberId, new HashSet<>(), -1, null, 0, ""); + int connectTimeout = (int) services.getConfig().getMemberTimeout() * 2; + when(tcpClientWrapper.sendCoordinatorFindRequest(new InetSocketAddress("localhost", 12345), + fcreq, connectTimeout)).thenReturn(fcr); + callAsnyc(() -> { + gmsJoinLeave.installView(view); + }); + Awaitility.await().atMost(10, TimeUnit.SECONDS).until (() -> + assertTrue("Should be able to join ", gmsJoinLeave.join())); } private void callAsnyc(Runnable run) {
