You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bs...@apache.org on 2017/05/15 18:02:24 UTC

[4/4] geode git commit: GEODE-2853: Change of locator list request interval

GEODE-2853: Change of locator list request interval

Moved the test added to AutoConnectionSourceDUnitTest to
AutoConnectionSourceImplJUnitTest, and revert
AutoConnectionSourceDUnitTest.


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

Branch: refs/heads/develop
Commit: 762666c23e63d1153ccfb902692b9ce9d1a90e4f
Parents: b62b9bc
Author: masaki.yamakawa <ma...@ulsystems.co.jp>
Authored: Fri May 12 22:44:04 2017 +0900
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Mon May 15 11:05:56 2017 -0700

----------------------------------------------------------------------
 .../internal/AutoConnectionSourceDUnitTest.java | 55 --------------------
 .../AutoConnectionSourceImplJUnitTest.java      | 27 ++++++++++
 2 files changed, 27 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/762666c2/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceDUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceDUnitTest.java
index 66679ba..789d326 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceDUnitTest.java
@@ -32,7 +32,6 @@ import org.apache.geode.internal.*;
 import org.apache.geode.internal.cache.*;
 import org.apache.geode.management.membership.*;
 import org.apache.geode.test.dunit.*;
-import org.apache.geode.test.dunit.rules.DistributedRestoreSystemProperties;
 import org.apache.geode.test.junit.categories.*;
 
 /**
@@ -45,10 +44,6 @@ public class AutoConnectionSourceDUnitTest extends LocatorTestBase {
   protected static final Object BRIDGE_LISTENER = "BRIDGE_LISTENER";
   private static final long MAX_WAIT = 60000;
 
-  @Rule
-  public DistributedRestoreSystemProperties restoreSystemProperties =
-      new DistributedRestoreSystemProperties();
-
   @Override
   public final void postSetUp() throws Exception {
     IgnoredException.addIgnoredException("NoAvailableLocatorsException");
@@ -426,40 +421,6 @@ public class AutoConnectionSourceDUnitTest extends LocatorTestBase {
     Assert.assertEquals(0, serverListener.getJoins());
   }
 
-  @Test
-  public void testUpdateLocatorListInterval() throws Exception {
-    final Host host = Host.getHost(0);
-    VM vm0 = host.getVM(0);
-    VM vm1 = host.getVM(1);
-
-    int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    String hostName = NetworkUtils.getServerHostName(vm0.getHost());
-    vm0.invoke("Start Locator", () -> startLocator(hostName, locatorPort, ""));
-
-    Properties props = new Properties();
-    long updateLocatorInterval;
-
-    vm1.invoke("StartBridgeClient", () -> startBridgeClient("group1",
-        NetworkUtils.getServerHostName(vm0.getHost()), locatorPort, props));
-    checkUpdateLocatorListInterval(vm1, 200);
-    stopBridgeMemberVM(vm1);
-
-    updateLocatorInterval = 0;
-    props.setProperty(DistributionConfig.GEMFIRE_PREFIX + "LOCATOR_UPDATE_INTERVAL",
-        String.valueOf(updateLocatorInterval));
-    vm1.invoke("StartBridgeClient", () -> startBridgeClient("group2",
-        NetworkUtils.getServerHostName(vm0.getHost()), locatorPort, props));
-    checkUpdateLocatorListInterval(vm1, updateLocatorInterval);
-    stopBridgeMemberVM(vm1);
-
-    updateLocatorInterval = 543;
-    props.setProperty(DistributionConfig.GEMFIRE_PREFIX + "LOCATOR_UPDATE_INTERVAL",
-        String.valueOf(updateLocatorInterval));
-    vm1.invoke("StartBridgeClient", () -> startBridgeClient("group2",
-        NetworkUtils.getServerHostName(vm0.getHost()), locatorPort, props));
-    checkUpdateLocatorListInterval(vm1, updateLocatorInterval);
-  }
-
   protected Object getInVM(VM vm, final Serializable key) {
     return getInVM(vm, REGION_NAME, key);
   }
@@ -574,22 +535,6 @@ public class AutoConnectionSourceDUnitTest extends LocatorTestBase {
     });
   }
 
-  protected void startBridgeClient(final String group, final String host, final int port,
-      Properties systemProperties) throws Exception {
-    systemProperties.entrySet().forEach(
-        entry -> System.setProperty(entry.getKey().toString(), entry.getValue().toString()));
-    startBridgeClient(group, host, port, new String[] {REGION_NAME});
-  }
-
-  protected void checkUpdateLocatorListInterval(VM vm, final long expected) {
-    vm.invoke(() -> {
-      PoolImpl pool = (PoolImpl) PoolManager.find(POOL_NAME);
-      long actual = AutoConnectionSourceImpl.class.cast(pool.getConnectionSource())
-          .getLocatorUpdateInterval();
-      Assert.assertEquals(expected, actual);
-    });
-  }
-
   protected void addBridgeListener(VM vm) {
     vm.invoke(new SerializableRunnable("Add membership listener") {
       public void run() {

http://git-wip-us.apache.org/repos/asf/geode/blob/762666c2/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java
index 385569c..0213609 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java
@@ -27,6 +27,7 @@ import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.distributed.internal.PoolStatHelper;
 import org.apache.geode.distributed.internal.ServerLocation;
 import org.apache.geode.distributed.internal.ClusterConfigurationService;
+import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.distributed.internal.tcpserver.TcpClient;
 import org.apache.geode.distributed.internal.tcpserver.TcpHandler;
 import org.apache.geode.distributed.internal.tcpserver.TcpServer;
@@ -109,6 +110,7 @@ public class AutoConnectionSourceImplJUnitTest {
 
   @After
   public void tearDown() {
+    System.clearProperty(DistributionConfig.GEMFIRE_PREFIX + "LOCATOR_UPDATE_INTERVAL");
     background.shutdownNow();
     try {
       cache.close();
@@ -239,6 +241,31 @@ public class AutoConnectionSourceImplJUnitTest {
     }
   }
 
+  @Test
+  public void testSysPropLocatorUpdateInterval() throws Exception {
+    long updateLocatorInterval = 543;
+    System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "LOCATOR_UPDATE_INTERVAL",
+        String.valueOf(updateLocatorInterval));
+    source.start(pool);
+    assertEquals(updateLocatorInterval, source.getLocatorUpdateInterval());
+  }
+
+  @Test
+  public void testDefaultLocatorUpdateInterval() throws Exception {
+    long updateLocatorInterval = pool.getPingInterval();
+    source.start(pool);
+    assertEquals(updateLocatorInterval, source.getLocatorUpdateInterval());
+  }
+
+  @Test
+  public void testLocatorUpdateIntervalZero() throws Exception {
+    long updateLocatorInterval = 0;
+    System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "LOCATOR_UPDATE_INTERVAL",
+        String.valueOf(updateLocatorInterval));
+    source.start(pool);
+    assertEquals(updateLocatorInterval, source.getLocatorUpdateInterval());
+  }
+
   private void startFakeLocator() throws UnknownHostException, IOException, InterruptedException {
     server = new TcpServer(port, InetAddress.getLocalHost(), null, null, handler, new FakeHelper(),
         Thread.currentThread().getThreadGroup(), "Tcp Server");