diff options
Diffstat (limited to 'utils/test/reporting')
-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 | ||||
-rw-r--r-- | utils/test/reporting/docker/Dockerfile | 33 | ||||
-rw-r--r-- | utils/test/reporting/docker/nginx.conf | 4 | ||||
-rwxr-xr-x | utils/test/reporting/docker/reporting.sh | 71 | ||||
-rw-r--r-- | utils/test/reporting/docker/supervisor.conf | 4 | ||||
-rwxr-xr-x | utils/test/reporting/docker/web_server.sh | 14 | ||||
-rw-r--r-- | utils/test/reporting/docs/_build/.buildinfo | 4 | ||||
-rw-r--r-- | utils/test/reporting/docs/_build/.doctrees/environment.pickle | bin | 0 -> 4207 bytes | |||
-rw-r--r-- | utils/test/reporting/docs/_build/.doctrees/index.doctree | bin | 0 -> 4892 bytes | |||
-rw-r--r-- | utils/test/reporting/docs/conf.py | 341 | ||||
-rw-r--r-- | utils/test/reporting/docs/index.rst | 16 | ||||
-rw-r--r-- | utils/test/reporting/pages/app/scripts/controllers/table.controller.js | 504 | ||||
-rw-r--r-- | utils/test/reporting/pages/app/scripts/factory/table.factory.js | 4 | ||||
-rw-r--r-- | utils/test/reporting/pages/app/views/commons/table.html | 28 | ||||
-rw-r--r-- | utils/test/reporting/reporting/__init__.py (renamed from utils/test/reporting/functest/__init__.py) | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/functest/__init__.py (renamed from utils/test/reporting/qtip/__init__.py) | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/gauge_0.png (renamed from utils/test/reporting/functest/img/gauge_0.png) | bin | 3644 -> 3644 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/gauge_100.png (renamed from utils/test/reporting/functest/img/gauge_100.png) | bin | 3191 -> 3191 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/gauge_16.7.png (renamed from utils/test/reporting/functest/img/gauge_16.7.png) | bin | 3170 -> 3170 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/gauge_25.png (renamed from utils/test/reporting/functest/img/gauge_25.png) | bin | 3108 -> 3108 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/gauge_33.3.png (renamed from utils/test/reporting/functest/img/gauge_33.3.png) | bin | 3081 -> 3081 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/gauge_41.7.png (renamed from utils/test/reporting/functest/img/gauge_41.7.png) | bin | 3169 -> 3169 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/gauge_50.png (renamed from utils/test/reporting/functest/img/gauge_50.png) | bin | 3123 -> 3123 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/gauge_58.3.png (renamed from utils/test/reporting/functest/img/gauge_58.3.png) | bin | 3161 -> 3161 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/gauge_66.7.png (renamed from utils/test/reporting/functest/img/gauge_66.7.png) | bin | 3069 -> 3069 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/gauge_75.png (renamed from utils/test/reporting/functest/img/gauge_75.png) | bin | 3030 -> 3030 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/gauge_8.3.png (renamed from utils/test/reporting/functest/img/gauge_8.3.png) | bin | 2993 -> 2993 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/gauge_83.3.png (renamed from utils/test/reporting/functest/img/gauge_83.3.png) | bin | 3122 -> 3122 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/gauge_91.7.png (renamed from utils/test/reporting/functest/img/gauge_91.7.png) | bin | 3008 -> 3008 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/icon-nok.png (renamed from utils/test/reporting/functest/img/icon-nok.png) | bin | 2317 -> 2317 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/icon-ok.png (renamed from utils/test/reporting/functest/img/icon-ok.png) | bin | 4063 -> 4063 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/weather-clear.png (renamed from utils/test/reporting/functest/img/weather-clear.png) | bin | 1560 -> 1560 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/weather-few-clouds.png (renamed from utils/test/reporting/functest/img/weather-few-clouds.png) | bin | 1927 -> 1927 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/weather-overcast.png (renamed from utils/test/reporting/functest/img/weather-overcast.png) | bin | 1588 -> 1588 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/img/weather-storm.png (renamed from utils/test/reporting/functest/img/weather-storm.png) | bin | 2137 -> 2137 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/functest/index.html (renamed from utils/test/reporting/functest/index.html) | 0 | ||||
-rwxr-xr-x | utils/test/reporting/reporting/functest/reporting-status.py (renamed from utils/test/reporting/functest/reporting-status.py) | 35 | ||||
-rwxr-xr-x | utils/test/reporting/reporting/functest/reporting-tempest.py (renamed from utils/test/reporting/functest/reporting-tempest.py) | 94 | ||||
-rwxr-xr-x | utils/test/reporting/reporting/functest/reporting-vims.py (renamed from utils/test/reporting/functest/reporting-vims.py) | 4 | ||||
-rw-r--r-- | utils/test/reporting/reporting/functest/scenarioResult.py (renamed from utils/test/reporting/functest/scenarioResult.py) | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/functest/template/index-status-tmpl.html (renamed from utils/test/reporting/functest/template/index-status-tmpl.html) | 30 | ||||
-rw-r--r-- | utils/test/reporting/reporting/functest/template/index-tempest-tmpl.html (renamed from utils/test/reporting/functest/template/index-tempest-tmpl.html) | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/functest/template/index-vims-tmpl.html (renamed from utils/test/reporting/functest/template/index-vims-tmpl.html) | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/functest/testCase.py (renamed from utils/test/reporting/functest/testCase.py) | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/qtip/__init__.py (renamed from utils/test/reporting/tests/__init__.py) | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/qtip/index.html (renamed from utils/test/reporting/qtip/index.html) | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/qtip/reporting-status.py (renamed from utils/test/reporting/qtip/reporting-status.py) | 7 | ||||
-rw-r--r-- | utils/test/reporting/reporting/qtip/template/index-status-tmpl.html (renamed from utils/test/reporting/qtip/template/index-status-tmpl.html) | 9 | ||||
-rw-r--r-- | utils/test/reporting/reporting/reporting.yaml (renamed from utils/test/reporting/reporting.yaml) | 1 | ||||
-rw-r--r-- | utils/test/reporting/reporting/storperf/__init__.py (renamed from utils/test/reporting/tests/unit/__init__.py) | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/storperf/reporting-status.py (renamed from utils/test/reporting/storperf/reporting-status.py) | 12 | ||||
-rw-r--r-- | utils/test/reporting/reporting/storperf/template/index-status-tmpl.html (renamed from utils/test/reporting/storperf/template/index-status-tmpl.html) | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/tests/__init__.py (renamed from utils/test/reporting/tests/unit/utils/__init__.py) | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/tests/unit/__init__.py (renamed from utils/test/reporting/utils/__init__.py) | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/tests/unit/utils/__init__.py | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/tests/unit/utils/test_utils.py (renamed from utils/test/reporting/tests/unit/utils/test_utils.py) | 9 | ||||
-rw-r--r-- | utils/test/reporting/reporting/utils/__init__.py | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/utils/reporting_utils.py (renamed from utils/test/reporting/utils/reporting_utils.py) | 264 | ||||
-rw-r--r-- | utils/test/reporting/reporting/utils/scenarioResult.py (renamed from utils/test/reporting/utils/scenarioResult.py) | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/vsperf/__init__.py | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/vsperf/reporting-status.py | 138 | ||||
-rw-r--r-- | utils/test/reporting/reporting/vsperf/template/index-status-tmpl.html | 114 | ||||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/__init__.py | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/gauge_0.png (renamed from utils/test/reporting/yardstick/img/gauge_0.png) | bin | 3644 -> 3644 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/gauge_100.png (renamed from utils/test/reporting/yardstick/img/gauge_100.png) | bin | 3191 -> 3191 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/gauge_16.7.png (renamed from utils/test/reporting/yardstick/img/gauge_16.7.png) | bin | 3170 -> 3170 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/gauge_25.png (renamed from utils/test/reporting/yardstick/img/gauge_25.png) | bin | 3108 -> 3108 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/gauge_33.3.png (renamed from utils/test/reporting/yardstick/img/gauge_33.3.png) | bin | 3081 -> 3081 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/gauge_41.7.png (renamed from utils/test/reporting/yardstick/img/gauge_41.7.png) | bin | 3169 -> 3169 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/gauge_50.png (renamed from utils/test/reporting/yardstick/img/gauge_50.png) | bin | 3123 -> 3123 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/gauge_58.3.png (renamed from utils/test/reporting/yardstick/img/gauge_58.3.png) | bin | 3161 -> 3161 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/gauge_66.7.png (renamed from utils/test/reporting/yardstick/img/gauge_66.7.png) | bin | 3069 -> 3069 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/gauge_75.png (renamed from utils/test/reporting/yardstick/img/gauge_75.png) | bin | 3030 -> 3030 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/gauge_8.3.png (renamed from utils/test/reporting/yardstick/img/gauge_8.3.png) | bin | 2993 -> 2993 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/gauge_83.3.png (renamed from utils/test/reporting/yardstick/img/gauge_83.3.png) | bin | 3122 -> 3122 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/gauge_91.7.png (renamed from utils/test/reporting/yardstick/img/gauge_91.7.png) | bin | 3008 -> 3008 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/icon-nok.png (renamed from utils/test/reporting/yardstick/img/icon-nok.png) | bin | 2317 -> 2317 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/icon-ok.png (renamed from utils/test/reporting/yardstick/img/icon-ok.png) | bin | 4063 -> 4063 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/weather-clear.png (renamed from utils/test/reporting/yardstick/img/weather-clear.png) | bin | 1560 -> 1560 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/weather-few-clouds.png (renamed from utils/test/reporting/yardstick/img/weather-few-clouds.png) | bin | 1927 -> 1927 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/weather-overcast.png (renamed from utils/test/reporting/yardstick/img/weather-overcast.png) | bin | 1588 -> 1588 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/img/weather-storm.png (renamed from utils/test/reporting/yardstick/img/weather-storm.png) | bin | 2137 -> 2137 bytes | |||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/index.html (renamed from utils/test/reporting/yardstick/index.html) | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/reporting-status.py (renamed from utils/test/reporting/yardstick/reporting-status.py) | 11 | ||||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/scenarios.py (renamed from utils/test/reporting/yardstick/scenarios.py) | 0 | ||||
-rw-r--r-- | utils/test/reporting/reporting/yardstick/template/index-status-tmpl.html (renamed from utils/test/reporting/yardstick/template/index-status-tmpl.html) | 0 | ||||
-rw-r--r-- | utils/test/reporting/requirements.txt | 7 | ||||
-rwxr-xr-x | utils/test/reporting/run_test.sh | 45 | ||||
-rw-r--r-- | utils/test/reporting/setup.cfg | 12 | ||||
-rw-r--r-- | utils/test/reporting/setup.py | 31 | ||||
-rw-r--r-- | utils/test/reporting/test-requirements.txt | 5 | ||||
-rw-r--r-- | utils/test/reporting/tox.ini | 27 |
102 files changed, 1274 insertions, 726 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 diff --git a/utils/test/reporting/docker/Dockerfile b/utils/test/reporting/docker/Dockerfile index ad278ce1e..f2357909d 100644 --- a/utils/test/reporting/docker/Dockerfile +++ b/utils/test/reporting/docker/Dockerfile @@ -16,38 +16,43 @@ FROM nginx:stable MAINTAINER Morgan Richomme <morgan.richomme@orange.com> -LABEL version="danube.1.0" description="OPNFV Test Reporting Docker container" +LABEL version="1.0" description="OPNFV Test Reporting Docker container" ARG BRANCH=master ENV HOME /home/opnfv -ENV working_dir /home/opnfv/utils/test/reporting -ENV TERM xterm -ENV COLORTERM gnome-terminal -ENV CONFIG_REPORTING_YAML /home/opnfv/utils/test/reporting/reporting.yaml +ENV working_dir ${HOME}/releng/utils/test/reporting +ENV CONFIG_REPORTING_YAML ${working_dir}/reporting.yaml +WORKDIR ${HOME} # Packaged dependencies RUN apt-get update && apt-get install -y \ +build-essential \ ssh \ +curl \ +gnupg \ python-pip \ +python-dev \ +python-setuptools \ git-core \ -wkhtmltopdf \ -nodejs \ -npm \ supervisor \ --no-install-recommends -RUN pip install --upgrade pip +RUN pip install --upgrade pip && easy_install -U setuptools==30.0.0 -RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/releng /home/opnfv -RUN pip install -r ${working_dir}/docker/requirements.pip +RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/releng /home/opnfv/releng +RUN pip install -r ${working_dir}/requirements.txt -WORKDIR ${working_dir}/api -RUN pip install -r requirements.txt -RUN python setup.py install +RUN sh -c 'curl -sL https://deb.nodesource.com/setup_8.x | bash -' \ + && apt-get install -y nodejs \ + && npm install -g bower \ + && npm install -g grunt \ + && npm install -g grunt-cli WORKDIR ${working_dir} +RUN python setup.py install RUN docker/reporting.sh +RUN docker/web_server.sh expose 8000 diff --git a/utils/test/reporting/docker/nginx.conf b/utils/test/reporting/docker/nginx.conf index 9e2697248..ced8179c1 100644 --- a/utils/test/reporting/docker/nginx.conf +++ b/utils/test/reporting/docker/nginx.conf @@ -15,10 +15,10 @@ server { } location /reporting/ { - alias /home/opnfv/utils/test/reporting/pages/dist/; + alias /home/opnfv/releng/utils/test/reporting/pages/dist/; } location /display/ { - alias /home/opnfv/utils/test/reporting/display/; + alias /home/opnfv/releng/utils/test/reporting/display/; } } diff --git a/utils/test/reporting/docker/reporting.sh b/utils/test/reporting/docker/reporting.sh index 7fe97a88e..d8db6201e 100755 --- a/utils/test/reporting/docker/reporting.sh +++ b/utils/test/reporting/docker/reporting.sh @@ -1,10 +1,10 @@ #!/bin/bash -export PYTHONPATH="${PYTHONPATH}:." -export CONFIG_REPORTING_YAML=./reporting.yaml +export PYTHONPATH="${PYTHONPATH}:./reporting" +export CONFIG_REPORTING_YAML=./reporting/reporting.yaml declare -a versions=(danube master) -declare -a projects=(functest storperf yardstick) +declare -a projects=(functest storperf yardstick qtip vsperf) project=$1 reporting_type=$2 @@ -29,8 +29,10 @@ cp -Rf js display # projet | option # $1 | $2 # functest | status, vims, tempest -# yardstick | -# storperf | +# yardstick | status +# storperf | status +# qtip | status +# vsperf | status function report_project() { @@ -40,7 +42,7 @@ function report_project() echo "********************************" echo " $project reporting " echo "********************************" - python ./$dir/reporting-$type.py + python ./reporting/$dir/reporting-$type.py if [ $? ]; then echo "$project reporting $type...OK" else @@ -50,53 +52,28 @@ function report_project() if [ -z "$1" ]; then echo "********************************" - echo " Functest reporting " + echo " * Static status reporting *" echo "********************************" - echo "reporting vIMS..." - python ./functest/reporting-vims.py - echo "reporting vIMS...OK" - sleep 10 - echo "reporting Tempest..." - python ./functest/reporting-tempest.py - echo "reporting Tempest...OK" - sleep 10 - echo "reporting status..." - python ./functest/reporting-status.py - echo "Functest reporting status...OK" - - echo "********************************" - echo " Yardstick reporting " - echo "********************************" - python ./yardstick/reporting-status.py - echo "Yardstick reporting status...OK" + for i in "${projects[@]}" + do + report_project $i $i "status" + sleep 5 + done + report_project "QTIP" "qtip" "status" - echo "********************************" - echo " Storperf reporting " - echo "********************************" - python ./storperf/reporting-status.py - echo "Storperf reporting status...OK" - report_project "QTIP" "qtip" "status" + echo "Functest reporting vIMS..." + report_project "functest" "functest" "vims" + echo "reporting vIMS...OK" + sleep 5 + echo "Functest reporting Tempest..." + report_project "functest" "functest" "tempest" + echo "reporting Tempest...OK" + sleep 5 else if [ -z "$2" ]; then reporting_type="status" fi - echo "********************************" - echo " $project/$reporting_type reporting " - echo "********************************" - python ./$project/reporting-$reporting_type.py + report_project $project $project $reporting_type fi -cp -r display /usr/share/nginx/html - - -# nginx config -cp /home/opnfv/utils/test/reporting/docker/nginx.conf /etc/nginx/conf.d/ -echo "daemon off;" >> /etc/nginx/nginx.conf - -# supervisor config -cp /home/opnfv/utils/test/reporting/docker/supervisor.conf /etc/supervisor/conf.d/ - -ln -s /usr/bin/nodejs /usr/bin/node - -cd pages && /bin/bash angular.sh diff --git a/utils/test/reporting/docker/supervisor.conf b/utils/test/reporting/docker/supervisor.conf index b323dd029..49310d430 100644 --- a/utils/test/reporting/docker/supervisor.conf +++ b/utils/test/reporting/docker/supervisor.conf @@ -3,7 +3,7 @@ nodaemon = true [program:tornado] user = root -directory = /home/opnfv/utils/test/reporting/api/api +directory = /home/opnfv/releng/utils/test/reporting/api command = python server.py --port=800%(process_num)d process_name=%(program_name)s%(process_num)d numprocs=4 @@ -15,5 +15,5 @@ command = service nginx restart [program:configuration] user = root -directory = /home/opnfv/utils/test/reporting/pages +directory = /home/opnfv/releng/utils/test/reporting/pages command = bash config.sh diff --git a/utils/test/reporting/docker/web_server.sh b/utils/test/reporting/docker/web_server.sh new file mode 100755 index 000000000..0dd8df73d --- /dev/null +++ b/utils/test/reporting/docker/web_server.sh @@ -0,0 +1,14 @@ +#!/bin/bash +cp -r display /usr/share/nginx/html + + +# nginx config +cp /home/opnfv/releng/utils/test/reporting/docker/nginx.conf /etc/nginx/conf.d/ +echo "daemon off;" >> /etc/nginx/nginx.conf + +# supervisor config +cp /home/opnfv/releng/utils/test/reporting/docker/supervisor.conf /etc/supervisor/conf.d/ + +# Manage Angular front end +cd pages && /bin/bash angular.sh + diff --git a/utils/test/reporting/docs/_build/.buildinfo b/utils/test/reporting/docs/_build/.buildinfo new file mode 100644 index 000000000..6bd6fd634 --- /dev/null +++ b/utils/test/reporting/docs/_build/.buildinfo @@ -0,0 +1,4 @@ +# Sphinx build info version 1 +# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. +config: 235ce07a48cec983846ad34dfd375b07 +tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/utils/test/reporting/docs/_build/.doctrees/environment.pickle b/utils/test/reporting/docs/_build/.doctrees/environment.pickle Binary files differnew file mode 100644 index 000000000..23f59c377 --- /dev/null +++ b/utils/test/reporting/docs/_build/.doctrees/environment.pickle diff --git a/utils/test/reporting/docs/_build/.doctrees/index.doctree b/utils/test/reporting/docs/_build/.doctrees/index.doctree Binary files differnew file mode 100644 index 000000000..51e2d5ad3 --- /dev/null +++ b/utils/test/reporting/docs/_build/.doctrees/index.doctree diff --git a/utils/test/reporting/docs/conf.py b/utils/test/reporting/docs/conf.py new file mode 100644 index 000000000..2e70d2b63 --- /dev/null +++ b/utils/test/reporting/docs/conf.py @@ -0,0 +1,341 @@ +# -*- coding: utf-8 -*- +# +# OPNFV testing Reporting documentation build configuration file, created by +# sphinx-quickstart on Mon July 4 10:03:43 2017. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The encoding of source files. +# +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'OPNFV Reporting' +copyright = u'2017, #opnfv-testperf (chat.freenode.net)' +author = u'#opnfv-testperf (chat.freenode.net)' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = u'master' +# The full version, including alpha/beta/rc tags. +release = u'master' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = 'en' + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# +# today = '' +# +# Else, today_fmt is used as the format for a strftime call. +# +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This patterns also effect to html_static_path and html_extra_path +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = False + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. +# "<project> v<release> documentation" by default. +# +# html_title = u'OPNFV Functest vmaster' + +# A shorter title for the navigation bar. Default is the same as html_title. +# +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# +# html_logo = None + +# The name of an image file (relative to this directory) to use as a favicon of +# the docs. This file should be a Windows icon file (.ico) being 16x16 or +# 32x32 pixels large. +# +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# +# html_extra_path = [] + +# If not None, a 'Last updated on:' timestamp is inserted at every page +# bottom, using the given strftime format. +# The empty string is equivalent to '%b %d, %Y'. +# +# html_last_updated_fmt = None + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# +# html_additional_pages = {} + +# If false, no module index is generated. +# +# html_domain_indices = True + +# If false, no index is generated. +# +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a <link> tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' +# +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# 'ja' uses this config value. +# 'zh' user can custom change `jieba` dictionary path. +# +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'OPNFVreportingdoc' + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'OPNFVReporting.tex', + u'OPNFV testing Reporting Documentation', + u'\\#opnfv-testperf (chat.freenode.net)', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# +# latex_use_parts = False + +# If true, show page references after internal links. +# +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# +# latex_appendices = [] + +# It false, will not define \strong, \code, itleref, \crossref ... but only +# \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added +# packages. +# +# latex_keep_old_macro_names = True + +# If false, no module index is generated. +# +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'opnfvReporting', u'OPNFV Testing Reporting Documentation', + [author], 1) +] + +# If true, show URL addresses after external links. +# +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'OPNFVReporting', u'OPNFV Testing reporting Documentation', + author, 'OPNFVTesting', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +# +# texinfo_appendices = [] + +# If false, no module index is generated. +# +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# +# texinfo_no_detailmenu = False diff --git a/utils/test/reporting/docs/index.rst b/utils/test/reporting/docs/index.rst new file mode 100644 index 000000000..af4187672 --- /dev/null +++ b/utils/test/reporting/docs/index.rst @@ -0,0 +1,16 @@ +Welcome to OPNFV Testing reporting documentation! +================================================= + +Contents: + +.. toctree:: + :maxdepth: 2 + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/utils/test/reporting/pages/app/scripts/controllers/table.controller.js b/utils/test/reporting/pages/app/scripts/controllers/table.controller.js index 44d9441de..8d494c3ae 100644 --- a/utils/test/reporting/pages/app/scripts/controllers/table.controller.js +++ b/utils/test/reporting/pages/app/scripts/controllers/table.controller.js @@ -11,396 +11,268 @@ angular.module('opnfvApp') .controller('TableController', ['$scope', '$state', '$stateParams', '$http', 'TableFactory', '$timeout', function($scope, $state, $stateParams, $http, TableFactory, $timeout) { - $scope.filterlist = []; - $scope.selection = []; - $scope.statusList = []; - $scope.projectList = []; - $scope.installerList = []; - $scope.versionlist = []; - $scope.loopci = []; - $scope.time = []; - $scope.tableDataAll = {}; - $scope.tableInfoAll = {}; - $scope.scenario = {}; - // $scope.selectProjects = []; - - - $scope.VersionConfig = { - create: true, - valueField: 'title', - labelField: 'title', - delimiter: '|', - maxItems: 1, - placeholder: 'Version', - onChange: function(value) { - checkElementArrayValue($scope.selection, $scope.VersionOption); - $scope.selection.push(value); - // console.log($scope.selection); - getScenarioData(); + init(); - } - } + function init() { + $scope.filterlist = []; + $scope.selection = []; - $scope.LoopConfig = { - create: true, - valueField: 'title', - labelField: 'title', - delimiter: '|', - maxItems: 1, - placeholder: 'Loop', - onChange: function(value) { - checkElementArrayValue($scope.selection, $scope.LoopOption); - $scope.selection.push(value); - // console.log($scope.selection); - getScenarioData(); + $scope.statusList = []; + $scope.projectList = []; + $scope.installerList = []; + $scope.versionlist = []; + $scope.loopList = []; + $scope.timeList = []; - } - } + $scope.selectStatus = []; + $scope.selectProjects = []; + $scope.selectInstallers = []; + $scope.selectVersion = null; + $scope.selectLoop = null; + $scope.selectTime = null; + + $scope.statusClicked = false; + $scope.installerClicked = false; + $scope.projectClicked = false; - $scope.TimeConfig = { - create: true, - valueField: 'title', - labelField: 'title', - delimiter: '|', - maxItems: 1, - placeholder: 'Time', - onChange: function(value) { - checkElementArrayValue($scope.selection, $scope.TimeOption); - $scope.selection.push(value); - // console.log($scope.selection) - getScenarioData(); + $scope.scenarios = {}; + $scope.VersionConfig = { + create: true, + valueField: 'title', + labelField: 'title', + delimiter: '|', + maxItems: 1, + placeholder: 'Version', + onChange: function(value) { + $scope.selectVersion = value; + getScenarioData(); + + } } - } + $scope.LoopConfig = { + create: true, + valueField: 'title', + labelField: 'title', + delimiter: '|', + maxItems: 1, + placeholder: 'Loop', + onChange: function(value) { + $scope.selectLoop = value; - init(); + getScenarioData(); + + } + } + + $scope.TimeConfig = { + create: true, + valueField: 'title', + labelField: 'title', + delimiter: '|', + maxItems: 1, + placeholder: 'Time', + onChange: function(value) { + $scope.selectTime = value; + + getScenarioData(); + } + } - function init() { - $scope.toggleSelection = toggleSelection; - getScenarioData(); getFilters(); } function getFilters() { TableFactory.getFilter().get({ - }).$promise.then(function(response) { if (response != null) { $scope.statusList = response.filters.status; $scope.projectList = response.filters.projects; $scope.installerList = response.filters.installers; - $scope.versionlist = response.filters.version; - $scope.loopci = response.filters.loops; - $scope.time = response.filters.time; - - $scope.statusListString = $scope.statusList.toString(); - $scope.projectListString = $scope.projectList.toString(); - $scope.installerListString = $scope.installerList.toString(); - $scope.VersionSelected = $scope.versionlist[1]; - $scope.LoopCiSelected = $scope.loopci[0]; - $scope.TimeSelected = $scope.time[0]; - radioSetting($scope.versionlist, $scope.loopci, $scope.time); + $scope.versionList = toSelectList(response.filters.version); + $scope.loopList = toSelectList(response.filters.loops); + $scope.timeList = toSelectList(response.filters.time); + + $scope.selectStatus = copy($scope.statusList); + $scope.selectInstallers = copy($scope.installerList); + $scope.selectProjects = copy($scope.projectList); + $scope.selectVersion = response.filters.version[0]; + $scope.selectLoop = response.filters.loops[0]; + $scope.selectTime = response.filters.time[0]; + + getScenarioData(); } else { - alert("网络错误"); } - }) + }); + } + + function toSelectList(arr){ + var tempList = []; + angular.forEach(arr, function(ele){ + tempList.push({'title': ele}); + }); + return tempList; + } + + function copy(arr){ + var tempList = []; + angular.forEach(arr, function(ele){ + tempList.push(ele); + }); + return tempList; } function getScenarioData() { - // var utl = BASE_URL + '/scenarios'; var data = { - 'status': ['success', 'danger', 'warning'], - 'projects': ['functest', 'yardstick'], - 'installers': ['apex', 'compass', 'fuel', 'joid'], - 'version': $scope.VersionSelected, - 'loops': $scope.LoopCiSelected, - 'time': $scope.TimeSelected + 'status': $scope.selectStatus, + 'projects': $scope.selectProjects, + 'installers': $scope.selectInstallers, + 'version': $scope.selectVersion, + 'loops': $scope.selectLoop, + 'time': $scope.selectTime }; TableFactory.getScenario(data).then(function(response) { if (response.status == 200) { - $scope.scenario = response.data; - - reSettingcolspan(); + $scope.scenarios = response.data.scenarios; + getScenario(); } }, function(error) { - - }) + }); } - function reSettingcolspan() { - if ($scope.selectProjects == undefined || $scope.selectProjects == null) { - constructJson(); - $scope.colspan = $scope.tableDataAll.colspan; + function getScenario(){ - } else { - constructJson(); - $scope.colspan = $scope.tempColspan; - } - // console.log("test") - } - - //construct json - function constructJson(selectProject) { + $scope.project_row = []; + angular.forEach($scope.selectInstallers, function(installer){ + angular.forEach($scope.selectProjects, function(project){ + var temp = { + 'installer': installer, + 'project': project + } + $scope.project_row.push(temp); - var colspan; - var InstallerData; - var projectsInfo; - $scope.tableDataAll["scenario"] = []; + }); + }); - for (var item in $scope.scenario.scenarios) { + $scope.scenario_rows = []; + angular.forEach($scope.scenarios, function(scenario, name){ + var scenario_row = { + 'name': null, + 'status': null, + 'statusDisplay': null, + 'datadisplay': [], + }; + scenario_row.name = name; + scenario_row.status = scenario.status; - var headData = Object.keys($scope.scenario.scenarios[item].installers).sort(); - var scenarioStatus = $scope.scenario.scenarios[item].status; var scenarioStatusDisplay; - if (scenarioStatus == "success") { + if (scenario.status == "success") { scenarioStatusDisplay = "navy"; - } else if (scenarioStatus == "danger") { + } else if (scenario.status == "danger") { scenarioStatusDisplay = "danger"; - } else if (scenarioStatus == "warning") { + } else if (scenario.status == "warning") { scenarioStatusDisplay = "warning"; } - - InstallerData = headData; - var projectData = []; - var datadisplay = []; - var projects = []; - - for (var j = 0; j < headData.length; j++) { - - projectData.push($scope.scenario.scenarios[item].installers[headData[j]]); - } - for (var j = 0; j < projectData.length; j++) { - - for (var k = 0; k < projectData[j].length; k++) { - projects.push(projectData[j][k].project); - var temArray = []; - if (projectData[j][k].score == null) { - temArray.push("null"); - temArray.push(projectData[j][k].project); - temArray.push(headData[j]); - } else { - temArray.push(projectData[j][k].score); - temArray.push(projectData[j][k].project); - temArray.push(headData[j]); - } - - - if (projectData[j][k].status == "platinium") { - temArray.push("primary"); - temArray.push("P"); - } else if (projectData[j][k].status == "gold") { - temArray.push("danger"); - temArray.push("G"); - } else if (projectData[j][k].status == "silver") { - temArray.push("warning"); - temArray.push("S"); - } else if (projectData[j][k].status == null) { - temArray.push("null"); + scenario_row.statusDisplay = scenarioStatusDisplay; + + angular.forEach($scope.selectInstallers, function(installer){ + angular.forEach($scope.selectProjects, function(project){ + var datadisplay = { + 'installer': null, + 'project': null, + 'value': null, + 'label': null, + 'label_value': null + }; + datadisplay.installer = installer; + datadisplay.project = project; + datadisplay.value = scenario.installers[installer][project].score; + + var single_status = scenario.installers[installer][project].status; + if (single_status == "platinium") { + datadisplay.label = 'primary'; + datadisplay.label_value = 'P'; + } else if (single_status == "gold") { + datadisplay.label = 'danger'; + datadisplay.label_value = 'G'; + } else if (single_status == "silver") { + datadisplay.label = 'warning'; + datadisplay.label_value = 'S'; + } else if (single_status == null) { } + scenario_row.datadisplay.push(datadisplay); - datadisplay.push(temArray); - - } - - } - - colspan = projects.length / headData.length; - - var tabledata = { - scenarioName: item, - Installer: InstallerData, - projectData: projectData, - projects: projects, - datadisplay: datadisplay, - colspan: colspan, - status: scenarioStatus, - statusDisplay: scenarioStatusDisplay - }; - - JSON.stringify(tabledata); - $scope.tableDataAll.scenario.push(tabledata); - - - // console.log(tabledata); - - } - - - projectsInfo = $scope.tableDataAll.scenario[0].projects; - - var tempHeadData = []; - - for (var i = 0; i < InstallerData.length; i++) { - for (var j = 0; j < colspan; j++) { - tempHeadData.push(InstallerData[i]); - } - } - - //console.log(tempHeadData); - - var projectsInfoAll = []; - - for (var i = 0; i < projectsInfo.length; i++) { - var tempA = []; - tempA.push(projectsInfo[i]); - tempA.push(tempHeadData[i]); - projectsInfoAll.push(tempA); - - } - //console.log(projectsInfoAll); - - $scope.tableDataAll["colspan"] = colspan; - $scope.tableDataAll["Installer"] = InstallerData; - $scope.tableDataAll["Projects"] = projectsInfoAll; - - // console.log($scope.tableDataAll); - $scope.colspan = $scope.tableDataAll.colspan; - console.log($scope.tableDataAll); - - } - - //get json element size - function getSize(jsondata) { - var size = 0; - for (var item in jsondata) { - size++; - } - return size; + }); + }); + $scope.scenario_rows.push(scenario_row); + }); } - // console.log($scope.colspan); - - - //find all same element index - function getSameElementIndex(array, element) { - var indices = []; - var idx = array.indexOf(element); - while (idx != -1) { - indices.push(idx); - idx = array.indexOf(element, idx + 1); + function clickBase(eleList, ele){ + var idx = eleList.indexOf(ele); + if(idx > -1){ + eleList.splice(idx, 1); + }else{ + eleList.push(ele); } - //return indices; - var result = { element: element, index: indices }; - JSON.stringify(result); - return result; } - //delete element in array - function deletElement(array, index) { - array.splice(index, 1); + $scope.clickStatus = function(status){ + if($scope.selectStatus.length == $scope.statusList.length && $scope.statusClicked == false){ + $scope.selectStatus = []; + $scope.statusClicked = true; + } - } + clickBase($scope.selectStatus, status); - function radioSetting(array1, array2, array3) { - var tempVersion = []; - var tempLoop = []; - var tempTime = []; - for (var i = 0; i < array1.length; i++) { - var temp = { - title: array1[i] - }; - tempVersion.push(temp); - } - for (var i = 0; i < array2.length; i++) { - var temp = { - title: array2[i] - }; - tempLoop.push(temp); + if($scope.selectStatus.length == 0 && $scope.statusClicked == true){ + $scope.selectStatus = copy($scope.statusList); + $scope.statusClicked = false; } - for (var i = 0; i < array3.length; i++) { - var temp = { - title: array3[i] - }; - tempTime.push(temp); - } - $scope.VersionOption = tempVersion; - $scope.LoopOption = tempLoop; - $scope.TimeOption = tempTime; - } - //remove element in the array - function removeArrayValue(arr, value) { - for (var i = 0; i < arr.length; i++) { - if (arr[i] == value) { - arr.splice(i, 1); - break; - } - } + getScenarioData(); } - //check if exist element - function checkElementArrayValue(arrayA, arrayB) { - for (var i = 0; i < arrayB.length; i++) { - if (arrayA.indexOf(arrayB[i].title) > -1) { - removeArrayValue(arrayA, arrayB[i].title); - } + $scope.clickInstaller = function(installer){ + if($scope.selectInstallers.length == $scope.installerList.length && $scope.installerClicked == false){ + $scope.selectInstallers = []; + $scope.installerClicked = true; } - } - function toggleSelection(status) { - var idx = $scope.selection.indexOf(status); + clickBase($scope.selectInstallers, installer); - if (idx > -1) { - $scope.selection.splice(idx, 1); - filterData($scope.selection) - } else { - $scope.selection.push(status); - filterData($scope.selection) + if($scope.selectInstallers.length == 0 && $scope.installerClicked == true){ + $scope.selectInstallers = copy($scope.installerList); + $scope.installerClicked = false; } - // console.log($scope.selection); + getScenarioData(); } - //filter function - function filterData(selection) { - - $scope.selectInstallers = []; - $scope.selectProjects = []; - $scope.selectStatus = []; - for (var i = 0; i < selection.length; i++) { - if ($scope.statusListString.indexOf(selection[i]) > -1) { - $scope.selectStatus.push(selection[i]); - } - if ($scope.projectListString.indexOf(selection[i]) > -1) { - $scope.selectProjects.push(selection[i]); - } - if ($scope.installerListString.indexOf(selection[i]) > -1) { - $scope.selectInstallers.push(selection[i]); - } + $scope.clickProject = function(project){ + if($scope.selectProjects.length == $scope.projectList.length && $scope.projectClicked == false){ + $scope.selectProjects = []; + $scope.projectClicked = true; } + clickBase($scope.selectProjects, project); - // $scope.colspan = $scope.selectProjects.length; - //when some selection is empty, we set it full - if ($scope.selectInstallers.length == 0) { - $scope.selectInstallers = $scope.installerList; - - } - if ($scope.selectProjects.length == 0) { - $scope.selectProjects = $scope.projectList; - $scope.colspan = $scope.tableDataAll.colspan; - } else { - $scope.colspan = $scope.selectProjects.length; - $scope.tempColspan = $scope.colspan; - } - if ($scope.selectStatus.length == 0) { - $scope.selectStatus = $scope.statusList + if($scope.selectProjects.length == 0 && $scope.projectClicked == true){ + $scope.selectProjects = copy($scope.projectList); + $scope.projectClicked = false; } - // console.log($scope.selectStatus); - // console.log($scope.selectProjects); - + getScenarioData(); } - } - ]);
\ No newline at end of file + ]); diff --git a/utils/test/reporting/pages/app/scripts/factory/table.factory.js b/utils/test/reporting/pages/app/scripts/factory/table.factory.js index f0af34fb2..e715c5c28 100644 --- a/utils/test/reporting/pages/app/scripts/factory/table.factory.js +++ b/utils/test/reporting/pages/app/scripts/factory/table.factory.js @@ -28,7 +28,7 @@ angular.module('opnfvApp') } }); }, - getScenario: function() { + getScenario: function(data) { var config = { headers: { @@ -36,7 +36,7 @@ angular.module('opnfvApp') } } - return $http.post(BASE_URL + '/landing-page/scenarios', {}, config); + return $http.post(BASE_URL + '/landing-page/scenarios', data, config); }, diff --git a/utils/test/reporting/pages/app/views/commons/table.html b/utils/test/reporting/pages/app/views/commons/table.html index f504bd76b..a33c48312 100644 --- a/utils/test/reporting/pages/app/views/commons/table.html +++ b/utils/test/reporting/pages/app/views/commons/table.html @@ -29,9 +29,9 @@ <div class=" col-md-12" data-toggle="buttons" aria-pressed="false"> <label> Status </label> - <label class="btn btn-outline btn-success btn-sm" style="height:25px; margin-right: 5px;" ng-repeat="status in statusList" value={{status}} ng-checked="selection.indexOf(status)>-1" ng-click="toggleSelection(status)"> + <label class="btn btn-outline btn-success btn-sm" style="height:25px; margin-right: 5px;" ng-repeat="status in statusList" value={{status}} ng-checked="selectStatus.indexOf(status)>-1" ng-click="clickStatus(status)"> <input type="checkbox" disabled="disabled" > {{status}} - + </label> </div> @@ -39,7 +39,7 @@ <div class=" col-md-12" data-toggle="buttons"> <label> Projects </label> - <label class="btn btn-outline btn-success btn-sm " style="height:25px;margin-right: 5px;" ng-repeat="project in projectList" value={{project}} ng-checked="selection.indexOf(project)>-1" ng-click="toggleSelection(project)"> + <label class="btn btn-outline btn-success btn-sm " style="height:25px;margin-right: 5px;" ng-repeat="project in projectList" value={{project}} ng-checked="selectProjects.indexOf(project)>-1" ng-click="clickProject(project)"> <input type="checkbox" disabled="disabled"> {{project}} </label> @@ -47,7 +47,7 @@ <hr class="myhr"> <div class=" col-md-12" data-toggle="buttons"> <label> Installers </label> - <label class="btn btn-outline btn-success btn-sm" style="height:25px;margin-right: 5px;" ng-repeat="installer in installerList" value={{installer}} ng-checked="selection.indexOf(installer)>-1" ng-click="toggleSelection(installer)"> + <label class="btn btn-outline btn-success btn-sm" style="height:25px;margin-right: 5px;" ng-repeat="installer in installerList" value={{installer}} ng-checked="selectInstallers.indexOf(installer)>-1" ng-click="clickInstaller(installer)"> <input type="checkbox" disabled="disabled"> {{installer}} </label> </div> @@ -56,17 +56,17 @@ <div class=" col-md-1" style="margin-top:5px;margin-right: 5px;"> - <selectize options="VersionOption" ng-model="VersionSelected" config="VersionConfig"></selectize> + <selectize options="versionList" ng-model="selectVersion" config="VersionConfig"></selectize> </div> <div class=" col-md-1" style="margin-top:5px;margin-right: 5px;"> - <selectize options="LoopOption" ng-model="LoopCiSelected" config="LoopConfig"></selectize> + <selectize options="loopList" ng-model="selectLoop" config="LoopConfig"></selectize> </div> <div class=" col-md-1" style="margin-top:5px;margin-right: 5px;"> - <selectize options="TimeOption" ng-model="TimeSelected" config="TimeConfig"></selectize> + <selectize options="timeList" ng-model="selectTime" config="TimeConfig"></selectize> </div> </div> <div class="table-responsive"> @@ -75,25 +75,25 @@ <thead class="thead"> <tr> <th>Scenario </th> - <th colspan={{colspan}} ng-show="selectInstallers.indexOf(key)!=-1" value={{key}} ng-repeat="key in tableDataAll.Installer"><a href="notfound.html">{{key}}</a> </th> + <th colspan={{selectProjects.length}} ng-show="selectInstallers.indexOf(key)!=-1" value={{key}} ng-repeat="key in selectInstallers"><a href="notfound.html">{{key}}</a> </th> </tr> <tr> <td></td> - <td ng-show="selectProjects.indexOf(project[0])!=-1 && selectInstallers.indexOf(project[1])!=-1" ng-repeat="project in tableDataAll.Projects track by $index" data={{project[1]}} value={{project[0]}}>{{project[0]}}</td> + <td ng-show="selectProjects.indexOf(project.project)!=-1 && selectInstallers.indexOf(project.installer)!=-1" ng-repeat="project in project_row track by $index" data={{project.installer}} value={{project.project}}>{{ project.project }}</td> </tr> </thead> <tbody class="tbody"> - <tr ng-repeat="scenario in tableDataAll.scenario" ng-show="selectStatus.indexOf(scenario.status)!=-1"> + <tr ng-repeat="scenario in scenario_rows" ng-show="selectStatus.indexOf(scenario.status)!=-1"> - <td nowrap="nowrap" data={{scenario.status}}><span class="fa fa-circle text-{{scenario.statusDisplay}}"></span> <a href="notfound.html">{{scenario.scenarioName}}</a> </td> + <td nowrap="nowrap" data={{scenario.status}}><span class="fa fa-circle text-{{scenario.statusDisplay}}"></span> <a href="notfound.html">{{scenario.name}}</a> </td> <!--<td style="background-color:#e7eaec" align="justify" ng-if="data[0]=='Not Support'" ng-repeat="data in scenario.datadisplay track by $index" data={{data[1]}} value={{data[2]}}></td>--> - <td nowrap="nowrap" ng-show="selectInstallers.indexOf(data[2])!=-1 && selectProjects.indexOf(data[1])!=-1" ng-repeat="data in scenario.datadisplay track by $index" data={{data[1]}} value={{data[2]}} class={{data[0]}}> - <span class="label label-{{data[3]}}">{{data[4]}}</a></span> {{data[0]}}</td> + <td nowrap="nowrap" ng-show="selectInstallers.indexOf(data.installer)!=-1 && selectProjects.indexOf(data.project)!=-1" ng-repeat="data in scenario.datadisplay track by $index" data={{data.project}} value={{data.installer}} class={{data.value}}> + <span class="label label-{{data.label}}">{{data.label_value}}</a></span> {{data.value}}</td> </tr> @@ -110,4 +110,4 @@ </div> </div> -</section>
\ No newline at end of file +</section> diff --git a/utils/test/reporting/functest/__init__.py b/utils/test/reporting/reporting/__init__.py index e69de29bb..e69de29bb 100644 --- a/utils/test/reporting/functest/__init__.py +++ b/utils/test/reporting/reporting/__init__.py diff --git a/utils/test/reporting/qtip/__init__.py b/utils/test/reporting/reporting/functest/__init__.py index e69de29bb..e69de29bb 100644 --- a/utils/test/reporting/qtip/__init__.py +++ b/utils/test/reporting/reporting/functest/__init__.py diff --git a/utils/test/reporting/functest/img/gauge_0.png b/utils/test/reporting/reporting/functest/img/gauge_0.png Binary files differindex ecefc0e66..ecefc0e66 100644 --- a/utils/test/reporting/functest/img/gauge_0.png +++ b/utils/test/reporting/reporting/functest/img/gauge_0.png diff --git a/utils/test/reporting/functest/img/gauge_100.png b/utils/test/reporting/reporting/functest/img/gauge_100.png Binary files differindex e199e1561..e199e1561 100644 --- a/utils/test/reporting/functest/img/gauge_100.png +++ b/utils/test/reporting/reporting/functest/img/gauge_100.png diff --git a/utils/test/reporting/functest/img/gauge_16.7.png b/utils/test/reporting/reporting/functest/img/gauge_16.7.png Binary files differindex 3e3993c3b..3e3993c3b 100644 --- a/utils/test/reporting/functest/img/gauge_16.7.png +++ b/utils/test/reporting/reporting/functest/img/gauge_16.7.png diff --git a/utils/test/reporting/functest/img/gauge_25.png b/utils/test/reporting/reporting/functest/img/gauge_25.png Binary files differindex 4923659b9..4923659b9 100644 --- a/utils/test/reporting/functest/img/gauge_25.png +++ b/utils/test/reporting/reporting/functest/img/gauge_25.png diff --git a/utils/test/reporting/functest/img/gauge_33.3.png b/utils/test/reporting/reporting/functest/img/gauge_33.3.png Binary files differindex 364574b4a..364574b4a 100644 --- a/utils/test/reporting/functest/img/gauge_33.3.png +++ b/utils/test/reporting/reporting/functest/img/gauge_33.3.png diff --git a/utils/test/reporting/functest/img/gauge_41.7.png b/utils/test/reporting/reporting/functest/img/gauge_41.7.png Binary files differindex 8c3e910fa..8c3e910fa 100644 --- a/utils/test/reporting/functest/img/gauge_41.7.png +++ b/utils/test/reporting/reporting/functest/img/gauge_41.7.png diff --git a/utils/test/reporting/functest/img/gauge_50.png b/utils/test/reporting/reporting/functest/img/gauge_50.png Binary files differindex 2874b9fcf..2874b9fcf 100644 --- a/utils/test/reporting/functest/img/gauge_50.png +++ b/utils/test/reporting/reporting/functest/img/gauge_50.png diff --git a/utils/test/reporting/functest/img/gauge_58.3.png b/utils/test/reporting/reporting/functest/img/gauge_58.3.png Binary files differindex beedc8aa9..beedc8aa9 100644 --- a/utils/test/reporting/functest/img/gauge_58.3.png +++ b/utils/test/reporting/reporting/functest/img/gauge_58.3.png diff --git a/utils/test/reporting/functest/img/gauge_66.7.png b/utils/test/reporting/reporting/functest/img/gauge_66.7.png Binary files differindex 93f44d133..93f44d133 100644 --- a/utils/test/reporting/functest/img/gauge_66.7.png +++ b/utils/test/reporting/reporting/functest/img/gauge_66.7.png diff --git a/utils/test/reporting/functest/img/gauge_75.png b/utils/test/reporting/reporting/functest/img/gauge_75.png Binary files differindex 9fc261ff8..9fc261ff8 100644 --- a/utils/test/reporting/functest/img/gauge_75.png +++ b/utils/test/reporting/reporting/functest/img/gauge_75.png diff --git a/utils/test/reporting/functest/img/gauge_8.3.png b/utils/test/reporting/reporting/functest/img/gauge_8.3.png Binary files differindex 59f86571e..59f86571e 100644 --- a/utils/test/reporting/functest/img/gauge_8.3.png +++ b/utils/test/reporting/reporting/functest/img/gauge_8.3.png diff --git a/utils/test/reporting/functest/img/gauge_83.3.png b/utils/test/reporting/reporting/functest/img/gauge_83.3.png Binary files differindex 27ae4ec54..27ae4ec54 100644 --- a/utils/test/reporting/functest/img/gauge_83.3.png +++ b/utils/test/reporting/reporting/functest/img/gauge_83.3.png diff --git a/utils/test/reporting/functest/img/gauge_91.7.png b/utils/test/reporting/reporting/functest/img/gauge_91.7.png Binary files differindex 280865714..280865714 100644 --- a/utils/test/reporting/functest/img/gauge_91.7.png +++ b/utils/test/reporting/reporting/functest/img/gauge_91.7.png diff --git a/utils/test/reporting/functest/img/icon-nok.png b/utils/test/reporting/reporting/functest/img/icon-nok.png Binary files differindex 526b5294b..526b5294b 100644 --- a/utils/test/reporting/functest/img/icon-nok.png +++ b/utils/test/reporting/reporting/functest/img/icon-nok.png diff --git a/utils/test/reporting/functest/img/icon-ok.png b/utils/test/reporting/reporting/functest/img/icon-ok.png Binary files differindex 3a9de2e89..3a9de2e89 100644 --- a/utils/test/reporting/functest/img/icon-ok.png +++ b/utils/test/reporting/reporting/functest/img/icon-ok.png diff --git a/utils/test/reporting/functest/img/weather-clear.png b/utils/test/reporting/reporting/functest/img/weather-clear.png Binary files differindex a0d967750..a0d967750 100644 --- a/utils/test/reporting/functest/img/weather-clear.png +++ b/utils/test/reporting/reporting/functest/img/weather-clear.png diff --git a/utils/test/reporting/functest/img/weather-few-clouds.png b/utils/test/reporting/reporting/functest/img/weather-few-clouds.png Binary files differindex acfa78398..acfa78398 100644 --- a/utils/test/reporting/functest/img/weather-few-clouds.png +++ b/utils/test/reporting/reporting/functest/img/weather-few-clouds.png diff --git a/utils/test/reporting/functest/img/weather-overcast.png b/utils/test/reporting/reporting/functest/img/weather-overcast.png Binary files differindex 4296246d0..4296246d0 100644 --- a/utils/test/reporting/functest/img/weather-overcast.png +++ b/utils/test/reporting/reporting/functest/img/weather-overcast.png diff --git a/utils/test/reporting/functest/img/weather-storm.png b/utils/test/reporting/reporting/functest/img/weather-storm.png Binary files differindex 956f0e20f..956f0e20f 100644 --- a/utils/test/reporting/functest/img/weather-storm.png +++ b/utils/test/reporting/reporting/functest/img/weather-storm.png diff --git a/utils/test/reporting/functest/index.html b/utils/test/reporting/reporting/functest/index.html index bb1bce209..bb1bce209 100644 --- a/utils/test/reporting/functest/index.html +++ b/utils/test/reporting/reporting/functest/index.html diff --git a/utils/test/reporting/functest/reporting-status.py b/utils/test/reporting/reporting/functest/reporting-status.py index 77ab7840f..02bf67d0e 100755 --- a/utils/test/reporting/functest/reporting-status.py +++ b/utils/test/reporting/reporting/functest/reporting-status.py @@ -7,16 +7,19 @@ # http://www.apache.org/licenses/LICENSE-2.0 # import datetime -import jinja2 import os import sys import time +import jinja2 + import testCase as tc import scenarioResult as sr +import reporting.utils.reporting_utils as rp_utils -# manage conf -import utils.reporting_utils as rp_utils +""" +Functest reporting status +""" # Logger logger = rp_utils.getLogger("Functest-Status") @@ -104,7 +107,8 @@ for version in versions: for installer in installers: # get scenarios - scenario_results = rp_utils.getScenarios(healthcheck, + scenario_results = rp_utils.getScenarios("functest", + "connection_check", installer, version) # get nb of supported architecture (x86, aarch64) @@ -124,7 +128,7 @@ for version in versions: # in case of more than 1 architecture supported # precise the architecture installer_display = installer - if (len(architectures) > 1): + if "fuel" in installer: installer_display = installer + "@" + architecture # For all the scenarios get results @@ -217,7 +221,7 @@ for version in versions: logger.debug("No results found") items[s] = testCases2BeDisplayed - except: + except Exception: logger.error("Error: installer %s, version %s, scenario %s" % (installer, version, s)) logger.error("No data available: %s" % (sys.exc_info()[0])) @@ -272,17 +276,18 @@ for version in versions: templateEnv = jinja2.Environment( loader=templateLoader, autoescape=True) - TEMPLATE_FILE = "./functest/template/index-status-tmpl.html" + TEMPLATE_FILE = ("./reporting/functest/template" + "/index-status-tmpl.html") template = templateEnv.get_template(TEMPLATE_FILE) outputText = template.render( - scenario_stats=scenario_stats, - scenario_results=scenario_result_criteria, - items=items, - installer=installer_display, - period=period, - version=version, - date=reportingDate) + scenario_stats=scenario_stats, + scenario_results=scenario_result_criteria, + items=items, + installer=installer_display, + period=period, + version=version, + date=reportingDate) with open("./display/" + version + "/functest/status-" + @@ -295,8 +300,6 @@ for version in versions: # Generate outputs for export # pdf - # TODO Change once web site updated...use the current one - # to test pdf production url_pdf = rp_utils.get_config('general.url') pdf_path = ("./display/" + version + "/functest/status-" + installer_display + ".html") diff --git a/utils/test/reporting/functest/reporting-tempest.py b/utils/test/reporting/reporting/functest/reporting-tempest.py index 0304298b4..d78d9a19d 100755 --- a/utils/test/reporting/functest/reporting-tempest.py +++ b/utils/test/reporting/reporting/functest/reporting-tempest.py @@ -8,58 +8,57 @@ # http://www.apache.org/licenses/LICENSE-2.0 # SPDX-license-identifier: Apache-2.0 -from urllib2 import Request, urlopen, URLError from datetime import datetime import json -import jinja2 import os -# manage conf -import utils.reporting_utils as rp_utils +from urllib2 import Request, urlopen, URLError +import jinja2 + +import reporting.utils.reporting_utils as rp_utils -installers = rp_utils.get_config('general.installers') -items = ["tests", "Success rate", "duration"] +INSTALLERS = rp_utils.get_config('general.installers') +ITEMS = ["tests", "Success rate", "duration"] CURRENT_DIR = os.getcwd() PERIOD = rp_utils.get_config('general.period') -criteria_nb_test = 165 -criteria_duration = 1800 -criteria_success_rate = 90 +CRITERIA_NB_TEST = 100 +CRITERIA_DURATION = 1800 +CRITERIA_SUCCESS_RATE = 100 logger = rp_utils.getLogger("Tempest") logger.info("************************************************") logger.info("* Generating reporting Tempest_smoke_serial *") -logger.info("* Data retention = %s days *" % PERIOD) +logger.info("* Data retention = %s days *", PERIOD) logger.info("* *") logger.info("************************************************") logger.info("Success criteria:") -logger.info("nb tests executed > %s s " % criteria_nb_test) -logger.info("test duration < %s s " % criteria_duration) -logger.info("success rate > %s " % criteria_success_rate) +logger.info("nb tests executed > %s s ", CRITERIA_NB_TEST) +logger.info("test duration < %s s ", CRITERIA_DURATION) +logger.info("success rate > %s ", CRITERIA_SUCCESS_RATE) # For all the versions for version in rp_utils.get_config('general.versions'): - for installer in installers: + for installer in INSTALLERS: # we consider the Tempest results of the last PERIOD days url = ("http://" + rp_utils.get_config('testapi.url') + - "?case=tempest_smoke_serial") - request = Request(url + '&period=' + str(PERIOD) + - '&installer=' + installer + - '&version=' + version) - logger.info("Search tempest_smoke_serial results for installer %s" - " for version %s" - % (installer, version)) + "?case=tempest_smoke_serial&period=" + str(PERIOD) + + "&installer=" + installer + "&version=" + version) + request = Request(url) + logger.info(("Search tempest_smoke_serial results for installer %s" + " for version %s"), installer, version) try: response = urlopen(request) k = response.read() results = json.loads(k) - except URLError as e: - logger.error("Error code: %s" % e) - + except URLError as err: + logger.error("Error code: %s", err) + logger.debug("request sent: %s", url) + logger.debug("Results from API: %s", results) test_results = results['results'] - + logger.debug("Test results: %s", test_results) scenario_results = {} criteria = {} errors = {} @@ -72,27 +71,37 @@ for version in rp_utils.get_config('general.versions'): scenario_results[r['scenario']] = [] scenario_results[r['scenario']].append(r) + logger.debug("Scenario results: %s", scenario_results) + for s, s_result in scenario_results.items(): scenario_results[s] = s_result[0:5] # For each scenario, we build a result object to deal with # results, criteria and error handling for result in scenario_results[s]: result["start_date"] = result["start_date"].split(".")[0] + logger.debug("start_date= %s", result["start_date"]) # retrieve results # **************** nb_tests_run = result['details']['tests'] nb_tests_failed = result['details']['failures'] - if nb_tests_run != 0: - success_rate = 100 * ((int(nb_tests_run) - + logger.debug("nb_tests_run= %s", nb_tests_run) + logger.debug("nb_tests_failed= %s", nb_tests_failed) + + try: + success_rate = (100 * (int(nb_tests_run) - int(nb_tests_failed)) / - int(nb_tests_run)) - else: + int(nb_tests_run)) + except ZeroDivisionError: success_rate = 0 result['details']["tests"] = nb_tests_run result['details']["Success rate"] = str(success_rate) + "%" + logger.info("nb_tests_run= %s", result['details']["tests"]) + logger.info("test rate = %s", + result['details']["Success rate"]) + # Criteria management # ******************* crit_tests = False @@ -100,11 +109,11 @@ for version in rp_utils.get_config('general.versions'): crit_time = False # Expect that at least 165 tests are run - if nb_tests_run >= criteria_nb_test: + if nb_tests_run >= CRITERIA_NB_TEST: crit_tests = True # Expect that at least 90% of success - if success_rate >= criteria_success_rate: + if success_rate >= CRITERIA_SUCCESS_RATE: crit_rate = True # Expect that the suite duration is inferior to 30m @@ -114,39 +123,38 @@ for version in rp_utils.get_config('general.versions'): '%Y-%m-%d %H:%M:%S') delta = stop_date - start_date - if (delta.total_seconds() < criteria_duration): + + if delta.total_seconds() < CRITERIA_DURATION: crit_time = True result['criteria'] = {'tests': crit_tests, 'Success rate': crit_rate, 'duration': crit_time} try: - logger.debug("Scenario %s, Installer %s" - % (s_result[1]['scenario'], installer)) - logger.debug("Nb Test run: %s" % nb_tests_run) - logger.debug("Test duration: %s" - % result['details']['duration']) - logger.debug("Success rate: %s" % success_rate) - except: + logger.debug("Nb Test run: %s", nb_tests_run) + logger.debug("Test duration: %s", delta) + logger.debug("Success rate: %s", success_rate) + except Exception: # pylint: disable=broad-except logger.error("Data format error") # Error management # **************** try: errors = result['details']['errors'] - result['errors'] = errors.replace('{0}', '') - except: + logger.info("errors: %s", errors) + result['errors'] = errors + except Exception: # pylint: disable=broad-except logger.error("Error field not present (Brahamputra runs?)") templateLoader = jinja2.FileSystemLoader(".") templateEnv = jinja2.Environment(loader=templateLoader, autoescape=True) - TEMPLATE_FILE = "./functest/template/index-tempest-tmpl.html" + TEMPLATE_FILE = "./reporting/functest/template/index-tempest-tmpl.html" template = templateEnv.get_template(TEMPLATE_FILE) outputText = template.render(scenario_results=scenario_results, - items=items, + items=ITEMS, installer=installer) with open("./display/" + version + diff --git a/utils/test/reporting/functest/reporting-vims.py b/utils/test/reporting/reporting/functest/reporting-vims.py index b236b8963..14fddbe25 100755 --- a/utils/test/reporting/functest/reporting-vims.py +++ b/utils/test/reporting/reporting/functest/reporting-vims.py @@ -104,7 +104,7 @@ for version in versions: % result['details']['sig_test']['duration']) logger.debug("Signaling testing results: %s" % format_result) - except: + except Exception: logger.error("Data badly formatted") logger.debug("----------------------------------------") @@ -112,7 +112,7 @@ for version in versions: templateEnv = jinja2.Environment(loader=templateLoader, autoescape=True) - TEMPLATE_FILE = "./functest/template/index-vims-tmpl.html" + TEMPLATE_FILE = "./reporting/functest/template/index-vims-tmpl.html" template = templateEnv.get_template(TEMPLATE_FILE) outputText = template.render(scenario_results=scenario_results, diff --git a/utils/test/reporting/functest/scenarioResult.py b/utils/test/reporting/reporting/functest/scenarioResult.py index 5a54eed96..5a54eed96 100644 --- a/utils/test/reporting/functest/scenarioResult.py +++ b/utils/test/reporting/reporting/functest/scenarioResult.py diff --git a/utils/test/reporting/functest/template/index-status-tmpl.html b/utils/test/reporting/reporting/functest/template/index-status-tmpl.html index cc4edaac5..50fc648aa 100644 --- a/utils/test/reporting/functest/template/index-status-tmpl.html +++ b/utils/test/reporting/reporting/functest/template/index-status-tmpl.html @@ -72,6 +72,7 @@ $(document).ready(function (){ <li class="active"><a href="../../index.html">Home</a></li> <li><a href="status-apex.html">Apex</a></li> <li><a href="status-compass.html">Compass</a></li> + <li><a href="status-daisy.html">Daisy</a></li> <li><a href="status-fuel@x86.html">fuel@x86</a></li> <li><a href="status-fuel@aarch64.html">fuel@aarch64</a></li> <li><a href="status-joid.html">Joid</a></li> @@ -89,7 +90,7 @@ $(document).ready(function (){ <div class="panel-heading"><h4><b>List of last scenarios ({{version}}) run over the last {{period}} days </b></h4></div> <table class="table"> <tr> - <th width="40%">Scenario</th> + <th width="40%">HA Scenario</th> <th width="20%">Status</th> <th width="20%">Trend</th> <th width="10%">Score</th> @@ -97,14 +98,39 @@ $(document).ready(function (){ </tr> {% for scenario,iteration in scenario_stats.iteritems() -%} <tr class="tr-ok"> + {% if '-ha' in scenario -%} <td><a href={{scenario_results[scenario].getUrlLastRun()}}>{{scenario}}</a></td> <td><div id="gaugeScenario{{loop.index}}"></div></td> <td><div id="trend_svg{{loop.index}}"></div></td> <td>{{scenario_results[scenario].getScore()}}</td> <td>{{iteration}}</td> + {%- endif %} + </tr> + {%- endfor %} + <br> + </table> + <br> + <table class="table"> + <tr> + <th width="40%">NOHA Scenario</th> + <th width="20%">Status</th> + <th width="20%">Trend</th> + <th width="10%">Score</th> + <th width="10%">Iteration</th> + </tr> + {% for scenario,iteration in scenario_stats.iteritems() -%} + <tr class="tr-ok"> + {% if '-noha' in scenario -%} + <td><a href={{scenario_results[scenario].getUrlLastRun()}}>{{scenario}}</a></td> + <td><div id="gaugeScenario{{loop.index}}"></div></td> + <td><div id="trend_svg{{loop.index}}"></div></td> + <td>{{scenario_results[scenario].getScore()}}</td> + <td>{{iteration}}</td> + {%- endif %} </tr> {%- endfor %} - </table> + </table> + </div> diff --git a/utils/test/reporting/functest/template/index-tempest-tmpl.html b/utils/test/reporting/reporting/functest/template/index-tempest-tmpl.html index 3a222276e..3a222276e 100644 --- a/utils/test/reporting/functest/template/index-tempest-tmpl.html +++ b/utils/test/reporting/reporting/functest/template/index-tempest-tmpl.html diff --git a/utils/test/reporting/functest/template/index-vims-tmpl.html b/utils/test/reporting/reporting/functest/template/index-vims-tmpl.html index cd51607b7..cd51607b7 100644 --- a/utils/test/reporting/functest/template/index-vims-tmpl.html +++ b/utils/test/reporting/reporting/functest/template/index-vims-tmpl.html diff --git a/utils/test/reporting/functest/testCase.py b/utils/test/reporting/reporting/functest/testCase.py index 9834f0753..9834f0753 100644 --- a/utils/test/reporting/functest/testCase.py +++ b/utils/test/reporting/reporting/functest/testCase.py diff --git a/utils/test/reporting/tests/__init__.py b/utils/test/reporting/reporting/qtip/__init__.py index e69de29bb..e69de29bb 100644 --- a/utils/test/reporting/tests/__init__.py +++ b/utils/test/reporting/reporting/qtip/__init__.py diff --git a/utils/test/reporting/qtip/index.html b/utils/test/reporting/reporting/qtip/index.html index 0f9df8564..0f9df8564 100644 --- a/utils/test/reporting/qtip/index.html +++ b/utils/test/reporting/reporting/qtip/index.html diff --git a/utils/test/reporting/qtip/reporting-status.py b/utils/test/reporting/reporting/qtip/reporting-status.py index 5967cf6b9..56f9e0aee 100644 --- a/utils/test/reporting/qtip/reporting-status.py +++ b/utils/test/reporting/reporting/qtip/reporting-status.py @@ -23,7 +23,7 @@ reportingDate = datetime.datetime.now().strftime("%Y-%m-%d %H:%M") logger.info("*******************************************") logger.info("* Generating reporting scenario status *") -logger.info("* Data retention = %s days *" % PERIOD) +logger.info("* Data retention = {} days *".format(PERIOD)) logger.info("* *") logger.info("*******************************************") @@ -33,7 +33,7 @@ def prepare_profile_file(version): if not os.path.exists(profile_dir): os.makedirs(profile_dir) - profile_file = '{}/scenario_history.txt'.format(profile_dir, version) + profile_file = "{}/scenario_history.txt".format(profile_dir) if not os.path.exists(profile_file): with open(profile_file, 'w') as f: info = 'date,scenario,installer,details,score\n' @@ -77,7 +77,7 @@ def render_html(prof_results, installer, version): template_env = jinja2.Environment(loader=template_loader, autoescape=True) - template_file = "./qtip/template/index-status-tmpl.html" + template_file = "./reporting/qtip/template/index-status-tmpl.html" template = template_env.get_template(template_file) render_outcome = template.render(prof_results=prof_results, @@ -106,5 +106,6 @@ def render_reporter(): rp_utils.generate_csv(profile_file) logger.info("CSV generated...") + if __name__ == '__main__': render_reporter() diff --git a/utils/test/reporting/qtip/template/index-status-tmpl.html b/utils/test/reporting/reporting/qtip/template/index-status-tmpl.html index 26da36ceb..92f3395dc 100644 --- a/utils/test/reporting/qtip/template/index-status-tmpl.html +++ b/utils/test/reporting/reporting/qtip/template/index-status-tmpl.html @@ -46,10 +46,11 @@ <nav> <ul class="nav nav-justified"> <li class="active"><a href="http://testresults.opnfv.org/reporting/index.html">Home</a></li> - <li><a href="index-status-apex.html">Apex</a></li> - <li><a href="index-status-compass.html">Compass</a></li> - <li><a href="index-status-fuel.html">Fuel</a></li> - <li><a href="index-status-joid.html">Joid</a></li> + <li><a href="status-apex.html">Apex</a></li> + <li><a href="status-compass.html">Compass</a></li> + <li><a href="status-daisy.html">Daisy</a></li> + <li><a href="status-fuel.html">Fuel</a></li> + <li><a href="status-joid.html">Joid</a></li> </ul> </nav> </div> diff --git a/utils/test/reporting/reporting.yaml b/utils/test/reporting/reporting/reporting.yaml index 1692f481d..26feb31d3 100644 --- a/utils/test/reporting/reporting.yaml +++ b/utils/test/reporting/reporting/reporting.yaml @@ -3,6 +3,7 @@ general: installers: - apex - compass + - daisy - fuel - joid diff --git a/utils/test/reporting/tests/unit/__init__.py b/utils/test/reporting/reporting/storperf/__init__.py index e69de29bb..e69de29bb 100644 --- a/utils/test/reporting/tests/unit/__init__.py +++ b/utils/test/reporting/reporting/storperf/__init__.py diff --git a/utils/test/reporting/storperf/reporting-status.py b/utils/test/reporting/reporting/storperf/reporting-status.py index 888e339f8..103b80fd9 100644 --- a/utils/test/reporting/storperf/reporting-status.py +++ b/utils/test/reporting/reporting/storperf/reporting-status.py @@ -7,13 +7,12 @@ # http://www.apache.org/licenses/LICENSE-2.0 # import datetime -import jinja2 import os -# manage conf -import utils.reporting_utils as rp_utils +import jinja2 -import utils.scenarioResult as sr +import reporting.utils.reporting_utils as rp_utils +import reporting.utils.scenarioResult as sr installers = rp_utils.get_config('general.installers') versions = rp_utils.get_config('general.versions') @@ -39,7 +38,8 @@ for version in versions: for installer in installers: # get scenarios results data # for the moment we consider only 1 case snia_steady_state - scenario_results = rp_utils.getScenarios("snia_steady_state", + scenario_results = rp_utils.getScenarios("storperf", + "snia_steady_state", installer, version) # logger.info("scenario_results: %s" % scenario_results) @@ -131,7 +131,7 @@ for version in versions: templateEnv = jinja2.Environment(loader=templateLoader, autoescape=True) - TEMPLATE_FILE = "./storperf/template/index-status-tmpl.html" + TEMPLATE_FILE = "./reporting/storperf/template/index-status-tmpl.html" template = templateEnv.get_template(TEMPLATE_FILE) outputText = template.render(scenario_results=scenario_result_criteria, diff --git a/utils/test/reporting/storperf/template/index-status-tmpl.html b/utils/test/reporting/reporting/storperf/template/index-status-tmpl.html index e872272c3..e872272c3 100644 --- a/utils/test/reporting/storperf/template/index-status-tmpl.html +++ b/utils/test/reporting/reporting/storperf/template/index-status-tmpl.html diff --git a/utils/test/reporting/tests/unit/utils/__init__.py b/utils/test/reporting/reporting/tests/__init__.py index e69de29bb..e69de29bb 100644 --- a/utils/test/reporting/tests/unit/utils/__init__.py +++ b/utils/test/reporting/reporting/tests/__init__.py diff --git a/utils/test/reporting/utils/__init__.py b/utils/test/reporting/reporting/tests/unit/__init__.py index e69de29bb..e69de29bb 100644 --- a/utils/test/reporting/utils/__init__.py +++ b/utils/test/reporting/reporting/tests/unit/__init__.py diff --git a/utils/test/reporting/reporting/tests/unit/utils/__init__.py b/utils/test/reporting/reporting/tests/unit/utils/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/utils/test/reporting/reporting/tests/unit/utils/__init__.py diff --git a/utils/test/reporting/tests/unit/utils/test_utils.py b/utils/test/reporting/reporting/tests/unit/utils/test_utils.py index b9c39806c..9614d74ff 100644 --- a/utils/test/reporting/tests/unit/utils/test_utils.py +++ b/utils/test/reporting/reporting/tests/unit/utils/test_utils.py @@ -10,7 +10,7 @@ import logging import unittest -from utils import reporting_utils +from reporting.utils import reporting_utils class reportingUtilsTesting(unittest.TestCase): @@ -20,10 +20,9 @@ class reportingUtilsTesting(unittest.TestCase): def setUp(self): self.test = reporting_utils - def test_getConfig(self): - self.assertEqual(self.test.get_config("general.period"), 10) -# TODO -# ... + def test_foo(self): + self.assertTrue(0 < 1) + if __name__ == "__main__": unittest.main(verbosity=2) diff --git a/utils/test/reporting/reporting/utils/__init__.py b/utils/test/reporting/reporting/utils/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/utils/test/reporting/reporting/utils/__init__.py diff --git a/utils/test/reporting/utils/reporting_utils.py b/utils/test/reporting/reporting/utils/reporting_utils.py index 0a178ba1f..235bd6ef9 100644 --- a/utils/test/reporting/utils/reporting_utils.py +++ b/utils/test/reporting/reporting/utils/reporting_utils.py @@ -20,15 +20,15 @@ import yaml # YAML UTILS # # ----------------------------------------------------------- -def get_parameter_from_yaml(parameter, file): +def get_parameter_from_yaml(parameter, config_file): """ Returns the value of a given parameter in file.yaml parameter must be given in string format with dots Example: general.openstack.image_name """ - with open(file) as f: - file_yaml = yaml.safe_load(f) - f.close() + with open(config_file) as my_file: + file_yaml = yaml.safe_load(my_file) + my_file.close() value = file_yaml for element in parameter.split("."): value = value.get(element) @@ -39,6 +39,9 @@ def get_parameter_from_yaml(parameter, file): def get_config(parameter): + """ + Get configuration parameter from yaml configuration file + """ yaml_ = os.environ["CONFIG_REPORTING_YAML"] return get_parameter_from_yaml(parameter, yaml_) @@ -49,20 +52,23 @@ def get_config(parameter): # # ----------------------------------------------------------- def getLogger(module): - logFormatter = logging.Formatter("%(asctime)s [" + - module + - "] [%(levelname)-5.5s] %(message)s") + """ + Get Logger + """ + log_formatter = logging.Formatter("%(asctime)s [" + + module + + "] [%(levelname)-5.5s] %(message)s") logger = logging.getLogger() log_file = get_config('general.log.log_file') log_level = get_config('general.log.log_level') - fileHandler = logging.FileHandler("{0}/{1}".format('.', log_file)) - fileHandler.setFormatter(logFormatter) - logger.addHandler(fileHandler) + file_handler = logging.FileHandler("{0}/{1}".format('.', log_file)) + file_handler.setFormatter(log_formatter) + logger.addHandler(file_handler) - consoleHandler = logging.StreamHandler() - consoleHandler.setFormatter(logFormatter) - logger.addHandler(consoleHandler) + console_handler = logging.StreamHandler() + console_handler.setFormatter(log_formatter) + logger.addHandler(console_handler) logger.setLevel(log_level) return logger @@ -73,6 +79,9 @@ def getLogger(module): # # ----------------------------------------------------------- def getApiResults(case, installer, scenario, version): + """ + Get Results by calling the API + """ results = json.dumps([]) # to remove proxy (to be removed at the end for local test only) # proxy_handler = urllib2.ProxyHandler({}) @@ -94,29 +103,32 @@ def getApiResults(case, installer, scenario, version): response = urlopen(request) k = response.read() results = json.loads(k) - except URLError as e: - print('No kittez. Got an error code:', e) + except URLError: + print "Error when retrieving results form API" return results -def getScenarios(case, installer, version): - - try: - case = case.getName() - except: - # if case is not an object test case, try the string - if type(case) == str: - case = case - else: - raise ValueError("Case cannot be evaluated") +def getScenarios(project, case, installer, version): + """ + Get the list of Scenarios + """ period = get_config('general.period') url_base = get_config('testapi.url') - url = ("http://" + url_base + "?case=" + case + - "&period=" + str(period) + "&installer=" + installer + - "&version=" + version) + url = ("http://" + url_base + + "?installer=" + installer + + "&period=" + str(period)) + + if version is not None: + url += "&version=" + version + + if project is not None: + url += "&project=" + project + + if case is not None: + url += "&case=" + case try: request = Request(url) @@ -124,50 +136,58 @@ def getScenarios(case, installer, version): k = response.read() results = json.loads(k) test_results = results['results'] - - 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'] + try: + 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 KeyError: + print "No pagination detected" except URLError as err: - print('Got an error code:', err) + print 'Got an error code: {}'.format(err) if test_results is not None: test_results.reverse() scenario_results = {} - for r in test_results: + for my_result in test_results: # Retrieve all the scenarios per installer - if not r['scenario'] in scenario_results.keys(): - scenario_results[r['scenario']] = [] + if not my_result['scenario'] in scenario_results.keys(): + scenario_results[my_result['scenario']] = [] # Do we consider results from virtual pods ... # Do we consider results for non HA scenarios... exclude_virtual_pod = get_config('functest.exclude_virtual') exclude_noha = get_config('functest.exclude_noha') - if ((exclude_virtual_pod and "virtual" in r['pod_name']) or - (exclude_noha and "noha" in r['scenario'])): - print("exclude virtual pod results...") + if ((exclude_virtual_pod and "virtual" in my_result['pod_name']) or + (exclude_noha and "noha" in my_result['scenario'])): + print "exclude virtual pod results..." else: - scenario_results[r['scenario']].append(r) + scenario_results[my_result['scenario']].append(my_result) return scenario_results def getScenarioStats(scenario_results): + """ + Get the number of occurence of scenarios over the defined PERIOD + """ scenario_stats = {} - for k, v in scenario_results.iteritems(): - scenario_stats[k] = len(v) - + for res_k, res_v in scenario_results.iteritems(): + scenario_stats[res_k] = len(res_v) return scenario_stats def getScenarioStatus(installer, version): + """ + Get the status of a scenariofor Yardstick + they used criteria SUCCESS (default: PASS) + """ period = get_config('general.period') url_base = get_config('testapi.url') @@ -182,33 +202,37 @@ def getScenarioStatus(installer, version): response.close() results = json.loads(k) test_results = results['results'] - except URLError as e: - print('Got an error code:', e) + except URLError: + print "GetScenarioStatus: error when calling the API" scenario_results = {} result_dict = {} if test_results is not None: - for r in test_results: - if r['stop_date'] != 'None' and r['criteria'] is not None: - if not r['scenario'] in scenario_results.keys(): - scenario_results[r['scenario']] = [] - scenario_results[r['scenario']].append(r) - - for k, v in scenario_results.items(): + for test_r in test_results: + if (test_r['stop_date'] != 'None' and + test_r['criteria'] is not None): + if not test_r['scenario'] in scenario_results.keys(): + scenario_results[test_r['scenario']] = [] + scenario_results[test_r['scenario']].append(test_r) + + for scen_k, scen_v in scenario_results.items(): # scenario_results[k] = v[:LASTEST_TESTS] s_list = [] - for element in v: + for element in scen_v: if element['criteria'] == 'SUCCESS': s_list.append(1) else: s_list.append(0) - result_dict[k] = s_list + result_dict[scen_k] = s_list # return scenario_results return result_dict def getQtipResults(version, installer): + """ + Get QTIP results + """ period = get_config('qtip.period') url_base = get_config('testapi.url') @@ -223,7 +247,7 @@ def getQtipResults(version, installer): response.close() results = json.loads(k)['results'] except URLError as err: - print('Got an error code:', err) + print 'Got an error code: {}'.format(err) result_dict = {} if results: @@ -238,19 +262,24 @@ def getQtipResults(version, installer): def getNbtestOk(results): + """ + based on default value (PASS) count the number of test OK + """ nb_test_ok = 0 - for r in results: - for k, v in r.iteritems(): + for my_result in results: + for res_k, res_v in my_result.iteritems(): try: - if "PASS" in v: + if "PASS" in res_v: nb_test_ok += 1 - except: - print("Cannot retrieve test status") + except Exception: + print "Cannot retrieve test status" return nb_test_ok def getResult(testCase, installer, scenario, version): - + """ + Get Result for a given Functest Testcase + """ # retrieve raw results results = getApiResults(testCase, installer, scenario, version) # let's concentrate on test results only @@ -267,10 +296,10 @@ def getResult(testCase, installer, scenario, version): # print " ---------------- " # print "nb of results:" + str(len(test_results)) - for r in test_results: + for res_r in test_results: # print r["start_date"] # print r["criteria"] - scenario_results.append({r["start_date"]: r["criteria"]}) + scenario_results.append({res_r["start_date"]: res_r["criteria"]}) # sort results scenario_results.sort() # 4 levels for the results @@ -293,7 +322,7 @@ def getResult(testCase, installer, scenario, version): test_result_indicator = 1 else: # Test the last 4 run - if (len(scenario_results) > 3): + if len(scenario_results) > 3: last4runResults = scenario_results[-4:] nbTestOkLast4 = getNbtestOk(last4runResults) # print "Nb test OK (last 4 run):"+ str(nbTestOkLast4) @@ -307,20 +336,23 @@ def getResult(testCase, installer, scenario, version): def getJenkinsUrl(build_tag): - # e.g. jenkins-functest-apex-apex-daily-colorado-daily-colorado-246 - # id = 246 - # jenkins-functest-compass-huawei-pod5-daily-master-136 - # id = 136 - # note it is linked to jenkins format - # if this format changes...function to be adapted.... + """ + Get Jenkins url_base corespoding to the last test CI run + e.g. jenkins-functest-apex-apex-daily-colorado-daily-colorado-246 + id = 246 + jenkins-functest-compass-huawei-pod5-daily-master-136 + id = 136 + note it is linked to jenkins format + if this format changes...function to be adapted.... + """ url_base = get_config('functest.jenkins_url') try: build_id = [int(s) for s in build_tag.split("-") if s.isdigit()] url_id = (build_tag[8:-(len(str(build_id[0])) + 1)] + "/" + str(build_id[0])) jenkins_url = url_base + url_id + "/console" - except: - print('Impossible to get jenkins url:') + except Exception: + print 'Impossible to get jenkins url:' if "jenkins-" not in build_tag: jenkins_url = None @@ -329,11 +361,14 @@ def getJenkinsUrl(build_tag): def getScenarioPercent(scenario_score, scenario_criteria): + """ + Get success rate of the scenario (in %) + """ score = 0.0 try: score = float(scenario_score) / float(scenario_criteria) * 100 - except: - print('Impossible to calculate the percentage score') + except Exception: + print 'Impossible to calculate the percentage score' return score @@ -341,32 +376,41 @@ def getScenarioPercent(scenario_score, scenario_criteria): # Functest # ********* def getFunctestConfig(version=""): + """ + Get Functest configuration + """ config_file = get_config('functest.test_conf') + version response = requests.get(config_file) return yaml.safe_load(response.text) def getArchitectures(scenario_results): + """ + Get software architecture (x86 or Aarch64) + """ supported_arch = ['x86'] - if (len(scenario_results) > 0): + if len(scenario_results) > 0: for scenario_result in scenario_results.values(): for value in scenario_result: - if ("armband" in value['build_tag']): + if "armband" in value['build_tag']: supported_arch.append('aarch64') return supported_arch return supported_arch def filterArchitecture(results, architecture): + """ + Restrict the list of results based on given architecture + """ filtered_results = {} - for name, results in results.items(): + for name, res in results.items(): filtered_values = [] - for value in results: - if (architecture is "x86"): + for value in res: + if architecture is "x86": # drop aarch64 results if ("armband" not in value['build_tag']): filtered_values.append(value) - elif(architecture is "aarch64"): + elif architecture is "aarch64": # drop x86 results if ("armband" in value['build_tag']): filtered_values.append(value) @@ -379,6 +423,9 @@ def filterArchitecture(results, architecture): # Yardstick # ********* def subfind(given_list, pattern_list): + """ + Yardstick util function + """ LASTEST_TESTS = get_config('general.nb_iteration_tests_success_criteria') for i in range(len(given_list)): if given_list[i] == pattern_list[0] and \ @@ -388,7 +435,9 @@ def subfind(given_list, pattern_list): def _get_percent(status): - + """ + Yardstick util function to calculate success rate + """ if status * 100 % 6: return round(float(status) * 100 / 6, 1) else: @@ -396,13 +445,16 @@ def _get_percent(status): def get_percent(four_list, ten_list): + """ + Yardstick util function to calculate success rate + """ four_score = 0 ten_score = 0 - for v in four_list: - four_score += v - for v in ten_list: - ten_score += v + for res_v in four_list: + four_score += res_v + for res_v in ten_list: + ten_score += res_v LASTEST_TESTS = get_config('general.nb_iteration_tests_success_criteria') if four_score == LASTEST_TESTS: @@ -418,9 +470,12 @@ def get_percent(four_list, ten_list): def _test(): + """ + Yardstick util function (test) + """ status = getScenarioStatus("compass", "master") - print("status:++++++++++++++++++++++++") - print(json.dumps(status, indent=4)) + print "status:++++++++++++++++++++++++" + print json.dumps(status, indent=4) # ---------------------------------------------------------- @@ -430,8 +485,9 @@ def _test(): # ----------------------------------------------------------- def export_csv(scenario_file_name, installer, version): - # csv - # generate sub files based on scenario_history.txt + """ + Generate sub files based on scenario_history.txt + """ scenario_installer_file_name = ("./display/" + version + "/functest/scenario_history_" + installer + ".csv") @@ -441,21 +497,25 @@ def export_csv(scenario_file_name, installer, version): for line in scenario_file: if installer in line: scenario_installer_file.write(line) - scenario_installer_file.close + scenario_installer_file.close def generate_csv(scenario_file): + """ + Generate sub files based on scenario_history.txt + """ import shutil - # csv - # generate sub files based on scenario_history.txt csv_file = scenario_file.replace('txt', 'csv') shutil.copy2(scenario_file, csv_file) def export_pdf(pdf_path, pdf_doc_name): + """ + Export results to pdf + """ try: pdfkit.from_file(pdf_path, pdf_doc_name) except IOError: - print("Error but pdf generated anyway...") - except: - print("impossible to generate PDF") + print "Error but pdf generated anyway..." + except Exception: + print "impossible to generate PDF" diff --git a/utils/test/reporting/utils/scenarioResult.py b/utils/test/reporting/reporting/utils/scenarioResult.py index 6029d7f42..6029d7f42 100644 --- a/utils/test/reporting/utils/scenarioResult.py +++ b/utils/test/reporting/reporting/utils/scenarioResult.py diff --git a/utils/test/reporting/reporting/vsperf/__init__.py b/utils/test/reporting/reporting/vsperf/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/utils/test/reporting/reporting/vsperf/__init__.py diff --git a/utils/test/reporting/reporting/vsperf/reporting-status.py b/utils/test/reporting/reporting/vsperf/reporting-status.py new file mode 100644 index 000000000..fc4cc677d --- /dev/null +++ b/utils/test/reporting/reporting/vsperf/reporting-status.py @@ -0,0 +1,138 @@ +#!/usr/bin/python +# +# This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +import datetime +import os + +import jinja2 + +import reporting.utils.reporting_utils as rp_utils +import reporting.utils.scenarioResult as sr + +installers = rp_utils.get_config('general.installers') +PERIOD = rp_utils.get_config('general.period') + +# Logger +logger = rp_utils.getLogger("Storperf-Status") +reportingDate = datetime.datetime.now().strftime("%Y-%m-%d %H:%M") + +logger.info("*******************************************") +logger.info("* Generating reporting scenario status *") +logger.info("* Data retention = %s days *" % PERIOD) +logger.info("* *") +logger.info("*******************************************") + +# retrieve the list of storperf tests +versions = {'master'} + +# For all the versions +for version in versions: + # For all the installers + for installer in installers: + scenario_results = rp_utils.getScenarios("vsperf", + None, + installer, + None) + items = {} + scenario_result_criteria = {} + logger.info("installer %s, version %s, scenario ", installer, version) + + # From each scenarios get results list + for s, s_result in scenario_results.items(): + logger.info("---------------------------------") + logger.info("installer %s, version %s, scenario %s", installer, + version, s) + ten_criteria = len(s_result) + + ten_score = 0 + for v in s_result: + if "PASS" in v['criteria']: + ten_score += 1 + + logger.info("ten_score: %s / %s" % (ten_score, ten_criteria)) + + four_score = 0 + try: + LASTEST_TESTS = rp_utils.get_config( + 'general.nb_iteration_tests_success_criteria') + s_result.sort(key=lambda x: x['start_date']) + four_result = s_result[-LASTEST_TESTS:] + logger.debug("four_result: {}".format(four_result)) + logger.debug("LASTEST_TESTS: {}".format(LASTEST_TESTS)) + # logger.debug("four_result: {}".format(four_result)) + four_criteria = len(four_result) + for v in four_result: + if "PASS" in v['criteria']: + four_score += 1 + logger.info("4 Score: %s / %s " % (four_score, + four_criteria)) + except Exception: + logger.error("Impossible to retrieve the four_score") + + try: + s_status = (four_score * 100) / four_criteria + except ZeroDivisionError: + s_status = 0 + logger.info("Score percent = %s" % str(s_status)) + s_four_score = str(four_score) + '/' + str(four_criteria) + s_ten_score = str(ten_score) + '/' + str(ten_criteria) + s_score_percent = str(s_status) + + logger.debug(" s_status: {}".format(s_status)) + if s_status == 100: + logger.info(">>>>> scenario OK, save the information") + else: + logger.info(">>>> scenario not OK, last 4 iterations = %s, \ + last 10 days = %s" % (s_four_score, s_ten_score)) + + s_url = "" + if len(s_result) > 0: + build_tag = s_result[len(s_result)-1]['build_tag'] + logger.debug("Build tag: %s" % build_tag) + s_url = s_url = rp_utils.getJenkinsUrl(build_tag) + logger.info("last jenkins url: %s" % s_url) + + # Save daily results in a file + path_validation_file = ("./display/" + version + + "/vsperf/scenario_history.txt") + + if not os.path.exists(path_validation_file): + with open(path_validation_file, 'w') as f: + info = 'date,scenario,installer,details,score\n' + f.write(info) + + with open(path_validation_file, "a") as f: + info = (reportingDate + "," + s + "," + installer + + "," + s_ten_score + "," + + str(s_score_percent) + "\n") + f.write(info) + + scenario_result_criteria[s] = sr.ScenarioResult(s_status, + s_four_score, + s_ten_score, + s_score_percent, + s_url) + + logger.info("--------------------------") + + templateLoader = jinja2.FileSystemLoader(".") + templateEnv = jinja2.Environment(loader=templateLoader, + autoescape=True) + + TEMPLATE_FILE = "./reporting/vsperf/template/index-status-tmpl.html" + template = templateEnv.get_template(TEMPLATE_FILE) + + outputText = template.render(scenario_results=scenario_result_criteria, + installer=installer, + period=PERIOD, + version=version, + date=reportingDate) + + with open("./display/" + version + + "/vsperf/status-" + installer + ".html", "wb") as fh: + fh.write(outputText) diff --git a/utils/test/reporting/reporting/vsperf/template/index-status-tmpl.html b/utils/test/reporting/reporting/vsperf/template/index-status-tmpl.html new file mode 100644 index 000000000..7e06ef66b --- /dev/null +++ b/utils/test/reporting/reporting/vsperf/template/index-status-tmpl.html @@ -0,0 +1,114 @@ + <html> + <head> + <meta charset="utf-8"> + <!-- Bootstrap core CSS --> + <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"> + <link href="../../css/default.css" rel="stylesheet"> + <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> + <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> + <script type="text/javascript" src="http://d3js.org/d3.v2.min.js"></script> + <script type="text/javascript" src="../../js/gauge.js"></script> + <script type="text/javascript" src="../../js/trend.js"></script> + <script> + function onDocumentReady() { + // Gauge management + {% for scenario in scenario_results.keys() -%} + var gaugeScenario{{loop.index}} = gauge('#gaugeScenario{{loop.index}}'); + {%- endfor %} + // assign success rate to the gauge + function updateReadings() { + {% for scenario in scenario_results.keys() -%} + gaugeScenario{{loop.index}}.update({{scenario_results[scenario].getScorePercent()}}); + {%- endfor %} + } + updateReadings(); + } + + // trend line management + d3.csv("./scenario_history.txt", function(data) { + // *************************************** + // Create the trend line + {% for scenario in scenario_results.keys() -%} + // for scenario {{scenario}} + // Filter results + var trend{{loop.index}} = data.filter(function(row) { + return row["scenario"]=="{{scenario}}" && row["installer"]=="{{installer}}"; + }) + // Parse the date + trend{{loop.index}}.forEach(function(d) { + d.date = parseDate(d.date); + d.score = +d.score + }); + // Draw the trend line + var mytrend = trend("#trend_svg{{loop.index}}",trend{{loop.index}}) + // **************************************** + {%- endfor %} + }); + if ( !window.isLoaded ) { + window.addEventListener("load", function() { + onDocumentReady(); + }, false); + } else { + onDocumentReady(); + } + </script> + <script type="text/javascript"> + $(document).ready(function (){ + $(".btn-more").click(function() { + $(this).hide(); + $(this).parent().find(".panel-default").show(); + }); + }) + </script> + </head> + <body> + <div class="container"> + <div class="masthead"> + <h3 class="text-muted">Vsperf status page ({{version}}, {{date}})</h3> + <nav> + <ul class="nav nav-justified"> + <li class="active"><a href="http://testresults.opnfv.org/reporting/index.html">Home</a></li> + <li><a href="status-apex.html">Apex</a></li> + <li><a href="status-compass.html">Compass</a></li> + <li><a href="status-fuel.html">Fuel</a></li> + <li><a href="status-joid.html">Joid</a></li> + </ul> + </nav> + </div> +<div class="row"> + <div class="col-md-1"></div> + <div class="col-md-10"> + <div class="page-header"> + <h2>{{installer}}</h2> + </div> + <div><h1>Reported values represent the percentage of completed + + CI tests during the reporting period, where results + + were communicated to the Test Database.</h1></div> + <div class="scenario-overview"> + <div class="panel-heading"><h4><b>List of last scenarios ({{version}}) run over the last {{period}} days </b></h4></div> + <table class="table"> + <tr> + <th width="40%">Scenario</th> + <th width="20%">Status</th> + <th width="20%">Trend</th> + <th width="10%">Last 4 Iterations</th> + <th width="10%">Last 10 Days</th> + </tr> + {% for scenario,result in scenario_results.iteritems() -%} + <tr class="tr-ok"> + <td><a href="{{scenario_results[scenario].getLastUrl()}}">{{scenario}}</a></td> + <td><div id="gaugeScenario{{loop.index}}"></div></td> + <td><div id="trend_svg{{loop.index}}"></div></td> + <td>{{scenario_results[scenario].getFourDaysScore()}}</td> + <td>{{scenario_results[scenario].getTenDaysScore()}}</td> + </tr> + {%- endfor %} + </table> + </div> + + + </div> + <div class="col-md-1"></div> +</div> diff --git a/utils/test/reporting/reporting/yardstick/__init__.py b/utils/test/reporting/reporting/yardstick/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/utils/test/reporting/reporting/yardstick/__init__.py diff --git a/utils/test/reporting/yardstick/img/gauge_0.png b/utils/test/reporting/reporting/yardstick/img/gauge_0.png Binary files differindex ecefc0e66..ecefc0e66 100644 --- a/utils/test/reporting/yardstick/img/gauge_0.png +++ b/utils/test/reporting/reporting/yardstick/img/gauge_0.png diff --git a/utils/test/reporting/yardstick/img/gauge_100.png b/utils/test/reporting/reporting/yardstick/img/gauge_100.png Binary files differindex e199e1561..e199e1561 100644 --- a/utils/test/reporting/yardstick/img/gauge_100.png +++ b/utils/test/reporting/reporting/yardstick/img/gauge_100.png diff --git a/utils/test/reporting/yardstick/img/gauge_16.7.png b/utils/test/reporting/reporting/yardstick/img/gauge_16.7.png Binary files differindex 3e3993c3b..3e3993c3b 100644 --- a/utils/test/reporting/yardstick/img/gauge_16.7.png +++ b/utils/test/reporting/reporting/yardstick/img/gauge_16.7.png diff --git a/utils/test/reporting/yardstick/img/gauge_25.png b/utils/test/reporting/reporting/yardstick/img/gauge_25.png Binary files differindex 4923659b9..4923659b9 100644 --- a/utils/test/reporting/yardstick/img/gauge_25.png +++ b/utils/test/reporting/reporting/yardstick/img/gauge_25.png diff --git a/utils/test/reporting/yardstick/img/gauge_33.3.png b/utils/test/reporting/reporting/yardstick/img/gauge_33.3.png Binary files differindex 364574b4a..364574b4a 100644 --- a/utils/test/reporting/yardstick/img/gauge_33.3.png +++ b/utils/test/reporting/reporting/yardstick/img/gauge_33.3.png diff --git a/utils/test/reporting/yardstick/img/gauge_41.7.png b/utils/test/reporting/reporting/yardstick/img/gauge_41.7.png Binary files differindex 8c3e910fa..8c3e910fa 100644 --- a/utils/test/reporting/yardstick/img/gauge_41.7.png +++ b/utils/test/reporting/reporting/yardstick/img/gauge_41.7.png diff --git a/utils/test/reporting/yardstick/img/gauge_50.png b/utils/test/reporting/reporting/yardstick/img/gauge_50.png Binary files differindex 2874b9fcf..2874b9fcf 100644 --- a/utils/test/reporting/yardstick/img/gauge_50.png +++ b/utils/test/reporting/reporting/yardstick/img/gauge_50.png diff --git a/utils/test/reporting/yardstick/img/gauge_58.3.png b/utils/test/reporting/reporting/yardstick/img/gauge_58.3.png Binary files differindex beedc8aa9..beedc8aa9 100644 --- a/utils/test/reporting/yardstick/img/gauge_58.3.png +++ b/utils/test/reporting/reporting/yardstick/img/gauge_58.3.png diff --git a/utils/test/reporting/yardstick/img/gauge_66.7.png b/utils/test/reporting/reporting/yardstick/img/gauge_66.7.png Binary files differindex 93f44d133..93f44d133 100644 --- a/utils/test/reporting/yardstick/img/gauge_66.7.png +++ b/utils/test/reporting/reporting/yardstick/img/gauge_66.7.png diff --git a/utils/test/reporting/yardstick/img/gauge_75.png b/utils/test/reporting/reporting/yardstick/img/gauge_75.png Binary files differindex 9fc261ff8..9fc261ff8 100644 --- a/utils/test/reporting/yardstick/img/gauge_75.png +++ b/utils/test/reporting/reporting/yardstick/img/gauge_75.png diff --git a/utils/test/reporting/yardstick/img/gauge_8.3.png b/utils/test/reporting/reporting/yardstick/img/gauge_8.3.png Binary files differindex 59f86571e..59f86571e 100644 --- a/utils/test/reporting/yardstick/img/gauge_8.3.png +++ b/utils/test/reporting/reporting/yardstick/img/gauge_8.3.png diff --git a/utils/test/reporting/yardstick/img/gauge_83.3.png b/utils/test/reporting/reporting/yardstick/img/gauge_83.3.png Binary files differindex 27ae4ec54..27ae4ec54 100644 --- a/utils/test/reporting/yardstick/img/gauge_83.3.png +++ b/utils/test/reporting/reporting/yardstick/img/gauge_83.3.png diff --git a/utils/test/reporting/yardstick/img/gauge_91.7.png b/utils/test/reporting/reporting/yardstick/img/gauge_91.7.png Binary files differindex 280865714..280865714 100644 --- a/utils/test/reporting/yardstick/img/gauge_91.7.png +++ b/utils/test/reporting/reporting/yardstick/img/gauge_91.7.png diff --git a/utils/test/reporting/yardstick/img/icon-nok.png b/utils/test/reporting/reporting/yardstick/img/icon-nok.png Binary files differindex 526b5294b..526b5294b 100644 --- a/utils/test/reporting/yardstick/img/icon-nok.png +++ b/utils/test/reporting/reporting/yardstick/img/icon-nok.png diff --git a/utils/test/reporting/yardstick/img/icon-ok.png b/utils/test/reporting/reporting/yardstick/img/icon-ok.png Binary files differindex 3a9de2e89..3a9de2e89 100644 --- a/utils/test/reporting/yardstick/img/icon-ok.png +++ b/utils/test/reporting/reporting/yardstick/img/icon-ok.png diff --git a/utils/test/reporting/yardstick/img/weather-clear.png b/utils/test/reporting/reporting/yardstick/img/weather-clear.png Binary files differindex a0d967750..a0d967750 100644 --- a/utils/test/reporting/yardstick/img/weather-clear.png +++ b/utils/test/reporting/reporting/yardstick/img/weather-clear.png diff --git a/utils/test/reporting/yardstick/img/weather-few-clouds.png b/utils/test/reporting/reporting/yardstick/img/weather-few-clouds.png Binary files differindex acfa78398..acfa78398 100644 --- a/utils/test/reporting/yardstick/img/weather-few-clouds.png +++ b/utils/test/reporting/reporting/yardstick/img/weather-few-clouds.png diff --git a/utils/test/reporting/yardstick/img/weather-overcast.png b/utils/test/reporting/reporting/yardstick/img/weather-overcast.png Binary files differindex 4296246d0..4296246d0 100644 --- a/utils/test/reporting/yardstick/img/weather-overcast.png +++ b/utils/test/reporting/reporting/yardstick/img/weather-overcast.png diff --git a/utils/test/reporting/yardstick/img/weather-storm.png b/utils/test/reporting/reporting/yardstick/img/weather-storm.png Binary files differindex 956f0e20f..956f0e20f 100644 --- a/utils/test/reporting/yardstick/img/weather-storm.png +++ b/utils/test/reporting/reporting/yardstick/img/weather-storm.png diff --git a/utils/test/reporting/yardstick/index.html b/utils/test/reporting/reporting/yardstick/index.html index 488f1421d..488f1421d 100644 --- a/utils/test/reporting/yardstick/index.html +++ b/utils/test/reporting/reporting/yardstick/index.html diff --git a/utils/test/reporting/yardstick/reporting-status.py b/utils/test/reporting/reporting/yardstick/reporting-status.py index 12f42ca31..6584f4e8d 100644 --- a/utils/test/reporting/yardstick/reporting-status.py +++ b/utils/test/reporting/reporting/yardstick/reporting-status.py @@ -7,14 +7,13 @@ # http://www.apache.org/licenses/LICENSE-2.0 # import datetime -import jinja2 import os -import utils.scenarioResult as sr -from scenarios import config as cf +import jinja2 -# manage conf -import utils.reporting_utils as rp_utils +import reporting.utils.scenarioResult as sr +import reporting.utils.reporting_utils as rp_utils +from scenarios import config as cf installers = rp_utils.get_config('general.installers') versions = rp_utils.get_config('general.versions') @@ -106,7 +105,7 @@ for version in versions: templateEnv = jinja2.Environment(loader=templateLoader, autoescape=True) - TEMPLATE_FILE = "./yardstick/template/index-status-tmpl.html" + TEMPLATE_FILE = "./reporting/yardstick/template/index-status-tmpl.html" template = templateEnv.get_template(TEMPLATE_FILE) outputText = template.render(scenario_results=scenario_result_criteria, diff --git a/utils/test/reporting/yardstick/scenarios.py b/utils/test/reporting/reporting/yardstick/scenarios.py index 26e8c8bb0..26e8c8bb0 100644 --- a/utils/test/reporting/yardstick/scenarios.py +++ b/utils/test/reporting/reporting/yardstick/scenarios.py diff --git a/utils/test/reporting/yardstick/template/index-status-tmpl.html b/utils/test/reporting/reporting/yardstick/template/index-status-tmpl.html index 77ba9502f..77ba9502f 100644 --- a/utils/test/reporting/yardstick/template/index-status-tmpl.html +++ b/utils/test/reporting/reporting/yardstick/template/index-status-tmpl.html diff --git a/utils/test/reporting/requirements.txt b/utils/test/reporting/requirements.txt new file mode 100644 index 000000000..344064ddc --- /dev/null +++ b/utils/test/reporting/requirements.txt @@ -0,0 +1,7 @@ +pdfkit>=0.6.1 # MIT +wkhtmltopdf-pack>=0.12.3 # MIT +PyYAML>=3.10.0 # MIT +simplejson>=2.2.0 # MIT +Jinja2!=2.9.0,!=2.9.1,!=2.9.2,!=2.9.3,!=2.9.4,>=2.8 # BSD License (3 clause) +requests!=2.12.2,>=2.10.0 # Apache-2.0 +tornado>=4.4.2 # Apache-2.0 diff --git a/utils/test/reporting/run_test.sh b/utils/test/reporting/run_test.sh index 8c674ce5f..b83b550b8 100755 --- a/utils/test/reporting/run_test.sh +++ b/utils/test/reporting/run_test.sh @@ -1,44 +1,3 @@ #!/bin/bash -set -o errexit -set -o pipefail - - -# Get script directory -SCRIPTDIR=`dirname $0` - -# Creating virtual environment -if [ ! -z $VIRTUAL_ENV ]; then - venv=$VIRTUAL_ENV -else - venv=$SCRIPTDIR/.venv - virtualenv $venv -fi - -source $venv/bin/activate - -export CONFIG_REPORTING_YAML=$SCRIPTDIR/reporting.yaml - -# *************** -# Run unit tests -# *************** -echo "Running unit tests..." - -# install python packages -easy_install -U setuptools -easy_install -U pip -pip install -r $SCRIPTDIR/docker/requirements.pip -pip install -e $SCRIPTDIR - -python $SCRIPTDIR/setup.py develop - -# unit tests -# TODO: remove cover-erase -# To be deleted when all functest packages will be listed -nosetests --with-xunit \ - --cover-package=$SCRIPTDIR/utils \ - --with-coverage \ - --cover-xml \ - $SCRIPTDIR/tests/unit -rc=$? - -deactivate +tox +exit $? diff --git a/utils/test/reporting/setup.cfg b/utils/test/reporting/setup.cfg new file mode 100644 index 000000000..9543945c7 --- /dev/null +++ b/utils/test/reporting/setup.cfg @@ -0,0 +1,12 @@ +[metadata] +name = reporting +version = 1 +home-page = https://wiki.opnfv.org/display/testing + +[files] +packages = + reporting + api +scripts = + docker/reporting.sh + docker/web_server.sh diff --git a/utils/test/reporting/setup.py b/utils/test/reporting/setup.py index 627785eca..17849f67b 100644 --- a/utils/test/reporting/setup.py +++ b/utils/test/reporting/setup.py @@ -1,22 +1,23 @@ -############################################################################## +#!/usr/bin/env python + +# Copyright (c) 2017 Orange and others. +# # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## -from setuptools import setup, find_packages +# pylint: disable=missing-docstring +import setuptools +# In python < 2.7.4, a lazy loading of package `pbr` will break +# setuptools if some other modules registered functions in `atexit`. +# solution from: http://bugs.python.org/issue15881#msg170215 +try: + import multiprocessing # noqa +except ImportError: + pass -setup( - name="reporting", - version="master", - packages=find_packages(), - include_package_data=True, - package_data={ - }, - url="https://www.opnfv.org", - install_requires=["coverage==4.1", - "mock==1.3.0", - "nose==1.3.7"], -) +setuptools.setup( + setup_requires=['pbr>=1.8'], + pbr=True) diff --git a/utils/test/reporting/test-requirements.txt b/utils/test/reporting/test-requirements.txt new file mode 100644 index 000000000..738f50862 --- /dev/null +++ b/utils/test/reporting/test-requirements.txt @@ -0,0 +1,5 @@ +coverage>=4.0 # Apache-2.0 +mock>=2.0 # BSD +nose # LGPL +flake8<2.6.0,>=2.5.4 # MIT +pylint==1.4.5 # GPLv2 diff --git a/utils/test/reporting/tox.ini b/utils/test/reporting/tox.ini new file mode 100644 index 000000000..2df503050 --- /dev/null +++ b/utils/test/reporting/tox.ini @@ -0,0 +1,27 @@ +[tox] +envlist = pep8,pylint,py27 + +[testenv] +usedevelop = True +deps = + -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +commands = nosetests --with-xunit \ + --with-coverage \ + --cover-tests \ + --cover-package=reporting \ + --cover-xml \ + --cover-html \ + reporting/tests/unit + +[testenv:pep8] +basepython = python2.7 +commands = flake8 + +[testenv:pylint] +basepython = python2.7 +whitelist_externals = bash +commands = + bash -c "\ + pylint --disable=locally-disabled reporting| \ + tee pylint.out | sed -ne '/Raw metrics/,//p'" |