GEODE-3251: make JMX test rules more robust Add "Failed to retrieve RMIServer stub" to rule await to help ensure that JMX RMI is ready before running the test.
Project: http://git-wip-us.apache.org/repos/asf/geode/repo Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/b6b92f6a Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/b6b92f6a Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/b6b92f6a Branch: refs/heads/feature/GEODE-3251 Commit: b6b92f6ac879643c480471e17cb5f61a042b2ad7 Parents: ef688c8 Author: Kirk Lund <kl...@apache.org> Authored: Wed Jul 19 10:09:51 2017 -0700 Committer: Kirk Lund <kl...@apache.org> Committed: Thu Jul 20 10:06:17 2017 -0700 ---------------------------------------------------------------------- .../DiskStoreMXBeanSecurityJUnitTest.java | 25 +++++++++----------- .../dunit/rules/GfshShellConnectionRule.java | 5 ++-- .../dunit/rules/MBeanServerConnectionRule.java | 3 ++- 3 files changed, 16 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode/blob/b6b92f6a/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java index 4d101e7..bc81e16 100644 --- a/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java @@ -17,7 +17,6 @@ package org.apache.geode.management.internal.security; import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import org.assertj.core.api.SoftAssertions; import org.junit.Before; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -35,6 +34,7 @@ import org.apache.geode.test.junit.categories.SecurityTest; @Category({IntegrationTest.class, SecurityTest.class}) public class DiskStoreMXBeanSecurityJUnitTest { + private DiskStoreMXBean bean; @ClassRule @@ -114,28 +114,25 @@ public class DiskStoreMXBeanSecurityJUnitTest { @Test @ConnectionConfiguration(user = "noAccess", password = "noAccess") public void testNoAccess() throws Exception { - SoftAssertions softly = new SoftAssertions(); - - softly.assertThatThrownBy(() -> bean.flush()) + assertThatThrownBy(() -> bean.flush()) .hasMessageContaining(TestCommand.clusterManageDisk.toString()); - softly.assertThatThrownBy(() -> bean.forceCompaction()) + assertThatThrownBy(() -> bean.forceCompaction()) .hasMessageContaining(TestCommand.clusterManageDisk.toString()); - softly.assertThatThrownBy(() -> bean.forceRoll()) + assertThatThrownBy(() -> bean.forceRoll()) .hasMessageContaining(TestCommand.clusterManageDisk.toString()); - softly.assertThatThrownBy(() -> bean.getCompactionThreshold()) + assertThatThrownBy(() -> bean.getCompactionThreshold()) .hasMessageContaining(TestCommand.clusterRead.toString()); - softly.assertThatThrownBy(() -> bean.getDiskDirectories()) + assertThatThrownBy(() -> bean.getDiskDirectories()) .hasMessageContaining(TestCommand.clusterRead.toString()); - softly.assertThatThrownBy(() -> bean.getDiskReadsRate()) + assertThatThrownBy(() -> bean.getDiskReadsRate()) .hasMessageContaining(TestCommand.clusterRead.toString()); - softly.assertThatThrownBy(() -> bean.isAutoCompact()) + assertThatThrownBy(() -> bean.isAutoCompact()) .hasMessageContaining(TestCommand.clusterRead.toString()); - softly.assertThatThrownBy(() -> bean.isForceCompactionAllowed()) + assertThatThrownBy(() -> bean.isForceCompactionAllowed()) .hasMessageContaining(TestCommand.clusterRead.toString()); - softly.assertThatThrownBy(() -> bean.setDiskUsageCriticalPercentage(0.5f)) + assertThatThrownBy(() -> bean.setDiskUsageCriticalPercentage(0.5f)) .hasMessageContaining(TestCommand.clusterManageDisk.toString()); - softly.assertThatThrownBy(() -> bean.setDiskUsageWarningPercentage(0.5f)) + assertThatThrownBy(() -> bean.setDiskUsageWarningPercentage(0.5f)) .hasMessageContaining(TestCommand.clusterManageDisk.toString()); - softly.assertAll(); } } http://git-wip-us.apache.org/repos/asf/geode/blob/b6b92f6a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java index 872553e..100c753 100644 --- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java +++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java @@ -161,10 +161,11 @@ public class GfshShellConnectionRule extends DescribedExternalResource { CommandResult result = null; for (int i = 0; i < 50; i++) { result = executeCommand(connectCommand.toString()); - if (!gfsh.outputString.contains("no such object in table")) { + if (!gfsh.outputString.contains("no such object in table") + && !gfsh.outputString.contains("Failed to retrieve RMIServer stub")) { break; } - Thread.currentThread().sleep(2000); + Thread.sleep(2000); } connected = (result.getStatus() == Result.Status.OK); } http://git-wip-us.apache.org/repos/asf/geode/blob/b6b92f6a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MBeanServerConnectionRule.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MBeanServerConnectionRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MBeanServerConnectionRule.java index 3addc4e..9116af5 100644 --- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MBeanServerConnectionRule.java +++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MBeanServerConnectionRule.java @@ -165,7 +165,8 @@ public class MBeanServerConnectionRule extends DescribedExternalResource { try { jmxConnector = JMXConnectorFactory.connect(url, env); } catch (Exception e) { - if (e.getMessage().contains("no such object in table")) { + if (e.getMessage().contains("no such object in table") + || e.getMessage().contains("Failed to retrieve RMIServer stub")) { // keep waiting return false; }