Mercurial > hg > ThermostatQA
view src/org/thermostat/qa2/framework/services/ThermostatStorage.java @ 181:e37e710e45df
added support for compatibility tests and some other improvements (generating thermostat config files from templates, posiblity to show @Before methods logs in report, ...)
Changes:
Makefile:
- added targets new for compatibility testing (and report generation)
src/org/thermostat/qa2/framework/utils/ThermostatUtilities.java:
- all thermostat and storage configuration code moved from TestRunner to ThermostatUtilities class
- webapp deployment (tomcat) is moved from makefile to testsuite (ThermostatUtilities class)
- storage configuration files are now generated from templates,
which are placed in templates directory
- added helper methods, which make using thermostat shell simpler
src/org/thermostat/qa2/framework/utils/ThermostatUtilities.java:
- code needed for replacing patterns moved from reporters Generator class to CommonUtilities class
(because it is now also used to generate config files from templates)
src/org/thermostat/qa2/reporter/Generator.java:
src/org/thermostat/qa2/reporter/LogParser.java:
src/org/thermostat/qa2/reporter/result/TestClassResult.java:
src/org/thermostat/qa2/framework/TestRunner.java
- added possibility to show logs of methods annotaded with @Before annotation,
when some of tests in that their test class failes
src/org/thermostat/qa2/tests/DBCommandsHeapDumpTest.java:
- code updated to use new methods from ThermostatUtilities class
src/org/thermostat/qa2/framework/annotations/SetupStorage.java
- it is now possible set SAVE_ON_EXIT property in agent.properties using this annotation
src/org/thermostat/qa2/framework/services/ThermostatStorage.java
- framework is now not waiting for timeout, when message about thermostat setup is displayed
src/org/thermostat/qa2/framework/ThermostatQAConfig.java
- added/updated to contain framework new configuration data,
removed code not needed anymore
templates/storage-config/*
- added thermostat config files templates
author | Zdenek Zambersky <zzambers@redhat.com> |
---|---|
date | Fri, 15 May 2015 18:51:56 +0200 |
parents | 0d34a379de82 |
children | 877b403e8344 |
line wrap: on
line source
/* ThermostatQA - test framework for Thermostat Monitoring Tool Copyright 2015 Red Hat, Inc. This file is part of ThermostatQA ThermostatQA is distributed under the GNU General Public License, version 2 or any later version (with a special exception described below, commonly known as the "Classpath Exception"). A copy of GNU General Public License (GPL) is included in this distribution, in the file COPYING. Linking ThermostatQA code with other modules is making a combined work based on ThermostatQA. Thus, the terms and conditions of the GPL cover the whole combination. As a special exception, the copyright holders of ThermostatQA give you permission to link this code with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on ThermostatQA code. If you modify ThermostatQA, you may extend this exception to your version of the software, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ package org.thermostat.qa2.framework.services; import java.io.File; import java.io.IOException; import java.util.List; import org.thermostat.qa2.framework.NativeProcess; import org.thermostat.qa2.framework.ThermostatQAConfig; import org.thermostat.qa2.framework.utils.CommonUtilities; /** * * @author Zdeněk Žamberský */ public class ThermostatStorage extends AbstractService { public String thermostatHome; public String thermostatUserHome; public ThermostatStorage() { this("tested"); } public ThermostatStorage(String targetThermostat) { this(ThermostatQAConfig.getThermostatHome(targetThermostat), ThermostatQAConfig.getThermostatUserHome(targetThermostat)); } public ThermostatStorage(String thermostatHome, String thermostatUserHome) { this.thermostatHome = thermostatHome; this.thermostatUserHome = thermostatUserHome; } @Override public String getServiceName() throws Exception { return "Thermostat storage"; } int mongoPort = ThermostatQAConfig.mongoPort; int timeout = 30; @Override public void startServiceImpl() throws Exception { setRunning(true); startProcess = new NativeProcess(thermostatHome + File.separator + "bin" + File.separator + "thermostat", "storage", "--start"); startProcess.setLabel(getServiceName()); startProcess.setEnvironmentVariable("USER_THERMOSTAT_HOME", thermostatUserHome); //if (startStdoutBuffering) { startProcess.setStdOutMode(NativeProcess.MODE_LOG_AND_BUFFER); //} startProcess.start(); startProcess.waitFor(); List<String> lines = startProcess.getStdoutLines(); if (CommonUtilities.findInLineList(lines, "Please run 'thermostat-setup'.", false)) { throw new Exception("Storage requires thermostat-setup to be run."); } waitForListeningPort(mongoPort, timeout); } @Override public void stopServiceImpl() throws Exception { setRunning(false); stopProcess = new NativeProcess(thermostatHome + File.separator + "bin" + File.separator + "thermostat", "storage", "--stop"); stopProcess.setLabel(getServiceName()); stopProcess.setEnvironmentVariable("USER_THERMOSTAT_HOME", thermostatUserHome); if (stopStdoutBuffering) { stopProcess.setStdOutMode(NativeProcess.MODE_LOG_AND_BUFFER); } stopProcess.start(); stopProcess.waitFor(); } boolean startStdoutBuffering = false; boolean stopStdoutBuffering = false; NativeProcess startProcess; NativeProcess stopProcess; public void setStartStdoutBuffering(boolean b) { startStdoutBuffering = b; } public void setStopStdoutBuffering(boolean b) { stopStdoutBuffering = b; } public List<String> getStartStdoutLines() throws IOException { return startProcess.getStdoutLines(); } public List<String> getStopStdoutLines() throws IOException { return stopProcess.getStdoutLines(); } }