Repository: beam Updated Branches: refs/heads/master 336b7f1cf -> 6cef5c7b6
[BEAM-2489] Use dynamic ES port in HIFIOWithElasticTest Project: http://git-wip-us.apache.org/repos/asf/beam/repo Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/f291713b Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/f291713b Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/f291713b Branch: refs/heads/master Commit: f291713b28e3ba0246a8c0a710c71506cd0a0f91 Parents: 336b7f1 Author: Etienne Chauchot <[email protected]> Authored: Wed Jun 21 10:39:39 2017 +0200 Committer: Jean-Baptiste Onofré <[email protected]> Committed: Fri Jun 23 14:25:41 2017 +0200 ---------------------------------------------------------------------- .../sdk/io/hadoop/inputformat/HIFIOWithElasticTest.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/beam/blob/f291713b/sdks/java/io/hadoop/jdk1.8-tests/src/test/java/org/apache/beam/sdk/io/hadoop/inputformat/HIFIOWithElasticTest.java ---------------------------------------------------------------------- diff --git a/sdks/java/io/hadoop/jdk1.8-tests/src/test/java/org/apache/beam/sdk/io/hadoop/inputformat/HIFIOWithElasticTest.java b/sdks/java/io/hadoop/jdk1.8-tests/src/test/java/org/apache/beam/sdk/io/hadoop/inputformat/HIFIOWithElasticTest.java index 8745521..3f866a4 100644 --- a/sdks/java/io/hadoop/jdk1.8-tests/src/test/java/org/apache/beam/sdk/io/hadoop/inputformat/HIFIOWithElasticTest.java +++ b/sdks/java/io/hadoop/jdk1.8-tests/src/test/java/org/apache/beam/sdk/io/hadoop/inputformat/HIFIOWithElasticTest.java @@ -20,6 +20,7 @@ package org.apache.beam.sdk.io.hadoop.inputformat; import java.io.File; import java.io.IOException; import java.io.Serializable; +import java.net.ServerSocket; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -76,7 +77,7 @@ public class HIFIOWithElasticTest implements Serializable { private static final long serialVersionUID = 1L; private static final Logger LOG = LoggerFactory.getLogger(HIFIOWithElasticTest.class); private static final String ELASTIC_IN_MEM_HOSTNAME = "127.0.0.1"; - private static final String ELASTIC_IN_MEM_PORT = "9200"; + private static String elasticInMemPort = "9200"; private static final String ELASTIC_INTERNAL_VERSION = "5.x"; private static final String TRUE = "true"; private static final String ELASTIC_INDEX_NAME = "beamdb"; @@ -94,6 +95,10 @@ public class HIFIOWithElasticTest implements Serializable { @BeforeClass public static void startServer() throws NodeValidationException, InterruptedException, IOException { + ServerSocket serverSocket = new ServerSocket(0); + int port = serverSocket.getLocalPort(); + serverSocket.close(); + elasticInMemPort = String.valueOf(port); ElasticEmbeddedServer.startElasticEmbeddedServer(); } @@ -173,7 +178,7 @@ public class HIFIOWithElasticTest implements Serializable { public Configuration getConfiguration() { Configuration conf = new Configuration(); conf.set(ConfigurationOptions.ES_NODES, ELASTIC_IN_MEM_HOSTNAME); - conf.set(ConfigurationOptions.ES_PORT, String.format("%s", ELASTIC_IN_MEM_PORT)); + conf.set(ConfigurationOptions.ES_PORT, String.format("%s", elasticInMemPort)); conf.set(ConfigurationOptions.ES_RESOURCE, ELASTIC_RESOURCE); conf.set("es.internal.es.version", ELASTIC_INTERNAL_VERSION); conf.set(ConfigurationOptions.ES_NODES_DISCOVERY, TRUE); @@ -209,7 +214,7 @@ public class HIFIOWithElasticTest implements Serializable { Settings settings = Settings.builder() .put("node.data", TRUE) .put("network.host", ELASTIC_IN_MEM_HOSTNAME) - .put("http.port", ELASTIC_IN_MEM_PORT) + .put("http.port", elasticInMemPort) .put("path.data", elasticTempFolder.getRoot().getPath()) .put("path.home", elasticTempFolder.getRoot().getPath()) .put("transport.type", "local")
