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/10/23 12:36:40 UTC
[10/13] git commit: SLIDER-460 factor out startup logic from test
cases; add --wait arg to launcher so the client can do most of the waiting
SLIDER-460 factor out startup logic from test cases; add --wait arg to launcher so the client can do most of the waiting
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/fe5ded1c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/fe5ded1c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/fe5ded1c
Branch: refs/heads/feature/SLIDER-460-stderr
Commit: fe5ded1c271e5f07d8728211159794c324f3fd0e
Parents: 0254e9d
Author: Steve Loughran <st...@apache.org>
Authored: Wed Oct 22 12:35:31 2014 +0100
Committer: Steve Loughran <st...@apache.org>
Committed: Thu Oct 23 11:35:54 2014 +0100
----------------------------------------------------------------------
.../framework/AgentCommandTestBase.groovy | 15 +++++++++
.../funtest/framework/CommandTestBase.groovy | 34 +++++++++++++-------
.../funtest/lifecycle/AMFailuresIT.groovy | 9 +-----
.../funtest/lifecycle/AgentFailures2IT.groovy | 10 +-----
.../funtest/lifecycle/AgentFailuresIT.groovy | 15 ++-------
.../AppsThroughAgentQueueAndLabelsIT.groovy | 17 ++--------
6 files changed, 44 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/fe5ded1c/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/AgentCommandTestBase.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/AgentCommandTestBase.groovy b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/AgentCommandTestBase.groovy
index effea44..4a46f8b 100644
--- a/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/AgentCommandTestBase.groovy
+++ b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/AgentCommandTestBase.groovy
@@ -163,6 +163,21 @@ implements FuntestProperties, Arguments, SliderExitCodes, SliderActions {
return queryRequestedCount(application, role) >= expectedCount
}
+ void expectContainerCountExceeded(String application, String role, int limit) {
+
+ repeatUntilTrue(
+ this.&hasRequestedContainerCountExceeded,
+ 50,
+ 1000 * 10,
+ [limit : Integer.toString(limit),
+ role : role,
+ application: application],
+ true,
+ "countainer count not reached") {
+ status(application).dumpOutput()
+ };
+
+ }
public ClusterDescription expectContainersLive(String clustername,
String component,
int count) {
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/fe5ded1c/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 cabf927..44d07d8 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
@@ -34,10 +34,10 @@ import org.apache.slider.core.main.ServiceLauncher
import org.apache.slider.common.SliderKeys
import org.apache.slider.common.SliderXmlConfKeys
import org.apache.slider.api.ClusterDescription
-import org.apache.slider.core.exceptions.SliderException
import org.apache.slider.common.tools.SliderUtils
import org.apache.slider.client.SliderClient
import org.apache.slider.test.SliderTestUtils
+import org.junit.Assert
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Rule
@@ -584,14 +584,16 @@ abstract class CommandTestBase extends SliderTestUtils {
List<String> commands = [
ACTION_CREATE, name,
ARG_TEMPLATE, appTemplate,
- ARG_RESOURCES, resourceTemplate
+ ARG_RESOURCES, resourceTemplate,
+ ARG_WAIT, Integer.toString(THAW_WAIT_TIME)
+
]
-
+
maybeAddCommandOption(commands,
[ARG_COMP_OPT, SliderKeys.COMPONENT_AM, SliderXmlConfKeys.KEY_AM_LOGIN_KEYTAB_NAME],
SLIDER_CONFIG.getTrimmed(SliderXmlConfKeys.KEY_AM_LOGIN_KEYTAB_NAME));
maybeAddCommandOption(commands,
- [ARG_COMP_OPT, SliderKeys.COMPONENT_AM, SliderXmlConfKeys.KEY_HDFS_KEYTAB_DIR ],
+ [ARG_COMP_OPT, SliderKeys.COMPONENT_AM, SliderXmlConfKeys.KEY_HDFS_KEYTAB_DIR],
SLIDER_CONFIG.getTrimmed(SliderXmlConfKeys.KEY_HDFS_KEYTAB_DIR));
maybeAddCommandOption(commands,
[ARG_COMP_OPT, SliderKeys.COMPONENT_AM, SliderXmlConfKeys.KEY_AM_KEYTAB_LOCAL_PATH],
@@ -657,7 +659,9 @@ abstract class CommandTestBase extends SliderTestUtils {
1000,
[application: application],
true,
- 'Application did not start, failing test.')
+ 'Application did not start, failing test.') {
+ exists(application,true).dumpOutput()
+ }
}
protected boolean isApplicationUp(Map<String, String> args) {
@@ -682,21 +686,27 @@ abstract class CommandTestBase extends SliderTestUtils {
return shell.ret == 0
}
- protected void repeatUntilTrue(Closure c, int maxAttempts, int sleepDur, Map args,
- boolean failIfUnsuccessful = false, String message = "") {
+ protected void repeatUntilTrue(Closure closure,
+ int maxAttempts, int sleepDur, Map args,
+ boolean failIfUnsuccessful = false, String message,
+ Closure failureHandler) {
int attemptCount = 0
while (attemptCount < maxAttempts) {
- if (c(args)) {
+ if (closure(args)) {
+ // finished
break
};
attemptCount++;
- if (failIfUnsuccessful) {
- assert attemptCount != maxAttempts, message
- }
-
sleep(sleepDur)
}
+
+ if (failIfUnsuccessful & attemptCount != maxAttempts) {
+ if (failureHandler) {
+ failureHandler()
+ }
+ fail(message)
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/fe5ded1c/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AMFailuresIT.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AMFailuresIT.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AMFailuresIT.groovy
index 323bf7d..f36950f 100644
--- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AMFailuresIT.groovy
+++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AMFailuresIT.groovy
@@ -67,14 +67,7 @@ implements FuntestProperties, Arguments, SliderExitCodes, SliderActions {
logShell(shell)
ensureApplicationIsUp(APPLICATION_NAME)
-
- repeatUntilTrue(
- this.&hasRequestedContainerCountExceeded,
- 20,
- 1000 * 10,
- [limit : '1',
- role : COMMAND_LOGGER,
- application: APPLICATION_NAME]);
+ expectContainerCountExceeded(APPLICATION_NAME, COMMAND_LOGGER, 1)
// Wait for 20 secs for AM and agent to both reach STARTED state
sleep(1000 * 20)
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/fe5ded1c/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentFailures2IT.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentFailures2IT.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentFailures2IT.groovy
index f1d5f84..9fd34f6 100644
--- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentFailures2IT.groovy
+++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentFailures2IT.groovy
@@ -58,15 +58,7 @@ implements FuntestProperties, Arguments, SliderExitCodes, SliderActions {
logShell(shell)
ensureApplicationIsUp(APPLICATION_NAME)
-
- repeatUntilTrue(
- this.&hasRequestedContainerCountExceeded,
- 20,
- 1000 * 10,
- [limit: '3',
- role: COMMAND_LOGGER ,
- application:APPLICATION_NAME]);
-
+ expectContainerCountExceeded(APPLICATION_NAME, COMMAND_LOGGER, 3)
sleep(1000 * 20)
def cd = execStatus(APPLICATION_NAME)
assert cd.statistics[COMMAND_LOGGER]["containers.requested"] >= 3
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/fe5ded1c/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentFailuresIT.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentFailuresIT.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentFailuresIT.groovy
index 97daff1..be8614c 100644
--- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentFailuresIT.groovy
+++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentFailuresIT.groovy
@@ -47,8 +47,7 @@ implements FuntestProperties, Arguments, SliderExitCodes, SliderActions {
@Test
public void testAgentFailRegistrationOnce() throws Throwable {
if (!AGENTTESTS_ENABLED) {
- log.info "TESTS are not run."
- return
+ skip("Agent tests are not run.")
}
cleanup(APPLICATION_NAME)
@@ -60,17 +59,9 @@ implements FuntestProperties, Arguments, SliderExitCodes, SliderActions {
ensureApplicationIsUp(APPLICATION_NAME)
- repeatUntilTrue(this.&hasRequestedContainerCountExceeded,
- 15,
- 1000 * 10,
- [
- application:APPLICATION_NAME,
- role:COMMAND_LOGGER,
- limit: '2'
- ]);
-
+ expectContainerCountExceeded(APPLICATION_NAME, COMMAND_LOGGER, 2)
sleep(1000 * 20)
-
+ assert isApplicationUp(APPLICATION_NAME), 'App is not running.'
def cd = expectContainersLive(APPLICATION_NAME, COMMAND_LOGGER, 1)
assert cd.statistics[COMMAND_LOGGER]["containers.requested"] >= 2
assert isApplicationUp(APPLICATION_NAME), 'App is not running.'
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/fe5ded1c/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AppsThroughAgentQueueAndLabelsIT.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AppsThroughAgentQueueAndLabelsIT.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AppsThroughAgentQueueAndLabelsIT.groovy
index 1a5c5ff..f41461c 100644
--- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AppsThroughAgentQueueAndLabelsIT.groovy
+++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AppsThroughAgentQueueAndLabelsIT.groovy
@@ -88,14 +88,7 @@ implements FuntestProperties, Arguments, SliderExitCodes, SliderActions {
ensureApplicationIsUp(APPLICATION_NAME)
- repeatUntilTrue(
- this.&hasRequestedContainerCountExceeded,
- 50,
- 1000 * 10,
- [limit : '1',
- role : COMMAND_LOGGER,
- application: APPLICATION_NAME]);
-
+ expectContainerCountExceeded(APPLICATION_NAME, COMMAND_LOGGER, 1 )
expectContainersLive(APPLICATION_NAME, COMMAND_LOGGER, 1)
//flex
@@ -109,14 +102,8 @@ implements FuntestProperties, Arguments, SliderExitCodes, SliderActions {
// sleep till the new instance starts
ensureApplicationIsUp(APPLICATION_NAME)
+ expectContainerCountExceeded(APPLICATION_NAME, COMMAND_LOGGER, 3)
- repeatUntilTrue(
- this.&hasRequestedContainerCountExceeded,
- 20,
- 1000 * 10,
- [limit : '3',
- role : COMMAND_LOGGER,
- application: APPLICATION_NAME]);
sleep(1000 * 20)
def cd = execStatus(APPLICATION_NAME)