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/10 23:45:58 UTC
[08/24] incubator-slider git commit: SLIDER-622 moved exec operations
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/290a5e89
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/290a5e89
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/290a5e89
Branch: refs/heads/develop
Commit: 290a5e890d245304b00af99006709a0584241846
Parents: 1ea195d
Author: Steve Loughran <st...@apache.org>
Authored: Mon Nov 10 17:50:12 2014 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Mon Nov 10 17:50:12 2014 +0000
----------------------------------------------------------------------
.../apache/slider/test/SliderTestUtils.groovy | 41 ++++++++++++++++++++
1 file changed, 41 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/290a5e89/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