You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2018/04/17 01:42:31 UTC

[geode] branch develop updated: GEODE-5080: Ensure that reconnect sequence has started (#1805)

This is an automated email from the ASF dual-hosted git repository.

jensdeppe pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 3e49318  GEODE-5080: Ensure that reconnect sequence has started (#1805)
3e49318 is described below

commit 3e4931858487a0b6ae1e23218dbf806c5f9f1359
Author: Jens Deppe <jd...@pivotal.io>
AuthorDate: Mon Apr 16 18:42:27 2018 -0700

    GEODE-5080: Ensure that reconnect sequence has started (#1805)
---
 .../ClusterConfigLocatorRestartDUnitTest.java      | 31 ++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigLocatorRestartDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigLocatorRestartDUnitTest.java
index a96e3ab..113521c 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigLocatorRestartDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigLocatorRestartDUnitTest.java
@@ -43,6 +43,20 @@ public class ClusterConfigLocatorRestartDUnitTest {
   @Rule
   public GfshCommandRule gfsh = new GfshCommandRule();
 
+  public static class TestDisconnectListener
+      implements InternalDistributedSystem.DisconnectListener {
+    static int disconnectCount;
+
+    public TestDisconnectListener() {
+      disconnectCount = 0;
+    }
+
+    @Override
+    public void onDisconnect(InternalDistributedSystem sys) {
+      disconnectCount += 1;
+    }
+  }
+
   @Test
   public void serverRestartsAfterLocatorReconnects() throws Exception {
     IgnoredException.addIgnoredException("org.apache.geode.ForcedDisconnectException: for testing");
@@ -54,6 +68,8 @@ public class ClusterConfigLocatorRestartDUnitTest {
     rule.startServerVM(1, props, locator0.getPort());
     MemberVM server2 = rule.startServerVM(2, props, locator0.getPort());
 
+    addDisconnectListener(locator0);
+
     server2.invokeAsync(() -> MembershipManagerHelper
         .crashDistributedSystem(InternalDistributedSystem.getConnectedInstance()));
     locator0.invokeAsync(() -> MembershipManagerHelper
@@ -100,8 +116,6 @@ public class ClusterConfigLocatorRestartDUnitTest {
     server3.invokeAsync(() -> MembershipManagerHelper
         .crashDistributedSystem(InternalDistributedSystem.getConnectedInstance()));
 
-    waitForLocatorToReconnect(locator1);
-
     rule.startServerVM(4, locator1.getPort(), locator0.getPort());
 
     gfsh.connectAndVerify(locator1);
@@ -111,7 +125,20 @@ public class ClusterConfigLocatorRestartDUnitTest {
             .tableHasColumnOnlyWithValues("Name", "locator-1", "server-2", "server-3", "server-4"));
   }
 
+  private void addDisconnectListener(MemberVM member) {
+    member.invoke(() -> {
+      InternalDistributedSystem ds =
+          (InternalDistributedSystem) InternalLocator.getLocator().getDistributedSystem();
+      ds.addDisconnectListener(new TestDisconnectListener());
+    });
+  }
+
   private void waitForLocatorToReconnect(MemberVM locator) {
+    // Ensure that disconnect/reconnect sequence starts otherwise in the next await we might end up
+    // with the initial locator instead of a newly created one.
+    Awaitility.waitAtMost(30, TimeUnit.SECONDS)
+        .until(() -> locator.invoke(() -> TestDisconnectListener.disconnectCount > 0));
+
     Awaitility.waitAtMost(30, TimeUnit.SECONDS).until(() -> locator.invoke(() -> {
       InternalLocator intLocator = InternalLocator.getLocator();
       return intLocator != null && intLocator.isSharedConfigurationRunning();

-- 
To stop receiving notification emails like this one, please contact
jensdeppe@apache.org.