You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/06/30 17:36:51 UTC

[02/50] [abbrv] SLIDER-126. Slider-Agent and Agent Provider need to handle component instance install/start failure gracefully

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/3aca57d2/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/TestAppsThroughAgent.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/TestAppsThroughAgent.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/TestAppsThroughAgent.groovy
index aef9aa1..e3422ee 100644
--- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/TestAppsThroughAgent.groovy
+++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/TestAppsThroughAgent.groovy
@@ -31,14 +31,14 @@ import org.junit.Test
 @CompileStatic
 @Slf4j
 public class TestAppsThroughAgent extends AgentCommandTestBase
-    implements FuntestProperties, Arguments, SliderExitCodes, SliderActions {
+implements FuntestProperties, Arguments, SliderExitCodes, SliderActions {
 
   private static String COMMAND_LOGGER = "COMMAND_LOGGER"
-  private static String APPLICATION_NAME = "agenttst"
+  private static String APPLICATION_NAME = "happy-path-with-flex"
 
   @After
   public void destroyCluster() {
-    cleanup()
+    cleanup(APPLICATION_NAME)
   }
 
   @Test
@@ -48,69 +48,39 @@ public class TestAppsThroughAgent extends AgentCommandTestBase
       return
     }
 
-    cleanup()
-    try {
-      SliderShell shell = slider(EXIT_SUCCESS,
-          [
-              ACTION_CREATE, APPLICATION_NAME,
-              ARG_IMAGE, agentTarballPath.toString(),
-              ARG_TEMPLATE, APP_TEMPLATE,
-              ARG_RESOURCES, APP_RESOURCE
-          ])
+    cleanup(APPLICATION_NAME)
+    SliderShell shell = slider(EXIT_SUCCESS,
+        [
+            ACTION_CREATE, APPLICATION_NAME,
+            ARG_IMAGE, agentTarballPath.toString(),
+            ARG_TEMPLATE, APP_TEMPLATE,
+            ARG_RESOURCES, APP_RESOURCE
+        ])
 
-      logShell(shell)
+    logShell(shell)
 
-      ensureApplicationIsUp(APPLICATION_NAME)
+    ensureApplicationIsUp(APPLICATION_NAME)
 
-      //flex
-      slider(EXIT_SUCCESS,
-          [
-              ACTION_FLEX,
-              APPLICATION_NAME,
-              ARG_COMPONENT,
-              COMMAND_LOGGER,
-              "2"])
+    //flex
+    slider(EXIT_SUCCESS,
+        [
+            ACTION_FLEX,
+            APPLICATION_NAME,
+            ARG_COMPONENT,
+            COMMAND_LOGGER,
+            "2"])
 
-      // sleep till the new instance starts
-      sleep(1000 * 10)
+    // sleep till the new instance starts
+    sleep(1000 * 10)
 
-      shell = slider(EXIT_SUCCESS,
-          [
-              ACTION_STATUS,
-              APPLICATION_NAME])
+    shell = slider(EXIT_SUCCESS,
+        [
+            ACTION_STATUS,
+            APPLICATION_NAME])
 
-      assertComponentCount(COMMAND_LOGGER, 2, shell)
+    assertComponentCount(COMMAND_LOGGER, 2, shell)
 
-      shell = slider(EXIT_SUCCESS,
-          [
-              ACTION_LIST,
-              APPLICATION_NAME])
-
-      assert isAppRunning("RUNNING", shell), 'App is not running.'
-
-      assertSuccess(shell)
-    } finally {
-      cleanup()
-    }
-  }
-
-
-  public void cleanup() throws Throwable {
-    log.info "Cleaning app instance, if exists, by name " + APPLICATION_NAME
-    teardown(APPLICATION_NAME)
-
-    // sleep till the instance is frozen
-    sleep(1000 * 3)
-
-    SliderShell shell = slider([
-        ACTION_DESTROY,
-        APPLICATION_NAME])
-
-    if (shell.ret != 0 && shell.ret != EXIT_UNKNOWN_INSTANCE) {
-      logShell(shell)
-      assert fail("Old cluster either should not exist or should get destroyed.")
-    }
+    assertSuccess(shell)
+    assert isApplicationInState("RUNNING", APPLICATION_NAME), 'App is not running.'
   }
-
-
 }