summaryrefslogtreecommitdiffstats
path: root/reporting
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2017-06-26 17:04:41 +0200
committerMorgan Richomme <morgan.richomme@orange.com>2017-06-26 17:04:41 +0200
commitbcbc07b37f1590651cce7ccb596e50f97423226f (patch)
tree8f533696698d32f9e6ce1aeb2e5495dec2231fad /reporting
parent83d399af614f359f3071e663a245cd1c5cf6480c (diff)
bug fix: consider pagination when retrieveing results for reporting
Due to pagination feature introduced in test API, reporting pages only considered the first page of results retrieved by the API the number of pages is now detected to aggregate the results JIRA: RELENG-259 Change-Id: I0ac90b125baf8c16341c8db22f5602fedd4cdf1b Signed-off-by: Morgan Richomme <morgan.richomme@orange.com>
Diffstat (limited to 'reporting')
-rwxr-xr-xreporting/functest/reporting-status.py1
-rw-r--r--reporting/utils/reporting_utils.py27
2 files changed, 18 insertions, 10 deletions
diff --git a/reporting/functest/reporting-status.py b/reporting/functest/reporting-status.py
index e700e04..77ab784 100755
--- a/reporting/functest/reporting-status.py
+++ b/reporting/functest/reporting-status.py
@@ -107,7 +107,6 @@ for version in versions:
scenario_results = rp_utils.getScenarios(healthcheck,
installer,
version)
-
# get nb of supported architecture (x86, aarch64)
architectures = rp_utils.getArchitectures(scenario_results)
logger.info("Supported architectures: {}".format(architectures))
diff --git a/reporting/utils/reporting_utils.py b/reporting/utils/reporting_utils.py
index 599a938..0a178ba 100644
--- a/reporting/utils/reporting_utils.py
+++ b/reporting/utils/reporting_utils.py
@@ -117,19 +117,29 @@ def getScenarios(case, installer, version):
url = ("http://" + url_base + "?case=" + case +
"&period=" + str(period) + "&installer=" + installer +
"&version=" + version)
- request = Request(url)
try:
+ request = Request(url)
response = urlopen(request)
k = response.read()
results = json.loads(k)
test_results = results['results']
- except URLError as e:
- print('Got an error code:', e)
+
+ page = results['pagination']['total_pages']
+ if page > 1:
+ test_results = []
+ for i in range(1, page + 1):
+ url_page = url + "&page=" + str(i)
+ request = Request(url_page)
+ response = urlopen(request)
+ k = response.read()
+ results = json.loads(k)
+ test_results += results['results']
+ except URLError as err:
+ print('Got an error code:', err)
if test_results is not None:
test_results.reverse()
-
scenario_results = {}
for r in test_results:
@@ -157,7 +167,6 @@ def getScenarioStats(scenario_results):
return scenario_stats
-# TODO convergence with above function getScenarios
def getScenarioStatus(installer, version):
period = get_config('general.period')
url_base = get_config('testapi.url')
@@ -213,8 +222,8 @@ def getQtipResults(version, installer):
k = response.read()
response.close()
results = json.loads(k)['results']
- except URLError as e:
- print('Got an error code:', e)
+ except URLError as err:
+ print('Got an error code:', err)
result_dict = {}
if results:
@@ -427,9 +436,9 @@ def export_csv(scenario_file_name, installer, version):
"/functest/scenario_history_" +
installer + ".csv")
scenario_installer_file = open(scenario_installer_file_name, "a")
- with open(scenario_file_name, "r") as f:
+ with open(scenario_file_name, "r") as scenario_file:
scenario_installer_file.write("date,scenario,installer,detail,score\n")
- for line in f:
+ for line in scenario_file:
if installer in line:
scenario_installer_file.write(line)
scenario_installer_file.close