Bläddra i källkod

YARN-6450. TestContainerManagerWithLCE requires override for each new test added to ContainerManagerTest? Contributed by Jason Lowe.

Eric Payne 8 år sedan
förälder
incheckning
a16ab2be91

+ 3 - 307
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestContainerManagerWithLCE.java

@@ -30,6 +30,7 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.TestContainerManager;
 import org.junit.After;
+import org.junit.Assume;
 
 public class TestContainerManagerWithLCE extends TestContainerManager {
 
@@ -51,11 +52,8 @@ public class TestContainerManagerWithLCE extends TestContainerManager {
 
   @Override
   public void setup() throws IOException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
+    Assume.assumeTrue("LCE binary path is not passed. Not running the test",
+        shouldRunTest());
     super.setup();
     localFS.setPermission(new Path(localDir.getCanonicalPath()),
         new FsPermission(
@@ -73,308 +71,6 @@ public class TestContainerManagerWithLCE extends TestContainerManager {
     }
   }
 
-  @Override
-  public void testContainerSetup() throws Exception, InterruptedException,
-      YarnException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testContainerSetup");
-    super.testContainerSetup();
-  }
-
-  @Override
-  public void testContainerManagerInitialization() throws IOException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testContainerManagerInitialization");
-    super.testContainerManagerInitialization();
-  }
-
-  @Override
-  public void testContainerLaunchAndStop() throws IOException,
-      InterruptedException, YarnException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testContainerLaunchAndStop");
-    super.testContainerLaunchAndStop();
-  }
-  
-  @Override
-  public void testContainerLaunchAndExitSuccess() throws IOException,
-      InterruptedException, YarnException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testContainerLaunchAndExitSuccess");
-    super.testContainerLaunchAndExitSuccess();
-  }
-
-  @Override
-  public void testContainerLaunchAndExitFailure() throws IOException,
-      InterruptedException, YarnException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testContainerLaunchAndExitFailure");
-    super.testContainerLaunchAndExitFailure();
-  }
-
-  @Override
-  public void testLocalingResourceWhileContainerRunning()
-      throws Exception {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    super.testLocalingResourceWhileContainerRunning();
-  }
-
-  @Override
-  public void testLocalFilesCleanup() throws InterruptedException,
-      IOException, YarnException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testLocalFilesCleanup");
-    super.testLocalFilesCleanup();
-  }
-
-  @Override
-  public void testContainerLaunchFromPreviousRM() throws InterruptedException,
-      IOException, YarnException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testContainerLaunchFromPreviousRM");
-    super.testContainerLaunchFromPreviousRM();
-  }
-
-  @Override
-  public void testMultipleContainersLaunch() throws Exception {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testContainerLaunchFromPreviousRM");
-    super.testMultipleContainersLaunch();
-  }
-
-  @Override
-  public void testMultipleContainersStopAndGetStatus() throws Exception {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testContainerLaunchFromPreviousRM");
-    super.testMultipleContainersStopAndGetStatus();
-  }
-
-  @Override
-  public void testUnauthorizedRequests() throws IOException, YarnException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testUnauthorizedRequests");
-    super.testUnauthorizedRequests();
-  }
-
-  @Override
-  public void testStartContainerFailureWithUnknownAuxService() throws Exception {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testContainerLaunchFromPreviousRM");
-    super.testStartContainerFailureWithUnknownAuxService();
-  }
-
-  @Override
-  public void testIncreaseContainerResourceWithInvalidRequests() throws Exception {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testIncreaseContainerResourceWithInvalidRequests");
-    super.testIncreaseContainerResourceWithInvalidRequests();
-  }
-
-  @Override
-  public void testIncreaseContainerResourceWithInvalidResource() throws Exception {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testIncreaseContainerResourceWithInvalidResource");
-    super.testIncreaseContainerResourceWithInvalidResource();
-  }
-
-  @Override
-  public void testChangeContainerResource() throws Exception {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testChangeContainerResource");
-    super.testChangeContainerResource();
-  }
-
-  @Override
-  public void testOutputThreadDumpSignal() throws IOException,
-      InterruptedException, YarnException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testOutputThreadDumpSignal");
-    super.testOutputThreadDumpSignal();
-  }
-
-  @Override
-  public void testGracefulShutdownSignal() throws IOException,
-      InterruptedException, YarnException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testGracefulShutdownSignal");
-    super.testGracefulShutdownSignal();
-  }
-
-  @Override
-  public void testForcefulShutdownSignal() throws IOException,
-      InterruptedException, YarnException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testForcefulShutdownSignal");
-    super.testForcefulShutdownSignal();
-  }
-
-  @Override
-  public void testContainerUpgradeSuccessAutoCommit() throws IOException,
-      InterruptedException, YarnException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testContainerUpgradeSuccessAutoCommit");
-    super.testContainerUpgradeSuccessAutoCommit();
-  }
-
-  @Override
-  public void testContainerUpgradeLocalizationFailure() throws IOException,
-      InterruptedException, YarnException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testContainerUpgradeLocalizationFailure");
-    super.testContainerUpgradeLocalizationFailure();
-  }
-
-  @Override
-  public void testContainerUpgradeSuccessExplicitCommit() throws IOException,
-    InterruptedException, YarnException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testContainerUpgradeSuccessExplicitCommit");
-    super.testContainerUpgradeSuccessExplicitCommit();
-  }
-
-  @Override
-  public void testContainerUpgradeSuccessExplicitRollback() throws IOException,
-      InterruptedException, YarnException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testContainerUpgradeSuccessExplicitRollback");
-    super.testContainerUpgradeSuccessExplicitRollback();
-  }
-
-  @Override
-  public void testContainerUpgradeRollbackDueToFailure() throws IOException,
-      InterruptedException, YarnException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testContainerUpgradeRollbackDueToFailure");
-    super.testContainerUpgradeRollbackDueToFailure();
-  }
-
-  @Override
-  public void testContainerUpgradeProcessFailure() throws IOException,
-      InterruptedException, YarnException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testContainerUpgradeProcessFailure");
-    super.testContainerUpgradeProcessFailure();
-  }
-
-  @Override
-  public void testContainerRestart() throws IOException, InterruptedException,
-      YarnException {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testContainerRestart");
-    super.testContainerRestart();
-  }
-
-  @Override
-  public void testStartContainerFailureWithInvalidLocalResource() throws Exception {
-    // Don't run the test if the binary is not available.
-    if (!shouldRunTest()) {
-      LOG.info("LCE binary path is not passed. Not running the test");
-      return;
-    }
-    LOG.info("Running testStartContainerFailureWithInvalidLocalResource");
-    super.testStartContainerFailureWithInvalidLocalResource();
-  }
-
   private boolean shouldRunTest() {
     return System
         .getProperty(YarnConfiguration.NM_LINUX_CONTAINER_EXECUTOR_PATH) != null;