Mercurial > hg > ThermostatQA
changeset 74:768acb232957
modifying ServiceSmokeTests testsuite
author | Jana Fabrikova <jfabriko@redhat.com> |
---|---|
date | Fri, 14 Jun 2013 10:19:36 +0200 |
parents | e5fc1bf81ded |
children | 76a23f5176f2 |
files | ChangeLog Makefile src/org/thermostat/qa/testsuites/ServiceSmokeTests.java src/org/thermostat/qa/testsuites/package-info.java |
diffstat | 4 files changed, 114 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Jun 13 17:02:56 2013 +0200 +++ b/ChangeLog Fri Jun 14 10:19:36 2013 +0200 @@ -1,3 +1,12 @@ +2013-06-14 Jana Fabrikova <jfabriko@redhat.com> + + * src/org/thermostat/qa/testsuites/ServiceSmokeTests.java: + adding auxiliary methods (getNumberOfAgentsRunning), + (stopAllThermostatAgents) and (getNumberOfMongosRunning), + modifying the testcase (testStartService) + * Makefile: + adding ServiceSmokeTests to the runtests goal + 2013-06-13 Jana Fabrikova <jfabriko@redhat.com> * src/org/thermostat/qa/framework/ThermostatTest.java:
--- a/Makefile Thu Jun 13 17:02:56 2013 +0200 +++ b/Makefile Fri Jun 14 10:19:36 2013 +0200 @@ -35,6 +35,7 @@ SmokeTests \ AgentTest \ StorageSmokeTest \ + ServiceSmokeTests \ GuiClientSmokeTest \ CliClientSmokeTest \ GuiClientDBModificationsSmokeTest \
--- a/src/org/thermostat/qa/testsuites/ServiceSmokeTests.java Thu Jun 13 17:02:56 2013 +0200 +++ b/src/org/thermostat/qa/testsuites/ServiceSmokeTests.java Fri Jun 14 10:19:36 2013 +0200 @@ -45,7 +45,13 @@ import org.thermostat.qa.framework.ThermostatTest; - +/** + * Class ServiceSmokeTests + * contains basic smoke tests for checking if thermostat service works + * properly. Starting the agent and storage by command "thermostat service" + * is checked. + * + */ @TestType(TestTypes.SERVICE_TEST) public class ServiceSmokeTests extends ThermostatTest { @@ -60,25 +66,117 @@ { // TODO Auto-generated method stub } + + /** + * Method getNumberOfAgentsRunning + * runs the script + * <a href="../../../../../../scripts/list_all_therm_agents.sh">list_all_therm_agents.sh</a> + * + * + * @return + * the count of running Thermostat agents + * @throws IOException + */ + private int getNumberOfAgentsRunning() throws IOException + { + + List<String> output = runHelperBashScript("list_all_therm_agents.sh"); + Assert.assertNotNull(output, "error running script 'list_all_therm_agents.sh'"); + + return output.size(); + } + + /** + * Method stopAllThermostatAgents + * kills all processes that are thermostat agents by running script + * <a href="../../../../../../scripts/stop_all_therm_agents.sh">stop_all_therm_agents.sh</a> + * + * @throws IOException + */ + private void stopAllThermostatAgents() throws IOException + { + List<String> output = runHelperBashScript("stop_all_therm_agents.sh"); + Assert.assertNotNull(output, "error running script 'list_all_therm_agents.sh'"); + } + + /** + * Method getNumberOfMongosRunning + * runs the script + * <a href="../../../../../../scripts/ps_mongo_daemon.sh">ps_mongo_daemon.sh</a> + * + * + * @return + * the count of running mongo processes + * @throws IOException + */ + private int getNumberOfMongosRunning() throws IOException + { + List<String> out = runHelperBashScript("ps_mongo_daemon.sh"); + Assert.assertNotNull(out, "script 'ps_mongo_daemon.sh' can't be started"); + + return out.size(); + } + /** + * Method testStartService + * runs thermostat service and checks if storage and agent are running + * at the right time. Before the command they should not be running, + * after the command they should, and after stopping the agent, calling + * "storage --stop" and waiting for 10s there should be no running db or + * agents present. + * + * Methods called from this test use the following scripts: + * <ul> + * <li><a href="../../../../../../scripts/list_all_therm_agents.sh">list_all_therm_agents.sh</a>, + * <li><a href="../../../../../../scripts/stop_all_therm_agents.sh">stop_all_therm_agents.sh</a>, + * <li><a href="../../../../../../scripts/ps_mongo_daemon.sh">ps_mongo_daemon.sh</a>. + * <ul> + * + * @throws IOException + */ public void testStartService() throws IOException { + //ensure there is no running storage before the test + Assert.assertEquals(getNumberOfMongosRunning(), 0, "there should be no db running before the test"); + + //ensure there is no running agent before the test + Assert.assertEquals(getNumberOfAgentsRunning(), 0, "there should not be any agent running before the test"); + + //run thermostat service new Thread(new ServiceStarter()).start(); try { - Thread.sleep(5000); + Thread.sleep(FIVE_SEC); } catch (InterruptedException e) { e.printStackTrace(); } - Process process = runThermostatInNewProcess("service", "--stop"); + + //detect a running storage + Assert.assertTrue(getNumberOfMongosRunning()>0, "the db should be running after service started"); + + //detect a running agent + Assert.assertTrue(getNumberOfAgentsRunning()>0, "there should be >0 running thermostat agents"); + + //stop thermostat agent + storage + stopAllThermostatAgents(); + Process process = runThermostatInNewProcess("storage", "--stop"); List<String> processOutput = readProcessOutput(process); for (String s : processOutput) { System.out.println("Service stopper: " + s); } Assert.assertNotNull(processOutput, "error getting standard output"); + + //wait till storage+agent stops + sleep(FIVE_SEC*2); + + //ensure there is no running storage after the test + Assert.assertEquals(getNumberOfMongosRunning(), 0, "there should be no db running after the test"); + + //ensure there is no running agent after the test + Assert.assertEquals(getNumberOfAgentsRunning(), 0, "there should not be any agent running after the test"); } public static void main(String[] args)
--- a/src/org/thermostat/qa/testsuites/package-info.java Thu Jun 13 17:02:56 2013 +0200 +++ b/src/org/thermostat/qa/testsuites/package-info.java Fri Jun 14 10:19:36 2013 +0200 @@ -8,6 +8,9 @@ * <ol> * <li> Set path to the thermostat binaries you want to test in * <i>test.properties</i> + * <li> Before the very first run of the tests you may need to create + * the directory <i>screenshots</i> in <i>ThermostatQA</i> if it does not + * exist already. * <li> (A) run tests absolutely anew * <ul> * <li><code>make clean</code>