Mercurial > hg > ThermostatQA
changeset 88:e432d6761009
preparations for web-storage tests
author | Jana Fabrikova <jfabriko@redhat.com> |
---|---|
date | Tue, 27 Aug 2013 16:33:57 +0200 |
parents | 5a0dbf602f3a |
children | 9e918f6158be |
files | ChangeLog Makefile src/org/thermostat/qa/annotations/StorageType.java src/org/thermostat/qa/annotations/StorageTypes.java src/org/thermostat/qa/common/Configuration.java src/org/thermostat/qa/framework/ThermostatUtilities.java storageconfig/db-mongodb/agent.auth storageconfig/db-mongodb/agent.properties storageconfig/db-mongodb/client.properties storageconfig/db-mongodb/thermostat-roles.properties storageconfig/db-mongodb/thermostat-users.properties storageconfig/web-tomcat/agent.auth storageconfig/web-tomcat/agent.properties storageconfig/web-tomcat/client.properties storageconfig/web-tomcat/thermostat-roles.properties storageconfig/web-tomcat/thermostat-users.properties |
diffstat | 16 files changed, 462 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Aug 26 16:04:48 2013 +0200 +++ b/ChangeLog Tue Aug 27 16:33:57 2013 +0200 @@ -1,3 +1,31 @@ +2013-08-27 Jana Fabrikova <jfabriko@redhat.com> + * src/org/thermostat/qa/annotations/StorageType.java: + * src/org/thermostat/qa/annotations/StorageTypes.java: + new annotations of classes denoting the type of used storage + * src/org/thermostat/qa/framework/ThermostatUtilities.java: + added new methods (makeScriptExecutable), (runBashScriptWithContent), + (startWebStorage), (stopWebStorage), (prepareWebStorageConfigFiles), + (restoreNormalStorageConfigFiles), (startTomcat), (stopTomcat), + (getTomcatOutputs), (eraseTomcatOutputFiles). + * storageconfig/db-mongodb/agent.auth: + * storageconfig/db-mongodb/agent.properties: + * storageconfig/db-mongodb/client.properties: + * storageconfig/db-mongodb/thermostat-users.properties: + * storageconfig/db-mongodb/thermostat-roles.properties: + * storageconfig/web-tomcat/agent.auth: + * storageconfig/web-tomcat/agent.properties: + * storageconfig/web-tomcat/client.properties: + * storageconfig/web-tomcat/thermostat-users.properties: + * storageconfig/web-tomcat/thermostat-roles.properties: + default web and mongodb config files that will be used by web-storage + testsuites + * src/org/thermostat/qa/common/Configuration.java: + added new properties regarding the settings of the web storage + * test.properties: + added the same properties also here + * Makefile: + appropriate classes added to build + 2013-08-26 Jana Fabrikova <jfabriko@redhat.com> * test.properties: * outputtexts/version5-0.14.0:
--- a/Makefile Mon Aug 26 16:04:48 2013 +0200 +++ b/Makefile Tue Aug 27 16:33:57 2013 +0200 @@ -45,6 +45,8 @@ ALL_CLASSES = \ $(BUILD_DIR)/$(ANNOTATIONS_PACKAGE)/TestTypes.class \ $(BUILD_DIR)/$(ANNOTATIONS_PACKAGE)/TestType.class \ + $(BUILD_DIR)/$(ANNOTATIONS_PACKAGE)/StorageTypes.class \ + $(BUILD_DIR)/$(ANNOTATIONS_PACKAGE)/StorageType.class \ $(BUILD_DIR)/$(COMMON_PACKAGE)/Configuration.class \ $(BUILD_DIR)/$(REPORTER_PACKAGE)/TestResult.class \ $(BUILD_DIR)/$(REPORTER_PACKAGE)/StringUtils.class \ @@ -93,6 +95,13 @@ $(JAVA) -cp $(BUILD_DIR) org.thermostat.qa.testsuites.$$tst 2>&1 | tee $(LOGS_DIR)/$(DATE)/$$tst.log ; \ done +#webstoragetests: +# cp +# cp +# make runtests +# cp +# cp + #create a directory outputtexts/versionN for the current version #of the output_texts (can be found in the test.properties) #generate output help messages into files
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/org/thermostat/qa/annotations/StorageType.java Tue Aug 27 16:33:57 2013 +0200 @@ -0,0 +1,51 @@ +/* + + ThermostatQA - test framework for Thermostat Monitoring Tool + + Copyright 2013 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.qa.annotations; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + + + +/** + * Declaration of annotation which can be used to select which storage is used + * by the test. + * + * @see StorageTypes + * + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface StorageType +{ + StorageTypes value(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/org/thermostat/qa/annotations/StorageTypes.java Tue Aug 27 16:33:57 2013 +0200 @@ -0,0 +1,47 @@ +/* + + ThermostatQA - test framework for Thermostat Monitoring Tool + + Copyright 2013 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.qa.annotations; + + + +/** + * Type of the storage (connection to storage). + * + * @see StorageType + * + */ +public enum StorageTypes +{ + MONGODB_STORAGE, + WEBTOMCAT_STORAGE, +}
--- a/src/org/thermostat/qa/common/Configuration.java Mon Aug 26 16:04:48 2013 +0200 +++ b/src/org/thermostat/qa/common/Configuration.java Tue Aug 27 16:33:57 2013 +0200 @@ -47,6 +47,9 @@ private String thermostatExecutablePath = null; private String thermostatExecutableName = null; private String thermostatOutputTextsVersion = null; + private String thermostatHome = null; + private String thermostatUserHome = null; + private String apacheTomcatHome = null; // if true -> gfx tests would be run against pre-generated screenshots private static boolean dummyGfxTests = false; @@ -102,6 +105,9 @@ this.thermostatExecutablePath = properties.getProperty("thermostat_executable_path"); this.thermostatExecutableName = properties.getProperty("thermostat_executable_name"); this.thermostatOutputTextsVersion = properties.getProperty("thermostat_output_version"); + this.thermostatHome = properties.getProperty("thermostat_home"); + this.thermostatUserHome = properties.getProperty("thermostat_user_home"); + this.apacheTomcatHome = properties.getProperty("apache_tomcat_home"); } public String getThermostatOutputTextsVersion() @@ -113,6 +119,21 @@ { return this.thermostatExecutablePath + this.thermostatExecutableName; } + + public String getThermostatHome() + { + return this.thermostatHome; + } + + public String getThermostatUserHome() + { + return this.thermostatUserHome; + } + + public String getApacheTomcatHome() + { + return this.apacheTomcatHome; + } public boolean useDummyGfxTests() {
--- a/src/org/thermostat/qa/framework/ThermostatUtilities.java Mon Aug 26 16:04:48 2013 +0200 +++ b/src/org/thermostat/qa/framework/ThermostatUtilities.java Tue Aug 27 16:33:57 2013 +0200 @@ -325,6 +325,27 @@ Process process = runProcess(cmdArray); return readProcessOutput(process); } + + /** + * Method makeScriptExecutable + * takes a name of a file in ./scripts and performs chmod +x + * + * @param scriptName + * @throws IOException + */ + protected void makeScriptExecutable(String scriptName) throws IOException + { + String[] cmdArray = new String[]{"chmod","+x","./scripts/"+scriptName}; + Runtime.getRuntime().exec(cmdArray); + } + + protected List<String> runBashScriptWithContent(String scriptName, List<String> content, String... params) throws IOException + { + //write content into a file in ./scripts + FileUtils.writeTextFile("./scripts/"+scriptName, content); + makeScriptExecutable(scriptName); + return runHelperBashScript(scriptName, params); + } protected void sleep(int ms) { @@ -374,9 +395,8 @@ FileUtils.writeTextFile("./scripts/"+scriptFileName, lines); //chmod - make the script executable - String[] cmdArray = new String[]{"chmod","+x","./scripts/"+scriptFileName}; - Runtime.getRuntime().exec(cmdArray); - + makeScriptExecutable(scriptFileName); + //run the new script return runHelperBashScript(scriptFileName); } @@ -386,4 +406,80 @@ robot.pressCtrlPlusKey(KeyEvent.VK_Q); } + protected void startWebStorage() throws IOException + { + // whereas the storage would be started/stopped many times + startStorage(); + startTomcat(); + } + + protected void stopWebStorage() throws IOException + { + stopTomcat(); + stopStorage(); + } + + protected void prepareWebStorageConfigFiles() throws IOException + { + List<String> lines = new LinkedList<String>(); + lines.add("cp ./storageconfig/web-tomcat/agent.auth "+this.configuration.getThermostatUserHome() + " etc/"); + lines.add("cp ./storageconfig/web-tomcat/agent.properties "+this.configuration.getThermostatUserHome() + " etc/"); + lines.add("cp ./storageconfig/web-tomcat/client.properties "+this.configuration.getThermostatUserHome() + " etc/"); + lines.add("cp ./storageconfig/web-tomcat/thermostat-roles.properties "+this.configuration.getThermostatHome() + " etc/"); + lines.add("cp ./storageconfig/web-tomcat/thermostat-users.properties "+this.configuration.getThermostatHome() + " etc/"); + + runBashScriptWithContent("webStorage_prepareWebConfig.sh", lines); + } + + protected void restoreNormalStorageConfigFiles() throws IOException + { + //move back the original versions of the configuration files + //web storage -> mongodb + List<String> lines = new LinkedList<String>(); + lines.add("cp ./storageconfig/db-mongodb/agent.auth "+this.configuration.getThermostatUserHome() + " etc/"); + lines.add("cp ./storageconfig/db-mongodb/agent.properties "+this.configuration.getThermostatUserHome() + " etc/"); + lines.add("cp ./storageconfig/db-mongodb/client.properties "+this.configuration.getThermostatUserHome() + " etc/"); + lines.add("cp ./storageconfig/db-mongodb/thermostat-roles.properties "+this.configuration.getThermostatHome() + " etc/"); + lines.add("cp ./storageconfig/db-mongodb/thermostat-users.properties "+this.configuration.getThermostatHome() + " etc/"); + + runBashScriptWithContent("webStorage_restoreNormalConfig.sh", lines); + } + + protected void startTomcat() throws IOException + { + //startup.sh from the apache-tomcat dir + List<String> lines = new LinkedList<String>(); + lines.add(this.configuration.getApacheTomcatHome() + "bin/startup.sh"); + + runBashScriptWithContent("webStorage_startTomcat.sh", lines); + } + + protected void stopTomcat() throws IOException + { + //shutdown.sh from the apache-tomcat dir + List<String> lines = new LinkedList<String>(); + lines.add(this.configuration.getApacheTomcatHome() + "bin/shutdown.sh"); + + runBashScriptWithContent("webStorage_stopTomcat.sh", lines); + } + + protected List<String> getTomcatOutputs() + { + List<String> result = new LinkedList<String>(); + + //for now only the catalina.out file + String catalinaOutFile = this.configuration.getApacheTomcatHome()+"logs/catalina.out"; + result = FileUtils.readTextFile(catalinaOutFile); + + return result; + } + + protected void eraseTomcatOutputFiles() + { + //catalina.out (and thermostat... not yet)to blank file again + String catalinaOutFile = this.configuration.getApacheTomcatHome()+"logs/catalina.out"; + List<String> lines = new LinkedList<String>(); + lines.add(""); + FileUtils.writeTextFile(catalinaOutFile, lines); //one line that is blank + } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storageconfig/db-mongodb/agent.auth Tue Aug 27 16:33:57 2013 +0200 @@ -0,0 +1,8 @@ +# This file is intended to be read by a hand-rolled reader/parser, to avoid +# passwords needing to be represented as String objects at runtime. It must +# be saved with Unix line end characters, and encoded as ascii. +# Uncomment the following lines and replace with your storage authentication +# parameters as needed. +# +#username=agent-tester +#password=heslo1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storageconfig/db-mongodb/agent.properties Tue Aug 27 16:33:57 2013 +0200 @@ -0,0 +1,16 @@ +# Indicates if this agent will save its data to the database on exit +# or rather will purge the db +SAVE_ON_EXIT=false + +# A netty-based side channel for accepting configuration/tuning +# requests from the client will listen for connections on the address +# configured here. +# If this is removed or commented out, the default port is 127.0.0.1:12000 +CONFIG_LISTEN_ADDRESS=127.0.0.1:12000 + +# Connection URL to storage. This can be overridden with the -d option +# on the command line. In order to use web storage instead, use something +# similar to the following line: +#DB_URL=https://storage-server.example.com:8443/thermostat/storage +DB_URL=mongodb://127.0.0.1:27518 +#DB_URL=http://127.0.0.1:8080/thermostat/storage
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storageconfig/db-mongodb/client.properties Tue Aug 27 16:33:57 2013 +0200 @@ -0,0 +1,5 @@ +# +#Mon Aug 26 10:34:41 CEST 2013 +connection-url=mongodb\://127.0.0.1\:27518 +save-entitlements=false +username=
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storageconfig/db-mongodb/thermostat-roles.properties Tue Aug 27 16:33:57 2013 +0200 @@ -0,0 +1,52 @@ +# This file is used if the PropertiesUsernameRolesLoginModule is used +# as a delegate in the JAAS configuration *and* the 'roles.properties' option +# has not been specified for the login module. +# +# If that is the case, this file does two things: +# 1. It maps user names to roles. +# 2. Defines an optional recursive set of roles. This is useful in order to +# define role sets. Users can then be members of such defined role sets. +# Note that every line which does not have a user name (as defined in the +# corresponding users.properties file) on the left hand side of the +# equals sign ('='), represents a role. +# +# A user is assigned multiple roles by separating them by a comma ','. Every +# entity in this file which isn't a user name, will be implicitly defined as a +# role. +# +# Format is as follows: +# +# user1 = my-role, my-role2 +# user2 = new-role, role1 +# role1 = other-role +# +# Considering users 'user1' and 'user2' are defined in users.properties, the +# above would assign 'user1' the roles 'my-role' and 'my-role2'. 'user2' would +# be a member of 'new-role', 'role1' and 'other-role' (transitively via role1) +# +# +# +# Example recursive role definition allowed-to-do-everything agent-users. You +# can uncomment the following lines and assign your agent users this +# "thermostat-agent" role. +#thermostat-agent = thermostat-add, thermostat-replace, thermostat-update, \ +# thermostat-remove, thermostat-save-file, thermostat-purge, \ +# thermostat-register-category, thermostat-register-category, \ +# thermostat-cmdc-verify, thermostat-login, thermostat-realm +# +# Example recursive role definition for allowed-to-see-everything client-users. +# You may uncomment the following lines and assign your client users this +# "thermostat-client" role. +#thermostat-client = thermostat-realm, thermostat-login, thermostat-query, \ +# thermostat-cmdc-generate, thermostat-load-file, \ +# thermostat-register-category, thermostat-prepare-statement +# +# Example recursive role definition that grants all command channel privileges. +# You may uncomment the following lines and assign your client users this +# "thermostat-cmdc" role. +#thermostat-cmdc = thermostat-cmdc-grant-garbage-collect, \ +# thermostat-cmdc-grant-dump-heap, \ +# thermostat-cmdc-grant-thread-harvester, \ +# thermostat-cmdc-grant-killvm, \ +# thermostat-cmdc-grant-ping, \ +# thermostat-cmdc-grant-jmx-toggle-notifications
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storageconfig/db-mongodb/thermostat-users.properties Tue Aug 27 16:33:57 2013 +0200 @@ -0,0 +1,19 @@ +# This file is used if the PropertiesUsernameRolesLoginModule is used +# as a delegate in the JAAS configuration *and* the 'users.properties' option +# has not been specified for the login module. +# +# If that is the case, this defines the database of users with corresponding +# passwords, the thermostat web storage servlet knows about. +# +# WARNING: Passwords of users are in plain text. This needs to be considered +# when using this module in production. The main goal of this login +# module is to provide a simple way to define thermostat users and +# their corresponding passwords. +# +# The format of this file is as follows (whitespace in usernames/passwords are +# not recommended): +# +# user1=password1 +# user2=password2 +# ... +#
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storageconfig/web-tomcat/agent.auth Tue Aug 27 16:33:57 2013 +0200 @@ -0,0 +1,8 @@ +# This file is intended to be read by a hand-rolled reader/parser, to avoid +# passwords needing to be represented as String objects at runtime. It must +# be saved with Unix line end characters, and encoded as ascii. +# Uncomment the following lines and replace with your storage authentication +# parameters as needed. +# +username=agent-tester +password=heslo1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storageconfig/web-tomcat/agent.properties Tue Aug 27 16:33:57 2013 +0200 @@ -0,0 +1,16 @@ +# Indicates if this agent will save its data to the database on exit +# or rather will purge the db +SAVE_ON_EXIT=false + +# A netty-based side channel for accepting configuration/tuning +# requests from the client will listen for connections on the address +# configured here. +# If this is removed or commented out, the default port is 127.0.0.1:12000 +CONFIG_LISTEN_ADDRESS=127.0.0.1:12000 + +# Connection URL to storage. This can be overridden with the -d option +# on the command line. In order to use web storage instead, use something +# similar to the following line: +#DB_URL=https://storage-server.example.com:8443/thermostat/storage +#DB_URL=mongodb://127.0.0.1:27518 +DB_URL=http://127.0.0.1:8080/thermostat/storage
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storageconfig/web-tomcat/client.properties Tue Aug 27 16:33:57 2013 +0200 @@ -0,0 +1,6 @@ +# +#Thu Aug 22 16:10:25 CEST 2013 +password=heslo2 +connection-url=http\://127.0.0.1\:8080/thermostat/storage +save-entitlements=true +username=client-tester
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storageconfig/web-tomcat/thermostat-roles.properties Tue Aug 27 16:33:57 2013 +0200 @@ -0,0 +1,56 @@ +# This file is used if the PropertiesUsernameRolesLoginModule is used +# as a delegate in the JAAS configuration *and* the 'roles.properties' option +# has not been specified for the login module. +# +# If that is the case, this file does two things: +# 1. It maps user names to roles. +# 2. Defines an optional recursive set of roles. This is useful in order to +# define role sets. Users can then be members of such defined role sets. +# Note that every line which does not have a user name (as defined in the +# corresponding users.properties file) on the left hand side of the +# equals sign ('='), represents a role. +# +# A user is assigned multiple roles by separating them by a comma ','. Every +# entity in this file which isn't a user name, will be implicitly defined as a +# role. +# +# Format is as follows: +# +# user1 = my-role, my-role2 +# user2 = new-role, role1 +# role1 = other-role +# +# Considering users 'user1' and 'user2' are defined in users.properties, the +# above would assign 'user1' the roles 'my-role' and 'my-role2'. 'user2' would +# be a member of 'new-role', 'role1' and 'other-role' (transitively via role1) +# +# +# +# Example recursive role definition allowed-to-do-everything agent-users. You +# can uncomment the following lines and assign your agent users this +# "thermostat-agent" role. +#thermostat-agent = thermostat-add, thermostat-replace, thermostat-update, \ +# thermostat-remove, thermostat-save-file, thermostat-purge, \ +# thermostat-register-category, thermostat-register-category, \ +# thermostat-cmdc-verify, thermostat-login, thermostat-realm +# +# Example recursive role definition for allowed-to-see-everything client-users. +# You may uncomment the following lines and assign your client users this +# "thermostat-client" role. +#thermostat-client = thermostat-realm, thermostat-login, thermostat-query, \ +# thermostat-cmdc-generate, thermostat-load-file, \ +# thermostat-register-category, thermostat-prepare-statement +# +# Example recursive role definition that grants all command channel privileges. +# You may uncomment the following lines and assign your client users this +# "thermostat-cmdc" role. +#thermostat-cmdc = thermostat-cmdc-grant-garbage-collect, \ +# thermostat-cmdc-grant-dump-heap, \ +# thermostat-cmdc-grant-thread-harvester, \ +# thermostat-cmdc-grant-killvm, \ +# thermostat-cmdc-grant-ping, \ +# thermostat-cmdc-grant-jmx-toggle-notifications +agent-tester=thermostat-agent +client-tester=thermostat-client +thermostat-agent=thermostat-add, thermostat-replace, thermostat-update, thermostat-remove, thermostat-save-file, thermostat-purge, thermostat-register-category, thermostat-register-category, thermostat-cmdc-verify, thermostat-login, thermostat-realm +thermostat-client=thermostat-agents-grant-read-agentId-ALL, thermostat-hosts-grant-read-hostname-ALL, thermostat-vms-grant-read-vmId-ALL,thermostat-vms-grant-read-username-sgehwolf, thermostat-realm, thermostat-login, thermostat-query, thermostat-prepare-statement, thermostat-cmdc-generate, thermostat-load-file, thermostat-get-count, thermostat-register-category
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/storageconfig/web-tomcat/thermostat-users.properties Tue Aug 27 16:33:57 2013 +0200 @@ -0,0 +1,21 @@ +# This file is used if the PropertiesUsernameRolesLoginModule is used +# as a delegate in the JAAS configuration *and* the 'users.properties' option +# has not been specified for the login module. +# +# If that is the case, this defines the database of users with corresponding +# passwords, the thermostat web storage servlet knows about. +# +# WARNING: Passwords of users are in plain text. This needs to be considered +# when using this module in production. The main goal of this login +# module is to provide a simple way to define thermostat users and +# their corresponding passwords. +# +# The format of this file is as follows (whitespace in usernames/passwords are +# not recommended): +# +# user1=password1 +# user2=password2 +# ... +# +agent-tester=heslo1 +client-tester=heslo2