Repository: incubator-slider
Updated Branches:
  refs/heads/develop 26eeddf8f -> 4e7ef8b09


SLIDER-787 App Upgrade/Reconfig support in Slider


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/4e7ef8b0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/4e7ef8b0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/4e7ef8b0

Branch: refs/heads/develop
Commit: 4e7ef8b09ecc93b5348bb2751e43cbfc9aba890f
Parents: 26eeddf
Author: Gour Saha <[email protected]>
Authored: Fri Apr 17 16:22:47 2015 -0700
Committer: Gour Saha <[email protected]>
Committed: Fri Apr 17 16:22:47 2015 -0700

----------------------------------------------------------------------
 .../org/apache/slider/client/SliderClient.java  |   2 +-
 .../client/TestUpgradeCommandOptions.groovy     | 114 +++++++++++++++++--
 2 files changed, 108 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4e7ef8b0/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java 
b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
index c166587..b7c4454 100644
--- a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
+++ b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
@@ -841,7 +841,7 @@ public class SliderClient extends 
AbstractSliderLaunchedService implements RunSe
     if (CollectionUtils.isEmpty(validContainers)
         && CollectionUtils.isEmpty(validComponents)) {
       log.error("Not a single valid container or component specified. Nothing 
to do.");
-      return EXIT_FALSE;
+      return EXIT_NOT_FOUND;
     }
 
     SliderClusterProtocol appMaster = connect(findInstance(clustername));

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4e7ef8b0/slider-core/src/test/groovy/org/apache/slider/client/TestUpgradeCommandOptions.groovy
----------------------------------------------------------------------
diff --git 
a/slider-core/src/test/groovy/org/apache/slider/client/TestUpgradeCommandOptions.groovy
 
b/slider-core/src/test/groovy/org/apache/slider/client/TestUpgradeCommandOptions.groovy
index 4620b32..1902743 100644
--- 
a/slider-core/src/test/groovy/org/apache/slider/client/TestUpgradeCommandOptions.groovy
+++ 
b/slider-core/src/test/groovy/org/apache/slider/client/TestUpgradeCommandOptions.groovy
@@ -92,9 +92,9 @@ class TestUpgradeCommandOptions extends 
AgentMiniClusterTestBase {
           ])
       fail("Upgrade command should have failed")
     } catch (SliderException e) {
+      log.info(e.toString())
       assert e instanceof UnknownApplicationInstanceException
       assert e.getMessage().contains("Unknown application instance")
-      log.info(e.toString())
     }
   }
 
@@ -112,10 +112,16 @@ class TestUpgradeCommandOptions extends 
AgentMiniClusterTestBase {
     ApplicationReport report = waitForClusterLive(sliderClient)
     addToTeardown(sliderClient)
 
-    // now call all the tests
+    // Now call all the tests.
+    // These tests are written in a way where one depends on the other (like
+    // testUpgradeInvalidContainers depends on testUpgradeSpecSuccess). So it
+    // is important to run them all together and in the listed order.
     testUpgradeInvalidResourcesFile(clustername)
     testUpgradeInvalidConfigFile(clustername)
-    testUpgradeSuccess(clustername)
+    testUpgradeSpecSuccess(clustername)
+    testUpgradeInvalidContainers(clustername)
+    testUpgradeInvalidComponents(clustername)
+    testUpgradeInvalidContainersAndComponents(clustername)
   }
 
   public void testUpgradeInvalidResourcesFile(String clustername) 
@@ -140,11 +146,11 @@ class TestUpgradeCommandOptions extends 
AgentMiniClusterTestBase {
       )
       fail("Upgrade command should have failed")
     } catch (SliderException e) {
+      log.info(e.toString())
       assert e instanceof BadConfigException
       assert e.getMessage().contains("incorrect argument to --resources: " +
         "\"/tmp/resources.json\" : java.io.FileNotFoundException: " +
         "/tmp/resources.json (No such file or directory)")
-      log.info(e.toString())
     }
   }
 
@@ -170,23 +176,35 @@ class TestUpgradeCommandOptions extends 
AgentMiniClusterTestBase {
       )
       fail("Upgrade command should have failed")
     } catch (SliderException e) {
+      log.info(e.toString())
       assert e instanceof BadConfigException
       assert e.getMessage().contains("incorrect argument to --template: " +
         "\"/tmp/appConfig.json\" : java.io.FileNotFoundException: " +
         "/tmp/appConfig.json (No such file or directory)")
-      log.info(e.toString())
     }
   }
 
-  public void testUpgradeSuccess(String clustername)
+  public void testUpgradeSpecSuccess(String clustername)
     throws Throwable {
     String resourceFile = Path.getPathWithoutSchemeAndAuthority(testFileSystem
       .buildClusterDirPath(clustername)).toString() + "/resources.json"
     String appConfigFile = Path.getPathWithoutSchemeAndAuthority(testFileSystem
       .buildClusterDirPath(clustername)).toString() + "/app_config.json"
 
-    describe("Calling upgrade - testUpgradeSuccess")
+    describe("Calling upgrade - testUpgradeSpecSuccess")
     try {
+      log.info("Listing application containers before upgrade spec")
+      launcher = launchClientAgainstMiniMR(
+          //config includes RM binding info
+          yarnConfig,
+          //varargs list of command line params
+          [
+              ClientArgs.ACTION_LIST,
+              clustername,
+              ClientArgs.ARG_CONTAINERS
+          ]
+      )
+
       launcher = launchClientAgainstMiniMR(
           //config includes RM binding info
           yarnConfig,
@@ -200,8 +218,90 @@ class TestUpgradeCommandOptions extends 
AgentMiniClusterTestBase {
               resourceFile
           ]
       )
+
+      log.info("Listing application containers after upgrade spec")
+      launcher = launchClientAgainstMiniMR(
+          //config includes RM binding info
+          yarnConfig,
+          //varargs list of command line params
+          [
+              ClientArgs.ACTION_LIST,
+              clustername,
+              ClientArgs.ARG_CONTAINERS
+          ]
+      )
     } catch (SliderException e) {
+      log.info(e.toString())
+      fail("Upgrade command should not have failed")
+    }
+    assert launcher.serviceExitCode == 0
+  }
+
+  public void testUpgradeInvalidContainers(String clustername)
+    throws Throwable {
+    describe("Calling upgrade - testUpgradeInvalidContainers")
+    try {
+      launcher = launchClientAgainstMiniMR(
+          //config includes RM binding info
+          yarnConfig,
+          //varargs list of command line params
+          [
+              ClientArgs.ACTION_UPGRADE,
+              clustername,
+              ClientArgs.ARG_CONTAINERS,
+              "container_1_invalid"
+          ]
+      )
+      fail("Upgrade command should have failed")
+    } catch (SliderException e) {
+      log.info(e.toString())
+    }
+    assert launcher.serviceExitCode == 0
+  }
+
+  public void testUpgradeInvalidComponents(String clustername)
+    throws Throwable {
+    describe("Calling upgrade - testUpgradeInvalidComponents")
+    try {
+      launcher = launchClientAgainstMiniMR(
+          //config includes RM binding info
+          yarnConfig,
+          //varargs list of command line params
+          [
+              ClientArgs.ACTION_UPGRADE,
+              clustername,
+              ClientArgs.ARG_COMPONENTS,
+              "HBASE_ROLE_INVALID"
+          ]
+      )
       fail("Upgrade command should have failed")
+    } catch (SliderException e) {
+      log.info(e.toString())
+    }
+    assert launcher.serviceExitCode == 0
+  }
+
+  public void testUpgradeInvalidContainersAndComponents(String clustername)
+    throws Throwable {
+    describe("Calling upgrade - testUpgradeInvalidContainersAndComponents")
+    try {
+      launcher = launchClientAgainstMiniMR(
+          //config includes RM binding info
+          yarnConfig,
+          //varargs list of command line params
+          [
+              ClientArgs.ACTION_UPGRADE,
+              clustername,
+              ClientArgs.ARG_CONTAINERS,
+              "container_1_invalid",
+              "container_2_invalid",
+              ClientArgs.ARG_COMPONENTS,
+              "HBASE_MASTER_ROLE_INVALID",
+              "HBASE_RS_ROLE_INVALID"
+          ]
+      )
+      fail("Upgrade command should have failed")
+    } catch (SliderException e) {
       log.info(e.toString())
     }
     assert launcher.serviceExitCode == 0

Reply via email to