Mercurial > hg > ThermostatQA
changeset 129:167a4f9adb46
adding new version of (testAddVMAndSeeItInShellTest) to the CliClientDBModificationsSmokeTest testsuite
author | Jana Fabrikova <jfabriko@redhat.com> |
---|---|
date | Thu, 28 Nov 2013 16:15:14 +0100 |
parents | 49c76d19d687 |
children | 8612e27034af |
files | ChangeLog scripts/list-vms_therm_shell2.txt src/org/thermostat/qa/testsuites/CliClientDBModificationsSmokeTest.java |
diffstat | 3 files changed, 96 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Nov 28 15:29:28 2013 +0100 +++ b/ChangeLog Thu Nov 28 16:15:14 2013 +0100 @@ -1,3 +1,13 @@ +2013-11-28 Jana Fabrikova <jfabriko@redhat.com> + + * src/org/thermostat/qa/testuites/CliClientDBModificationsSmokeTest.java: + adding annotation TillVersion 0.18.1 to (testAddVMAndSeeItInShellTest), + adding new version (testAddVMAndSeeItInShellTest2) with annotation + SinceVersion 1.1.0, added behaviour is issuing empty strings as login and + password for the thermostat shell when attempting to call list-vms + * scripts/list-vms_therm_shell2.txt + auxiliary script containing thermostat shell commands for the new test + 2013-11-28 Jana Fabrikova <jfabriko@redhat.com> * src/org/thermostat/qa/framework/GuiRobot.java:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/list-vms_therm_shell2.txt Thu Nov 28 16:15:14 2013 +0100 @@ -0,0 +1,5 @@ +list-vms + + +exit +
--- a/src/org/thermostat/qa/testsuites/CliClientDBModificationsSmokeTest.java Thu Nov 28 15:29:28 2013 +0100 +++ b/src/org/thermostat/qa/testsuites/CliClientDBModificationsSmokeTest.java Thu Nov 28 16:15:14 2013 +0100 @@ -44,6 +44,8 @@ import org.thermostat.qa.annotations.TestTypes; import org.thermostat.qa.framework.Assert; import org.thermostat.qa.framework.ThermostatTest; +import org.thermostat.qa.annotations.TillVersion; +import org.thermostat.qa.annotations.SinceVersion; /** @@ -90,6 +92,7 @@ * @throws IOException * @throws AWTException */ + @TillVersion("0.18.1") public void testAddVMAndSeeItInShellTest() throws IOException, AWTException { // start storage startStorage(); @@ -139,6 +142,84 @@ stopStorage(); } + + /** + * Method testAddVMAndSeeItInShellTest2 + * tests if a virtual machine added to the thermostat database is visible + * in the shell if the command list-vms is issued, difference from + * testAddVMAndSeeItInShellTest is that the test issues login+password + * after the command list-vms (both empty strings). + * The method adds a vm and a host into the vm-info and host-info + * collections of the thermostat database respectively and deletes + * the new items after the tests. + * + * This method uses scripts and files + * <ul> + * <li><a href="scripts/find_mongo_port.sh">find_mongo_port.sh</a>, + * <li><a href="scripts/add_vm.sh">add_vm2.sh</a>, + * <li><a href="scripts/add_vm_db_commands.txt">add_vm_db_commands2.txt</a>, + * <li><a href="scripts/list-vms_therm_shell2.txt">list-vms_therm_shell2.txt</a>, + * <li><a href="scripts/delete_added_vm.sh">delete_added_vm.sh</a>, + * <li><a href="scripts/remove_vm_db_commands.txt">remove_vm_db_commands.txt</a> + * <ul> + * and rewrites one text file + * <a href="scripts/mongoPortNumber.txt">mongoPortNumber.txt</a>. + * and one script file + * <a href="scripts/run_thermostat_shell_with_commands.sh">run_thermostat_shell_with_commands.sh</a>. + * + * @throws IOException + * @throws AWTException + */ + @SinceVersion("1.1.0") + public void testAddVMAndSeeItInShellTest2() throws IOException, AWTException { + // start storage + startStorage(); + + // find out on which port to connect to db and add new vm to db + List<String> output1 = runHelperBashScript("find_mongo_port.sh"); + for (String s : output1) + { + logInfo("run", "Finding mongo port: " + s); + } + output1 = runHelperBashScript("add_vm2.sh"); + for (String s : output1) + { + logInfo("run", "Adding vm to mongo: " + s); + } + + // run shell command list-vms + output1 = runCommandsInThermostatShell("list-vms_therm_shell2.txt"); + + // test the output + some logging + Assert.assertNotNull(output1, "error getting standard output"); + for (String s : output1) + { + logInfo("run", "Thermostat shell: " + s); + } + + String headerLine = output1.get(4); + for (String headerElem : new String[] { "HOST_ID", "HOST", "VM_ID", "STATUS", "VM_NAME" }) + { + Assert.assertTrue(headerLine.contains(headerElem), headerElem + " not in the header of thermostat shell output"); + } + + boolean addedVmPresent = false; + for(String vmsLine : output1) + { + addedVmPresent = addedVmPresent || checkPresenceOfPatterns(vmsLine, new String[] { "non-existing-agent-no1", "artif.added.host0.name", "12345", "RUNNING", "unknown" }); + } + Assert.assertTrue(addedVmPresent," added vm not listed in the output"); + + // remove the added vm from db + List<String> output2 = runHelperBashScript("delete_added_vm.sh"); + for (String s : output2) + { + logInfo("run", "Deleting vm from mongo: " + s); + } + + stopStorage(); + + } public static void main(String[] args) { new CliClientDBModificationsSmokeTest().doTests(args);