Mercurial > hg > ThermostatQA
changeset 184:40990362e151
Improved reporter
- for compatibility report thermostat versions are now diplayed in heading and
title of pages.
- fixed bug in replacePatterns method in CommonUtilities class,
when there is more then one pattern on single line.
author | Zdenek Zambersky <zzambers@redhat.com> |
---|---|
date | Fri, 15 May 2015 19:09:02 +0200 |
parents | 67f1ec14b9cd |
children | 3ec1dcfecb16 |
files | Makefile src/org/thermostat/qa2/framework/ThermostatQAConfig.java src/org/thermostat/qa2/framework/utils/CommonUtilities.java src/org/thermostat/qa2/reporter/Generator.java src/org/thermostat/qa2/reporter/Reporter.java templates/graph.html templates/hist.html templates/index.html templates/log.html |
diffstat | 9 files changed, 55 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Fri May 15 19:03:37 2015 +0200 +++ b/Makefile Fri May 15 19:09:02 2015 +0200 @@ -230,6 +230,7 @@ cp -r $(FLOTR_DIR) $(REPORT_DIR)/compatibility/$(THERMOSTAT_OTHER_VERSION) $(JAVA) -cp $(CLASSES_DIR) \ -Dthermostat.version=$(THERMOSTAT_VERSION) \ + -Dthermostat.other.version=$(THERMOSTAT_OTHER_VERSION) \ -Dlogs.path=$(LOGS_DIR)/compatibility/$(THERMOSTAT_OTHER_VERSION)/ \ -Dreports.path=$(REPORT_DIR)/compatibility/$(THERMOSTAT_OTHER_VERSION) \ org.thermostat.qa2.reporter.Reporter
--- a/src/org/thermostat/qa2/framework/ThermostatQAConfig.java Fri May 15 19:03:37 2015 +0200 +++ b/src/org/thermostat/qa2/framework/ThermostatQAConfig.java Fri May 15 19:09:02 2015 +0200 @@ -162,6 +162,10 @@ return "." + File.separator + "outputtexts" + File.separator + thermostatVersion; } + public static boolean isCompatibilityTesting() { + return thermostatOtherVersion != null; + } + public static Login getMongoLogin() { return mongoLogin; }
--- a/src/org/thermostat/qa2/framework/utils/CommonUtilities.java Fri May 15 19:03:37 2015 +0200 +++ b/src/org/thermostat/qa2/framework/utils/CommonUtilities.java Fri May 15 19:09:02 2015 +0200 @@ -89,7 +89,7 @@ patterns.entrySet().toArray(entries); for (String line : template) { String restOfLine = line; - String toPrint = null; + String toPrint = ""; Map.Entry<String, List<String>> entryFound; do { entryFound = null; @@ -107,18 +107,18 @@ String pattern = entryFound.getKey(); List<String> replacement = entryFound.getValue(); int replacementSize = replacement.size(); - toPrint = line.substring(0, index); + toPrint += restOfLine.substring(0, index); for (int j = 0; j < replacementSize - 1; ++j) { String replacementLine = replacement.get(j); - output.add(toPrint == null ? replacementLine : toPrint + replacementLine); - toPrint = null; + output.add(toPrint += replacementLine); + toPrint = ""; } String lastReplacementLine = replacementSize > 0 ? replacement.get(replacementSize - 1) : ""; - toPrint = toPrint == null ? lastReplacementLine : toPrint + lastReplacementLine; - restOfLine = line.substring(index + pattern.length()); + toPrint += lastReplacementLine; + restOfLine = restOfLine.substring(index + pattern.length()); } } while (entryFound != null); - output.add(toPrint == null ? restOfLine : toPrint + restOfLine); + output.add(toPrint + restOfLine); } }
--- a/src/org/thermostat/qa2/reporter/Generator.java Fri May 15 19:03:37 2015 +0200 +++ b/src/org/thermostat/qa2/reporter/Generator.java Fri May 15 19:09:02 2015 +0200 @@ -47,6 +47,8 @@ * @author Zdeněk Žamberský */ public class Generator { + + public static final String testsNamePattern = "${TESTS_NAME}"; public static final String resultsUrlPattern = "${RESULTS_URL}"; public static final String datePattern = "${DATE}"; @@ -83,8 +85,9 @@ //////////////////// //// INDEX PAGE //// //////////////////// - public static void generateIndexPage(List<String> output, TestRunResult run) throws IOException { + public static void generateIndexPage(List<String> output, TestRunResult run, String testsName) throws IOException { Map<String, List<String>> replacements = new HashMap(); + CommonUtilities.addReplacementToMap(replacements, Generator.testsNamePattern, testsName); CommonUtilities.addReplacementToMap(replacements, Generator.resultsUrlPattern, "log_" + run.date + ".xhtml"); CommonUtilities.addReplacementToMap(replacements, Generator.datePattern, run.date); CommonUtilities.addReplacementToMap(replacements, Generator.passedPattern, Integer.toString(run.passedCount)); @@ -104,7 +107,7 @@ ////////////////// //// LOG PAGE //// ////////////////// - public static void generateLogPage(List<String> output, TestRunResult run) throws IOException { + public static void generateLogPage(List<String> output, TestRunResult run, String testsName) throws IOException { List<String> dateText = new ArrayList(); dateText.add(run.date); List<String> summaryText = new ArrayList(); @@ -112,6 +115,7 @@ List<String> resultsText = new ArrayList(); generateLogTable(resultsText, run); Map<String, List<String>> replacements = new HashMap(); + CommonUtilities.addReplacementToMap(replacements, Generator.testsNamePattern, testsName); replacements.put(datePattern, dateText); replacements.put(sumaryPattern, summaryText); replacements.put(resultsPattern, resultsText); @@ -188,12 +192,13 @@ ////////////////////// //// HISTORY PAGE //// ////////////////////// - public static void generateHistoryPage(List<String> output, List<TestRunResult> runs, String resultsType, int count, boolean onlyFail) throws IOException { + public static void generateHistoryPage(List<String> output, List<TestRunResult> runs, String testsName, String resultsType, int count, boolean onlyFail) throws IOException { List<String> resultTypeText = new ArrayList(); resultTypeText.add(resultsType); List<String> historyTableText = new ArrayList(); generateHistoryTable(historyTableText, runs, count, onlyFail); Map<String, List<String>> replacements = new HashMap(); + CommonUtilities.addReplacementToMap(replacements, Generator.testsNamePattern, testsName); replacements.put(resultsPattern, resultTypeText); replacements.put(tableDataPattern, historyTableText); List<String> template = FileUtilities.getLineListFromFile(historyPageTemplate); @@ -270,7 +275,7 @@ //////////////////// //// GRAPH PAGE //// //////////////////// - public static void generateGraphPage(List<String> output, List<TestRunResult> runs, int count) throws IOException { + public static void generateGraphPage(List<String> output, List<TestRunResult> runs, String testsName, int count) throws IOException { List<String> testCountText = new ArrayList(); testCountText.add(Integer.toString(count)); List<String> passedDataText = new ArrayList(); @@ -286,6 +291,7 @@ List<String> tableText = new ArrayList(); generateGraphTable(tableText, runs, count); Map<String, List<String>> replacements = new HashMap(); + CommonUtilities.addReplacementToMap(replacements, testsNamePattern, testsName); replacements.put(testCountPattern, testCountText); replacements.put(graphDataPassedPattern, passedDataText); replacements.put(graphDataFailedPattern, failedDataText);
--- a/src/org/thermostat/qa2/reporter/Reporter.java Fri May 15 19:03:37 2015 +0200 +++ b/src/org/thermostat/qa2/reporter/Reporter.java Fri May 15 19:09:02 2015 +0200 @@ -35,7 +35,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import org.thermostat.qa.reporter.ResultsGraphGenerator; import org.thermostat.qa.reporter.TestResult; @@ -48,17 +48,24 @@ */ public class Reporter { - public static void generateReport() throws IOException { - File logsDir = new File(ThermostatQAConfig.logsDir); - File[] runDirs = logsDir.listFiles(); - Arrays.sort(runDirs); + public static void generateReport(String logsDirectory, String testsName) throws IOException { + File logsDir = new File(logsDirectory); + File[] runDirsArray = logsDir.listFiles(); + List<File> runDirs = new ArrayList(); - int runsCount = runDirs.length; + for (File f : runDirsArray) { + if (!f.getName().equals("compatibility")) { + runDirs.add(f); + } + } + Collections.sort(runDirs); + + int runsCount = runDirs.size(); int limit = 30; if (runsCount > 0) { List<TestRunResult> runs = new ArrayList(); for (int i = Math.max(0, runsCount - limit); i < runsCount; ++i) { - TestRunResult run = LogParser.parseLogDir(runDirs[i]); + TestRunResult run = LogParser.parseLogDir(runDirs.get(i)); runs.add(run); } TestRunResult lastRun = runs.get(runs.size() - 1); @@ -66,13 +73,13 @@ // index page String indexPagePath = ThermostatQAConfig.reportDir + File.separator + "index.xhtml"; List<String> indexPageText = new ArrayList(); - Generator.generateIndexPage(indexPageText, lastRun); + Generator.generateIndexPage(indexPageText, lastRun, testsName); FileUtilities.printLineListToFile(indexPagePath, indexPageText); // log page String logPagePath = ThermostatQAConfig.reportDir + File.separator + "log_" + lastRun.date + ".xhtml"; List<String> logPageText = new ArrayList(); - Generator.generateLogPage(logPageText, lastRun); + Generator.generateLogPage(logPageText, lastRun, testsName); FileUtilities.printLineListToFile(logPagePath, logPageText); // history pages @@ -84,7 +91,7 @@ for (int i = 0; i < fileNames.length; ++i) { String historyPagePath = ThermostatQAConfig.reportDir + File.separator + fileNames[i] + ".xhtml"; List<String> historyPageText = new ArrayList(); - Generator.generateHistoryPage(historyPageText, runs, labels[i], counts[i], onlyFailed[i]); + Generator.generateHistoryPage(historyPageText, runs, testsName, labels[i], counts[i], onlyFailed[i]); FileUtilities.printLineListToFile(historyPagePath, historyPageText); } @@ -94,7 +101,7 @@ for (int i = 0; i < fileNames.length; ++i) { String graphsPagePath = ThermostatQAConfig.reportDir + File.separator + fileNames[i] + ".xhtml"; List<String> graphPageText = new ArrayList(); - Generator.generateGraphPage(graphPageText, runs, counts[i]); + Generator.generateGraphPage(graphPageText, runs, testsName, counts[i]); FileUtilities.printLineListToFile(graphsPagePath, graphPageText); } @@ -106,7 +113,11 @@ } public static void main(String[] args) throws IOException { - generateReport(); + String logsDir = ThermostatQAConfig.logsDir; + String testsName = ThermostatQAConfig.isCompatibilityTesting() + ? "ThermostatQA compatibility tests (" + ThermostatQAConfig.getThermostatVersion("tested") + " against " + ThermostatQAConfig.getThermostatVersion("other") + ")" + : "ThermostatQA tests"; + generateReport(logsDir, testsName); } }
--- a/templates/graph.html Fri May 15 19:03:37 2015 +0200 +++ b/templates/graph.html Fri May 15 19:09:02 2015 +0200 @@ -34,7 +34,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> - <title>ThermostatQA tests report – graph for ${TEST_COUNT} tests</title> + <title>${TESTS_NAME} – graph for ${TEST_COUNT} tests</title> <meta name="Author" content="Pavel Tisnovsky" /> <meta name="Generator" content="org.thermostat.qa.reporter.Reporter" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> @@ -52,7 +52,7 @@ </head> <body> <div> - <h1>ThermostatQA tests report - graph for ${TEST_COUNT} tests</h1> + <h1>${TESTS_NAME} - graph for ${TEST_COUNT} tests</h1> <table border="0"> <tr>
--- a/templates/hist.html Fri May 15 19:03:37 2015 +0200 +++ b/templates/hist.html Fri May 15 19:09:02 2015 +0200 @@ -34,7 +34,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> - <title>ThermostatQA tests report – ${RESULTS}</title> + <title>${TESTS_NAME} history – ${RESULTS}</title> <meta name="Author" content="Pavel Tisnovsky" /> <meta name="Generator" content="org.thermostat.qa.reporter.Reporter" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> @@ -42,7 +42,7 @@ </head> <body> <div> - <h1>ThermostatQA tests history - ${RESULTS}</h1> + <h1>${TESTS_NAME} history - ${RESULTS}</h1> <br />
--- a/templates/index.html Fri May 15 19:03:37 2015 +0200 +++ b/templates/index.html Fri May 15 19:09:02 2015 +0200 @@ -34,7 +34,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> - <title>ThermostatQA tests report: JDK ${JAVA_VERSION}</title> + <title>${TESTS_NAME} report</title> <meta name="Author" content="Pavel Tisnovsky" /> <meta name="Generator" content="org.thermostat.qa.reporter.Reporter" /> <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" /> @@ -42,12 +42,14 @@ </head> <body> <div> - <h1>ThermostatQA tests report: JDK ${JAVA_VERSION}</h1> + <h1>${TESTS_NAME} report</h1> <p> + <!-- Link to more results + javadoc: <a href="${RESULTS_URL}"> ${RESULTS_URL}</a> + --> </p>
--- a/templates/log.html Fri May 15 19:03:37 2015 +0200 +++ b/templates/log.html Fri May 15 19:09:02 2015 +0200 @@ -34,7 +34,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> - <title>ThermostatQA tests log for date ${DATE}</title> + <title>${TESTS_NAME} log for date ${DATE}</title> <meta name="Author" content="Pavel Tisnovsky" /> <meta name="Generator" content="org.thermostat.qa.reporter.Reporter" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> @@ -42,7 +42,7 @@ </head> <body> <div> - <h1>ThermostatQA tests log for date ${DATE}</h1> + <h1>${TESTS_NAME} log for date ${DATE}</h1> <br />