Mercurial > hg > thermostat-ng > agent
changeset 2651:7be582a246e9
Don't attempt to run setup command
Reviewed-by: neugens, jkang
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-May/023075.html
author | Elliott Baron <ebaron@redhat.com> |
---|---|
date | Fri, 12 May 2017 11:08:29 -0400 |
parents | c6e6f0375b45 |
children | f293cef5a741 |
files | launcher/src/main/java/com/redhat/thermostat/launcher/internal/LauncherImpl.java launcher/src/test/java/com/redhat/thermostat/launcher/internal/LauncherImplTest.java |
diffstat | 2 files changed, 2 insertions(+), 74 deletions(-) [+] |
line wrap: on
line diff
--- a/launcher/src/main/java/com/redhat/thermostat/launcher/internal/LauncherImpl.java Fri May 12 10:26:38 2017 -0400 +++ b/launcher/src/main/java/com/redhat/thermostat/launcher/internal/LauncherImpl.java Fri May 12 11:08:29 2017 -0400 @@ -36,11 +36,10 @@ package com.redhat.thermostat.launcher.internal; -import java.io.File; import java.io.IOException; import java.io.PrintStream; +import java.util.ArrayList; import java.util.Arrays; -import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; @@ -76,7 +75,6 @@ import com.redhat.thermostat.launcher.InteractiveStorageCredentials; import com.redhat.thermostat.launcher.Launcher; import com.redhat.thermostat.shared.config.CommonPaths; -import com.redhat.thermostat.shared.config.InvalidConfigurationException; import com.redhat.thermostat.shared.config.SSLConfiguration; import com.redhat.thermostat.shared.locale.LocalizedString; import com.redhat.thermostat.shared.locale.Translate; @@ -170,14 +168,7 @@ } else if (isInfoQuery(args, inShell)) { showInfo(); } else { - // With web-always-on we need to make sure that the setup ran. - if (isSomeHelpInvocation(args) || isThermostatConfigured()) { - logger.log(Level.FINE, "Running command without setup interception."); - runCommandFromArguments(args, listeners, inShell); - } else { - logger.log(Level.FINE, "Running command through setup."); - runSetupThenInterceptedCommand(args); - } + runCommandFromArguments(args, listeners, inShell); } } catch (NoClassDefFoundError e) { // This could mean pom is missing <Private-Package> or <Export-Package> lines. @@ -201,47 +192,6 @@ } } - private boolean isSomeHelpInvocation(String[] args) { - for (String arg: args) { - if (HELP_SET.contains(arg)) { - return true; - } - } - return false; - } - - private void runSetupThenInterceptedCommand(String[] originalCmdArgs) { - String origCmdArgs = convertOriginalArgsToString(originalCmdArgs); - String[] setupArgs = { "setup", - "--origArgs", - origCmdArgs - }; - runCommandFromArguments(setupArgs, null, false); - } - - private String convertOriginalArgsToString(String[] origArgs) { - if (origArgs.length == 0) { - throw new AssertionError("Running setup with no argument?"); - } - final String separator = "|||"; - // single argument - if (origArgs.length == 1) { - return origArgs[0]; - } - StringBuilder buffer = new StringBuilder(); - for (int i = 0; i < origArgs.length - 1; i++) { - buffer.append(origArgs[i]); - buffer.append(separator); - } - buffer.append(origArgs[origArgs.length - 1]); - return buffer.toString(); - } - - private boolean isThermostatConfigured() throws InvalidConfigurationException { - File setupCompleteFile = paths.getUserSetupCompleteStampFile(); - return setupCompleteFile.exists(); - } - @SuppressWarnings({ "unchecked", "rawtypes" }) private void shutdown() throws InternalError { try {
--- a/launcher/src/test/java/com/redhat/thermostat/launcher/internal/LauncherImplTest.java Fri May 12 10:26:38 2017 -0400 +++ b/launcher/src/test/java/com/redhat/thermostat/launcher/internal/LauncherImplTest.java Fri May 12 11:08:29 2017 -0400 @@ -874,28 +874,6 @@ runAndVerifyCommand(new String[] { cmdName }, expected, isInShell); } - @Test - public void verifyOriginalCmdArgsArePassedOnToSetup() { - String[] argsList = new String[] { "list-vms", "--dbUrl=foo" }; - List<Pair<String[], Boolean>> resultList = runAsUnconfiguredThermostat(argsList); - assertEquals("Expected to run only setup", 1, resultList.size()); - Pair<String[], Boolean> actual = resultList.get(0); - assertFalse("Expected to run outside shell", actual.getSecond()); - String[] expectedList = new String[] { "setup", "--origArgs", "list-vms|||--dbUrl=foo" }; - assertArrayEquals(expectedList, actual.getFirst()); - } - - @Test - public void verifyOriginalCmdArgsArePassedOnToSetup2() { - String[] argsList = new String[] { "web-storage-service" }; - List<Pair<String[], Boolean>> resultList = runAsUnconfiguredThermostat(argsList); - assertEquals("Expected to run only setup", 1, resultList.size()); - Pair<String[], Boolean> actual = resultList.get(0); - assertFalse("Expected to run outside shell", actual.getSecond()); - String[] expectedList = new String[] { "setup", "--origArgs", "web-storage-service" }; - assertArrayEquals(expectedList, actual.getFirst()); - } - /* * Bash completion uses help which expects help to always run * (no setup required).