Repository: incubator-geode Updated Branches: refs/heads/develop bcff8428a -> 285a85307
GEODE-1107 CI failure: RestAPIsWithSSLDUnitTest.testSimpleSSL Enable REST Admin HTTP service. Retry with a different available port, if address is in use. Change the help information of DUnitLauncher, since DistributedTestCase.addExpectedException no longer exists. Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/285a8530 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/285a8530 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/285a8530 Branch: refs/heads/develop Commit: 285a85307f7241ea23f01066ec1b68a5ef23b18e Parents: bcff842 Author: Jianxia Chen <[email protected]> Authored: Fri Mar 25 09:20:06 2016 -0700 Committer: Jianxia Chen <[email protected]> Committed: Fri Mar 25 09:20:06 2016 -0700 ---------------------------------------------------------------------- .../controllers/RestAPIsWithSSLDUnitTest.java | 52 +++++++++++++++++--- .../test/dunit/standalone/DUnitLauncher.java | 4 +- 2 files changed, 48 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/285a8530/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java index 852591f..1d1d883 100644 --- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java +++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java @@ -22,6 +22,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.net.BindException; import java.security.KeyStore; import java.util.Calendar; import java.util.HashMap; @@ -56,11 +57,14 @@ import com.gemstone.gemfire.cache.client.internal.LocatorTestBase; import com.gemstone.gemfire.cache.server.CacheServer; import com.gemstone.gemfire.distributed.DistributedSystem; import com.gemstone.gemfire.distributed.internal.DistributionConfig; +import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; import com.gemstone.gemfire.internal.AvailablePort; import com.gemstone.gemfire.internal.AvailablePortHelper; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; +import com.gemstone.gemfire.management.ManagementException; import com.gemstone.gemfire.management.ManagementTestBase; import com.gemstone.gemfire.test.dunit.Host; +import com.gemstone.gemfire.test.dunit.IgnoredException; import com.gemstone.gemfire.test.dunit.NetworkUtils; import com.gemstone.gemfire.test.dunit.SerializableCallable; import com.gemstone.gemfire.test.dunit.SerializableRunnable; @@ -374,7 +378,11 @@ public class RestAPIsWithSSLDUnitTest extends LocatorTestBase { } private int startManagerInVM(VM vm, final String locators, final String[] regions, final Properties sslProperties) { - + + IgnoredException.addIgnoredException("java.net.BindException"); + IgnoredException.addIgnoredException("java.rmi.server.ExportException"); + IgnoredException.addIgnoredException("com.gemstone.gemfire.management.ManagementException"); + SerializableCallable connect = new SerializableCallable("Start Manager ") { public Object call() throws IOException { Properties props = new Properties(); @@ -382,12 +390,44 @@ public class RestAPIsWithSSLDUnitTest extends LocatorTestBase { props.setProperty(DistributionConfig.LOCATORS_NAME, locators); props.setProperty("jmx-manager", "true"); props.setProperty("jmx-manager-start", "true"); - props.setProperty(DistributionConfig.JMX_MANAGER_HTTP_PORT_NAME, "0"); - - configureSSL(props, sslProperties, false); - DistributedSystem ds = getSystem(props); - Cache cache = CacheFactory.create(ds); + Cache cache = null; + while (true) { + try { + configureSSL(props, sslProperties, false); + DistributedSystem ds = getSystem(props); + System.out.println("Creating cache with http-service-port " + props.getProperty("http-service-port", "7070") + + " and jmx-manager-port " + props.getProperty("jmx-manager-port", "1099")); + cache = CacheFactory.create(ds); + System.out.println("Successfully created cache."); + break; + } + catch (ManagementException ex) { + if ((ex.getCause() instanceof BindException) + || (ex.getCause() != null && ex.getCause().getCause() instanceof BindException)) { + //close cache and disconnect + GemFireCacheImpl existingInstance = GemFireCacheImpl.getInstance(); + if (existingInstance != null) { + existingInstance.close(); + } + InternalDistributedSystem ids = InternalDistributedSystem + .getConnectedInstance(); + if (ids != null) { + ids.disconnect(); + } + //try a different port + int httpServicePort = AvailablePortHelper.getRandomAvailableTCPPort(); + int jmxManagerPort = AvailablePortHelper.getRandomAvailableTCPPort(); + props.setProperty("http-service-port", Integer.toString(httpServicePort)); + props.setProperty("jmx-manager-port", Integer.toString(jmxManagerPort)); + System.out.println("Try a different http-service-port " + httpServicePort); + System.out.println("Try a different jmx-manager-port " + jmxManagerPort); + } + else { + throw ex; + } + } + } AttributesFactory factory = new AttributesFactory(); factory.setEnableBridgeConflation(true); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/285a8530/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java index 99548b3..349b449 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/DUnitLauncher.java @@ -349,11 +349,11 @@ public class DUnitLauncher { if (suspectStringBuilder.length() != 0) { System.err.println("Suspicious strings were written to the log during this run.\n" - + "Fix the strings or use DistributedTestCase.addExpectedException to ignore.\n" + + "Fix the strings or use IgnoredException.addIgnoredException to ignore.\n" + suspectStringBuilder); Assert.fail("Suspicious strings were written to the log during this run.\n" - + "Fix the strings or use DistributedTestCase.addExpectedException to ignore.\n" + + "Fix the strings or use IgnoredException.addIgnoredException to ignore.\n" + suspectStringBuilder); } }
