hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjs...@apache.org
Subject [28/50] [abbrv] hadoop git commit: YARN-3302. TestDockerContainerExecutor should run automatically if it can detect docker in the usual place (Ravindra Kumar Naik via raviprak)
Date Fri, 22 May 2015 21:41:46 GMT
YARN-3302. TestDockerContainerExecutor should run automatically if it can detect docker in
the usual place (Ravindra Kumar Naik via raviprak)


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

Branch: refs/heads/YARN-2928
Commit: 509e6cbe56f56a52ef1cb9fc66e94cfcaff8e96a
Parents: b22cb5e
Author: Ravi Prakash <raviprak@altiscale.com>
Authored: Tue May 19 10:28:11 2015 -0700
Committer: Zhijie Shen <zjshen@apache.org>
Committed: Fri May 22 11:52:09 2015 -0700

----------------------------------------------------------------------
 hadoop-yarn-project/CHANGES.txt                 |  3 +++
 .../TestDockerContainerExecutor.java            | 27 +++++++++++++++-----
 2 files changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/509e6cbe/hadoop-yarn-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index a2f3914..e5a0b95 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -498,6 +498,9 @@ Release 2.8.0 - UNRELEASED
     YARN-2421. RM still allocates containers to an app in the FINISHING
     state (Chang Li via jlowe)
 
+    YARN-3302. TestDockerContainerExecutor should run automatically if it can
+    detect docker in the usual place (Ravindra Kumar Naik via raviprak)
+
 Release 2.7.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/509e6cbe/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestDockerContainerExecutor.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestDockerContainerExecutor.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestDockerContainerExecutor.java
index 65e381c..9386897 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestDockerContainerExecutor.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestDockerContainerExecutor.java
@@ -51,10 +51,11 @@ import com.google.common.base.Strings;
  * This is intended to test the DockerContainerExecutor code, but it requires
  * docker to be installed.
  * <br><ol>
- * <li>Install docker, and Compile the code with docker-service-url set to the
- * host and port where docker service is running.
+ * <li>To run the tests, set the docker-service-url to the host and port where
+ * docker service is running (If docker-service-url is not specified then the
+ * local daemon will be used).
  * <br><pre><code>
- * > mvn clean install -Ddocker-service-url=tcp://0.0.0.0:4243 -DskipTests
+ * mvn test -Ddocker-service-url=tcp://0.0.0.0:4243 -Dtest=TestDockerContainerExecutor
  * </code></pre>
  */
 public class TestDockerContainerExecutor {
@@ -98,10 +99,13 @@ public class TestDockerContainerExecutor {
 
     dockerUrl = System.getProperty("docker-service-url");
     LOG.info("dockerUrl: " + dockerUrl);
-    if (Strings.isNullOrEmpty(dockerUrl)) {
+    if (!Strings.isNullOrEmpty(dockerUrl)) {
+      dockerUrl = " -H " + dockerUrl;
+    } else if(isDockerDaemonRunningLocally()) {
+      dockerUrl = "";
+    } else {
       return;
     }
-    dockerUrl = " -H " + dockerUrl;
     dockerExec = "docker " + dockerUrl;
     conf.set(
       YarnConfiguration.NM_DOCKER_CONTAINER_EXECUTOR_IMAGE_NAME, yarnImage);
@@ -136,6 +140,17 @@ public class TestDockerContainerExecutor {
     return exec != null;
   }
 
+  private boolean isDockerDaemonRunningLocally() {
+    boolean dockerDaemonRunningLocally = true;
+      try {
+        shellExec("docker info");
+      } catch (Exception e) {
+        LOG.info("docker daemon is not running on local machine.");
+        dockerDaemonRunningLocally = false;
+      }
+      return dockerDaemonRunningLocally;
+  }
+
   /**
    * Test that a docker container can be launched to run a command
    * @param cId a fake ContainerID
@@ -200,7 +215,7 @@ public class TestDockerContainerExecutor {
    * Test that a touch command can be launched successfully in a docker
    * container
    */
-  @Test
+  @Test(timeout=1000000)
   public void testLaunchContainer() throws IOException {
     if (!shouldRun()) {
       LOG.warn("Docker not installed, aborting test.");


Mime
View raw message