SLIDER-616 AppsThroughAgentIT working; improved assertion logic
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/2b8dd550 Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/2b8dd550 Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/2b8dd550 Branch: refs/heads/feature/SLIDER-616_re-enable_AMFailuresIT Commit: 2b8dd5502656258c43598fbebbc2bad7e76c9399 Parents: d64b2c7 Author: Steve Loughran <ste...@apache.org> Authored: Thu Nov 6 14:39:26 2014 +0000 Committer: Steve Loughran <ste...@apache.org> Committed: Thu Nov 6 14:39:26 2014 +0000 ---------------------------------------------------------------------- .../funtest/framework/CommandTestBase.groovy | 70 ++++++++++++++++++ .../funtest/lifecycle/AppsThroughAgentIT.groovy | 75 +------------------- 2 files changed, 72 insertions(+), 73 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2b8dd550/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 1d436da..210e257 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 @@ -1187,4 +1187,74 @@ abstract class CommandTestBase extends SliderTestUtils { assertContainersLive(application, component, expected) } } + + /** + * Spin for <code>REGISTRY_STARTUP_TIMEOUT</code> waiting + * for the output of the registry command to contain the specified + * values + * @param outfile file to save the output to + * @param commands commands to execute + * @param match text to match on + */ + public void awaitRegistryOutfileContains( + File outfile, + List<String> commands, + String match) { + def errorText = "failed to find $match in output. Check your hadoop versions and the agent logs" + repeatUntilSuccess("registry", + this.&generatedFileContains, + REGISTRY_STARTUP_TIMEOUT, + PROBE_SLEEP_TIME, + [ + text : match, + filename: outfile.absolutePath, + command : commands + ], + true, + errorText) { + slider(0, commands).dumpOutput() + if (!outfile.length()) { + log.warn("No exported entries.\n" + + "Is your application using a consistent version of Hadoop? ") + } + fail(errorText + "\n" + outfile.text) + } + } + /** + * Is the registry accessible for an application? + * @param args argument map containing <code>"application"</code> + * @return probe outcome + */ + protected Outcome commandOutputContains(Map args) { + String text = args['text']; + List<String> command = (List < String >)args['command'] + SliderShell shell = slider(0, command) + return Outcome.fromBool(shell.outputContains(text)) + } + /** + * Is the registry accessible for an application? + * @param args argument map containing <code>"application"</code> + * @return probe outcome + */ + protected Outcome commandSucceeds(Map args) { + List<String> command = (List<String>) args['command'] + SliderShell shell = slider(command) + return Outcome.fromBool(shell.ret == 0) + } + /** + * Is the registry accessible for an application? + * @param args argument map + * @return probe outcome + */ + protected Outcome generatedFileContains(Map args) { + List<String> command = (List<String>) args['command'] + String text = args['text']; + String filename = args['filename']; + File f = new File(filename) + f.delete() + SliderShell shell = slider(0, command) + shell.dumpOutput() + assert f.exists() + return Outcome.fromBool(f.text.contains(text)) + } } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2b8dd550/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AppsThroughAgentIT.groovy ---------------------------------------------------------------------- diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AppsThroughAgentIT.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AppsThroughAgentIT.groovy index 8ddc38f..8b15a0c 100644 --- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AppsThroughAgentIT.groovy +++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AppsThroughAgentIT.groovy @@ -26,7 +26,6 @@ import org.apache.slider.common.params.SliderActions import org.apache.slider.funtest.framework.AgentCommandTestBase import org.apache.slider.funtest.framework.FuntestProperties import org.apache.slider.funtest.framework.SliderShell -import org.apache.slider.test.Outcome import org.junit.After import org.junit.Before import org.junit.Test @@ -90,9 +89,8 @@ implements FuntestProperties, Arguments, SliderExitCodes, SliderActions { log.info(amWebUrl.toURL().text); ensureRegistryCallSucceeds(application) - def outfile = tmpFile(".txt") - assertAppRunning(appId) + def outfile = tmpFile(".txt") def commands = [ ACTION_REGISTRY, @@ -105,15 +103,6 @@ implements FuntestProperties, Arguments, SliderExitCodes, SliderActions { awaitRegistryOutfileContains(outfile, commands, "container_log_dirs") awaitRegistryOutfileContains(outfile, commands, "container_work_dirs") - // get log folders - shell = slider(EXIT_SUCCESS, - [ - ACTION_REGISTRY, - ARG_NAME, - application, - ARG_LISTEXP]) - assertOutputContains(shell, "container_log_dirs") - assertOutputContains(shell, "container_work_dirs") // get log folders shell = slider(EXIT_SUCCESS, @@ -125,7 +114,7 @@ implements FuntestProperties, Arguments, SliderExitCodes, SliderActions { "container_log_dirs"]) assertOutputContains(shell, '"tag" : "COMMAND_LOGGER"', 2) - assertOutputContains(shell, '"level" : "level"', 2) + assertOutputContains(shell, '"level" : "component"', 2) // get cl-site config @@ -157,64 +146,4 @@ implements FuntestProperties, Arguments, SliderExitCodes, SliderActions { assertAppRunning(appId) } - public awaitRegistryOutfileContains( - File outfile, - List<String> commands, - String match) { - repeatUntilSuccess("registry", - this.&generatedFileContains, - REGISTRY_STARTUP_TIMEOUT * 2, - PROBE_SLEEP_TIME, - [ - text : match, - filename: outfile.absolutePath, - command : commands - ], - true, - "failed to find $match in output") { - slider(0, commands).dumpOutput() - fail("no $match in \n$outfile.text") - } - } - - /** - * Is the registry accessible for an application? - * @param args argument map containing <code>"application"</code> - * @return probe outcome - */ - protected Outcome commandOutputContains(Map args) { - String text = args['text']; - List<String> command = (List < String >)args['command'] - SliderShell shell = slider(0, command) - return Outcome.fromBool(shell.outputContains(text)) - } - - /** - * Is the registry accessible for an application? - * @param args argument map containing <code>"application"</code> - * @return probe outcome - */ - protected Outcome commandSucceeds(Map args) { - List<String> command = (List<String>) args['command'] - SliderShell shell = slider(command) - return Outcome.fromBool(shell.ret == 0) - } - - /** - * Is the registry accessible for an application? - * @param args argument map - * @return probe outcome - */ - protected Outcome generatedFileContains(Map args) { - List<String> command = (List<String>) args['command'] - String text = args['text']; - String filename = args['filename']; - File f = new File(filename) - f.delete() - SliderShell shell = slider(0, command) - shell.dumpOutput() - assert f.exists() - return Outcome.fromBool(f.text.contains(text)) - } - }