SLIDER-555-JVM
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/18ef3ede Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/18ef3ede Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/18ef3ede Branch: refs/heads/develop Commit: 18ef3ede3b7b98e1fdb1416de440dc94d9de5426 Parents: 0991ba5 Author: Steve Loughran <[email protected]> Authored: Sun Oct 26 14:33:01 2014 +0000 Committer: Steve Loughran <[email protected]> Committed: Sun Oct 26 16:09:11 2014 +0000 ---------------------------------------------------------------------- .../org/apache/slider/common/SliderKeys.java | 11 ++++ .../framework/AgentCommandTestBase.groovy | 58 +----------------- .../slider/funtest/framework/SliderShell.groovy | 63 ++++++++++++++++++++ .../commands/DiagnosticsCommandIT.groovy | 23 ++++++- 4 files changed, 99 insertions(+), 56 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/18ef3ede/slider-core/src/main/java/org/apache/slider/common/SliderKeys.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/common/SliderKeys.java b/slider-core/src/main/java/org/apache/slider/common/SliderKeys.java index 5f16e56..89cc263 100644 --- a/slider-core/src/main/java/org/apache/slider/common/SliderKeys.java +++ b/slider-core/src/main/java/org/apache/slider/common/SliderKeys.java @@ -190,4 +190,15 @@ public interface SliderKeys extends SliderXmlConfKeys { "org.apache.hadoop.yarn.server.webproxy.amfilter.AmFilterInitializer"; String KEY_ALLOWED_PORT_RANGE = "site.global.slider.allowed.ports"; + /** + * Allowed port range + */ + String KEY_AM_ALLOWED_PORT_RANGE = "slider.am.allowed.port.range"; + + /** + * env var for custom JVM options. + */ + String SLIDER_JVM_OPTS = "SLIDER_JVM_OPTS"; + + String SLIDER_CLASSPATH_EXTRA = "SLIDER_CLASSPATH_EXTRA"; } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/18ef3ede/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 8af51b4..b44ae07 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 @@ -24,7 +24,6 @@ import org.apache.hadoop.security.UserGroupInformation import org.apache.slider.common.SliderExitCodes import org.apache.slider.common.params.Arguments import org.apache.slider.common.params.SliderActions -import org.apache.slider.common.tools.SliderUtils import org.apache.tools.zip.ZipEntry import org.apache.tools.zip.ZipOutputStream import org.junit.Before @@ -125,66 +124,15 @@ implements FuntestProperties, Arguments, SliderExitCodes, SliderActions { } public static String findLineEntry(SliderShell shell, String[] locaters) { - int index = 0; - def output = shell.out - output += shell.err - for (String str in output) { - if (str.contains("\"" + locaters[index] + "\"")) { - if (locaters.size() == index + 1) { - return str; - } else { - index++; - } - } - } - - return null; + return shell.findLineEntry(locaters) } public static boolean containsString(SliderShell shell, String lookThisUp, int n = 1) { - int count = 0 - def output = shell.out - output += shell.err - for (String str in output) { - int subCount = countString(str, lookThisUp) - count = count + subCount - if (count == n) { - return true; - } - } - - return false; - } - - public static int countString(String str, String search) { - int count = 0 - if (SliderUtils.isUnset(str) || SliderUtils.isUnset(search)) { - return count - } - - int index = str.indexOf(search, 0) - while (index > 0) { - index = str.indexOf(search, index + 1) - ++count - } - return count + return shell.outputContains(lookThisUp, n) } public static String findLineEntryValue(SliderShell shell, String[] locaters) { - String line = findLineEntry(shell, locaters); - - if (line != null) { - log.info("Parsing {} for value.", line) - int dividerIndex = line.indexOf(":"); - if (dividerIndex > 0) { - String value = line.substring(dividerIndex + 1).trim() - if (value.endsWith(",")) { - value = value.subSequence(0, value.length() - 1) - } - return value; - } - } - return null; + return shell.findLineEntryValue(locaters) } public static void addDir(File dirObj, ZipOutputStream zipFile, String prefix) { http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/18ef3ede/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/SliderShell.groovy ---------------------------------------------------------------------- diff --git a/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/SliderShell.groovy b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/SliderShell.groovy index 86595dc..d7665ae 100644 --- a/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/SliderShell.groovy +++ b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/SliderShell.groovy @@ -280,4 +280,67 @@ class SliderShell extends Shell { return this } + + public String findLineEntry(String[] locaters) { + int index = 0; + def output = out +"\n"+ err + for (String str in output) { + if (str.contains("\"" + locaters[index] + "\"")) { + if (locaters.size() == index + 1) { + return str; + } else { + index++; + } + } + } + + return null; + } + + public boolean outputContains( + String lookThisUp, + int n = 1) { + int count = 0 + def output = out + "\n" + err + for (String str in output) { + int subCount = countString(str, lookThisUp) + count = count + subCount + if (count == n) { + return true; + } + } + return false; + } + + public static int countString(String str, String search) { + int count = 0 + if (SliderUtils.isUnset(str) || SliderUtils.isUnset(search)) { + return count + } + + int index = str.indexOf(search, 0) + while (index > 0) { + index = str.indexOf(search, index + 1) + ++count + } + return count + } + + public findLineEntryValue(String[] locaters) { + String line = findLineEntry(locaters); + + if (line != null) { + log.info("Parsing {} for value.", line) + int dividerIndex = line.indexOf(":"); + if (dividerIndex > 0) { + String value = line.substring(dividerIndex + 1).trim() + if (value.endsWith(",")) { + value = value.subSequence(0, value.length() - 1) + } + return value; + } + } + return null; + } + } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/18ef3ede/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/DiagnosticsCommandIT.groovy ---------------------------------------------------------------------- diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/DiagnosticsCommandIT.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/DiagnosticsCommandIT.groovy index bc19367..7541dbe 100644 --- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/DiagnosticsCommandIT.groovy +++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/DiagnosticsCommandIT.groovy @@ -20,9 +20,11 @@ package org.apache.slider.funtest.commands import groovy.transform.CompileStatic import groovy.util.logging.Slf4j +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.CommandTestBase +import org.apache.slider.funtest.framework.SliderShell import org.junit.Test @CompileStatic @@ -41,7 +43,26 @@ public class DiagnosticsCommandIT extends CommandTestBase { println(shell.stdoutHistory) println() println(shell.stdErrHistory) - + } + + @Test + public void testJVMOptionPassdown() throws Throwable { + SliderShell shell = new SliderShell([ + SliderActions.ACTION_DIAGNOSTICS, + Arguments.ARG_CLIENT, + Arguments.ARG_VERBOSE + ]) + + def name = "testpropertySetInFuntest" + + def val = "TestPropertyValue" + shell.setEnv(SliderKeys.SLIDER_JVM_OPTS, "-D" + name + "=" + val) + shell.execute(0) + assert shell.outputContains(name) + assert shell.outputContains(val) + assert shell.outputContains(SliderKeys.PROPERTY_LIB_DIR) + assert shell.outputContains(SliderKeys.PROPERTY_CONF_DIR) + } }
