diff options
Diffstat (limited to 'utils/test/reporting/api')
-rw-r--r-- | utils/test/reporting/api/__init__.py (renamed from utils/test/reporting/api/api/__init__.py) | 0 | ||||
-rw-r--r-- | utils/test/reporting/api/conf.py (renamed from utils/test/reporting/api/api/conf.py) | 0 | ||||
-rw-r--r-- | utils/test/reporting/api/handlers/__init__.py (renamed from utils/test/reporting/api/api/handlers/__init__.py) | 0 | ||||
-rw-r--r-- | utils/test/reporting/api/handlers/landing.py (renamed from utils/test/reporting/api/api/handlers/landing.py) | 78 | ||||
-rw-r--r-- | utils/test/reporting/api/handlers/projects.py (renamed from utils/test/reporting/api/api/handlers/projects.py) | 0 | ||||
-rw-r--r-- | utils/test/reporting/api/handlers/testcases.py (renamed from utils/test/reporting/api/api/handlers/testcases.py) | 0 | ||||
-rw-r--r-- | utils/test/reporting/api/requirements.txt | 3 | ||||
-rw-r--r-- | utils/test/reporting/api/server.py (renamed from utils/test/reporting/api/api/server.py) | 0 | ||||
-rw-r--r-- | utils/test/reporting/api/setup.cfg | 32 | ||||
-rw-r--r-- | utils/test/reporting/api/setup.py | 9 | ||||
-rw-r--r-- | utils/test/reporting/api/urls.py (renamed from utils/test/reporting/api/api/urls.py) | 0 |
11 files changed, 40 insertions, 82 deletions
diff --git a/utils/test/reporting/api/api/__init__.py b/utils/test/reporting/api/__init__.py index e69de29bb..e69de29bb 100644 --- a/utils/test/reporting/api/api/__init__.py +++ b/utils/test/reporting/api/__init__.py diff --git a/utils/test/reporting/api/api/conf.py b/utils/test/reporting/api/conf.py index 5897d4f97..5897d4f97 100644 --- a/utils/test/reporting/api/api/conf.py +++ b/utils/test/reporting/api/conf.py diff --git a/utils/test/reporting/api/api/handlers/__init__.py b/utils/test/reporting/api/handlers/__init__.py index bcda66438..bcda66438 100644 --- a/utils/test/reporting/api/api/handlers/__init__.py +++ b/utils/test/reporting/api/handlers/__init__.py diff --git a/utils/test/reporting/api/api/handlers/landing.py b/utils/test/reporting/api/handlers/landing.py index 749916fb6..0bf602dc9 100644 --- a/utils/test/reporting/api/api/handlers/landing.py +++ b/utils/test/reporting/api/handlers/landing.py @@ -7,6 +7,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## import requests +import time from tornado.escape import json_encode from tornado.escape import json_decode @@ -24,7 +25,7 @@ class FiltersHandler(BaseHandler): 'status': ['success', 'warning', 'danger'], 'projects': ['functest', 'yardstick'], 'installers': ['apex', 'compass', 'fuel', 'joid'], - 'version': ['colorado', 'master'], + 'version': ['master', 'colorado', 'danube'], 'loops': ['daily', 'weekly', 'monthly'], 'time': ['10 days', '30 days'] } @@ -53,27 +54,27 @@ class ScenariosHandler(BaseHandler): def _get_scenario_result(self, scenario, data, args): result = { 'status': data.get('status'), - 'installers': self._get_installers_result(data['installers'], args) + 'installers': self._get_installers_result(data, args) } return result def _get_installers_result(self, data, args): func = self._get_installer_result - return {k: func(k, data.get(k, {}), args) for k in args['installers']} + return {k: func(data.get(k, {}), args) for k in args['installers']} - def _get_installer_result(self, installer, data, args): - projects = data.get(args['version'], []) - return [self._get_project_data(projects, p) for p in args['projects']] + def _get_installer_result(self, data, args): + return self._get_version_data(data.get(args['version'], {}), args) - def _get_project_data(self, projects, project): + def _get_version_data(self, data, args): + return {k: self._get_project_data(data.get(k, {})) + for k in args['projects']} + + def _get_project_data(self, data): atom = { - 'project': project, - 'score': None, - 'status': None + 'score': data.get('score', ''), + 'status': data.get('status', '') } - for p in projects: - if p['project'] == project: - return p + return atom def _get_scenarios(self): @@ -88,41 +89,42 @@ class ScenariosHandler(BaseHandler): []) ) for a in data} scenario = { - 'status': self._get_status(), - 'installers': installers + 'status': self._get_status() } + scenario.update(installers) + return scenario def _get_status(self): return 'success' def _get_installer(self, data): - return {a.get('version'): self._get_version(a) for a in data} + return {a.get('version'): self._get_version(a.get('projects')) + for a in data} def _get_version(self, data): + return {a.get('project'): self._get_project(a) for a in data} + + def _get_project(self, data): + scores = data.get('scores', []) + trusts = data.get('trust_indicators', []) + try: - scores = data.get('score', {}).get('projects')[0] - trusts = data.get('trust_indicator', {}).get('projects')[0] - except (TypeError, IndexError): - return [] - else: - scores = {key: [dict(date=a.get('date')[:10], - score=a.get('score') - ) for a in scores[key]] for key in scores} - trusts = {key: [dict(date=a.get('date')[:10], - status=a.get('status') - ) for a in trusts[key]] for key in trusts} - atom = self._get_atom(scores, trusts) - return [dict(project=k, - score=sorted(atom[k], reverse=True)[0].get('score'), - status=sorted(atom[k], reverse=True)[0].get('status') - ) for k in atom if atom[k]] - - def _get_atom(self, scores, trusts): - s = {k: {a['date']: a['score'] for a in scores[k]} for k in scores} - t = {k: {a['date']: a['status'] for a in trusts[k]} for k in trusts} - return {k: [dict(score=s[k][a], status=t[k][a], data=a - ) for a in s[k] if a in t[k]] for k in s} + date = sorted(scores, reverse=True)[0].get('date') + except IndexError: + data = time.time() + + try: + score = sorted(scores, reverse=True)[0].get('score') + except IndexError: + score = None + + try: + status = sorted(trusts, reverse=True)[0].get('status') + except IndexError: + status = None + + return {'date': date, 'score': score, 'status': status} def _change_to_utf8(self, obj): if isinstance(obj, dict): diff --git a/utils/test/reporting/api/api/handlers/projects.py b/utils/test/reporting/api/handlers/projects.py index 02412cd62..02412cd62 100644 --- a/utils/test/reporting/api/api/handlers/projects.py +++ b/utils/test/reporting/api/handlers/projects.py diff --git a/utils/test/reporting/api/api/handlers/testcases.py b/utils/test/reporting/api/handlers/testcases.py index 2b9118623..2b9118623 100644 --- a/utils/test/reporting/api/api/handlers/testcases.py +++ b/utils/test/reporting/api/handlers/testcases.py diff --git a/utils/test/reporting/api/requirements.txt b/utils/test/reporting/api/requirements.txt deleted file mode 100644 index 12ad6881b..000000000 --- a/utils/test/reporting/api/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -tornado==4.4.2 -requests==2.1.0 - diff --git a/utils/test/reporting/api/api/server.py b/utils/test/reporting/api/server.py index e340b0181..e340b0181 100644 --- a/utils/test/reporting/api/api/server.py +++ b/utils/test/reporting/api/server.py diff --git a/utils/test/reporting/api/setup.cfg b/utils/test/reporting/api/setup.cfg deleted file mode 100644 index 53d1092b9..000000000 --- a/utils/test/reporting/api/setup.cfg +++ /dev/null @@ -1,32 +0,0 @@ -[metadata] -name = reporting - -author = JackChan -author-email = chenjiankun1@huawei.com - -classifier = - Environment :: opnfv - Intended Audience :: Information Technology - Intended Audience :: System Administrators - License :: OSI Approved :: Apache Software License - Operating System :: POSIX :: Linux - Programming Language :: Python - Programming Language :: Python :: 2 - Programming Language :: Python :: 2.7 - -[global] -setup-hooks = - pbr.hooks.setup_hook - -[files] -packages = - api - -[entry_points] -console_scripts = - api = api.server:main - -[egg_info] -tag_build = -tag_date = 0 -tag_svn_revision = 0 diff --git a/utils/test/reporting/api/setup.py b/utils/test/reporting/api/setup.py deleted file mode 100644 index d97481642..000000000 --- a/utils/test/reporting/api/setup.py +++ /dev/null @@ -1,9 +0,0 @@ -import setuptools - - -__author__ = 'JackChan' - - -setuptools.setup( - setup_requires=['pbr>=1.8'], - pbr=True) diff --git a/utils/test/reporting/api/api/urls.py b/utils/test/reporting/api/urls.py index a5228b2d4..a5228b2d4 100644 --- a/utils/test/reporting/api/api/urls.py +++ b/utils/test/reporting/api/urls.py |