# HG changeset patch # User Zdenek Zambersky # Date 1436892800 -7200 # Node ID 2650531d6d93d1419bfeff5c7738de00638d709a # Parent 7ffc366993b5a2706c7cdb867588d96db12d70c0 Reflecting shell parameter changes done in thermostat diff -r 7ffc366993b5 -r 2650531d6d93 src/org/thermostat/qa2/framework/utils/ThermostatUtilities.java --- a/src/org/thermostat/qa2/framework/utils/ThermostatUtilities.java Tue Jul 14 18:50:43 2015 +0200 +++ b/src/org/thermostat/qa2/framework/utils/ThermostatUtilities.java Tue Jul 14 18:53:20 2015 +0200 @@ -266,6 +266,41 @@ ProcessUtilities.shellRun("mv " + deployDir + File.separator + name + " " + deployedAppPath); } + /* Zero, negative or positive value is returned for first version equal to, + lower or higher than second */ + public static int compareVersions(String version1, String version2) { + String version1lc = version1.toLowerCase(); + String version2lc = version2.toLowerCase(); + + int index1; + int index2; + int index1Old = -1; + int index2Old = -1; + String component1; + String component2; + do { + index1 = version1.indexOf(".", index1Old + 1); + index2 = version2.indexOf(".", index2Old + 1); + component1 = index1 >= 0 ? version1lc.substring(index1Old + 1, index1) : version1lc.substring(index1Old + 1); + component2 = index2 >= 0 ? version2lc.substring(index2Old + 1, index2) : version2lc.substring(index2Old + 1); + if (!component1.equals(component2)) { + if (component1.equals("head")) { + return 1; + } + if (component2.equals("head")) { + return -1; + } + int sub = Integer.valueOf(component1) - Integer.valueOf(component2); + if (sub != 0) { + return sub; + } + } + index1Old = index1; + index2Old = index2; + } while (index1 >= 0 && index2 >= 0); + return 0; + } + /* Starts thermostat shell executes requested command in it, writes username/password, exits shell and returns output as line list */ public static List getShellCommandOutput(String target, String command) throws Exception { @@ -354,7 +389,11 @@ } public static List killVm(String hostId, String vmId) throws Exception { - return getShellCommandOutput("tested", "kill-vm --vmId " + vmId + " --hostId " + hostId); + if (compareVersions(ThermostatQAConfig.getThermostatVersion("tested"), "head") == 0) { + return getShellCommandOutput("tested", "kill-vm --vmId " + vmId); + } else { + return getShellCommandOutput("tested", "kill-vm --vmId " + vmId + " --hostId " + hostId); + } } public static String getHeapDumpLine(String hostId, String vmId) throws Exception { @@ -391,7 +430,11 @@ } public static void dumpHeap(String target, String hostId, String vmId) throws Exception { - getShellCommandOutput(target, "dump-heap --hostId " + hostId + " --vmId " + vmId); + if (compareVersions(ThermostatQAConfig.getThermostatVersion(target), "head") == 0) { + getShellCommandOutput(target, "dump-heap --vmId " + vmId); + } else { + getShellCommandOutput(target, "dump-heap --hostId " + hostId + " --vmId " + vmId); + } } public static List saveHeapDumpToFile(String heapId, String file) throws Exception {