SLIDER-622 moved exec operations
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/75e6efc0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/75e6efc0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/75e6efc0 Branch: refs/heads/master Commit: 75e6efc025962cea8c819c117607d2f0208ce532 Parents: f2e63f6 Author: Steve Loughran <[email protected]> Authored: Mon Nov 10 17:50:12 2014 +0000 Committer: Steve Loughran <[email protected]> Committed: Mon Nov 10 22:48:09 2014 +0000 ---------------------------------------------------------------------- .../apache/slider/test/SliderTestUtils.groovy | 41 ++++++++++++++++++++ 1 file changed, 41 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/75e6efc0/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy index 634b6b5..8d6c036 100644 --- a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy @@ -28,6 +28,7 @@ import org.apache.hadoop.conf.Configuration import org.apache.hadoop.fs.FileStatus import org.apache.hadoop.fs.FileSystem as HadoopFS import org.apache.hadoop.fs.Path +import org.apache.hadoop.service.ServiceStateException import org.apache.hadoop.util.Shell import org.apache.hadoop.yarn.api.records.ApplicationReport import org.apache.hadoop.yarn.conf.YarnConfiguration @@ -46,6 +47,7 @@ import org.apache.slider.core.exceptions.WaitTimeoutException import org.apache.slider.core.main.ServiceLaunchException import org.apache.slider.core.main.ServiceLauncher import org.apache.slider.core.registry.docstore.PublishedConfigSet +import org.apache.slider.server.services.workflow.ForkedProcessService import org.junit.Assert import org.junit.Assume @@ -520,6 +522,45 @@ class SliderTestUtils extends Assert { int actual = instances != null ? instances.size() : 0 return actual } + /** + * Exec a set of commands, wait a few seconds for it to finish. + * @param status code + * @param commands + * @return the process + */ + public static ForkedProcessService exec(int status, List<String> commands) { + ForkedProcessService process = exec(commands) + assert status == process.exitCode + return process + } + /** + * Exec a set of commands, wait a few seconds for it to finish. + * @param commands + * @return + */ + public static ForkedProcessService exec(List<String> commands) { + ForkedProcessService process; + process = new ForkedProcessService( + commands[0], + [:], + commands); + process.init(new Configuration()); + process.start(); + process.waitForServiceToStop(10000); + process + } + + public static boolean doesWindowsAppExist(List<String> commands) { + try { + exec(0, commands) + return true; + } catch (ServiceStateException e) { + if (!(e.cause instanceof FileNotFoundException)) { + throw e; + } + return false; + } + } /** * Execute a closure, assert it fails with a given exit code and text
