Mercurial > hg > ThermostatQA
changeset 98:994289841798
adding a testcase to AgentWebStorageTest and modifying GuiClientSmokeTest
author | Jana Fabrikova <jfabriko@redhat.com> |
---|---|
date | Wed, 25 Sep 2013 08:55:25 +0200 |
parents | 5960410c77e5 |
children | 6ebca48f4353 |
files | ChangeLog src/org/thermostat/qa/framework/ThermostatUtilities.java src/org/thermostat/qa/testsuites/AgentWebStorageTest.java src/org/thermostat/qa/testsuites/GuiClientSmokeTest.java |
diffstat | 4 files changed, 221 insertions(+), 87 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Sep 23 17:57:39 2013 +0200 +++ b/ChangeLog Wed Sep 25 08:55:25 2013 +0200 @@ -1,3 +1,18 @@ +2013-09-25 Jana Fabrikova <jfabriko@redhat.com> + + * src/org/thermostat/qa/testsuites/GuiClientSmokeTest.java: + modifying the (testStartGUIWithStorageMenuEditTest) testcase + so the gui artifacts that appear only when clicking automatically + do not make the test fail too often + +2013-09-23 Jana Fabrikova <jfabriko@redhat.com> + + * src/org/thermostat/qa/framework/ThermostatUtilities.java: + adding method (prepareWebStorageBadAgentLoginFile) + * src/org/thermostat/qa/testsuites/AgentWebStorageTest.java: + adding new testcase (testStartAgentWithBadLogin), + modifications in the other tescases + 2013-09-23 Pavel Tisnovsky <ptisnovs@redhat.com> * Makefile:
--- a/src/org/thermostat/qa/framework/ThermostatUtilities.java Mon Sep 23 17:57:39 2013 +0200 +++ b/src/org/thermostat/qa/framework/ThermostatUtilities.java Wed Sep 25 08:55:25 2013 +0200 @@ -452,6 +452,26 @@ runBashScriptWithContent("webStorage_prepareWebConfig.sh", lines); } + + /** + * Method prepareWebStorageBadAgentLoginFile + * copies a thermostat configuration file for agent logins that would not + * work, because the login and password will be different from the ones + * given in the thermostat configuration. + * + * The method does it by creating a script + * webStorage_prepareBadAgentAuth.sh + * and running this script. + * + * @throws IOException + */ + protected void prepareWebStorageBadAgentLoginFile() throws IOException + { + List<String> lines = new LinkedList<String>(); + lines.add("cp ./storageconfig/web-tomcat/agent.badauth "+this.configuration.getThermostatUserHome() + "etc/agent.auth"); + + runBashScriptWithContent("webStorage_prepareBadAgentAuth.sh", lines); + } /** * Method restoreNormalStorageConfigFiles
--- a/src/org/thermostat/qa/testsuites/AgentWebStorageTest.java Mon Sep 23 17:57:39 2013 +0200 +++ b/src/org/thermostat/qa/testsuites/AgentWebStorageTest.java Wed Sep 25 08:55:25 2013 +0200 @@ -37,10 +37,7 @@ import java.util.List; import org.thermostat.qa.framework.Assert; -import org.thermostat.qa.framework.GuiRobot; -import org.thermostat.qa.framework.ThermostatGuiTest; import org.thermostat.qa.framework.ThermostatTest; -import org.thermostat.qa.framework.ThermostatUtilities.GuiThread; /** * Class AgentTest @@ -48,45 +45,70 @@ * various parts of web storage (which should not work) and with web storage is checked. * */ -public class AgentWebStorageTest extends ThermostatGuiTest +public class AgentWebStorageTest extends ThermostatTest { - private static final String[] THERM_AGENT_WITH_TOMCAT_ONLY_THERMOSTAT_LOGS = new String[] { - "com.mongodb.MongoException.Network: Read operation to server /127.0.0.1:27518 failed on database thermostat", - "java.net.ConnectException: Connection refused" + private String[] THERM_AGENT_WITH_TOMCAT_ONLY_THERMOSTAT_LOGS; + private String[] THERM_AGENT_WITH_TOMCAT_ONLY_CATALINA_LOGS; + private String[] THERM_AGENT_WITH_WEB_STORAGE_THERMOSTAT_LOGS; + private String[] THERM_AGENT_WITH_WEB_STORAGE_CATALINA_LOGS; + private String[] THERM_AGENT_BAD_LOGIN_CATALINA_LOGS; + + protected void setCheckedStrings() + { + THERM_AGENT_WITH_TOMCAT_ONLY_THERMOSTAT_LOGS = new String[] { + "com.mongodb.MongoException.Network: Read operation to server /127.0.0.1:27518 failed on database thermostat", + "java.net.ConnectException: Connection refused" + }; + THERM_AGENT_WITH_TOMCAT_ONLY_CATALINA_LOGS = new String[] { + "WebStorageEndPoint: Initializing web service", + "WebStorageEndPoint: THERMOSTAT_HOME == " + this.configuration.getThermostatHome(), + "WARNING - MongoConnection: Failed to connect to storage", + "com.mongodb.MongoException.Network: Read operation to server /127.0.0.1:27518 failed on database thermostat", + "java.net.ConnectException: Connection refused" }; - private static final String[] THERM_AGENT_WITH_TOMCAT_ONLY_CATALINA_LOGS = new String[] { - "WebStorageEndPoint: Initializing web service", - "WebStorageEndPoint: THERMOSTAT_HOME == /home/jfabriko/thermostaty/testing_thermostat/thermostat/distribution/target/image", - "WARNING - MongoConnection: Failed to connect to storage", - "com.mongodb.MongoException.Network: Read operation to server /127.0.0.1:27518 failed on database thermostat", - "java.net.ConnectException: Connection refused" - }; - - private static final String[] THERM_AGENT_WITH_WEB_STORAGE_THERMOSTAT_LOGS = new String[] { - "WebStorageEndPoint: Initializing web service", - "WebStorageEndPoint: THERMOSTAT_HOME == /home/jfabriko/thermostaty/testing_thermostat/thermostat/distribution/target/image", - "MongoConnection: Using plain socket for mongodb://", - "WebStorageEndPoint: (id: 0) registered non-aggreate category: vm-cpu-stats|com.redhat.thermostat.vm.cpu.common.model.VmCpuStat|{timeStamp=Key: timeStamp, agentId=Key: agentId, vmId=Key: vmId, cpuLoad=Key: cpuLoad}", - "WebStorageEndPoint: (id: 1) registered non-aggreate category: vm-heap-info|com.redhat.thermostat.vm.heap.analysis.common.model.HeapInfo|{timeStamp=Key: timeStamp, agentId=Key: agentId, vmId=Key: vmId, heapId=Key: heapId, heapDumpId=Key: heapDumpId, histogramId=Key: histogramId}", - "WebStorageEndPoint: (id: 2) registered non-aggreate category: vm-gc-stats|com.redhat.thermostat.vm.gc.common.model.VmGcStat|{runCount=Key: runCount, timeStamp=Key: timeStamp, agentId=Key: agentId, vmId=Key: vmId, wallTime=Key: wallTime, collectorName=Key: collectorName}", - "WebStorageEndPoint: (id: 3) registered non-aggreate category: vm-memory-stats|com.redhat.thermostat.vm.memory.common.model.VmMemoryStat|{timeStamp=Key: timeStamp, generations=Key: generations, agentId=Key: agentId, vmId=Key: vmId}", - "WebStorageEndPoint: (id: 4) registered non-aggreate category: numa-stat|com.redhat.thermostat.numa.common.NumaStat|{nodeStats=Key: nodeStats, timeStamp=Key: timeStamp, agentId=Key: agentId}", - "WebStorageEndPoint: (id: 5) registered non-aggreate category: numa-host-info|com.redhat.thermostat.numa.common.NumaHostInfo|{agentId=Key: agentId, hostNumNumaNodes=Key: hostNumNumaNodes}", - "WebStorageEndPoint: (id: 6) registered non-aggreate category: memory-stats|com.redhat.thermostat.host.memory.common.model.MemoryStat|{total=Key: total, cached=Key: cached, free=Key: free, timeStamp=Key: timeStamp, swapFree=Key: swapFree, swapTotal=Key: swapTotal, buffers=Key: buffers, agentId=Key: agentId, commitLimit=Key: commitLimit}" + + THERM_AGENT_WITH_WEB_STORAGE_THERMOSTAT_LOGS = new String[] { + "WebStorageEndPoint: Initializing web service", + "WebStorageEndPoint: THERMOSTAT_HOME == " + this.configuration.getThermostatHome(), + "MongoConnection: Using plain socket for mongodb://", + "WebStorageEndPoint: (id: 0) registered non-aggreate category: vm-cpu-stats|com.redhat.thermostat.vm.cpu.common.model.VmCpuStat|{timeStamp=Key: timeStamp, agentId=Key: agentId, vmId=Key: vmId, cpuLoad=Key: cpuLoad}", + "WebStorageEndPoint: (id: 1) registered non-aggreate category: vm-heap-info|com.redhat.thermostat.vm.heap.analysis.common.model.HeapInfo|{timeStamp=Key: timeStamp, agentId=Key: agentId, vmId=Key: vmId, heapId=Key: heapId, heapDumpId=Key: heapDumpId, histogramId=Key: histogramId}", + "WebStorageEndPoint: (id: 2) registered non-aggreate category: vm-gc-stats|com.redhat.thermostat.vm.gc.common.model.VmGcStat|{runCount=Key: runCount, timeStamp=Key: timeStamp, agentId=Key: agentId, vmId=Key: vmId, wallTime=Key: wallTime, collectorName=Key: collectorName}", + "WebStorageEndPoint: (id: 3) registered non-aggreate category: vm-memory-stats|com.redhat.thermostat.vm.memory.common.model.VmMemoryStat|{timeStamp=Key: timeStamp, generations=Key: generations, agentId=Key: agentId, vmId=Key: vmId}", + "WebStorageEndPoint: (id: 4) registered non-aggreate category: numa-stat|com.redhat.thermostat.numa.common.NumaStat|{nodeStats=Key: nodeStats, timeStamp=Key: timeStamp, agentId=Key: agentId}", + "WebStorageEndPoint: (id: 5) registered non-aggreate category: numa-host-info|com.redhat.thermostat.numa.common.NumaHostInfo|{agentId=Key: agentId, hostNumNumaNodes=Key: hostNumNumaNodes}", + "WebStorageEndPoint: (id: 6) registered non-aggreate category: memory-stats|com.redhat.thermostat.host.memory.common.model.MemoryStat|{total=Key: total, cached=Key: cached, free=Key: free, timeStamp=Key: timeStamp, swapFree=Key: swapFree, swapTotal=Key: swapTotal, buffers=Key: buffers, agentId=Key: agentId, commitLimit=Key: commitLimit}" + }; + + THERM_AGENT_WITH_WEB_STORAGE_CATALINA_LOGS = new String[] { + "INFO: Deploying web application directory", + "/webapps/thermostat", + "WebStorageEndPoint: Initializing web service", + "WebStorageEndPoint: THERMOSTAT_HOME == " + this.configuration.getThermostatHome(), + "MongoConnection: Using plain socket for mongodb://", + "WebStorageEndPoint: (id: 0) registered non-aggreate category: vm-cpu-stats|com.redhat.thermostat.vm.cpu.common.model.VmCpuStat|{timeStamp=Key: timeStamp, agentId=Key: agentId, vmId=Key: vmId, cpuLoad=Key: cpuLoad}", + "WebStorageEndPoint: (id: 1) registered non-aggreate category: vm-heap-info|com.redhat.thermostat.vm.heap.analysis.common.model.HeapInfo|{timeStamp=Key: timeStamp, agentId=Key: agentId, vmId=Key: vmId, heapId=Key: heapId, heapDumpId=Key: heapDumpId, histogramId=Key: histogramId}", + "WebStorageEndPoint: (id: 2) registered non-aggreate category: vm-gc-stats|com.redhat.thermostat.vm.gc.common.model.VmGcStat|{runCount=Key: runCount, timeStamp=Key: timeStamp, agentId=Key: agentId, vmId=Key: vmId, wallTime=Key: wallTime, collectorName=Key: collectorName}", + "WebStorageEndPoint: (id: 3) registered non-aggreate category: vm-memory-stats|com.redhat.thermostat.vm.memory.common.model.VmMemoryStat|{timeStamp=Key: timeStamp, generations=Key: generations, agentId=Key: agentId, vmId=Key: vmId}", + "WebStorageEndPoint: (id: 4) registered non-aggreate category: numa-stat|com.redhat.thermostat.numa.common.NumaStat|{nodeStats=Key: nodeStats, timeStamp=Key: timeStamp, agentId=Key: agentId}" + }; + + THERM_AGENT_BAD_LOGIN_CATALINA_LOGS = new String[] { + "WARNING: Login exception authenticating username \"doctor-evil\"", + "javax.security.auth.login.LoginException: User 'doctor-evil' not found" }; - private static final String[] THERM_AGENT_WITH_WEB_STORAGE_CATALINA_LOGS = new String[] { - "INFO: Deploying web application directory", - "/webapps/thermostat", - "WebStorageEndPoint: Initializing web service", - "WebStorageEndPoint: THERMOSTAT_HOME == /home/jfabriko/thermostaty/testing_thermostat/thermostat/distribution/target/image", - "MongoConnection: Using plain socket for mongodb://", - "WebStorageEndPoint: (id: 0) registered non-aggreate category: vm-cpu-stats|com.redhat.thermostat.vm.cpu.common.model.VmCpuStat|{timeStamp=Key: timeStamp, agentId=Key: agentId, vmId=Key: vmId, cpuLoad=Key: cpuLoad}", - "WebStorageEndPoint: (id: 1) registered non-aggreate category: vm-heap-info|com.redhat.thermostat.vm.heap.analysis.common.model.HeapInfo|{timeStamp=Key: timeStamp, agentId=Key: agentId, vmId=Key: vmId, heapId=Key: heapId, heapDumpId=Key: heapDumpId, histogramId=Key: histogramId}", - "WebStorageEndPoint: (id: 2) registered non-aggreate category: vm-gc-stats|com.redhat.thermostat.vm.gc.common.model.VmGcStat|{runCount=Key: runCount, timeStamp=Key: timeStamp, agentId=Key: agentId, vmId=Key: vmId, wallTime=Key: wallTime, collectorName=Key: collectorName}", - "WebStorageEndPoint: (id: 3) registered non-aggreate category: vm-memory-stats|com.redhat.thermostat.vm.memory.common.model.VmMemoryStat|{timeStamp=Key: timeStamp, generations=Key: generations, agentId=Key: agentId, vmId=Key: vmId}", - "WebStorageEndPoint: (id: 4) registered non-aggreate category: numa-stat|com.redhat.thermostat.numa.common.NumaStat|{nodeStats=Key: nodeStats, timeStamp=Key: timeStamp, agentId=Key: agentId}" - }; + } + protected List<String> listAgents() throws IOException + { + logInfo("lists agents", "if any"); + List<String> output = runHelperBashScript("list_all_therm_agents.sh"); + for (String message : output) + { + logInfo("Agent list", message); + } + return output; + } @Override protected void tearDown() @@ -94,18 +116,19 @@ try { restoreNormalStorageConfigFiles(); + runHelperBashScript("stop_all_therm_agents.sh"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); - } + } } @Override protected void setUp() { - + setCheckedStrings(); try { eraseTomcatOutputFiles(); @@ -132,29 +155,43 @@ * <ul> * * @throws IOException + * @throws InterruptedException */ - public void testStartWithoutAnyStorage() throws IOException + public void testStartWithoutAnyStorage() throws IOException, InterruptedException { //start only agent - new AgentThread().start(); + Thread agent = new AgentThread(); + agent.start(); logInfo("runAgentThread", "Thermostat Agent tried to start"); - //wait till agent stops - sleep(FIVE_SEC); + //wait before the agent realizes it cannot run and stops + agent.join(FIVE_SEC); //there should not be any agent running (check the jps) - List<String> output = runHelperBashScript("list_all_therm_agents.sh"); - Assert.assertNotNull(output, "error running script 'list_all_therm_agents.sh'"); - for (String message : output) - { - logInfo("Agent list:", message); - } + List<String> output = listAgents(); + //to be sure there is no running agent runHelperBashScript("stop_all_therm_agents.sh"); Assert.assertTrue(output.size()==0, "there should not be any running thermostat agents"); } + /** + * Method testStartWithTomcatWithoutStorage + * tries to start thermostat agent in new thread without previously + * starting the storage, but with running tomcat. There may be an agent + * running, because it connects to the web storage not to the db, but + * there should definitely be some logs in the tomcat logs directory + * about not being able to connect to the underlying mongodb. + * + * This test uses 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>. + * <ul> + * + * @throws IOException + */ public void testStartWithTomcatWithoutStorage() throws IOException { startTomcat(); @@ -163,51 +200,60 @@ new AgentThread().start(); logInfo("runAgentThread", "Thermostat Agent tried to start"); - //wait till agent stops - sleep(FIVE_SEC); + //wait before the agent is stopped, + //so it can communicate with web storage + sleep(3000); - - stopTomcat(); - //switch off the agent that probably runs, because tomcat was on runHelperBashScript("stop_all_therm_agents.sh"); + + stopTomcat(); + sleep(FIVE_SEC); + + stopTomcat(); + sleep(FIVE_SEC); //analyse the contents of logs in tomcat createTomcatThermostatOutputFiles(); List<String> outputs = getTomcatOutputs("catalina-logs.txt"); checkPresenceOfPatterns(outputs, THERM_AGENT_WITH_TOMCAT_ONLY_CATALINA_LOGS); - /*for(String s : outputs) - { - logInfo("+Tomcat-Storage catalina-logs.txt: ", s); - }*/ - + outputs = getTomcatOutputs("thermostat-web-storage-logs.txt"); checkPresenceOfPatterns(outputs, THERM_AGENT_WITH_TOMCAT_ONLY_THERMOSTAT_LOGS); - /*for(String s : outputs) - { - logInfo("+Tomcat-Storage thermostat-web-storage-logs.txt: ", s); - }*/ - + outputs = getTomcatOutputs("localhost_access_logs.txt"); - /*for(String s : outputs) - { - logInfo("+Tomcat-Storage localhost_access_logs.txt: ", s); - }*/ - + + listAgents(); } - public void testStartWithStorageWithoutTomcat() throws IOException + /** + * Method testStartWithStorageWithoutTomcat + * tries to start thermostat agent in new thread without previously + * starting tomcat, only the db is running. There should be no thermostat + * agents running, because the agent connects to web storage. + * + * This test uses 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>. + * <ul> + * + * @throws IOException + * @throws InterruptedException + */ + public void testStartWithStorageWithoutTomcat() throws IOException, InterruptedException { startStorage(); //start only agent - new AgentThread().start(); + Thread agent = new AgentThread(); + agent.start(); logInfo("runAgentThread", "Thermostat Agent tried to start"); - //wait till agent stops - sleep(FIVE_SEC); - + //wait till agent realizes it cannot run and stops + agent.join(FIVE_SEC); + //there should not be any agent running (check the jps) List<String> output = runHelperBashScript("list_all_therm_agents.sh"); @@ -219,7 +265,7 @@ Assert.assertNotNull(output, "error running script 'list_all_therm_agents.sh'"); for (String message : output) { - logInfo("Agent list:", message); + logInfo("Agent list", message); } Assert.assertTrue(output.size()==0, "there should not be any running thermostat agents"); } @@ -247,21 +293,17 @@ logInfo("runAgentThread", "Thermostat Agent tried to start"); //check if the agent is running (jps) - List<String> output = runHelperBashScript("list_all_therm_agents.sh"); + List<String> output = listAgents(); Assert.assertNotNull(output, "error running script 'list_all_therm_agents.sh'"); Assert.assertTrue(output.size()>0, "there should be >0 running thermostat agents"); //let the agent write some data - sleep(5000); + sleep(3000); //stop the agent output = runHelperBashScript("stop_all_therm_agents.sh"); Assert.assertNotNull(output, "error running script 'stop_all_therm_agents.sh'"); - // runThermostatGuiInANewThread(); - //sleep(3000); - // stopGUI(new GuiRobot()); - stopWebStorage(); sleep(3000); @@ -280,14 +322,69 @@ outputs = getTomcatOutputs("localhost_access_logs.txt"); } - /* - public void testStartAgentWithBadLogin(){ + /** + * Method testStartAgentWithBadLogin + * starts the web storage and tries to connect an agent with bad login. + * The attempt should be logged in catalina.out as unsuccessful login. + * + * This test uses 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>. + * <ul> + * + * @throws IOException + */ + public void testStartAgentWithBadLogin() throws IOException{ //copy bad login info into agent conf + prepareWebStorageBadAgentLoginFile(); //try to run - //there should not be any agents - //interesting logs + startWebStorage(); + + //start agent + new AgentThread().start(); + logInfo("runAgentThread", "Thermostat Agent tried to start"); + + //check if the agent is running (jps) + List<String> outputs = listAgents(); + Assert.assertNotNull(outputs, "error running script 'list_all_therm_agents.sh'"); + Assert.assertTrue(outputs.size()>0, "there should be a running thermostat agent trying to access the db"); + + //let the agent try to use its login for web storage + sleep(6000); + + //stop the agent + outputs = runHelperBashScript("stop_all_therm_agents.sh"); + Assert.assertNotNull(outputs, "error running script 'stop_all_therm_agents.sh'"); + + stopWebStorage(); + sleep(3000); + + //analyse the contents of logs in tomcat + createTomcatThermostatOutputFiles(); + + outputs = getTomcatOutputs("catalina-logs.txt"); + /*for(String s : outputs) + { + logInfo("Bad login catalina-logs.txt: ", s); + }*/ + checkPresenceOfPatterns(outputs, THERM_AGENT_BAD_LOGIN_CATALINA_LOGS); + + outputs = getTomcatOutputs("thermostat-web-storage-logs.txt"); + /*for(String s : outputs) + { + logInfo("Bad login thermostat-web-storage-logs.txt: ", s); + }*/ + + outputs = getTomcatOutputs("localhost_access_logs.txt"); + /*for(String s : outputs) + { + logInfo("Bad login localhost_access_logs.txt: ", s); + }*/ + //copy back the good login info - }*/ + prepareWebStorageConfigFiles(); + } public static void main(String[] args) { new AgentWebStorageTest().doTests(args);
--- a/src/org/thermostat/qa/testsuites/GuiClientSmokeTest.java Mon Sep 23 17:57:39 2013 +0200 +++ b/src/org/thermostat/qa/testsuites/GuiClientSmokeTest.java Wed Sep 25 08:55:25 2013 +0200 @@ -223,6 +223,8 @@ enterMainMenu(robot); robot.pressKey(KeyEvent.VK_RIGHT); + robot.pressKey(KeyEvent.VK_LEFT); + robot.pressKey(KeyEvent.VK_RIGHT); createScreenshot(robot, "testStartGUIWithStorageMenuEditTest1"); checkForPattern(robot, Patterns.MainWindowMenuEdit.CLIENT_PREFERENCES, "edit/client preferences");