sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject sqoop git commit: SQOOP-1962: Sqoop2: Start sqoop2 minicluster on random port
Date Mon, 05 Jan 2015 08:25:54 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 d56d6417f -> dcb3eb340


SQOOP-1962: Sqoop2: Start sqoop2 minicluster on random port

(Abraham Elmahrek via Jarek Jarcec Cecho)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/dcb3eb34
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/dcb3eb34
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/dcb3eb34

Branch: refs/heads/sqoop2
Commit: dcb3eb34055a618d8d659b51b837d649692e215d
Parents: d56d641
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Mon Jan 5 09:25:26 2015 +0100
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Mon Jan 5 09:25:26 2015 +0100

----------------------------------------------------------------------
 .../test/minicluster/TomcatSqoopMiniCluster.java      | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/dcb3eb34/test/src/main/java/org/apache/sqoop/test/minicluster/TomcatSqoopMiniCluster.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/minicluster/TomcatSqoopMiniCluster.java
b/test/src/main/java/org/apache/sqoop/test/minicluster/TomcatSqoopMiniCluster.java
index 9c099fc..648e2f6 100644
--- a/test/src/main/java/org/apache/sqoop/test/minicluster/TomcatSqoopMiniCluster.java
+++ b/test/src/main/java/org/apache/sqoop/test/minicluster/TomcatSqoopMiniCluster.java
@@ -24,6 +24,8 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.hadoop.conf.Configuration;
+import org.apache.log4j.Logger;
+import org.apache.sqoop.common.test.utils.NetworkUtils;
 import org.codehaus.cargo.container.ContainerType;
 import org.codehaus.cargo.container.InstalledLocalContainer;
 import org.codehaus.cargo.container.configuration.ConfigurationType;
@@ -31,6 +33,7 @@ import org.codehaus.cargo.container.configuration.LocalConfiguration;
 import org.codehaus.cargo.container.deployable.WAR;
 import org.codehaus.cargo.container.installer.Installer;
 import org.codehaus.cargo.container.installer.ZipURLInstaller;
+import org.codehaus.cargo.container.property.ServletPropertySet;
 import org.codehaus.cargo.generic.DefaultContainerFactory;
 import org.codehaus.cargo.generic.configuration.DefaultConfigurationFactory;
 
@@ -42,15 +45,20 @@ import org.codehaus.cargo.generic.configuration.DefaultConfigurationFactory;
 public class TomcatSqoopMiniCluster extends SqoopMiniCluster {
 
   private InstalledLocalContainer container = null;
+  private Integer port;
+
+  private static final Logger LOG = Logger.getLogger(TomcatSqoopMiniCluster.class);
 
   /** {@inheritDoc} */
   public TomcatSqoopMiniCluster(String temporaryPath) throws Exception {
     super(temporaryPath);
+    port = NetworkUtils.findAvailablePort();
   }
 
   /** {@inheritDoc} */
   public TomcatSqoopMiniCluster(String temporaryPath, Configuration configuration) throws
Exception {
     super(temporaryPath, configuration);
+    port = NetworkUtils.findAvailablePort();
   }
 
   /** {@inheritDoc} */
@@ -116,7 +124,11 @@ public class TomcatSqoopMiniCluster extends SqoopMiniCluster {
     // Finally deploy Sqoop server war file
     configuration.addDeployable(new WAR("../server/target/sqoop.war"));
 
+    // Random port
+    configuration.setProperty(ServletPropertySet.PORT, port.toString());
+
     // Start Sqoop server
+    LOG.info("Starting tomcat server on port " + port);
     container.start();
   }
 
@@ -157,6 +169,6 @@ public class TomcatSqoopMiniCluster extends SqoopMiniCluster {
    */
   public String getServerUrl() {
     // We're not doing any changes, so return default URL
-    return "http://localhost:8080/sqoop/";
+    return "http://localhost:" + port + "/sqoop/";
   }
 }


Mime
View raw message