hadoop-yarn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject svn commit: r1407172 - in /hadoop/common/branches/branch-2/hadoop-yarn-project: ./ hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/ hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-...
Date Thu, 08 Nov 2012 17:28:00 GMT
Author: bobby
Date: Thu Nov  8 17:28:00 2012
New Revision: 1407172

URL: http://svn.apache.org/viewvc?rev=1407172&view=rev
Log:
svn merge -c 1407171 FIXES: YARN-186. Coverage fixing LinuxContainerExecutor (Aleksey Gorshkov
via bobby)

Added:
    hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/resources/mock-container-executer-with-error
      - copied unchanged from r1407171, hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/resources/mock-container-executer-with-error
Modified:
    hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt
    hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestLinuxContainerExecutorWithMocks.java

Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt?rev=1407172&r1=1407171&r2=1407172&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt Thu Nov  8 17:28:00 2012
@@ -152,6 +152,9 @@ Release 0.23.5 - UNRELEASED
     YARN-32. Fix TestApplicationTokens to not depend on test order and thus pass
     on JDK7. (vinodkv)
 
+    YARN-186. Coverage fixing LinuxContainerExecutor (Aleksey Gorshkov via
+    bobby)
+
   OPTIMIZATIONS
 
   BUG FIXES

Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestLinuxContainerExecutorWithMocks.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestLinuxContainerExecutorWithMocks.java?rev=1407172&r1=1407171&r2=1407172&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestLinuxContainerExecutorWithMocks.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestLinuxContainerExecutorWithMocks.java
Thu Nov  8 17:28:00 2012
@@ -26,11 +26,13 @@ import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.LineNumberReader;
+import java.net.InetSocketAddress;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 
+import junit.framework.Assert;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
@@ -46,7 +48,6 @@ import org.junit.Test;
 
 public class TestLinuxContainerExecutorWithMocks {
 
-  @SuppressWarnings("unused")
   private static final Log LOG = LogFactory
       .getLog(TestLinuxContainerExecutorWithMocks.class);
 
@@ -54,6 +55,7 @@ public class TestLinuxContainerExecutorW
   private final File mockParamFile = new File("./params.txt");
   private LocalDirsHandlerService dirsHandler;
   
+
   private void deleteMockParamFile() {
     if(mockParamFile.exists()) {
       mockParamFile.delete();
@@ -126,8 +128,102 @@ public class TestLinuxContainerExecutorW
         StringUtils.join(",", dirsHandler.getLocalDirs()),
         StringUtils.join(",", dirsHandler.getLogDirs())),
         readMockParams());
+    
+  }
+
+  
+  @Test
+  public void testStartLocalizer() throws IOException {
+
+  
+    InetSocketAddress address = InetSocketAddress.createUnresolved("localhost", 8040);
+    Path nmPrivateCTokensPath= new Path("file:///bin/nmPrivateCTokensPath");
+ 
+    try {
+      mockExec.startLocalizer(nmPrivateCTokensPath, address, "test", "application_0", "12345",
dirsHandler.getLocalDirs(), dirsHandler.getLogDirs());
+      List<String> result=readMockParams();
+      Assert.assertEquals(result.size(), 16);
+      Assert.assertEquals(result.get(0), "test");
+      Assert.assertEquals(result.get(1), "0" );
+      Assert.assertEquals(result.get(2),"application_0" );
+      Assert.assertEquals(result.get(3), "/bin/nmPrivateCTokensPath");
+      Assert.assertEquals(result.get(7), "-classpath" );
+      Assert.assertEquals(result.get(10),"org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.ContainerLocalizer"
);
+      Assert.assertEquals(result.get(11), "test");
+      Assert.assertEquals(result.get(12), "application_0");
+      Assert.assertEquals(result.get(13),"12345" );
+      Assert.assertEquals(result.get(14),"localhost" );
+      Assert.assertEquals(result.get(15),"8040" );
+
+    } catch (InterruptedException e) {
+      LOG.error("Error:"+e.getMessage(),e);
+      Assert.fail();
+    }
+  }
+  
+  
+  @Test
+  public void testContainerLaunchError() throws IOException {
+
+    // reinitialize executer
+    File f = new File("./src/test/resources/mock-container-executer-with-error");
+    if (!f.canExecute()) {
+      f.setExecutable(true);
+    }
+    String executorPath = f.getAbsolutePath();
+    Configuration conf = new Configuration();
+    conf.set(YarnConfiguration.NM_LINUX_CONTAINER_EXECUTOR_PATH, executorPath);
+    conf.set(YarnConfiguration.NM_LOCAL_DIRS, "file:///bin/echo");
+    conf.set(YarnConfiguration.NM_LOG_DIRS, "file:///dev/null");
+
+    mockExec = new LinuxContainerExecutor();
+    dirsHandler = new LocalDirsHandlerService();
+    dirsHandler.init(conf);
+    mockExec.setConf(conf);
+
+    String appSubmitter = "nobody";
+    String cmd = String
+        .valueOf(LinuxContainerExecutor.Commands.LAUNCH_CONTAINER.getValue());
+    String appId = "APP_ID";
+    String containerId = "CONTAINER_ID";
+    Container container = mock(Container.class);
+    ContainerId cId = mock(ContainerId.class);
+    ContainerLaunchContext context = mock(ContainerLaunchContext.class);
+    HashMap<String, String> env = new HashMap<String, String>();
+
+    when(container.getContainerID()).thenReturn(cId);
+    when(container.getLaunchContext()).thenReturn(context);
+
+    when(cId.toString()).thenReturn(containerId);
+
+    when(context.getEnvironment()).thenReturn(env);
+
+    Path scriptPath = new Path("file:///bin/echo");
+    Path tokensPath = new Path("file:///dev/null");
+    Path workDir = new Path("/tmp");
+    Path pidFile = new Path(workDir, "pid.txt");
+
+    mockExec.activateContainer(cId, pidFile);
+    int ret = mockExec.launchContainer(container, scriptPath, tokensPath,
+        appSubmitter, appId, workDir, dirsHandler.getLocalDirs(),
+        dirsHandler.getLogDirs());
+    Assert.assertNotSame(0, ret);
+    assertEquals(Arrays.asList(appSubmitter, cmd, appId, containerId,
+        workDir.toString(), "/bin/echo", "/dev/null", pidFile.toString(),
+        StringUtils.join(",", dirsHandler.getLocalDirs()),
+        StringUtils.join(",", dirsHandler.getLogDirs())), readMockParams());
+
   }
+  
+  @Test
+  public void testInit() throws Exception {
 
+    mockExec.init();
+    assertEquals(Arrays.asList("--checksetup"), readMockParams());
+    
+  }
+
+  
   @Test
   public void testContainerKill() throws IOException {
     String appSubmitter = "nobody";



Mime
View raw message