summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2016-10-19 06:44:11 +0000
committerGerrit Code Review <gerrit@opnfv.org>2016-10-19 06:44:11 +0000
commitae1a2c2abfbd125af61abffd99bf3582d240c05e (patch)
treefea52c92ab050a6ac4332018c4e9ad437dec5f65
parent1c15b700150be0a3f6f462733df36726bb6a1d7e (diff)
parent87417c6333e84c1ed0a3d5fd3a42b413b6d437e3 (diff)
Merge "bug fix: pdf generation"
-rwxr-xr-xutils/test/reporting/functest/reporting-status.py81
-rw-r--r--utils/test/reporting/functest/reportingUtils.py8
2 files changed, 50 insertions, 39 deletions
diff --git a/utils/test/reporting/functest/reporting-status.py b/utils/test/reporting/functest/reporting-status.py
index b527b7861..653448eaf 100755
--- a/utils/test/reporting/functest/reporting-status.py
+++ b/utils/test/reporting/functest/reporting-status.py
@@ -82,6 +82,10 @@ for version in conf.versions:
items = {}
scenario_result_criteria = {}
+ scenario_file_name = (conf.REPORTING_PATH +
+ "/functest/release/" + version +
+ "/scenario_history.txt")
+
# For all the scenarios get results
for s, s_result in scenario_results.items():
logger.info("---------------------------------")
@@ -185,11 +189,8 @@ for version in conf.versions:
scenario_criteria = conf.MAX_SCENARIO_CRITERIA
s_score = str(scenario_score) + "/" + str(scenario_criteria)
- s_score_percent = 0.0
- try:
- s_score_percent = float(scenario_score) / float(scenario_criteria) * 100
- except:
- logger.error("cannot calculate the score percent")
+ s_score_percent = utils.getScenarioPercent(scenario_score,
+ scenario_criteria)
s_status = "KO"
if scenario_score < scenario_criteria:
@@ -209,10 +210,7 @@ for version in conf.versions:
f.write(info)
# Save daily results in a file
- path_validation_file = (conf.REPORTING_PATH +
- "/functest/release/" + version +
- "/scenario_history.txt")
- with open(path_validation_file, "a") as f:
+ with open(scenario_file_name, "a") as f:
info = (reportingDate + "," + s + "," + installer +
"," + s_score + "," +
str(round(s_score_percent)) + "\n")
@@ -239,34 +237,39 @@ for version in conf.versions:
version=version,
date=reportingDate)
- with open(conf.REPORTING_PATH + "/functest/release/" + version +
- "/index-status-" + installer + ".html", "wb") as fh:
- fh.write(outputText)
+ # csv
+ # generate sub files based on scenario_history.txt
+ scenario_installer_file_name = (conf.REPORTING_PATH +
+ "/functest/release/" + version +
+ "/scenario_history_" + installer +
+ ".txt")
+ scenario_installer_file = open(scenario_installer_file_name, "a")
+ logger.info("Generate CSV...")
+ with open(scenario_file_name, "r") as f:
+ for line in f:
+ if installer in line:
+ logger.debug("Add new line... %s" % line)
+ scenario_installer_file.write(line)
+ scenario_installer_file.close
+
+ with open(conf.REPORTING_PATH + "/functest/release/" + version +
+ "/index-status-" + installer + ".html", "wb") as fh:
+ fh.write(outputText)
+ logger.info("CSV generated...")
- # Generate outputs for export
- # pdf
- try:
- pdf_path = ("http://testresults.opnfv.org/reporting/" +
- "functest/release/" + version +
- "/index-status-" + installer + ".html")
- pdf_doc_name = (conf.REPORTING_PATH +
- "/functest/release/" + version +
- "/status-" + installer + ".pdf")
- pdfkit.from_url(pdf_path, pdf_doc_name)
- except IOError:
- logger.info("pdf generated anyway...")
- except:
- logger.error("impossible to generate PDF")
- # csv
- # generate sub files based on scenario_history.txt
- scenario_installer_file_name = (conf.REPORTING_PATH +
- "/functest/release/" + version +
- "/scenario_history_" +
- installer + ".txt")
- scenario_installer_file = open(scenario_installer_file_name, "w")
-
- with open(path_validation_file, "r") as f:
- for line in f:
- if installer in line:
- scenario_installer_file.write(line)
- scenario_installer_file.close
+ # Generate outputs for export
+ # pdf
+ logger.info("Generate PDF...")
+ try:
+ pdf_path = ("http://testresults.opnfv.org/reporting/" +
+ "functest/release/" + version +
+ "/index-status-" + installer + ".html")
+ pdf_doc_name = (conf.REPORTING_PATH +
+ "/functest/release/" + version +
+ "/status-" + installer + ".pdf")
+ pdfkit.from_url(pdf_path, pdf_doc_name)
+ logger.info("PDF generated...")
+ except IOError:
+ logger.info("pdf generated anyway...")
+ except:
+ logger.error("impossible to generate PDF")
diff --git a/utils/test/reporting/functest/reportingUtils.py b/utils/test/reporting/functest/reportingUtils.py
index 9ba02e821..74d6f19c9 100644
--- a/utils/test/reporting/functest/reportingUtils.py
+++ b/utils/test/reporting/functest/reportingUtils.py
@@ -176,3 +176,11 @@ def getJenkinsUrl(build_tag):
print 'Impossible to get jenkins url:'
return jenkins_url
+
+def getScenarioPercent(scenario_score,scenario_criteria):
+ score = 0.0
+ try:
+ score = float(scenario_score) / float(scenario_criteria) * 100
+ except:
+ print 'Impossible to calculate the percentage score'
+ return score