You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by go...@apache.org on 2018/06/25 18:55:46 UTC

[geode] branch develop updated: Write a test that hangs without the fix for GEODE-3563. (#2057)

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

gosullivan 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 880a9d6  Write a test that hangs without the fix for GEODE-3563. (#2057)
880a9d6 is described below

commit 880a9d614d1ac2418c5bace4fdbb8e255ab8e3dd
Author: Galen O'Sullivan <go...@pivotal.io>
AuthorDate: Mon Jun 25 11:55:41 2018 -0700

    Write a test that hangs without the fix for GEODE-3563. (#2057)
    
    Write a test that hangs without the fix for GEODE-3563.
    
    and remove an unneeded rule.
    
    Signed-off-by: Bruce Schuchardt <bs...@pivotal.io>
---
 .../geode/internal/tcp/TCPConduitDUnitTest.java    | 128 +++++++++++++++++++++
 .../geode/test/dunit/DistributedTestUtils.java     |  17 ++-
 2 files changed, 136 insertions(+), 9 deletions(-)

diff --git a/geode-core/src/test/java/org/apache/geode/internal/tcp/TCPConduitDUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/tcp/TCPConduitDUnitTest.java
new file mode 100644
index 0000000..55f3055
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/tcp/TCPConduitDUnitTest.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.tcp;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import org.awaitility.Awaitility;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import org.apache.geode.distributed.ConfigurationProperties;
+import org.apache.geode.distributed.DistributedSystem;
+import org.apache.geode.distributed.Locator;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.distributed.internal.SerialAckedMessage;
+import org.apache.geode.test.dunit.DistributedTestCase;
+import org.apache.geode.test.dunit.DistributedTestUtils;
+import org.apache.geode.test.dunit.IgnoredException;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory;
+import org.apache.geode.util.test.TestUtil;
+
+
+@Category(DistributedTest.class)
+@RunWith(Parameterized.class)
+@Parameterized.UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class)
+public class TCPConduitDUnitTest extends DistributedTestCase {
+  public static final String TEST_REGION = "testRegion";
+  private final Properties properties;
+
+  @Parameterized.Parameters
+  public static Collection<Properties> data() {
+    Properties nonSSL = new Properties();
+    nonSSL.setProperty(ConfigurationProperties.SOCKET_LEASE_TIME, "1000");
+    nonSSL.setProperty(ConfigurationProperties.DISABLE_AUTO_RECONNECT, "true");
+
+    Properties SSL = new Properties();
+    SSL.putAll(nonSSL);
+
+    final String keystorePath = TestUtil.getResourcePath(TCPConduitDUnitTest.class,
+        "/org/apache/geode/cache/client/internal/default.keystore");
+
+    SSL.setProperty(ConfigurationProperties.SSL_ENABLED_COMPONENTS, "cluster");
+    SSL.setProperty(ConfigurationProperties.SSL_KEYSTORE, keystorePath);
+    SSL.setProperty(ConfigurationProperties.SSL_KEYSTORE_PASSWORD, "password");
+    SSL.setProperty(ConfigurationProperties.SSL_TRUSTSTORE, keystorePath);
+    SSL.setProperty(ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD, "password");
+
+    return Arrays.asList(nonSSL, SSL);
+  }
+
+  public TCPConduitDUnitTest(Properties properties) {
+    this.properties = properties;
+  }
+
+  /**
+   * This was a bug where SSL connections were being configured with a timeout that was non-zero,
+   * but didn't handle socket timeouts. This resulted in a permanently hung P2P socket.
+   *
+   * We set the lease time to 1000, which in that case would cause the socket to break in 1 second.
+   */
+  @Test
+  public void basicAcceptConnection() throws Exception {
+    final VM vm1 = VM.getVM(1);
+    final VM vm2 = VM.getVM(2);
+    final VM vm3 = VM.getVM(3);
+
+    disconnectAllFromDS();
+
+    int port = startLocator();
+    properties.put(ConfigurationProperties.LOCATORS, "localhost[" + port + "]");
+
+    vm1.invoke(() -> startServer(properties));
+    vm2.invoke(() -> startServer(properties));
+    vm3.invoke(() -> startServer(properties));
+
+    Thread.sleep(5000);
+
+    try {
+      Awaitility.await("for message to be sent").atMost(10, TimeUnit.SECONDS).until(() -> {
+        final SerialAckedMessage serialAckedMessage = new SerialAckedMessage();
+        serialAckedMessage.send(system.getAllOtherMembers(), false);
+        return true;
+      });
+    } finally {
+      // DUnit won't clean up properly if the sockets are hung; we have to crash the systems.
+      IgnoredException.addIgnoredException("ForcedDisconnectException|loss of quorum");
+      for (VM vm : Arrays.asList(vm1, vm2, vm3)) {
+        vm.invoke("crash system in case it's hung", () -> {
+          if (system != null && system.isConnected()) {
+            DistributedTestUtils.crashDistributedSystem(system);
+          }
+        });
+      }
+      DistributedTestUtils.crashDistributedSystem(system);
+    }
+  }
+
+  private int startLocator() throws Exception {
+    Locator locator = Locator.startLocatorAndDS(0, new File(""), properties);
+    system = (InternalDistributedSystem) locator.getDistributedSystem();
+    return locator.getPort();
+  }
+
+  private void startServer(Properties properties) throws IOException {
+    system = (InternalDistributedSystem) DistributedSystem.connect(properties);
+  }
+}
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java b/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java
index 8010ecf..5d7e135 100755
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java
@@ -93,12 +93,13 @@ public class DistributedTestUtils {
    * NOTE: if you use this method be sure that you clean up the VM before the end of your test with
    * disconnectFromDS() or disconnectAllFromDS().
    */
-  public static boolean crashDistributedSystem(final VM vm) {
-    return vm.invoke(() -> {
-      DistributedSystem system = InternalDistributedSystem.getAnyInstance();
-      crashDistributedSystem(system);
-      return true;
-    });
+  public static void crashDistributedSystem(final VM... vms) {
+    for (VM vm : vms) {
+      vm.invoke(() -> {
+        DistributedSystem system = InternalDistributedSystem.getAnyInstance();
+        crashDistributedSystem(system);
+      });
+    }
   }
 
   /**
@@ -122,9 +123,7 @@ public class DistributedTestUtils {
       dsProperties.put(DISABLE_AUTO_RECONNECT, "true");
     }
 
-    for (Iterator<Map.Entry<Object, Object>> iterator = properties.entrySet().iterator(); iterator
-        .hasNext();) {
-      Map.Entry<Object, Object> entry = iterator.next();
+    for (Map.Entry<Object, Object> entry : properties.entrySet()) {
       String key = (String) entry.getKey();
       Object value = entry.getValue();
       dsProperties.put(key, value);