This is an automated email from the ASF dual-hosted git repository. mmartell pushed a commit to branch feature/GEODE-5794-fix in repository https://gitbox.apache.org/repos/asf/geode.git
commit 92a02d869b3d02cef3a23caca6b519a3068801ff Author: Sai Boorlagadda <[email protected]> AuthorDate: Fri Sep 28 15:08:10 2018 -0700 GEODE-5794: fix failing JMXMBeanReconnectDUnitTest Signed-off-by: Jens Deppe <[email protected]> --- .../management/JMXMBeanReconnectDUnitTest.java | 20 +------------ .../apache/geode/test/dunit/rules/MemberVM.java | 34 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/JMXMBeanReconnectDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/JMXMBeanReconnectDUnitTest.java index b7a5c77..7a11953 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/management/JMXMBeanReconnectDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/management/JMXMBeanReconnectDUnitTest.java @@ -18,11 +18,9 @@ package org.apache.geode.management; import static java.util.concurrent.TimeUnit.MINUTES; import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.stream.Collectors.toList; -import static org.apache.geode.internal.lang.SystemUtils.isWindows; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.SoftAssertions.assertSoftly; import static org.awaitility.Awaitility.waitAtMost; -import static org.junit.Assume.assumeFalse; import java.io.IOException; import java.util.List; @@ -100,10 +98,6 @@ public class JMXMBeanReconnectDUnitTest { @Test public void testLocalBeans_MaintainServerAndCrashLocator() { - // TODO: Currently failing on windows and causing CI job to hang. - // TODO: Ignoring these until they are fixed. - assumeFalse(isWindows()); - List<String> initialServerBeans = canonicalBeanNamesFor(server1); locator1.forceDisconnect(); @@ -123,10 +117,6 @@ public class JMXMBeanReconnectDUnitTest { @Test public void testLocalBeans_MaintainLocatorAndCrashServer() { - // TODO: Currently failing on windows and causing CI job to hang. - // TODO: Ignoring these until they are fixed. - assumeFalse(isWindows()); - List<String> initialLocatorBeans = canonicalBeanNamesFor(locator1); server1.forceDisconnect(); @@ -147,10 +137,6 @@ public class JMXMBeanReconnectDUnitTest { @Test public void testRemoteBeanKnowledge_MaintainServerAndCrashLocator() throws IOException { - // TODO: Currently failing on windows and causing CI job to hang. - // TODO: Ignoring these until they are fixed. - assumeFalse(isWindows()); - List<ObjectName> initialLocator1GemfireBeans = getFederatedGemfireBeansFrom(locator1); List<ObjectName> initialLocator2GemfireBeans = @@ -189,10 +175,6 @@ public class JMXMBeanReconnectDUnitTest { @Test public void testRemoteBeanKnowledge_MaintainLocatorAndCrashServer() throws IOException { - // TODO: Currently failing on windows and causing CI job to hang. - // TODO: Ignoring these until they are fixed. - assumeFalse(isWindows()); - List<ObjectName> initialLocator1GemfireBeans = getFederatedGemfireBeansFrom(locator1); List<ObjectName> initialLocator2GemfireBeans = @@ -201,7 +183,7 @@ public class JMXMBeanReconnectDUnitTest { assertThat(initialLocator1GemfireBeans) .containsExactlyElementsOf(initialLocator2GemfireBeans); - server1.forceDisconnect(); + server1.forceDisconnect(2000); List<ObjectName> intermediateLocator1GemfireBeans = getFederatedGemfireBeansFrom(locator1); diff --git a/geode-dunit/src/main/java/org/apache/geode/test/dunit/rules/MemberVM.java b/geode-dunit/src/main/java/org/apache/geode/test/dunit/rules/MemberVM.java index 1fe04c8..06e44e4 100644 --- a/geode-dunit/src/main/java/org/apache/geode/test/dunit/rules/MemberVM.java +++ b/geode-dunit/src/main/java/org/apache/geode/test/dunit/rules/MemberVM.java @@ -16,6 +16,7 @@ package org.apache.geode.test.dunit.rules; import static java.util.concurrent.TimeUnit.SECONDS; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import org.apache.logging.log4j.Logger; @@ -88,6 +89,39 @@ public class MemberVM extends VMProvider implements Member { vm.invoke("force disconnect", () -> ClusterStartupRule.memberStarter.forceDisconnectMember()); } + /** + * This disconnects the distributed system of the member. The reconnect thread will wait for at + * least the given delay before completing the attempt. + * + * @param delayReconnecting minimum delay in milliseconds before reconnect can complete. + */ + public void forceDisconnect(final long delayReconnecting) { + vm.invoke(() -> { + // The reconnect thread can yield the CPU before allowing the listeners to be invoked. The + // latch ensures that the listener is guaranteed to be called before this method returns thus + // ensuring that reconnection has started but not yet completed. + CountDownLatch latch = new CountDownLatch(1); + InternalDistributedSystem.addReconnectListener( + new InternalDistributedSystem.ReconnectListener() { + @Override + public void reconnecting(InternalDistributedSystem oldSystem) { + try { + Thread.sleep(delayReconnecting); + latch.countDown(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + @Override + public void onReconnect(InternalDistributedSystem oldSystem, + InternalDistributedSystem newSystem) {} + }); + ClusterStartupRule.memberStarter.forceDisconnectMember(); + latch.await(); + }); + } + public void waitTilLocatorFullyReconnected() { vm.invoke(() -> { try {
