SLIDER-570 tests to simulate launch failures and validate output
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.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 @@
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 @@
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 @@
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()
-
}
}
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 @@
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)
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 @@
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.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 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,
[
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 @@
ARG_RESOURCES, APP_RESOURCE
])
-
assert clusterFS.exists(clusterDirPath)
//cluster exists if you don't want it to be live
exists(EXIT_SUCCESS, CLUSTER, false)