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/11/02 15:25:38 UTC

[26/50] git commit: SLIDER-570 tests to simulate launch failures and validate output

SLIDER-570 tests to simulate launch failures and validate output


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

Branch: refs/heads/feature/SLIDER-531-registry-enhancements
Commit: f63ac6c90b95386715f8487a7b810a7e26f561d7
Parents: 69712cb
Author: Steve Loughran <st...@apache.org>
Authored: Thu Oct 30 11:25:30 2014 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Fri Oct 31 11:07:49 2014 +0000

----------------------------------------------------------------------
 .../funtest/framework/CommandTestBase.groovy    | 24 +++++++++---------
 .../lifecycle/AgentClusterLifecycleIT.groovy    |  9 ++++++-
 .../lifecycle/AgentLaunchFailureIT.groovy       | 26 +++++++++++---------
 .../lifecycle/ClusterBuildDestroyIT.groovy      |  1 -
 4 files changed, 35 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/f63ac6c9/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy
index 7928642..1c65394 100644
--- a/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy
+++ b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy
@@ -30,7 +30,6 @@ import org.apache.hadoop.yarn.api.records.YarnApplicationState
 import org.apache.hadoop.yarn.conf.YarnConfiguration
 import org.apache.slider.api.StatusKeys
 import org.apache.slider.common.tools.ConfigHelper
-import org.apache.slider.core.exceptions.SliderException
 import org.apache.slider.core.launch.SerializedApplicationReport
 import org.apache.slider.core.main.ServiceLauncher
 import org.apache.slider.common.SliderKeys
@@ -626,17 +625,19 @@ abstract class CommandTestBase extends SliderTestUtils {
       String appTemplate,
       String resourceTemplate,
       List<String> extraArgs = [],
-      File launchReport = null) {
+      File launchReportFile = null) {
 
-    if (!launchReport) {
-      launchReport = createAppReportFile()
+    if (!launchReportFile) {
+      launchReportFile = createAppReportFile()
     }
+    // delete any previous copy of the file
+    launchReportFile.delete();
     
     List<String> commands = [
         ACTION_CREATE, name,
         ARG_TEMPLATE, appTemplate,
         ARG_RESOURCES, resourceTemplate,
-        ARG_OUTPUT, launchReport.absolutePath,
+        ARG_OUTPUT, launchReportFile.absolutePath,
         ARG_WAIT, Integer.toString(THAW_WAIT_TIME)
     ]
 
@@ -655,18 +656,17 @@ abstract class CommandTestBase extends SliderTestUtils {
     commands.addAll(extraArgs)
     SliderShell shell = new SliderShell(commands)
     shell.execute()
-    if (!shell.execute()) {
+    if (0 != shell.execute()) {
       // app has failed.
 
       // grab the app report of the last known instance of this app
       // which may not be there if it was a config failure; may be out of date
       // from a previous run
-      log.error(
-          "Launch failed with exit code ${shell.ret}")
+      log.error("Launch failed with exit code ${shell.ret}")
       shell.dumpOutput()
 
       // now grab that app report if it is there
-      def appReport = maybeLookupFromLaunchReport(launchReport)
+      def appReport = maybeLookupFromLaunchReport(launchReportFile)
       String extraText = ""
       if (appReport) {
         log.error("Application report:\n$appReport")
@@ -729,15 +729,15 @@ abstract class CommandTestBase extends SliderTestUtils {
     File reportFile = createAppReportFile();
     try {
       def shell = lookup(id, reportFile)
-      if (shell.ret) {
+      if (shell.ret == 0) {
         return maybeLoadAppReport(reportFile)
       } else {
-        log.warn("Lookup operation failed:\n" + shell.dumpOutput())
+        log.warn("Lookup operation failed with ${shell.ret}")
+        shell.dumpOutput()
         return null
       }
     } finally {
       reportFile.delete()
-      
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/f63ac6c9/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentClusterLifecycleIT.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentClusterLifecycleIT.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentClusterLifecycleIT.groovy
index f0fa546..8b123c3 100644
--- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentClusterLifecycleIT.groovy
+++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentClusterLifecycleIT.groovy
@@ -66,11 +66,18 @@ public class AgentClusterLifecycleIT extends AgentCommandTestBase
 
     def clusterpath = buildClusterPath(CLUSTER)
     assert !clusterFS.exists(clusterpath)
+    File launchReportFile = createAppReportFile();
     SliderShell shell = createTemplatedSliderApplication(CLUSTER,
         APP_TEMPLATE,
-        APP_RESOURCE2)
+        APP_RESOURCE2,
+        [],
+        launchReportFile)
 
     logShell(shell)
+    assert launchReportFile.exists()
+    assert launchReportFile.size() > 0
+    def launchReport = maybeLoadAppReport(launchReportFile)
+    assert launchReport;
 
     ensureApplicationIsUp(CLUSTER)
 

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/f63ac6c9/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentLaunchFailureIT.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentLaunchFailureIT.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentLaunchFailureIT.groovy
index ce1e0f1..1a0d2c3 100644
--- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentLaunchFailureIT.groovy
+++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentLaunchFailureIT.groovy
@@ -20,12 +20,8 @@ package org.apache.slider.funtest.lifecycle
 
 import groovy.transform.CompileStatic
 import groovy.util.logging.Slf4j
-import org.apache.hadoop.registry.client.binding.RegistryUtils
-import org.apache.hadoop.registry.client.types.Endpoint
-import org.apache.hadoop.registry.client.types.ServiceRecord
 import org.apache.slider.api.InternalKeys
 import org.apache.slider.common.SliderExitCodes
-import org.apache.slider.common.SliderKeys
 import org.apache.slider.common.params.Arguments
 import org.apache.slider.common.params.SliderActions
 import org.apache.slider.funtest.framework.AgentCommandTestBase
@@ -35,8 +31,6 @@ import org.junit.After
 import org.junit.Before
 import org.junit.Test
 
-import static org.apache.slider.core.registry.info.CustomRegistryConstants.*
-
 @CompileStatic
 @Slf4j
 public class AgentLaunchFailureIT extends AgentCommandTestBase
@@ -62,22 +56,32 @@ public class AgentLaunchFailureIT extends AgentCommandTestBase
   public void testAgentLaunchFailure() throws Throwable {
     describe("Create a failing cluster and validate failure logic")
 
+    // verify no cluster
+    assert 0 != exists(CLUSTER).ret
+ 
     // create an AM which fails to launch within a second
     File launchReportFile = createAppReportFile();
     SliderShell shell = createTemplatedSliderApplication(CLUSTER,
         APP_TEMPLATE,
         APP_RESOURCE2,
         [
-            ARG_INTERNAL, InternalKeys.CHAOS_MONKEY_ENABLED, "true",
-            ARG_INTERNAL, InternalKeys.CHAOS_MONKEY_INTERVAL_SECONDS, "1",
-            ARG_INTERNAL, InternalKeys.CHAOS_MONKEY_PROBABILITY_AM_FAILURE, "100",
+            ARG_OPTION, InternalKeys.CHAOS_MONKEY_ENABLED, "true",
+            ARG_OPTION, InternalKeys.CHAOS_MONKEY_DELAY_SECONDS, "1",
+            ARG_OPTION, InternalKeys.CHAOS_MONKEY_INTERVAL_SECONDS, "60",
+            ARG_OPTION, InternalKeys.CHAOS_MONKEY_PROBABILITY_AM_FAILURE, "100",
         ],
         launchReportFile)
 
-    maybeLookupFromLaunchReport(launchReportFile)
+    shell.dumpOutput();
+    assert launchReportFile.exists()
+    assert launchReportFile.size() > 0
+    def launchReport = maybeLoadAppReport(launchReportFile)
+    assert launchReport;
+    assert launchReport.applicationId;
+    def report = maybeLookupFromLaunchReport(launchReportFile)
+    assert report;
     ensureApplicationIsUp(CLUSTER)
 
-
     //stop
     freeze(0, CLUSTER,
         [

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/f63ac6c9/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/ClusterBuildDestroyIT.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/ClusterBuildDestroyIT.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/ClusterBuildDestroyIT.groovy
index 0581ed0..f03fb63 100644
--- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/ClusterBuildDestroyIT.groovy
+++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/ClusterBuildDestroyIT.groovy
@@ -68,7 +68,6 @@ public class ClusterBuildDestroyIT extends AgentCommandTestBase
             ARG_RESOURCES, APP_RESOURCE
         ])
 
-
     assert clusterFS.exists(clusterDirPath)
     //cluster exists if you don't want it to be live
     exists(EXIT_SUCCESS, CLUSTER, false)