Mercurial > hg > ThermostatQA
changeset 80:c654a3c99500
modified CliClientSmokeTest, OutputMessagesTest and output texts generator
author | Jana Fabrikova <jfabriko@redhat.com> |
---|---|
date | Wed, 17 Jul 2013 14:57:56 +0200 |
parents | 192f89a34e98 |
children | ea3f2926eea3 |
files | ChangeLog src/org/thermostat/qa/framework/ThermostatOutputTextsGenerator.java src/org/thermostat/qa/reporter/FileUtils.java src/org/thermostat/qa/testsuites/CliClientSmokeTest.java src/org/thermostat/qa/testsuites/OutputMessagesTest.java test.properties |
diffstat | 6 files changed, 104 insertions(+), 77 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Jul 10 18:06:09 2013 +0200 +++ b/ChangeLog Wed Jul 17 14:57:56 2013 +0200 @@ -1,3 +1,20 @@ +2013-07-17 Jana Fabrikova <jfabriko@redhat.com> + * src/org/thermostat/qa/framework/ThermostatOutputTextsGenerator.java: + added generating output texts for CliClientSmokeTest testsuite, + added method (getFileNameFromScriptName) + * src/org/thermostat/qa/reporter/FileUtils.java: + adding method (getStringArrayFromOutputTextFile), originally from + OutputMessagesTest.java + * src/org/thermostat/qa/testsuites/CliClientSmokeTest.java: + modified both testcases so that they use versioned output messages + from outputtexts instead of String[] constants + * src/org/thermostat/qa/testsuites/OutputMessagesTest.java: + modifications due to moving method (getStringArrayFormOutputTextFile) + to FileUtils.java + * test.properties: + changed default version of output texts from version1 + to version2DesertRose + 2013-07-10 Jana Fabrikova <jfabriko@redhat.com> * outputtexts/version1: added 21 text files with current version of the thermostat help output
--- a/src/org/thermostat/qa/framework/ThermostatOutputTextsGenerator.java Wed Jul 10 18:06:09 2013 +0200 +++ b/src/org/thermostat/qa/framework/ThermostatOutputTextsGenerator.java Wed Jul 17 14:57:56 2013 +0200 @@ -40,12 +40,15 @@ import org.thermostat.qa.reporter.FileUtils; import org.thermostat.qa.testsuites.OutputMessagesTest; - +import org.thermostat.qa.testsuites.CliClientSmokeTest; /** * Class ThermostatOutputTextGenerator * contains methods for generating the output texts needed for - * OutputMessagesTest testsuite automatically. + * <ul> + * <li> CliClientSmokeTest + * <li> OutputMessagesTest + * </ul> testsuites automatically. */ public class ThermostatOutputTextsGenerator extends ThermostatUtilities { @@ -64,7 +67,7 @@ Process process = runThermostatInNewProcess(flags); return readProcessOutput(process); } - + /** * Method writeTextsForOutputMessagesTest * gets output for all the possible commands that appear @@ -78,9 +81,11 @@ { List<String> output = null; String fileName = null; - String[][] allflags = OutputMessagesTest.allflags; + String[][] allflags = OutputMessagesTest.allflags; + String[] allscripts = CliClientSmokeTest.allscripts; int i=0; + int maxi = allflags.length + allscripts.length; for(String[] flags : allflags) { i++; @@ -89,11 +94,25 @@ if(output != null) { FileUtils.writeTextFile(fileName, output); - System.out.println(fileName+" written (file "+i+" from "+allflags.length+")"); + System.out.println(fileName+" written (file "+i+" from "+maxi+")"); }else{ - System.out.println(fileName+" NULL OUTPUT, NOT WRITTEN (file "+i+" from "+allflags.length+")"); + System.out.println(fileName+" NULL OUTPUT, NOT WRITTEN (file "+i+" from "+maxi+")"); } - } + } + for(String s : allscripts) + { + i++; + output = runCommandsInThermostatShell(s); + fileName = getFileNameFromScriptName(s); + if(output != null) + { + FileUtils.writeTextFile(fileName, output); + System.out.println(fileName+" written (file "+i+" from "+maxi+")"); + }else{ + System.out.println(fileName+" NULL OUTPUT, NOT WRITTEN (file "+i+" from "+maxi+")"); + } + } + } /** @@ -123,6 +142,15 @@ return str; } + public String getFileNameFromScriptName(String scriptname) + { + StringBuffer sb = new StringBuffer(); + sb.append("outputtexts/"); + sb.append(this.configuration.getThermostatOutputTextsVersion()); + sb.append("/output_of_"); + return sb.toString()+scriptname; + } + /** * Method main * reads current configuration from test.properties, and
--- a/src/org/thermostat/qa/reporter/FileUtils.java Wed Jul 10 18:06:09 2013 +0200 +++ b/src/org/thermostat/qa/reporter/FileUtils.java Wed Jul 17 14:57:56 2013 +0200 @@ -130,6 +130,14 @@ closeBufferedWriter(fout); } } + + + + public static String[] getStringArrayFromOutputTextFile(String pathTofileAndItsName) + { + String[] strs = FileUtils.readTextFile(pathTofileAndItsName).toArray(new String[0]); + return strs; + } /** * Write list of string to a file with given name. No exception is thrown
--- a/src/org/thermostat/qa/testsuites/CliClientSmokeTest.java Wed Jul 10 18:06:09 2013 +0200 +++ b/src/org/thermostat/qa/testsuites/CliClientSmokeTest.java Wed Jul 17 14:57:56 2013 +0200 @@ -38,6 +38,7 @@ import org.thermostat.qa.annotations.TestTypes; import org.thermostat.qa.framework.Assert; import org.thermostat.qa.framework.ThermostatTest; +import org.thermostat.qa.reporter.FileUtils; @@ -56,30 +57,9 @@ @TestType(TestTypes.CLI_TEST) public class CliClientSmokeTest extends ThermostatTest { - private static final String[] THERMOSTAT_SHELL_HELP_MESSAGE = new String[] { - "list of commands:", - "", - " help show help for a given command or help overview", - " agent starts and stops the thermostat agent", - " connect persistently connect to storage", - " disconnect disconnect from the currently used storage", - " dump-heap trigger a heap dump on the VM", - " find-objects finds objects in a heapdump", - " find-root finds the shortest path from an object to a GC root", - " gui launches the GUI client", - " list-heap-dumps list all heap dumps", - " list-vms lists all currently monitored VMs", - " object-info prints information about an object in a heap dump", - " ping using the Command Channel, send a ping to a running agent", - " save-heap-dump-to-file saves a heap dump to a local file", - " service starts and stops the thermostat storage and agent", - " shell launches the Thermostat interactive shell", - " show-heap-histogram show the heap histogram", - " storage starts and stops the thermostat storage", - " vm-info shows basic information about a VM", - " vm-stat show various statistics about a VM", - " webservice starts and stops the thermostat web service" - }; + public static final String[] allscripts = new String[] {"exit_therm_shell.txt", "help_therm_shell.txt"}; + private String pathToOutputTexts; + private String[] THERMOSTAT_SHELL_HELP_MESSAGE, THERMOSTAT_SHELL_EXIT_MESSAGE; @Override protected void tearDown() @@ -91,8 +71,9 @@ @Override protected void setUp() { - // TODO Auto-generated method stub - + pathToOutputTexts = "outputtexts/"+this.configuration.getThermostatOutputTextsVersion()+"/"; + THERMOSTAT_SHELL_HELP_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(pathToOutputTexts+"output_of_help_therm_shell.txt"); + THERMOSTAT_SHELL_EXIT_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(pathToOutputTexts+"output_of_exit_therm_shell.txt"); } /** @@ -119,10 +100,9 @@ logInfo("run", "Thermostat shell: " + s); } - Assert.assertTrue(output.size()>=2, "too few lines in the thermostat shell output"); + Assert.assertTrue(output.size()>=THERMOSTAT_SHELL_EXIT_MESSAGE.length, "too few lines in the thermostat shell output"); - compareTwoLines(output.get(0), "Thermostat version 0.10.0"); - compareTwoLines(output.get(1), "Thermostat > exit"); + compareListAndArrayOfStrings(output, THERMOSTAT_SHELL_EXIT_MESSAGE); stopStorage(); } @@ -151,21 +131,21 @@ logInfo("run", "Thermostat shell: " + s); } - Assert.assertTrue(output.size()>=25, "too few lines in the thermostat shell output"); - - compareTwoLines(output.get(0), "Thermostat version 0.10.0"); - compareTwoLines(output.get(1), "Thermostat > help"); + Assert.assertTrue(output.size()>=THERMOSTAT_SHELL_HELP_MESSAGE.length, "too few lines in the thermostat shell output"); + + compareListAndArrayOfStrings(output, THERMOSTAT_SHELL_HELP_MESSAGE); - int i = 2; - for(String wanted : THERMOSTAT_SHELL_HELP_MESSAGE) + stopStorage(); + } + + private void compareListAndArrayOfStrings(List<String> list, String[] wantedArr) + { + int i = 0; + for(String wanted : wantedArr) { - compareTwoLines(output.get(i), wanted); + compareTwoLines(list.get(i), wanted); i++; } - - compareTwoLines(output.get(24), "Thermostat > exit"); - - stopStorage(); } public static void main(String[] args) {
--- a/src/org/thermostat/qa/testsuites/OutputMessagesTest.java Wed Jul 10 18:06:09 2013 +0200 +++ b/src/org/thermostat/qa/testsuites/OutputMessagesTest.java Wed Jul 17 14:57:56 2013 +0200 @@ -82,7 +82,7 @@ {"help", "vm-stat"}, {"help", "webservice"} }; - private String pathToOutputTexts; + private String outputsPath; private String[] THERMOSTAT_STANDARD_MESSAGE, THERMOSTAT_HELP_MESSAGE, THERMOSTAT_HELP_AGENT_MESSAGE, @@ -108,28 +108,28 @@ @Override protected void setUp() { - pathToOutputTexts = "outputtexts/"+this.configuration.getThermostatOutputTextsVersion()+"/"; - THERMOSTAT_STANDARD_MESSAGE = getStringArrayFromOutputTextFile("thermostat.txt"); - THERMOSTAT_HELP_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help.txt"); - THERMOSTAT_HELP_AGENT_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_agent.txt"); - THERMOSTAT_HELP_CONNECT_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_connect.txt"); - THERMOSTAT_HELP_DISCONNECT_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_disconnect.txt"); - THERMOSTAT_HELP_DUMP_HEAP_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_dump-heap.txt"); - THERMOSTAT_HELP_FIND_OBJECTS_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_find-objects.txt"); - THERMOSTAT_HELP_FIND_ROOT_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_find-root.txt"); - THERMOSTAT_HELP_GUI_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_gui.txt"); - THERMOSTAT_HELP_LIST_HEAP_DUMPS_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_list-heap-dumps.txt"); - THERMOSTAT_HELP_LIST_VMS_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_list-vms.txt"); - THERMOSTAT_HELP_OBJECT_INFO_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_object-info.txt"); - THERMOSTAT_HELP_PING_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_ping.txt"); - THERMOSTAT_HELP_SAVE_HEAP_DUMP_TO_FILE_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_save-heap-dump-to-file.txt"); - THERMOSTAT_HELP_SERVICE_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_service.txt"); - THERMOSTAT_HELP_SHELL_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_shell.txt"); - THERMOSTAT_HELP_SHOW_HEAP_HISTOGRAM_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_show-heap-histogram.txt"); - THERMOSTAT_HELP_STORAGE_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_storage.txt"); - THERMOSTAT_HELP_VM_INFO_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_vm-info.txt"); - THERMOSTAT_HELP_VM_STAT_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_vm-stat.txt"); - THERMOSTAT_HELP_WEBSERVICE_MESSAGE = getStringArrayFromOutputTextFile("thermostat_help_webservice.txt"); + outputsPath = "outputtexts/"+this.configuration.getThermostatOutputTextsVersion()+"/"; + THERMOSTAT_STANDARD_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat.txt"); + THERMOSTAT_HELP_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help.txt"); + THERMOSTAT_HELP_AGENT_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_agent.txt"); + THERMOSTAT_HELP_CONNECT_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_connect.txt"); + THERMOSTAT_HELP_DISCONNECT_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_disconnect.txt"); + THERMOSTAT_HELP_DUMP_HEAP_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_dump-heap.txt"); + THERMOSTAT_HELP_FIND_OBJECTS_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_find-objects.txt"); + THERMOSTAT_HELP_FIND_ROOT_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_find-root.txt"); + THERMOSTAT_HELP_GUI_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_gui.txt"); + THERMOSTAT_HELP_LIST_HEAP_DUMPS_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_list-heap-dumps.txt"); + THERMOSTAT_HELP_LIST_VMS_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_list-vms.txt"); + THERMOSTAT_HELP_OBJECT_INFO_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_object-info.txt"); + THERMOSTAT_HELP_PING_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_ping.txt"); + THERMOSTAT_HELP_SAVE_HEAP_DUMP_TO_FILE_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_save-heap-dump-to-file.txt"); + THERMOSTAT_HELP_SERVICE_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_service.txt"); + THERMOSTAT_HELP_SHELL_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_shell.txt"); + THERMOSTAT_HELP_SHOW_HEAP_HISTOGRAM_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_show-heap-histogram.txt"); + THERMOSTAT_HELP_STORAGE_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_storage.txt"); + THERMOSTAT_HELP_VM_INFO_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_vm-info.txt"); + THERMOSTAT_HELP_VM_STAT_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_vm-stat.txt"); + THERMOSTAT_HELP_WEBSERVICE_MESSAGE = FileUtils.getStringArrayFromOutputTextFile(outputsPath+"thermostat_help_webservice.txt"); } @Override @@ -163,12 +163,6 @@ Assert.assertNotNull(processOutput, "error getting standard output"); compareMessages(template, processOutput); } - - private String[] getStringArrayFromOutputTextFile(String fileName) - { - String[] strs = FileUtils.readTextFile(pathToOutputTexts+fileName).toArray(new String[0]); - return strs; - } /** * Method testCheckStandardMessage
--- a/test.properties Wed Jul 10 18:06:09 2013 +0200 +++ b/test.properties Wed Jul 17 14:57:56 2013 +0200 @@ -1,3 +1,3 @@ thermostat_executable_path=/home/jfabriko/thermostaty/testing_thermostat/thermostat/distribution/target/bin/ thermostat_executable_name=thermostat -thermostat_output_version=version1 +thermostat_output_version=version2DesertRose