# HG changeset patch # User Zdenek Zambersky # Date 1449509510 -3600 # Node ID 1b447165fbd0a2b03071f8ed65dfa4c42618aac1 # Parent a74aa91ab44ca147f19cad8d521cdfc2fe6dc5b2 enabled collection where missing diff -r a74aa91ab44c -r 1b447165fbd0 src/org/thermostat/qa2/framework/utils/ProcessUtilities.java --- a/src/org/thermostat/qa2/framework/utils/ProcessUtilities.java Mon Nov 30 19:08:04 2015 +0100 +++ b/src/org/thermostat/qa2/framework/utils/ProcessUtilities.java Mon Dec 07 18:31:50 2015 +0100 @@ -95,7 +95,7 @@ public static Shell createMongoShell() { String[] mongoCmds = {"mongo", "127.0.0.1:" + ThermostatQAConfig.mongoPort}; - Shell mongo = new Shell(mongoCmds); + Shell mongo = new Shell(getCommandLine(mongoCmds)); return mongo; } @@ -105,12 +105,16 @@ public static Shell createThermostatShell(String target) { String[] thermostatCmds = {ThermostatQAConfig.getThermostatExecutablePath(target), "shell"}; - Shell thermostat = new Shell(thermostatCmds); + Shell thermostat = new Shell(getCommandLine(thermostatCmds)); thermostat.setEnvironmentVariable("USER_THERMOSTAT_HOME", ThermostatQAConfig.getThermostatUserHome()); return thermostat; } - public static String[] getCommandlineWithCollection(String... args) { + public static String[] getCommandLine(String... args) { + return ThermostatQAConfig.isCollectionUsed() ? getCommandLineWithCollection(args) : args; + } + + public static String[] getCommandLineWithCollection(String... args) { String[] cmds = new String[4]; cmds[0] = "scl"; cmds[1] = "enable"; diff -r a74aa91ab44c -r 1b447165fbd0 src/org/thermostat/qa2/framework/utils/ThermostatUtilities.java --- a/src/org/thermostat/qa2/framework/utils/ThermostatUtilities.java Mon Nov 30 19:08:04 2015 +0100 +++ b/src/org/thermostat/qa2/framework/utils/ThermostatUtilities.java Mon Dec 07 18:31:50 2015 +0100 @@ -110,9 +110,7 @@ + users + "\\n\" | " + setupPath}; - if (ThermostatQAConfig.isCollectionUsed()) { - cmds = ProcessUtilities.getCommandlineWithCollection(cmds); - } + cmds = ProcessUtilities.getCommandLine(cmds); process = new NativeProcess(cmds); process.setLabel("Thermostat setup"); @@ -542,27 +540,12 @@ } public static String[] getThermostatCommandLineTargeted(String target, String... args) { - String[] cmds; - if (target.equals("tested") && ThermostatQAConfig.isCollectionUsed()) { - cmds = new String[4]; - cmds[0] = "scl"; - cmds[1] = "enable"; - cmds[2] = ThermostatQAConfig.getCollectionName(); - StringBuilder sb = new StringBuilder(); - sb.append(ThermostatQAConfig.getThermostatExecutablePath()); - for (int i = 0; i < args.length; ++i) { - sb.append(" "); - sb.append(args[i]); - } - cmds[3] = sb.toString(); - } else { - cmds = new String[args.length + 1]; - cmds[0] = ThermostatQAConfig.getThermostatExecutablePath(target); - for (int i = 0; i < args.length; ++i) { - cmds[i + 1] = args[i]; - } + String[] cmds = new String[args.length + 1]; + cmds[0] = ThermostatQAConfig.getThermostatExecutablePath(target); + for (int i = 0; i < args.length; ++i) { + cmds[i + 1] = args[i]; } - return cmds; + return ProcessUtilities.getCommandLine(cmds); } } diff -r a74aa91ab44c -r 1b447165fbd0 src/org/thermostat/qa2/tests/CliClientDBModificationsSmokeTest.java --- a/src/org/thermostat/qa2/tests/CliClientDBModificationsSmokeTest.java Mon Nov 30 19:08:04 2015 +0100 +++ b/src/org/thermostat/qa2/tests/CliClientDBModificationsSmokeTest.java Mon Dec 07 18:31:50 2015 +0100 @@ -63,8 +63,7 @@ mongo.writeln("quit()"); mongo.waitFor(); - String[] thermostatCmds = {ThermostatQAConfig.getThermostatExecutablePath(), "shell"}; - Shell thermostat = new Shell(thermostatCmds); + Shell thermostat = ProcessUtilities.createThermostatShell(); thermostat.setEnvironmentVariable("USER_THERMOSTAT_HOME", ThermostatQAConfig.getThermostatUserHome()); thermostat.setStdOutMode(NativeProcess.MODE_LOG_AND_BUFFER); thermostat.start(); diff -r a74aa91ab44c -r 1b447165fbd0 src/org/thermostat/qa2/tests/DBCommandsHeapDumpTest.java --- a/src/org/thermostat/qa2/tests/DBCommandsHeapDumpTest.java Mon Nov 30 19:08:04 2015 +0100 +++ b/src/org/thermostat/qa2/tests/DBCommandsHeapDumpTest.java Mon Dec 07 18:31:50 2015 +0100 @@ -41,6 +41,7 @@ /** * Test class ported from old framework + * * @author Zdeněk Žamberský */ public class DBCommandsHeapDumpTest { @@ -55,7 +56,7 @@ public void setUp() throws Exception { List vmsLines = ThermostatUtilities.getListVmsOutput(); String vmLine = ThermostatUtilities.getRunningVmLine(); - + assertTrue(vmLine != null, "Problem finding a running vm!"); String[] lineParts = vmLine.split(" "); String hostId = lineParts[0]; @@ -64,11 +65,13 @@ ThermostatUtilities.dumpHeap(hostId, vmId); String script = "." + File.separator + "scripts" + File.separator + "check-collections-heap-dump.js"; - scriptOutput = ProcessUtilities.runGetOutput("mongo", "127.0.0.1:" + ThermostatQAConfig.mongoPort, script); + String[] commands = new String[]{"mongo", "127.0.0.1:" + ThermostatQAConfig.mongoPort, script}; + commands = ProcessUtilities.getCommandLine(commands); + scriptOutput = ProcessUtilities.runGetOutput(commands); } public static String errMessage = "problems running auxiliary script"; - + @Test public void hostInfo() { assertNotNull(scriptOutput, errMessage); @@ -135,7 +138,6 @@ assertContainsPattern(scriptOutput, "schema for vm-memory-stats is OK"); } - @Test public void vmThreadHarvesting() { assertNotNull(scriptOutput, errMessage); diff -r a74aa91ab44c -r 1b447165fbd0 src/org/thermostat/qa2/tests/DBGuiHeapDumpTest.java --- a/src/org/thermostat/qa2/tests/DBGuiHeapDumpTest.java Mon Nov 30 19:08:04 2015 +0100 +++ b/src/org/thermostat/qa2/tests/DBGuiHeapDumpTest.java Mon Dec 07 18:31:50 2015 +0100 @@ -75,7 +75,9 @@ CommonUtilities.sleep(5000); String script = "." + File.separator + "scripts" + File.separator + "check-collections-heap-dump.js"; - scriptOutput = ProcessUtilities.runGetOutput("mongo", "127.0.0.1:" + ThermostatQAConfig.mongoPort, script); + String[] commands = new String[]{"mongo", "127.0.0.1:" + ThermostatQAConfig.mongoPort, script}; + commands= ProcessUtilities.getCommandLine(commands); + scriptOutput = ProcessUtilities.runGetOutput(commands); } public static String errMessage = "problems running auxiliary script"; diff -r a74aa91ab44c -r 1b447165fbd0 src/org/thermostat/qa2/tests/DBSchemeSmokeTest.java --- a/src/org/thermostat/qa2/tests/DBSchemeSmokeTest.java Mon Nov 30 19:08:04 2015 +0100 +++ b/src/org/thermostat/qa2/tests/DBSchemeSmokeTest.java Mon Dec 07 18:31:50 2015 +0100 @@ -42,9 +42,11 @@ import org.thermostat.qa2.framework.annotations.Test; import org.thermostat.qa2.framework.services.ThermostatAgent; import org.thermostat.qa2.framework.utils.CommonUtilities; +import org.thermostat.qa2.framework.utils.ProcessUtilities; /** * Test class ported from old framework + * * @author Zdeněk Žamberský */ public class DBSchemeSmokeTest { @@ -61,7 +63,8 @@ assertRuns(agent, "agent should be running"); CommonUtilities.sleep(5000); String script = "." + File.separator + "scripts" + File.separator + "check-collections-smoke.js"; - NativeProcess process = new NativeProcess("mongo", "127.0.0.1:" + ThermostatQAConfig.mongoPort, script); + String[] commands = new String[]{"mongo", "127.0.0.1:" + ThermostatQAConfig.mongoPort, script}; + NativeProcess process = new NativeProcess(ProcessUtilities.getCommandLine(commands)); process.setStdOutMode(NativeProcess.MODE_LOG_AND_BUFFER); process.start(); process.waitFor(); @@ -145,5 +148,5 @@ assertNotNull(scriptOutput, "problems running auxiliary js script in mongo shell"); assertContainsPattern(scriptOutput, "schema for vm-thread-harvesting is OK"); } - + } diff -r a74aa91ab44c -r 1b447165fbd0 src/org/thermostat/qa2/tests/OutputMessagesTest.java --- a/src/org/thermostat/qa2/tests/OutputMessagesTest.java Mon Nov 30 19:08:04 2015 +0100 +++ b/src/org/thermostat/qa2/tests/OutputMessagesTest.java Mon Dec 07 18:31:50 2015 +0100 @@ -38,6 +38,7 @@ import org.thermostat.qa2.framework.annotations.SetupThermostat; import org.thermostat.qa2.framework.annotations.Test; import org.thermostat.qa2.framework.utils.FileUtilities; +import org.thermostat.qa2.framework.utils.ThermostatUtilities; /** * Test class ported from old framework @@ -47,13 +48,11 @@ public class OutputMessagesTest { public static void checkHelpMessage(String[] commands) throws Exception { + String[] allCommands = ThermostatUtilities.getThermostatCommandLine(commands); + String fileName = "thermostat"; - String[] allCommands = new String[commands.length + 1]; - allCommands[0] = ThermostatQAConfig.getThermostatExecutablePath(); - for (int i = 0; i < commands.length; ++i) { fileName += "_" + commands[i]; - allCommands[i + 1] = commands[i]; } NativeProcess process = new NativeProcess(allCommands); diff -r a74aa91ab44c -r 1b447165fbd0 src/org/thermostat/qa2/tests/SmokeTests.java --- a/src/org/thermostat/qa2/tests/SmokeTests.java Mon Nov 30 19:08:04 2015 +0100 +++ b/src/org/thermostat/qa2/tests/SmokeTests.java Mon Dec 07 18:31:50 2015 +0100 @@ -39,9 +39,11 @@ import org.thermostat.qa2.framework.annotations.SetupThermostat; import org.thermostat.qa2.framework.annotations.Test; import org.thermostat.qa2.framework.utils.ProcessUtilities; +import org.thermostat.qa2.framework.utils.ThermostatUtilities; /** * Test class ported from old framework + * * @author Zdeněk Žamberský */ @SetupThermostat @@ -70,18 +72,18 @@ @Test public void tryToRunThermostatExecutable() throws IOException, InterruptedException { - ProcessUtilities.runRaw(ThermostatQAConfig.getThermostatExecutablePath()); + ProcessUtilities.runRaw(ThermostatUtilities.getThermostatCommandLine(new String[]{})); } @Test public void checkExitValue() throws IOException, InterruptedException { - int exitValue = ProcessUtilities.runRaw(ThermostatQAConfig.getThermostatExecutablePath()); + int exitValue = ProcessUtilities.runRaw(ThermostatUtilities.getThermostatCommandLine(new String[]{})); assertTrue(exitValue == 0, "thermostat returned non-zero value"); } @Test public void checkStandardMessage() throws IOException, Exception { - NativeProcess process = new NativeProcess(ThermostatQAConfig.getThermostatExecutablePath()); + NativeProcess process = new NativeProcess(ThermostatUtilities.getThermostatCommandLine(new String[]{})); process.setEnvironmentVariable("USER_THERMOSTAT_HOME", ThermostatQAConfig.getThermostatUserHome()); process.setStdOutMode(NativeProcess.MODE_LOG_AND_BUFFER); process.start();