geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bschucha...@apache.org
Subject [3/3] incubator-geode git commit: GEODE-77 modified two tests to account for background thread timed-wait, and modified a second to create temp files in /etc on non-Windows machines
Date Wed, 09 Sep 2015 18:46:00 GMT
GEODE-77 modified two tests to account for background thread timed-wait,
and modified a second to create temp files in /etc on non-Windows machines


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/299966d7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/299966d7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/299966d7

Branch: refs/heads/feature/GEODE-77
Commit: 299966d7af04838dfa0651adda22e63100b92281
Parents: ae43aca
Author: Bruce Schuchardt <bschuchardt@pivotal.io>
Authored: Wed Sep 9 11:43:44 2015 -0700
Committer: Bruce Schuchardt <bschuchardt@pivotal.io>
Committed: Wed Sep 9 11:44:29 2015 -0700

----------------------------------------------------------------------
 .../internal/membership/gms/fd/GMSHealthMonitor.java  |  2 +-
 .../internal/membership/gms/locator/GMSLocator.java   |  6 +++++-
 .../membership/gms/membership/GMSJoinLeave.java       |  2 +-
 .../membership/gms/locator/GMSLocatorJUnitTest.java   | 14 +++++++++++++-
 .../gms/membership/GMSHealthMonitorJUnitTest.java     |  9 +++------
 .../gms/membership/GMSJoinLeaveJUnitTest.java         |  1 +
 6 files changed, 24 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/299966d7/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
index 613299a..c6f1e02 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
@@ -79,7 +79,7 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler {
       "geode.logical-message-received-interval", 10) : 10;
 
   /** stall time to wait for members leaving concurrently */
-  private static final long MEMBER_SUSPECT_COLLECTION_INTERVAL = Long.getLong("geode.suspect-member-collection-interval",
200);
+  public static final long MEMBER_SUSPECT_COLLECTION_INTERVAL = Long.getLong("geode.suspect-member-collection-interval",
200);
 
   /**
    * If member don't see any activity from particular member then it sends check request

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/299966d7/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocator.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocator.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocator.java
index 66aa0a9..3296b80 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocator.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocator.java
@@ -305,7 +305,11 @@ public class GMSLocator implements Locator, NetLocator {
         ois2 = new VersionedObjectInput(ois2, geodeVersion);
       }
     
-      this.view = DataSerializer.readObject(ois2);
+      Object o = DataSerializer.readObject(ois2);
+      if (!(o instanceof NetView)) {
+        return false;
+      }
+      this.view = (NetView)o;
       logger.info("Peer locator initial membership is " + view);
       return true;
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/299966d7/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
index 8844b23..b248f1b 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
@@ -78,7 +78,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
   private static final int VIEW_INSTALLATION_TIMEOUT = Integer.getInteger("gemfire.view-ack-timeout",
12500);
 
   /** stall time to wait for concurrent join/leave/remove requests to be received */
-  private static final long MEMBER_REQUEST_COLLECTION_INTERVAL = Long.getLong("gemfire.member-request-collection-interval",
2000);
+  public static final long MEMBER_REQUEST_COLLECTION_INTERVAL = Long.getLong("gemfire.member-request-collection-interval",
2000);
 
   /** time to wait for a leave request to be transmitted by jgroups */
   private static final long LEAVE_MESSAGE_SLEEP_TIME = Long.getLong("gemfire.leave-message-sleep-time",
4000);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/299966d7/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorJUnitTest.java
index 048dd65..35a6e13 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorJUnitTest.java
@@ -14,6 +14,7 @@ import com.gemstone.gemfire.distributed.internal.membership.MemberFactory;
 import com.gemstone.gemfire.distributed.internal.membership.MembershipManager;
 import com.gemstone.gemfire.distributed.internal.membership.NetView;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.internal.OSProcess;
 import com.gemstone.gemfire.internal.SocketCreator;
 import com.gemstone.gemfire.internal.Version;
 import com.gemstone.gemfire.internal.admin.remote.RemoteTransportConfig;
@@ -42,7 +43,18 @@ public class GMSLocatorJUnitTest {
 
   @Before
   public void setUp() throws Exception {
-    tempStateFile = File.createTempFile("tempLocator-", ".dat", new File(""));
+    String directory = "";
+    boolean isWindows = false;
+    String os = System.getProperty("os.name");
+    if (os != null) {
+      if (os.indexOf("Windows") != -1) {
+        isWindows = true;
+      }
+    }
+    if (!isWindows) {
+      directory = "/etc/";
+    }
+    tempStateFile = File.createTempFile(directory+"tempLocator-", ".dat", new File(""));
     locator = new GMSLocator(null, tempStateFile, null, false, false, new LocatorStats());
     // System.out.println("temp state file: " + tempStateFile);
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/299966d7/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSHealthMonitorJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSHealthMonitorJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSHealthMonitorJUnitTest.java
index e7962a3..079bbb7 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSHealthMonitorJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSHealthMonitorJUnitTest.java
@@ -225,7 +225,7 @@ public class GMSHealthMonitorJUnitTest {
    * Checks whether suspect thread sends suspectMembers message
    */
   @Test
-  public void testSuspectMembersCalledThroughSuspectThread() {
+  public void testSuspectMembersCalledThroughSuspectThread() throws Exception {
     NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new ArrayList<InternalDistributedMember>(),
new ArrayList<InternalDistributedMember>());
     
     MethodExecuted messageSent = new MethodExecuted();
@@ -238,11 +238,8 @@ public class GMSHealthMonitorJUnitTest {
 
     when(messenger.send(any(SuspectMembersMessage.class))).thenAnswer(messageSent);
 
-    try {
-      // suspect thread timeout is 200 ms
-      Thread.sleep(300l);
-    } catch (InterruptedException e) {
-    }
+    Thread.sleep(GMSHealthMonitor.MEMBER_SUSPECT_COLLECTION_INTERVAL + 1000);
+
     Assert.assertTrue("SuspectMembersMessage should have sent", messageSent.isMethodExecuted());
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/299966d7/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
index 822e074..bb5abe7 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
@@ -177,6 +177,7 @@ public class GMSJoinLeaveJUnitTest {
     MethodExecuted removeMessageSent = new MethodExecuted();
     when(messenger.send(any(RemoveMemberMessage.class))).thenAnswer(removeMessageSent);
     gmsJoinLeave.remove(mockMembers[1], "removing for test");
+    Thread.sleep(GMSJoinLeave.MEMBER_REQUEST_COLLECTION_INTERVAL*2);
     assert removeMessageSent.methodExecuted;
   }
   


Mime
View raw message