Mercurial > hg > ThermostatQA
changeset 115:19b3729973f4
Fixed graph generator. Added support for invalid tests.
author | Pavel Tisnovsky <ptisnovs@redhat.com> |
---|---|
date | Wed, 09 Oct 2013 13:55:58 +0200 |
parents | d3ccb7632ce4 |
children | 74e32384684c |
files | ChangeLog src/org/thermostat/qa/reporter/GraphPagesGenerator.java src/org/thermostat/qa/reporter/HistoryPagesGenerator.java templates/graph.html |
diffstat | 4 files changed, 117 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Oct 08 10:24:14 2013 +0200 +++ b/ChangeLog Wed Oct 09 13:55:58 2013 +0200 @@ -1,3 +1,11 @@ +2013-10-09 Pavel Tisnovsky <ptisnovs@redhat.com> + + * src/org/thermostat/qa/reporter/GraphPagesGenerator.java: + Fixed graph generator. Added support for invalid tests. + * src/org/thermostat/qa/reporter/HistoryPagesGenerator.java: + * templates/graph.html: + Added support for invalid tests. + 2013-10-08 Pavel Tisnovsky <ptisnovs@redhat.com> * src/org/thermostat/qa/framework/ThermostatOutputTextsGenerator.java:
--- a/src/org/thermostat/qa/reporter/GraphPagesGenerator.java Tue Oct 08 10:24:14 2013 +0200 +++ b/src/org/thermostat/qa/reporter/GraphPagesGenerator.java Wed Oct 09 13:55:58 2013 +0200 @@ -73,6 +73,10 @@ templateLine = templateLine.replace("${TEST_COUNT}", testCountMessage); out.add(templateLine); } + else if (templateLine.contains("${GRAPH_DATA_NONE}")) + { + renderGraphDataNone(out, testResultList); + } else if (templateLine.contains("${GRAPH_DATA_PASSED}")) { renderGraphDataPassed(out, testResultList); @@ -85,6 +89,10 @@ { renderGraphDataError(out, testResultList); } + else if (templateLine.contains("${GRAPH_DATA_IGNORED}")) + { + renderGraphDataIgnored(out, testResultList); + } else if (templateLine.contains("${TABLE_DATA}")) { renderTableData(out, testResults, testCount); @@ -104,6 +112,14 @@ return "[" + (i + 1) + ", " + cnt + "],"; } + private static void renderGraphDataNone(List<String> out, List<TestResult> testResultList) + { + for (int i = 0; i < testResultList.size(); i++) + { + out.add(oneRecord(i, 0)); + } + } + private static void renderGraphDataPassed(List<String> out, List<TestResult> testResultList) { for (int i = 0; i < testResultList.size(); i++) @@ -128,6 +144,14 @@ } } + private static void renderGraphDataIgnored(List<String> out, List<TestResult> testResultList) + { + for (int i = 0; i < testResultList.size(); i++) + { + out.add(oneRecord(i, testResultList.get(i).getIgnored())); + } + } + private static List<TestResult> processTestResultList(Map<String, Map<String, List<String>>> testResults, int testCount) { @@ -163,6 +187,7 @@ out.add("<td style='color:#006000;text-align:right;'>" + testResult.getPassed() + "</td>"); out.add("<td style='color:#800000;text-align:right;'>" + testResult.getFailed() + "</td>"); out.add("<td style='color:#000080;text-align:right;'>" + testResult.getError() + "</td>"); + out.add("<td style='color:#606060;text-align:right;'>" + testResult.getIgnored() + "</td>"); out.add("</tr>"); } index++;
--- a/src/org/thermostat/qa/reporter/HistoryPagesGenerator.java Tue Oct 08 10:24:14 2013 +0200 +++ b/src/org/thermostat/qa/reporter/HistoryPagesGenerator.java Wed Oct 09 13:55:58 2013 +0200 @@ -32,6 +32,7 @@ package org.thermostat.qa.reporter; +import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -49,6 +50,8 @@ public class HistoryPagesGenerator { + private static boolean debug = true; + public static void generate(Map<String, Map<String, List<String>>> testResults, CommandLineParameters params) { createHtmlPageFromTemplate(testResults, params, 10, TestType.FAILED); @@ -67,8 +70,18 @@ // list of dates List<String> dateList = getDateList(testResults, testCount, testType); + if (debug) + { + printDateList(dateList); + } + // list of all tests - Set<String> testList = getTestList(testResults, dateList); + Set<String> testList = getTestList(testResults, dateList); + + if (debug) + { + printTestList(testList); + } // iterate through whole template for (String templateLine : template) { @@ -94,6 +107,25 @@ FileUtils.writeTextFile(params.getReportDir() + "/" + outName + ".html", out); } + private static void printDateList(List<String> dateList) { + System.out.println("Date list:"); + printStringCollection(dateList); + } + + private static void printTestList(Set<String> testList) { + System.out.println("Test list:"); + printStringCollection(testList); + } + + /** + * @param dateList + */ + private static void printStringCollection(Collection<String> dateList) { + for (String date : dateList) { + System.out.println(" " + date); + } + } + private static List<String> getDateList(Map<String, Map<String, List<String>>> testResults, int testCount, TestType testType) { List<String> dates = new LinkedList<String>(); for (Map.Entry<String, Map<String, List<String>>> oneResult : testResults.entrySet()) { @@ -116,6 +148,11 @@ failedTests.addAll(grepTests(test.getValue(), "FAILED: ")); } } + if (debug) + { + System.out.println("# of failed tests: " + failedTests.size()); + } + for (int i = 0; i < dateList.size() - 1; i++) { String date1 = dateList.get(i); @@ -214,8 +251,8 @@ for (String date : dateList) { TestStatus testStatus = getTestStatus(testName, date, testResults); - String cssClass = testStatus == TestStatus.PASSED ? "passed-header" : testStatus == TestStatus.FAILED ? "failed-header" : "empty"; - String cellText = testStatus == TestStatus.PASSED ? "ok" : testStatus == TestStatus.FAILED ? "fail" : " "; + String cssClass = getCssClass(testStatus); + String cellText = getCellText(testStatus); if (testStatus == TestStatus.NOT_FOUND) { out.add("<td class='" + cssClass + "'>" + cellText + "</td>"); @@ -231,6 +268,30 @@ } /** + * @param testStatus + * @return + */ + private static String getCssClass(TestStatus testStatus) { + String cssClass = testStatus == TestStatus.PASSED ? "passed-header" : + testStatus == TestStatus.FAILED ? "failed-header" : + testStatus == TestStatus.IGNORED ? "ignored-header" : + "empty"; + return cssClass; + } + + /** + * @param testStatus + * @return + */ + private static String getCellText(TestStatus testStatus) { + String cellText = testStatus == TestStatus.PASSED ? "ok" : + testStatus == TestStatus.FAILED ? "fail" : + testStatus == TestStatus.IGNORED ? "x" : + " "; + return cellText; + } + + /** * @param testName * @return */ @@ -247,7 +308,6 @@ private static TestStatus getTestStatus(String testName, String date, Map<String, Map<String, List<String>>> testResults) { String simpleName = date + "/" + testName.substring("org.thermostat.qa.testsuites.".length(), testName.lastIndexOf('.')) + ".log"; - System.out.println("******** "+ simpleName); for (Map.Entry<String, List<String>> test : testResults.get(date).entrySet()) { if (test.getKey().endsWith(simpleName)) @@ -279,6 +339,14 @@ return TestStatus.PASSED; } } + if (line.startsWith("IGNORED: ")) + { + String tn = line.substring("IGNORED: ".length()); + if (tn.equals(testName)) + { + return TestStatus.IGNORED; + } + } } } }
--- a/templates/graph.html Tue Oct 08 10:24:14 2013 +0200 +++ b/templates/graph.html Wed Oct 09 13:55:58 2013 +0200 @@ -72,15 +72,19 @@ var d_error = [ ${GRAPH_DATA_ERROR} ]; + var d_ignored = [ +${GRAPH_DATA_IGNORED} + ]; /** * Draw the graph in the first container. */ Flotr.draw( $('graph1'), [ - {data:d_passed, mouse:{track: true}, label:'PASSED', lines:{fill:false}}, - {data:d_failed, mouse:{track: true}, label:'FAILED', lines:{fill:false}}, - {data:d_error, mouse:{track: true}, label:'ERROR', lines:{fill:false}}, + {data:d_passed, mouse:{track: true}, label:'PASSED', lines:{fill:false}}, + {data:d_failed, mouse:{track: true}, label:'FAILED', lines:{fill:false}}, + {data:d_error, mouse:{track: true}, label:'ERROR', lines:{fill:false}}, + {data:d_ignored, mouse:{track: true}, label:'IGNORED', lines:{fill:false}}, ], { lines: {show: true}, points: {show: true}, @@ -116,6 +120,9 @@ var d_error = [ ${GRAPH_DATA_ERROR} ]; + var d_ignored = [ +${GRAPH_DATA_IGNORED} + ]; /** * Draw the graph in the second container. */ @@ -125,6 +132,7 @@ {data:d_none, mouse:{track: false}, label:'', lines:{fill:false, show:false}}, {data:d_failed, mouse:{track: true}, label:'FAILED', lines:{fill:false}}, {data:d_error, mouse:{track: true}, label:'ERROR', lines:{fill:false}}, + {data:d_ignored, mouse:{track: true}, label:'IGNORED', lines:{fill:false}}, ], { lines: {show: true}, points: {show: true}, @@ -151,7 +159,7 @@ <tr> <td> <table border="2" frame="border" rules="all" cellspacing="1" cellpadding="1" style="background-color: #f0f0dd; vertical-align: top; border-collapse: collapse; border-color:#808080"> - <tr><td>#</td><td>Date</td><td>Passed</td><td>Failed</td><td>Error</td></tr> + <tr><td>#</td><td>Date</td><td>Passed</td><td>Failed</td><td>Error</td><td>Ignored</td></tr> ${TABLE_DATA} </table> </td>