summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/create_pod_file.py19
-rwxr-xr-xutils/fetch_os_creds.sh135
-rwxr-xr-xutils/jenkins-jnlp-connect.sh4
-rw-r--r--utils/push-test-logs.sh7
-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.txt3
-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.cfg32
-rw-r--r--utils/test/reporting/api/setup.py9
-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/Dockerfile33
-rw-r--r--utils/test/reporting/docker/nginx.conf4
-rwxr-xr-xutils/test/reporting/docker/reporting.sh68
-rw-r--r--utils/test/reporting/docker/requirements.pip1
-rw-r--r--utils/test/reporting/docker/supervisor.conf15
-rwxr-xr-xutils/test/reporting/docker/web_server.sh14
-rw-r--r--utils/test/reporting/docs/_build/.buildinfo4
-rw-r--r--utils/test/reporting/docs/_build/.doctrees/environment.picklebin0 -> 4207 bytes
-rw-r--r--utils/test/reporting/docs/_build/.doctrees/index.doctreebin0 -> 4892 bytes
-rw-r--r--utils/test/reporting/docs/conf.py341
-rw-r--r--utils/test/reporting/docs/index.rst16
-rwxr-xr-xutils/test/reporting/pages/angular.sh5
-rw-r--r--utils/test/reporting/pages/app/index.html3
-rw-r--r--utils/test/reporting/pages/app/scripts/controllers/table.controller.js555
-rw-r--r--utils/test/reporting/pages/app/scripts/controllers/testvisual.controller.js17
-rw-r--r--utils/test/reporting/pages/app/scripts/factory/table.factory.js52
-rw-r--r--utils/test/reporting/pages/app/views/commons/table.html28
-rw-r--r--utils/test/reporting/pages/app/views/commons/testCaseVisual.html4
-rwxr-xr-xutils/test/reporting/pages/config.sh3
-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)bin3644 -> 3644 bytes
-rw-r--r--utils/test/reporting/reporting/functest/img/gauge_100.png (renamed from utils/test/reporting/functest/img/gauge_100.png)bin3191 -> 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)bin3170 -> 3170 bytes
-rw-r--r--utils/test/reporting/reporting/functest/img/gauge_25.png (renamed from utils/test/reporting/functest/img/gauge_25.png)bin3108 -> 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)bin3081 -> 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)bin3169 -> 3169 bytes
-rw-r--r--utils/test/reporting/reporting/functest/img/gauge_50.png (renamed from utils/test/reporting/functest/img/gauge_50.png)bin3123 -> 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)bin3161 -> 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)bin3069 -> 3069 bytes
-rw-r--r--utils/test/reporting/reporting/functest/img/gauge_75.png (renamed from utils/test/reporting/functest/img/gauge_75.png)bin3030 -> 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)bin2993 -> 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)bin3122 -> 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)bin3008 -> 3008 bytes
-rw-r--r--utils/test/reporting/reporting/functest/img/icon-nok.png (renamed from utils/test/reporting/functest/img/icon-nok.png)bin2317 -> 2317 bytes
-rw-r--r--utils/test/reporting/reporting/functest/img/icon-ok.png (renamed from utils/test/reporting/functest/img/icon-ok.png)bin4063 -> 4063 bytes
-rw-r--r--utils/test/reporting/reporting/functest/img/weather-clear.png (renamed from utils/test/reporting/functest/img/weather-clear.png)bin1560 -> 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)bin1927 -> 1927 bytes
-rw-r--r--utils/test/reporting/reporting/functest/img/weather-overcast.png (renamed from utils/test/reporting/functest/img/weather-overcast.png)bin1588 -> 1588 bytes
-rw-r--r--utils/test/reporting/reporting/functest/img/weather-storm.png (renamed from utils/test/reporting/functest/img/weather-storm.png)bin2137 -> 2137 bytes
-rw-r--r--utils/test/reporting/reporting/functest/index.html (renamed from utils/test/reporting/functest/index.html)0
-rwxr-xr-xutils/test/reporting/reporting/functest/reporting-status.py (renamed from utils/test/reporting/functest/reporting-status.py)8
-rwxr-xr-xutils/test/reporting/reporting/functest/reporting-tempest.py (renamed from utils/test/reporting/functest/reporting-tempest.py)21
-rwxr-xr-xutils/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)2
-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 (renamed from utils/test/reporting/pages/app/scripts/app.config.js)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__.py0
-rw-r--r--utils/test/reporting/reporting/utils/reporting_utils.py (renamed from utils/test/reporting/utils/reporting_utils.py)47
-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/yardstick/__init__.py0
-rw-r--r--utils/test/reporting/reporting/yardstick/img/gauge_0.png (renamed from utils/test/reporting/yardstick/img/gauge_0.png)bin3644 -> 3644 bytes
-rw-r--r--utils/test/reporting/reporting/yardstick/img/gauge_100.png (renamed from utils/test/reporting/yardstick/img/gauge_100.png)bin3191 -> 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)bin3170 -> 3170 bytes
-rw-r--r--utils/test/reporting/reporting/yardstick/img/gauge_25.png (renamed from utils/test/reporting/yardstick/img/gauge_25.png)bin3108 -> 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)bin3081 -> 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)bin3169 -> 3169 bytes
-rw-r--r--utils/test/reporting/reporting/yardstick/img/gauge_50.png (renamed from utils/test/reporting/yardstick/img/gauge_50.png)bin3123 -> 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)bin3161 -> 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)bin3069 -> 3069 bytes
-rw-r--r--utils/test/reporting/reporting/yardstick/img/gauge_75.png (renamed from utils/test/reporting/yardstick/img/gauge_75.png)bin3030 -> 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)bin2993 -> 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)bin3122 -> 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)bin3008 -> 3008 bytes
-rw-r--r--utils/test/reporting/reporting/yardstick/img/icon-nok.png (renamed from utils/test/reporting/yardstick/img/icon-nok.png)bin2317 -> 2317 bytes
-rw-r--r--utils/test/reporting/reporting/yardstick/img/icon-ok.png (renamed from utils/test/reporting/yardstick/img/icon-ok.png)bin4063 -> 4063 bytes
-rw-r--r--utils/test/reporting/reporting/yardstick/img/weather-clear.png (renamed from utils/test/reporting/yardstick/img/weather-clear.png)bin1560 -> 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)bin1927 -> 1927 bytes
-rw-r--r--utils/test/reporting/reporting/yardstick/img/weather-overcast.png (renamed from utils/test/reporting/yardstick/img/weather-overcast.png)bin1588 -> 1588 bytes
-rw-r--r--utils/test/reporting/reporting/yardstick/img/weather-storm.png (renamed from utils/test/reporting/yardstick/img/weather-storm.png)bin2137 -> 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)2
-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.txt7
-rwxr-xr-xutils/test/reporting/run_test.sh3
-rwxr-xr-xutils/test/reporting/run_unit_tests.sh43
-rw-r--r--utils/test/reporting/setup.cfg12
-rw-r--r--utils/test/reporting/setup.py31
-rw-r--r--utils/test/reporting/test-requirements.txt5
-rw-r--r--utils/test/reporting/tox.ini27
-rw-r--r--utils/test/testapi/.gitignore7
-rw-r--r--utils/test/testapi/3rd_party/static/testapi-ui/app.js40
-rw-r--r--utils/test/testapi/3rd_party/static/testapi-ui/components/guidelines/guidelines.html80
-rw-r--r--utils/test/testapi/3rd_party/static/testapi-ui/components/guidelines/guidelinesController.js322
-rw-r--r--utils/test/testapi/3rd_party/static/testapi-ui/components/guidelines/partials/guidelineDetails.html50
-rw-r--r--utils/test/testapi/3rd_party/static/testapi-ui/components/guidelines/partials/testListModal.html46
-rw-r--r--utils/test/testapi/3rd_party/static/testapi-ui/components/pods/pods.html71
-rw-r--r--utils/test/testapi/3rd_party/static/testapi-ui/components/pods/podsController.js119
-rw-r--r--utils/test/testapi/3rd_party/static/testapi-ui/components/results/results.html20
-rw-r--r--utils/test/testapi/3rd_party/static/testapi-ui/components/results/resultsController.js62
-rw-r--r--utils/test/testapi/3rd_party/static/testapi-ui/index.html2
-rw-r--r--utils/test/testapi/3rd_party/static/testapi-ui/shared/header/header.html4
-rw-r--r--utils/test/testapi/deployment/deploy.py10
-rw-r--r--utils/test/testapi/deployment/docker-compose.yml.template2
-rw-r--r--utils/test/testapi/docker/Dockerfile4
-rwxr-xr-xutils/test/testapi/docker/prepare-env.sh7
-rw-r--r--utils/test/testapi/etc/config.ini9
-rw-r--r--utils/test/testapi/htmlize/htmlize.py5
-rwxr-xr-xutils/test/testapi/install.sh30
-rw-r--r--utils/test/testapi/opnfv_testapi/cmd/server.py27
-rw-r--r--utils/test/testapi/opnfv_testapi/common/check.py11
-rw-r--r--utils/test/testapi/opnfv_testapi/common/config.py41
-rw-r--r--utils/test/testapi/opnfv_testapi/common/message.py4
-rw-r--r--utils/test/testapi/opnfv_testapi/common/raises.py4
-rw-r--r--utils/test/testapi/opnfv_testapi/db/__init__.py0
-rw-r--r--utils/test/testapi/opnfv_testapi/db/api.py38
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/handlers.py107
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/models.py23
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/result_handlers.py94
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/result_models.py8
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py703
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/scenario_models.py52
-rw-r--r--utils/test/testapi/opnfv_testapi/router/url_mappings.py20
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/common/noparam.ini4
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/common/normal.ini4
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/common/nosection.ini4
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/common/notboolean.ini4
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/common/notint.ini4
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/common/test_config.py27
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/conftest.py8
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/executor.py14
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/fake_pymongo.py75
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/resources/__init__.py0
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/resources/scenario-c1.json (renamed from utils/test/testapi/opnfv_testapi/tests/unit/scenario-c1.json)0
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/resources/scenario-c2.json (renamed from utils/test/testapi/opnfv_testapi/tests/unit/scenario-c2.json)4
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/resources/test_base.py (renamed from utils/test/testapi/opnfv_testapi/tests/unit/test_base.py)63
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/resources/test_fake_pymongo.py (renamed from utils/test/testapi/opnfv_testapi/tests/unit/test_fake_pymongo.py)0
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/resources/test_pod.py (renamed from utils/test/testapi/opnfv_testapi/tests/unit/test_pod.py)3
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/resources/test_project.py (renamed from utils/test/testapi/opnfv_testapi/tests/unit/test_project.py)3
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/resources/test_result.py (renamed from utils/test/testapi/opnfv_testapi/tests/unit/test_result.py)86
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py449
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/resources/test_testcase.py (renamed from utils/test/testapi/opnfv_testapi/tests/unit/test_testcase.py)2
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/resources/test_token.py (renamed from utils/test/testapi/opnfv_testapi/tests/unit/test_token.py)5
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/resources/test_version.py (renamed from utils/test/testapi/opnfv_testapi/tests/unit/test_version.py)2
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/test_scenario.py360
-rw-r--r--utils/test/testapi/opnfv_testapi/tornado_swagger/swagger.py17
-rw-r--r--utils/test/testapi/opnfv_testapi/ui/auth/constants.py2
-rw-r--r--utils/test/testapi/opnfv_testapi/ui/auth/sign.py32
-rw-r--r--utils/test/testapi/opnfv_testapi/ui/auth/user.py5
-rw-r--r--utils/test/testapi/opnfv_testapi/ui/root.py4
-rw-r--r--utils/test/testapi/requirements.txt10
-rwxr-xr-xutils/test/testapi/run_test.sh40
-rw-r--r--utils/test/testapi/setup.py15
-rw-r--r--utils/test/testapi/test-requirements.txt10
-rw-r--r--utils/test/testapi/tox.ini10
-rw-r--r--utils/test/testapi/update/templates/backup_mongodb.py1
-rw-r--r--utils/test/testapi/update/templates/update_mongodb.py1
-rw-r--r--utils/upload-artifact.sh48
178 files changed, 3061 insertions, 1995 deletions
diff --git a/utils/create_pod_file.py b/utils/create_pod_file.py
index 197e4933c..def5ecca8 100644
--- a/utils/create_pod_file.py
+++ b/utils/create_pod_file.py
@@ -12,6 +12,8 @@ parser.add_argument("-u", "--user", help="Give username of this pod")
parser.add_argument("-k", "--key", help="Give key file of the user")
parser.add_argument("-p", "--password", help="Give password of the user")
parser.add_argument("-f", "--filepath", help="Give dest path of output file")
+parser.add_argument("-s", "--sshkey", default="/root/.ssh/id_rsa",
+ help="Give the path for ssh key")
args = parser.parse_args()
@@ -49,7 +51,7 @@ def get_with_passwd():
args.user, installer_pwd=args.password)
-def create_file(handler):
+def create_file(handler, INSTALLER_TYPE):
"""
Create the yaml file of nodes info.
As Yardstick required, node name must be node1, node2, ... and node1 must
@@ -62,34 +64,37 @@ def create_file(handler):
nodes = handler.nodes
node_list = []
index = 1
+ user = 'root'
+ if INSTALLER_TYPE == 'apex':
+ user = 'heat-admin'
for node in nodes:
try:
if node.roles[0].lower() == "controller":
node_info = {'name': "node%s" % index, 'role': node.roles[0],
- 'ip': node.ip, 'user': 'root'}
+ 'ip': node.ip, 'user': user}
node_list.append(node_info)
index += 1
except Exception:
node_info = {'name': node.name, 'role': 'unknown', 'ip': node.ip,
- 'user': 'root'}
+ 'user': user}
node_list.append(node_info)
for node in nodes:
try:
if node.roles[0].lower() == "compute":
node_info = {'name': "node%s" % index, 'role': node.roles[0],
- 'ip': node.ip, 'user': 'root'}
+ 'ip': node.ip, 'user': user}
node_list.append(node_info)
index += 1
except Exception:
node_info = {'name': node.name, 'role': 'unknown', 'ip': node.ip,
- 'user': 'root'}
+ 'user': user}
node_list.append(node_info)
if args.INSTALLER_TYPE == 'compass':
for item in node_list:
item['password'] = 'root'
else:
for item in node_list:
- item['key_filename'] = '/root/.ssh/id_rsa'
+ item['key_filename'] = args.sshkey
data = {'nodes': node_list}
with open(args.filepath, "w") as fw:
yaml.dump(data, fw)
@@ -105,7 +110,7 @@ def main():
if not handler:
print("Error: failed to get the node's handler.")
return 1
- create_file(handler)
+ create_file(handler, args.INSTALLER_TYPE)
if __name__ == '__main__':
diff --git a/utils/fetch_os_creds.sh b/utils/fetch_os_creds.sh
index 458bbda3b..377930d66 100755
--- a/utils/fetch_os_creds.sh
+++ b/utils/fetch_os_creds.sh
@@ -12,8 +12,9 @@ set -o nounset
set -o pipefail
usage() {
- echo "usage: $0 [-v] -d <destination> -i <installer_type> -a <installer_ip>" >&2
+ echo "usage: $0 [-v] -d <destination> -i <installer_type> -a <installer_ip> [-o <os_cacert>] [-s <ssh_key>]" >&2
echo "[-v] Virtualized deployment" >&2
+ echo "[-s <ssh_key>] Path to ssh key. For MCP deployments only" >&2
}
info () {
@@ -53,11 +54,13 @@ swap_to_public() {
: ${DEPLOY_TYPE:=''}
#Get options
-while getopts ":d:i:a:h:v" optchar; do
+while getopts ":d:i:a:h:s:o:v" optchar; do
case "${optchar}" in
d) dest_path=${OPTARG} ;;
i) installer_type=${OPTARG} ;;
a) installer_ip=${OPTARG} ;;
+ s) ssh_key=${OPTARG} ;;
+ o) os_cacert=${OPTARG} ;;
v) DEPLOY_TYPE="virt" ;;
*) echo "Non-option argument: '-${OPTARG}'" >&2
usage
@@ -68,8 +71,12 @@ done
# set vars from env if not provided by user as options
dest_path=${dest_path:-$HOME/opnfv-openrc.sh}
+os_cacert=${os_cacert:-$HOME/os_cacert}
installer_type=${installer_type:-$INSTALLER_TYPE}
installer_ip=${installer_ip:-$INSTALLER_IP}
+if [ "${installer_type}" == "fuel" ] && [ "${BRANCH}" == "master" ]; then
+ installer_ip=${SALT_MASTER_IP}
+fi
if [ -z $dest_path ] || [ -z $installer_type ] || [ -z $installer_ip ]; then
usage
@@ -89,40 +96,49 @@ ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
# Start fetching the files
if [ "$installer_type" == "fuel" ]; then
- #ip_fuel="10.20.0.2"
verify_connectivity $installer_ip
+ if [ "${BRANCH}" == "master" ]; then
+ ssh_key=${ssh_key:-$SSH_KEY}
+ if [ -z $ssh_key ] || [ ! -f $ssh_key ]; then
+ error "Please provide path to existing ssh key for mcp deployment."
+ exit 2
+ fi
+ ssh_options+=" -i ${ssh_key}"
- env=$(sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} \
- 'fuel env'|grep operational|head -1|awk '{print $1}') &> /dev/null
- if [ -z $env ]; then
- error "No operational environment detected in Fuel"
- fi
- env_id="${FUEL_ENV:-$env}"
+ # retrieving controller vip
+ controller_ip=$(ssh 2>/dev/null ${ssh_options} ubuntu@${installer_ip} \
+ "sudo salt --out txt 'ctl*' pillar.get _param:openstack_control_address | awk '{print \$2; exit}'" | \
+ sed 's/ //g') &> /dev/null
- # Check if controller is alive (online='True')
- controller_ip=$(sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} \
- "fuel node --env ${env_id} | grep controller | grep 'True\| 1' | awk -F\| '{print \$5}' | head -1" | \
- sed 's/ //g') &> /dev/null
+ info "Fetching rc file from controller $controller_ip..."
+ ssh ${ssh_options} ubuntu@${controller_ip} "sudo cat /root/keystonercv3" > $dest_path
- if [ -z $controller_ip ]; then
- error "The controller $controller_ip is not up. Please check that the POD is correctly deployed."
- fi
+ if [[ $BUILD_TAG =~ "baremetal" ]]; then
+ ssh ${ssh_options} ubuntu@${installer_ip} "cat /etc/ssl/certs/os_cacert" > $os_cacert
+ fi
+ else
+ #ip_fuel="10.20.0.2"
+ env=$(sshpass -p r00tme ssh 2>/dev/null ${ssh_options} root@${installer_ip} \
+ 'fuel env'|grep operational|head -1|awk '{print $1}') &> /dev/null
+ if [ -z $env ]; then
+ error "No operational environment detected in Fuel"
+ fi
+ env_id="${FUEL_ENV:-$env}"
- info "Fetching rc file from controller $controller_ip..."
- sshpass -p r00tme ssh 2>/dev/null $ssh_options root@${installer_ip} \
- "scp $ssh_options ${controller_ip}:/root/openrc ." &> /dev/null
- sshpass -p r00tme scp 2>/dev/null $ssh_options root@${installer_ip}:~/openrc $dest_path &> /dev/null
+ # Check if controller is alive (online='True')
+ controller_ip=$(sshpass -p r00tme ssh 2>/dev/null ${ssh_options} root@${installer_ip} \
+ "fuel node --env ${env_id} | grep controller | grep 'True\| 1' | awk -F\| '{print \$5}' | head -1" | \
+ sed 's/ //g') &> /dev/null
- #This file contains the mgmt keystone API, we need the public one for our rc file
- admin_ip=$(cat $dest_path | grep "OS_AUTH_URL" | sed 's/^.*\=//' | sed "s/^\([\"']\)\(.*\)\1\$/\2/g" | sed s'/\/$//')
- public_ip=$(sshpass -p r00tme ssh $ssh_options root@${installer_ip} \
- "ssh ${controller_ip} 'source openrc; openstack endpoint list'" \
- | grep keystone | grep public | sed 's/ /\n/g' | grep ^http | head -1) &> /dev/null
- #| grep http | head -1 | cut -d '|' -f 4 | sed 's/v1\/.*/v1\//' | sed 's/ //g') &> /dev/null
- #NOTE: this is super ugly sed 's/v1\/.*/v1\//'OS_AUTH_URL
- # but sometimes the output of endpoint-list is like this: http://172.30.9.70:8004/v1/%(tenant_id)s
- # Fuel virtual need a fix
+ if [ -z $controller_ip ]; then
+ error "The controller $controller_ip is not up. Please check that the POD is correctly deployed."
+ fi
+ info "Fetching rc file from controller $controller_ip..."
+ sshpass -p r00tme ssh 2>/dev/null ${ssh_options} root@${installer_ip} \
+ "scp ${ssh_options} ${controller_ip}:/root/openrc ." &> /dev/null
+ sshpass -p r00tme scp 2>/dev/null ${ssh_options} root@${installer_ip}:~/openrc $dest_path &> /dev/null
+ fi
#convert to v3 URL
auth_url=$(cat $dest_path|grep AUTH_URL)
if [[ -z `echo $auth_url |grep v3` ]]; then
@@ -143,36 +159,41 @@ elif [ "$installer_type" == "apex" ]; then
sudo scp $ssh_options root@$installer_ip:/home/stack/overcloudrc.v3 $dest_path
elif [ "$installer_type" == "compass" ]; then
- verify_connectivity $installer_ip
- controller_ip=$(sshpass -p'root' ssh 2>/dev/null $ssh_options root@${installer_ip} \
- 'mysql -ucompass -pcompass -Dcompass -e"select * from cluster;"' \
- | awk -F"," '{for(i=1;i<NF;i++)if($i~/\"127.0.0.1\"/) {print $(i+2);break;}}' \
- | grep -oP "\d+.\d+.\d+.\d+")
-
- if [ -z $controller_ip ]; then
- error "The controller $controller_ip is not up. Please check that the POD is correctly deployed."
- fi
-
- info "Fetching rc file from controller $controller_ip..."
- sshpass -p root ssh 2>/dev/null $ssh_options root@${installer_ip} \
- "scp $ssh_options ${controller_ip}:/opt/admin-openrc.sh ." &> /dev/null
- sshpass -p root scp 2>/dev/null $ssh_options root@${installer_ip}:~/admin-openrc.sh $dest_path &> /dev/null
-
- info "This file contains the mgmt keystone API, we need the public one for our rc file"
-
- if grep "OS_AUTH_URL.*v2" $dest_path > /dev/null 2>&1 ; then
- public_ip=$(sshpass -p root ssh $ssh_options root@${installer_ip} \
- "ssh ${controller_ip} 'source /opt/admin-openrc.sh; openstack endpoint show identity '" \
- | grep publicurl | awk '{print $4}')
+ if [ "${BRANCH}" == "master" ]; then
+ sudo docker cp compass-tasks:/opt/openrc $dest_path &> /dev/null
+ sudo chown $(whoami):$(whoami) $dest_path
+ sudo docker cp compass-tasks:/opt/os_cacert $os_cacert &> /dev/null
else
- public_ip=$(sshpass -p root ssh $ssh_options root@${installer_ip} \
- "ssh ${controller_ip} 'source /opt/admin-openrc.sh; \
- openstack endpoint list --interface public --service identity '" \
- | grep identity | awk '{print $14}')
- fi
- info "public_ip: $public_ip"
- swap_to_public $public_ip
+ verify_connectivity $installer_ip
+ controller_ip=$(sshpass -p'root' ssh 2>/dev/null $ssh_options root@${installer_ip} \
+ 'mysql -ucompass -pcompass -Dcompass -e"select * from cluster;"' \
+ | awk -F"," '{for(i=1;i<NF;i++)if($i~/\"127.0.0.1\"/) {print $(i+2);break;}}' \
+ | grep -oP "\d+.\d+.\d+.\d+")
+
+ if [ -z $controller_ip ]; then
+ error "The controller $controller_ip is not up. Please check that the POD is correctly deployed."
+ fi
+ info "Fetching rc file from controller $controller_ip..."
+ sshpass -p root ssh 2>/dev/null $ssh_options root@${installer_ip} \
+ "scp $ssh_options ${controller_ip}:/opt/admin-openrc.sh ." &> /dev/null
+ sshpass -p root scp 2>/dev/null $ssh_options root@${installer_ip}:~/admin-openrc.sh $dest_path &> /dev/null
+
+ info "This file contains the mgmt keystone API, we need the public one for our rc file"
+
+ if grep "OS_AUTH_URL.*v2" $dest_path > /dev/null 2>&1 ; then
+ public_ip=$(sshpass -p root ssh $ssh_options root@${installer_ip} \
+ "ssh ${controller_ip} 'source /opt/admin-openrc.sh; openstack endpoint show identity '" \
+ | grep publicurl | awk '{print $4}')
+ else
+ public_ip=$(sshpass -p root ssh $ssh_options root@${installer_ip} \
+ "ssh ${controller_ip} 'source /opt/admin-openrc.sh; \
+ openstack endpoint list --interface public --service identity '" \
+ | grep identity | awk '{print $14}')
+ fi
+ info "public_ip: $public_ip"
+ swap_to_public $public_ip
+ fi
elif [ "$installer_type" == "joid" ]; then
# do nothing...for the moment
diff --git a/utils/jenkins-jnlp-connect.sh b/utils/jenkins-jnlp-connect.sh
index 8fce2e021..c46ca89f5 100755
--- a/utils/jenkins-jnlp-connect.sh
+++ b/utils/jenkins-jnlp-connect.sh
@@ -61,8 +61,8 @@ main () {
#make pid dir
pidfile="/var/run/$jenkinsuser/jenkins_jnlp_pid"
if ! [ -d /var/run/$jenkinsuser/ ]; then
- mkdir /var/run/$jenkinsuser/
- chown $jenkinsuser:$jenkinsuser /var/run/$jenkinsuser/
+ sudo mkdir /var/run/$jenkinsuser/
+ sudo chown $jenkinsuser:$jenkinsuser /var/run/$jenkinsuser/
fi
if [[ $skip_monit != true ]]; then
diff --git a/utils/push-test-logs.sh b/utils/push-test-logs.sh
index f0c488a5a..518d20ae5 100644
--- a/utils/push-test-logs.sh
+++ b/utils/push-test-logs.sh
@@ -27,10 +27,13 @@ node_list=(\
'ericsson-pod1' 'ericsson-pod2' \
'ericsson-virtual1' 'ericsson-virtual2' 'ericsson-virtual3' \
'ericsson-virtual4' 'ericsson-virtual5' 'ericsson-virtual12' \
-'arm-pod1' 'arm-pod3' \
+'arm-pod1' 'arm-pod5' \
'huawei-pod1' 'huawei-pod2' 'huawei-pod3' 'huawei-pod4' 'huawei-pod5' \
'huawei-pod6' 'huawei-pod7' 'huawei-pod12' \
-'huawei-virtual1' 'huawei-virtual2' 'huawei-virtual3' 'huawei-virtual4')
+'huawei-virtual1' 'huawei-virtual2' 'huawei-virtual3' 'huawei-virtual4' \
+'huawei-virtual5' 'huawei-virtual8' 'huawei-virtual9' \
+'zte-pod2' \
+'zte-virtual1')
if [[ ! " ${node_list[@]} " =~ " ${testbed} " ]]; then
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 49f4517f7..076dc4719 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)
project=$1
reporting_type=$2
@@ -29,8 +29,9 @@ cp -Rf js display
# projet | option
# $1 | $2
# functest | status, vims, tempest
-# yardstick |
-# storperf |
+# yardstick | status
+# storperf | status
+# qtip | status
function report_project()
{
@@ -40,7 +41,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,51 +51,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
diff --git a/utils/test/reporting/docker/requirements.pip b/utils/test/reporting/docker/requirements.pip
index 6de856e35..aeee3ba96 100644
--- a/utils/test/reporting/docker/requirements.pip
+++ b/utils/test/reporting/docker/requirements.pip
@@ -12,3 +12,4 @@ PyYAML==3.11
simplejson==3.8.1
jinja2==2.8
tornado==4.4.2
+requests==2.12.5
diff --git a/utils/test/reporting/docker/supervisor.conf b/utils/test/reporting/docker/supervisor.conf
index 5e315babe..49310d430 100644
--- a/utils/test/reporting/docker/supervisor.conf
+++ b/utils/test/reporting/docker/supervisor.conf
@@ -1,22 +1,19 @@
[supervisord]
nodaemon = true
-[program:reporting_tornado]
+[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
numprocs_start=1
-autorestart = true
-[program:reporting_nginx]
+[program:nginx]
user = root
command = service nginx restart
-autorestart = true
-[program:reporting_angular]
+[program:configuration]
user = root
-directory = /home/opnfv/utils/test/reporting/pages
-command = bash angular.sh
-autorestart = true
+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
new file mode 100644
index 000000000..23f59c377
--- /dev/null
+++ b/utils/test/reporting/docs/_build/.doctrees/environment.pickle
Binary files differ
diff --git a/utils/test/reporting/docs/_build/.doctrees/index.doctree b/utils/test/reporting/docs/_build/.doctrees/index.doctree
new file mode 100644
index 000000000..51e2d5ad3
--- /dev/null
+++ b/utils/test/reporting/docs/_build/.doctrees/index.doctree
Binary files differ
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/angular.sh b/utils/test/reporting/pages/angular.sh
index 080f27bb7..0e00ea635 100755
--- a/utils/test/reporting/pages/angular.sh
+++ b/utils/test/reporting/pages/angular.sh
@@ -1,8 +1,3 @@
-: ${SERVER_URL:='http://testresults.opnfv.org/reporting/api'}
-
-echo "var BASE_URL = 'http://${SERVER_URL}/landing-page'" >> app/scripts/app.config.js
-echo "var PROJECT_URL = 'http://${SERVER_URL}'" >> app/scripts/app.config.js
-
apt-get install -y nodejs
apt-get install -y npm
npm install
diff --git a/utils/test/reporting/pages/app/index.html b/utils/test/reporting/pages/app/index.html
index f4eb65adf..843a6230e 100644
--- a/utils/test/reporting/pages/app/index.html
+++ b/utils/test/reporting/pages/app/index.html
@@ -87,10 +87,9 @@
<script src="scripts/controllers/auth.controller.js"></script>
<script src="scripts/controllers/admin.controller.js"></script>
<script src="scripts/controllers/main.controller.js"></script>
- <script src="scripts/app.config.js"></script>
<script src="scripts/controllers/testvisual.controller.js"></script>
<!-- endbuild -->
</body>
-</html> \ No newline at end of file
+</html>
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 0f3a17a03..8d494c3ae 100644
--- a/utils/test/reporting/pages/app/scripts/controllers/table.controller.js
+++ b/utils/test/reporting/pages/app/scripts/controllers/table.controller.js
@@ -8,378 +8,271 @@
* Controller of the opnfvdashBoardAngularApp
*/
angular.module('opnfvApp')
- .controller('TableController', ['$scope', '$state', '$stateParams', '$http', 'TableFactory', function($scope, $state, $stateParams, $http, TableFactory) {
-
- $scope.filterlist = [];
- $scope.selection = [];
- $scope.statusList = [];
- $scope.projectList = [];
- $scope.installerList = [];
- $scope.versionlist = [];
- $scope.loopci = [];
- $scope.time = [];
- $scope.tableDataAll = {};
- $scope.tableInfoAll = {};
- $scope.scenario = {};
-
- $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();
-
- }
- }
-
- $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.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();
-
+ .controller('TableController', ['$scope', '$state', '$stateParams', '$http', 'TableFactory', '$timeout',
+ function($scope, $state, $stateParams, $http, TableFactory, $timeout) {
+
+ init();
+
+ function init() {
+ $scope.filterlist = [];
+ $scope.selection = [];
+
+ $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.scenarios = {};
+
+ $scope.VersionConfig = {
+ create: true,
+ valueField: 'title',
+ labelField: 'title',
+ delimiter: '|',
+ maxItems: 1,
+ placeholder: 'Version',
+ onChange: function(value) {
+ $scope.selectVersion = value;
+
+ getScenarioData();
- }
- }
-
-
- init();
-
- function init() {
- $scope.toggleSelection = toggleSelection;
- getScenarioData();
- // radioSetting();
- 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);
-
- } else {
- alert("网络错误");
- }
- })
- }
-
- 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
- };
- var config = {
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
- }
- }
- $http.post(utl, data, config).then(function(response) {
- if (response.status == 200) {
- $scope.scenario = response.data;
- constructJson();
- }
- })
- }
-
- //construct json
- function constructJson() {
-
- var colspan;
- var InstallerData;
- var projectsInfo;
- $scope.tableDataAll["scenario"] = [];
-
-
- for (var item in $scope.scenario.scenarios) {
-
- var headData = Object.keys($scope.scenario.scenarios[item].installers).sort();
- var scenarioStatus = $scope.scenario.scenarios[item].status;
- var scenarioStatusDisplay;
- if (scenarioStatus == "success") {
- scenarioStatusDisplay = "navy";
- } else if (scenarioStatus == "danger") {
- scenarioStatusDisplay = "danger";
- } else if (scenarioStatus == "warning") {
- scenarioStatusDisplay = "warning";
+ }
}
- InstallerData = headData;
- var projectData = [];
- var datadisplay = [];
- var projects = [];
+ $scope.LoopConfig = {
+ create: true,
+ valueField: 'title',
+ labelField: 'title',
+ delimiter: '|',
+ maxItems: 1,
+ placeholder: 'Loop',
+ onChange: function(value) {
+ $scope.selectLoop = value;
- for (var j = 0; j < headData.length; j++) {
+ getScenarioData();
- 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");
- }
-
- datadisplay.push(temArray);
+ $scope.TimeConfig = {
+ create: true,
+ valueField: 'title',
+ labelField: 'title',
+ delimiter: '|',
+ maxItems: 1,
+ placeholder: 'Time',
+ onChange: function(value) {
+ $scope.selectTime = value;
+
+ getScenarioData();
}
-
}
- 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);
-
+ 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 = 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 {
+ }
+ });
+ }
- 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]);
- }
+ function toSelectList(arr){
+ var tempList = [];
+ angular.forEach(arr, function(ele){
+ tempList.push({'title': ele});
+ });
+ return tempList;
}
- //console.log(tempHeadData);
+ function copy(arr){
+ var tempList = [];
+ angular.forEach(arr, function(ele){
+ tempList.push(ele);
+ });
+ return tempList;
+ }
- var projectsInfoAll = [];
+ function getScenarioData() {
- for (var i = 0; i < projectsInfo.length; i++) {
- var tempA = [];
- tempA.push(projectsInfo[i]);
- tempA.push(tempHeadData[i]);
- projectsInfoAll.push(tempA);
+ var data = {
+ 'status': $scope.selectStatus,
+ 'projects': $scope.selectProjects,
+ 'installers': $scope.selectInstallers,
+ 'version': $scope.selectVersion,
+ 'loops': $scope.selectLoop,
+ 'time': $scope.selectTime
+ };
- }
- //console.log(projectsInfoAll);
+ TableFactory.getScenario(data).then(function(response) {
+ if (response.status == 200) {
+ $scope.scenarios = response.data.scenarios;
+ getScenario();
+ }
- $scope.tableDataAll["colspan"] = colspan;
- $scope.tableDataAll["Installer"] = InstallerData;
- $scope.tableDataAll["Projects"] = projectsInfoAll;
+ }, function(error) {
+ });
- // console.log($scope.tableDataAll);
- $scope.colspan = $scope.tableDataAll.colspan;
+ }
- }
+ function getScenario(){
- //get json element size
- function getSize(jsondata) {
- var size = 0;
- for (var item in jsondata) {
- size++;
+ $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);
+
+ });
+ });
+
+
+ $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 scenarioStatusDisplay;
+ if (scenario.status == "success") {
+ scenarioStatusDisplay = "navy";
+ } else if (scenario.status == "danger") {
+ scenarioStatusDisplay = "danger";
+ } else if (scenario.status == "warning") {
+ scenarioStatusDisplay = "warning";
+ }
+ 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);
+
+ });
+ });
+ $scope.scenario_rows.push(scenario_row);
+ });
}
- return size;
- }
- $scope.colspan = $scope.tableDataAll.colspan;
- // 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);
- }
- 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;
+ if($scope.selectStatus.length == 0 && $scope.statusClicked == true){
+ $scope.selectStatus = copy($scope.statusList);
+ $scope.statusClicked = false;
}
+
+ 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($scope.selectInstallers.length == 0 && $scope.installerClicked == true){
+ $scope.selectInstallers = copy($scope.installerList);
+ $scope.installerClicked = false;
+ }
- if (idx > -1) {
- $scope.selection.splice(idx, 1);
- filterData($scope.selection)
- } else {
- $scope.selection.push(status);
- filterData($scope.selection)
+ getScenarioData();
}
- // console.log($scope.selection);
- }
+ $scope.clickProject = function(project){
+ if($scope.selectProjects.length == $scope.projectList.length && $scope.projectClicked == false){
+ $scope.selectProjects = [];
+ $scope.projectClicked = true;
+ }
- //filter function
- function filterData(selection) {
+ clickBase($scope.selectProjects, project);
- $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]);
+ if($scope.selectProjects.length == 0 && $scope.projectClicked == true){
+ $scope.selectProjects = copy($scope.projectList);
+ $scope.projectClicked = false;
}
- }
-
- $scope.colspan = $scope.selectProjects.length;
- //when some selection is empty, we set it full
- if ($scope.selectInstallers.length == 0) {
- $scope.selectInstallers = $scope.installerList;
+ getScenarioData();
}
- if ($scope.selectProjects.length == 0) {
- $scope.selectProjects = $scope.projectList;
- $scope.colspan = $scope.tableDataAll.colspan;
- }
- if ($scope.selectStatus.length == 0) {
- $scope.selectStatus = $scope.statusList
- }
-
- // console.log($scope.selectStatus);
- // console.log($scope.selectProjects);
}
-
-
- }]); \ No newline at end of file
+ ]);
diff --git a/utils/test/reporting/pages/app/scripts/controllers/testvisual.controller.js b/utils/test/reporting/pages/app/scripts/controllers/testvisual.controller.js
index def8e7293..894e10f77 100644
--- a/utils/test/reporting/pages/app/scripts/controllers/testvisual.controller.js
+++ b/utils/test/reporting/pages/app/scripts/controllers/testvisual.controller.js
@@ -16,7 +16,7 @@ angular.module('opnfvApp')
$scope.vsperf = "542,185,640,414";
$scope.stor = "658,187,750,410";
$scope.qtip = "769,190,852,416";
- $scope.bootleneck = "870,192,983,419";
+ $scope.bottlenecks = "870,192,983,419";
$scope.noPopArea1 = "26,8,1190,180";
$scope.noPopArea2 = "1018,193,1190,590";
$scope.noPopArea3 = "37,455,1003,584";
@@ -41,25 +41,18 @@ angular.module('opnfvApp')
$scope.tableData = null;
$scope.modalName = name;
- var url = PROJECT_URL + '/projects/' + name + '/cases';
-
- var config = {
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
- }
- }
- $http.get(url, config).then(function(response) {
+ TableFactory.getProjectTestCases(name).then(function(response) {
if (response.status == 200) {
$scope.tableData = response.data;
$scope.tableData = constructObjectArray($scope.tableData);
console.log($scope.tableData);
$loading.finish('Key');
-
-
-
}
+ }, function(error) {
+
})
+
}
//construct key value for tableData
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 2a8cbd046..e715c5c28 100644
--- a/utils/test/reporting/pages/app/scripts/factory/table.factory.js
+++ b/utils/test/reporting/pages/app/scripts/factory/table.factory.js
@@ -4,45 +4,67 @@
* get data factory
*/
angular.module('opnfvApp')
- .factory('TableFactory', function($resource, $rootScope) {
+ .factory('TableFactory', function($resource, $rootScope, $http) {
+
+ var BASE_URL = 'http://testresults.opnfv.org/reporting2';
+ $.ajax({
+ url: 'config.json',
+ async: false,
+ dataType: 'json',
+ success: function (response) {
+ BASE_URL = response.url;
+ },
+ error: function (response){
+ alert('fail to get api url, using default: http://testresults.opnfv.org/reporting2')
+ }
+ });
return {
getFilter: function() {
- return $resource(BASE_URL + '/filters', {}, {
+ return $resource(BASE_URL + '/landing-page/filters', {}, {
'get': {
method: 'GET',
}
});
},
- getScenario: function() {
- return $resource(BASE_URL + '/scenarios', {}, {
- 'post': {
- method: 'POST',
+ getScenario: function(data) {
+
+ var config = {
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
}
- })
+ }
+
+ return $http.post(BASE_URL + '/landing-page/scenarios', data, config);
},
+
+
getProjectUrl: function() {
- return $resource(PROJECT_URL + '/projects-page/projects', {}, {
+ return $resource(BASE_URL + '/projects-page/projects', {}, {
'get': {
method: 'GET'
}
})
},
- getProjectTestCases: function() {
- return $resource(PROJECT_URL + '/projects/:project/cases', { project: '@project' }, {
- 'get': {
- method: 'GET'
+ getProjectTestCases: function(name) {
+ var config = {
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
}
- })
+ };
+ return $http.get(BASE_URL + '/projects/' + name + '/cases', {}, config)
+
+
},
getProjectTestCaseDetail: function() {
- return $resource(PROJECT_URL + '/projects/:project/cases/:testcase', { project: '@project', testcase: '@testcase' }, {
+ return $resource(BASE_URL + '/projects/:project/cases/:testcase', { project: '@project', testcase: '@testcase' }, {
'get': {
method: 'GET'
}
})
}
+
};
- }); \ No newline at end of file
+ });
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> &nbsp;&nbsp; &nbsp;
- <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> &nbsp;
- <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/pages/app/views/commons/testCaseVisual.html b/utils/test/reporting/pages/app/views/commons/testCaseVisual.html
index 74eb56eba..4de4e187f 100644
--- a/utils/test/reporting/pages/app/views/commons/testCaseVisual.html
+++ b/utils/test/reporting/pages/app/views/commons/testCaseVisual.html
@@ -20,7 +20,7 @@
<area shape="rect" coords={{vsperf}} alt="test" href="{{vsperfurl}}" onmouseover="pop(event)" ng-mouseover="myTrigger('vsperf')" />
<area shape="rect" coords={{stor}} alt="test" href="{{storperfurl}}" onmouseover="pop(event)" ng-mouseover="myTrigger('storperf')"/>
<area shape="rect" coords={{qtip}} alt="test" href="{{qtipurl}}" onmouseover="pop(event)" ng-mouseover="myTrigger('qtip')" />
- <area shape="rect" coords={{bootleneck}} alt="test" href="{{bottlenecksurl}}" onmouseover="pop(event)" ng-mouseover="myTrigger('bootlenecks')" />
+ <area shape="rect" coords={{bottlenecks}} alt="test" href="{{bottlenecksurl}}" onmouseover="pop(event)" ng-mouseover="myTrigger('bottlenecks')" />
<area shape="rect" coords={{noPopArea1}} alt="test" onmouseover="pophide(event)" />
<area shape="rect" coords={{noPopArea2}} alt="test" onmouseover="pophide(event)" />
<area shape="rect" coords={{noPopArea3}} alt="test" onmouseover="pophide(event)" />
@@ -124,4 +124,4 @@
$('#popup').hide();
return true;
}
- </script> \ No newline at end of file
+ </script>
diff --git a/utils/test/reporting/pages/config.sh b/utils/test/reporting/pages/config.sh
new file mode 100755
index 000000000..f9bb89ac8
--- /dev/null
+++ b/utils/test/reporting/pages/config.sh
@@ -0,0 +1,3 @@
+: ${SERVER_URL:='testresults.opnfv.org/reporting2'}
+
+echo "{\"url\": \"http://${SERVER_URL}\"}" > dist/config.json
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
index ecefc0e66..ecefc0e66 100644
--- a/utils/test/reporting/functest/img/gauge_0.png
+++ b/utils/test/reporting/reporting/functest/img/gauge_0.png
Binary files differ
diff --git a/utils/test/reporting/functest/img/gauge_100.png b/utils/test/reporting/reporting/functest/img/gauge_100.png
index e199e1561..e199e1561 100644
--- a/utils/test/reporting/functest/img/gauge_100.png
+++ b/utils/test/reporting/reporting/functest/img/gauge_100.png
Binary files differ
diff --git a/utils/test/reporting/functest/img/gauge_16.7.png b/utils/test/reporting/reporting/functest/img/gauge_16.7.png
index 3e3993c3b..3e3993c3b 100644
--- a/utils/test/reporting/functest/img/gauge_16.7.png
+++ b/utils/test/reporting/reporting/functest/img/gauge_16.7.png
Binary files differ
diff --git a/utils/test/reporting/functest/img/gauge_25.png b/utils/test/reporting/reporting/functest/img/gauge_25.png
index 4923659b9..4923659b9 100644
--- a/utils/test/reporting/functest/img/gauge_25.png
+++ b/utils/test/reporting/reporting/functest/img/gauge_25.png
Binary files differ
diff --git a/utils/test/reporting/functest/img/gauge_33.3.png b/utils/test/reporting/reporting/functest/img/gauge_33.3.png
index 364574b4a..364574b4a 100644
--- a/utils/test/reporting/functest/img/gauge_33.3.png
+++ b/utils/test/reporting/reporting/functest/img/gauge_33.3.png
Binary files differ
diff --git a/utils/test/reporting/functest/img/gauge_41.7.png b/utils/test/reporting/reporting/functest/img/gauge_41.7.png
index 8c3e910fa..8c3e910fa 100644
--- a/utils/test/reporting/functest/img/gauge_41.7.png
+++ b/utils/test/reporting/reporting/functest/img/gauge_41.7.png
Binary files differ
diff --git a/utils/test/reporting/functest/img/gauge_50.png b/utils/test/reporting/reporting/functest/img/gauge_50.png
index 2874b9fcf..2874b9fcf 100644
--- a/utils/test/reporting/functest/img/gauge_50.png
+++ b/utils/test/reporting/reporting/functest/img/gauge_50.png
Binary files differ
diff --git a/utils/test/reporting/functest/img/gauge_58.3.png b/utils/test/reporting/reporting/functest/img/gauge_58.3.png
index beedc8aa9..beedc8aa9 100644
--- a/utils/test/reporting/functest/img/gauge_58.3.png
+++ b/utils/test/reporting/reporting/functest/img/gauge_58.3.png
Binary files differ
diff --git a/utils/test/reporting/functest/img/gauge_66.7.png b/utils/test/reporting/reporting/functest/img/gauge_66.7.png
index 93f44d133..93f44d133 100644
--- a/utils/test/reporting/functest/img/gauge_66.7.png
+++ b/utils/test/reporting/reporting/functest/img/gauge_66.7.png
Binary files differ
diff --git a/utils/test/reporting/functest/img/gauge_75.png b/utils/test/reporting/reporting/functest/img/gauge_75.png
index 9fc261ff8..9fc261ff8 100644
--- a/utils/test/reporting/functest/img/gauge_75.png
+++ b/utils/test/reporting/reporting/functest/img/gauge_75.png
Binary files differ
diff --git a/utils/test/reporting/functest/img/gauge_8.3.png b/utils/test/reporting/reporting/functest/img/gauge_8.3.png
index 59f86571e..59f86571e 100644
--- a/utils/test/reporting/functest/img/gauge_8.3.png
+++ b/utils/test/reporting/reporting/functest/img/gauge_8.3.png
Binary files differ
diff --git a/utils/test/reporting/functest/img/gauge_83.3.png b/utils/test/reporting/reporting/functest/img/gauge_83.3.png
index 27ae4ec54..27ae4ec54 100644
--- a/utils/test/reporting/functest/img/gauge_83.3.png
+++ b/utils/test/reporting/reporting/functest/img/gauge_83.3.png
Binary files differ
diff --git a/utils/test/reporting/functest/img/gauge_91.7.png b/utils/test/reporting/reporting/functest/img/gauge_91.7.png
index 280865714..280865714 100644
--- a/utils/test/reporting/functest/img/gauge_91.7.png
+++ b/utils/test/reporting/reporting/functest/img/gauge_91.7.png
Binary files differ
diff --git a/utils/test/reporting/functest/img/icon-nok.png b/utils/test/reporting/reporting/functest/img/icon-nok.png
index 526b5294b..526b5294b 100644
--- a/utils/test/reporting/functest/img/icon-nok.png
+++ b/utils/test/reporting/reporting/functest/img/icon-nok.png
Binary files differ
diff --git a/utils/test/reporting/functest/img/icon-ok.png b/utils/test/reporting/reporting/functest/img/icon-ok.png
index 3a9de2e89..3a9de2e89 100644
--- a/utils/test/reporting/functest/img/icon-ok.png
+++ b/utils/test/reporting/reporting/functest/img/icon-ok.png
Binary files differ
diff --git a/utils/test/reporting/functest/img/weather-clear.png b/utils/test/reporting/reporting/functest/img/weather-clear.png
index a0d967750..a0d967750 100644
--- a/utils/test/reporting/functest/img/weather-clear.png
+++ b/utils/test/reporting/reporting/functest/img/weather-clear.png
Binary files differ
diff --git a/utils/test/reporting/functest/img/weather-few-clouds.png b/utils/test/reporting/reporting/functest/img/weather-few-clouds.png
index acfa78398..acfa78398 100644
--- a/utils/test/reporting/functest/img/weather-few-clouds.png
+++ b/utils/test/reporting/reporting/functest/img/weather-few-clouds.png
Binary files differ
diff --git a/utils/test/reporting/functest/img/weather-overcast.png b/utils/test/reporting/reporting/functest/img/weather-overcast.png
index 4296246d0..4296246d0 100644
--- a/utils/test/reporting/functest/img/weather-overcast.png
+++ b/utils/test/reporting/reporting/functest/img/weather-overcast.png
Binary files differ
diff --git a/utils/test/reporting/functest/img/weather-storm.png b/utils/test/reporting/reporting/functest/img/weather-storm.png
index 956f0e20f..956f0e20f 100644
--- a/utils/test/reporting/functest/img/weather-storm.png
+++ b/utils/test/reporting/reporting/functest/img/weather-storm.png
Binary files differ
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 e700e047f..c7c2051a3 100755
--- a/utils/test/reporting/functest/reporting-status.py
+++ b/utils/test/reporting/reporting/functest/reporting-status.py
@@ -18,6 +18,8 @@ import scenarioResult as sr
# manage conf
import utils.reporting_utils as rp_utils
+"""Functest reporting status"""
+
# Logger
logger = rp_utils.getLogger("Functest-Status")
@@ -107,7 +109,6 @@ for version in versions:
scenario_results = rp_utils.getScenarios(healthcheck,
installer,
version)
-
# get nb of supported architecture (x86, aarch64)
architectures = rp_utils.getArchitectures(scenario_results)
logger.info("Supported architectures: {}".format(architectures))
@@ -125,7 +126,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
@@ -273,7 +274,8 @@ 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(
diff --git a/utils/test/reporting/functest/reporting-tempest.py b/utils/test/reporting/reporting/functest/reporting-tempest.py
index 6e6585a32..bc2885639 100755
--- a/utils/test/reporting/functest/reporting-tempest.py
+++ b/utils/test/reporting/reporting/functest/reporting-tempest.py
@@ -1,4 +1,15 @@
+#!/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
+# SPDX-license-identifier: Apache-2.0
+
from urllib2 import Request, urlopen, URLError
+from datetime import datetime
import json
import jinja2
import os
@@ -97,7 +108,13 @@ for version in rp_utils.get_config('general.versions'):
crit_rate = True
# Expect that the suite duration is inferior to 30m
- if result['details']['duration'] < criteria_duration:
+ stop_date = datetime.strptime(result['stop_date'],
+ '%Y-%m-%d %H:%M:%S')
+ start_date = datetime.strptime(result['start_date'],
+ '%Y-%m-%d %H:%M:%S')
+
+ delta = stop_date - start_date
+ if (delta.total_seconds() < criteria_duration):
crit_time = True
result['criteria'] = {'tests': crit_tests,
@@ -125,7 +142,7 @@ for version in rp_utils.get_config('general.versions'):
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,
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..0c188a338 100644
--- a/utils/test/reporting/storperf/reporting-status.py
+++ b/utils/test/reporting/reporting/storperf/reporting-status.py
@@ -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/pages/app/scripts/app.config.js b/utils/test/reporting/reporting/tests/unit/utils/__init__.py
index e69de29bb..e69de29bb 100644
--- a/utils/test/reporting/pages/app/scripts/app.config.js
+++ 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 599a93818..62820914a 100644
--- a/utils/test/reporting/utils/reporting_utils.py
+++ b/utils/test/reporting/reporting/utils/reporting_utils.py
@@ -95,7 +95,7 @@ def getApiResults(case, installer, scenario, version):
k = response.read()
results = json.loads(k)
except URLError as e:
- print('No kittez. Got an error code:', e)
+ print 'No kittez. Got an error code:'.format(e)
return results
@@ -117,19 +117,31 @@ def getScenarios(case, installer, version):
url = ("http://" + url_base + "?case=" + case +
"&period=" + str(period) + "&installer=" + installer +
"&version=" + version)
- request = Request(url)
try:
+ request = Request(url)
response = urlopen(request)
k = response.read()
results = json.loads(k)
test_results = results['results']
- except URLError as e:
- print('Got an error code:', e)
+ 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: {}'.format(err)
if test_results is not None:
test_results.reverse()
-
scenario_results = {}
for r in test_results:
@@ -142,7 +154,7 @@ def getScenarios(case, installer, version):
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...")
+ print "exclude virtual pod results..."
else:
scenario_results[r['scenario']].append(r)
@@ -157,7 +169,6 @@ def getScenarioStats(scenario_results):
return scenario_stats
-# TODO convergence with above function getScenarios
def getScenarioStatus(installer, version):
period = get_config('general.period')
url_base = get_config('testapi.url')
@@ -174,7 +185,7 @@ def getScenarioStatus(installer, version):
results = json.loads(k)
test_results = results['results']
except URLError as e:
- print('Got an error code:', e)
+ print 'Got an error code: {}'.format(e)
scenario_results = {}
result_dict = {}
@@ -213,8 +224,8 @@ def getQtipResults(version, installer):
k = response.read()
response.close()
results = json.loads(k)['results']
- except URLError as e:
- print('Got an error code:', e)
+ except URLError as err:
+ print 'Got an error code: {}'.format(err)
result_dict = {}
if results:
@@ -236,7 +247,7 @@ def getNbtestOk(results):
if "PASS" in v:
nb_test_ok += 1
except:
- print("Cannot retrieve test status")
+ print "Cannot retrieve test status"
return nb_test_ok
@@ -311,7 +322,7 @@ def getJenkinsUrl(build_tag):
"/" + str(build_id[0]))
jenkins_url = url_base + url_id + "/console"
except:
- print('Impossible to get jenkins url:')
+ print 'Impossible to get jenkins url:'
if "jenkins-" not in build_tag:
jenkins_url = None
@@ -324,7 +335,7 @@ def getScenarioPercent(scenario_score, scenario_criteria):
try:
score = float(scenario_score) / float(scenario_criteria) * 100
except:
- print('Impossible to calculate the percentage score')
+ print 'Impossible to calculate the percentage score'
return score
@@ -410,7 +421,7 @@ def get_percent(four_list, ten_list):
def _test():
status = getScenarioStatus("compass", "master")
- print("status:++++++++++++++++++++++++")
+ print "status:++++++++++++++++++++++++"
print(json.dumps(status, indent=4))
@@ -427,9 +438,9 @@ def export_csv(scenario_file_name, installer, version):
"/functest/scenario_history_" +
installer + ".csv")
scenario_installer_file = open(scenario_installer_file_name, "a")
- with open(scenario_file_name, "r") as f:
+ with open(scenario_file_name, "r") as scenario_file:
scenario_installer_file.write("date,scenario,installer,detail,score\n")
- for line in f:
+ for line in scenario_file:
if installer in line:
scenario_installer_file.write(line)
scenario_installer_file.close
@@ -447,6 +458,6 @@ def export_pdf(pdf_path, pdf_doc_name):
try:
pdfkit.from_file(pdf_path, pdf_doc_name)
except IOError:
- print("Error but pdf generated anyway...")
+ print "Error but pdf generated anyway..."
except:
- print("impossible to generate PDF")
+ 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/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
index ecefc0e66..ecefc0e66 100644
--- a/utils/test/reporting/yardstick/img/gauge_0.png
+++ b/utils/test/reporting/reporting/yardstick/img/gauge_0.png
Binary files differ
diff --git a/utils/test/reporting/yardstick/img/gauge_100.png b/utils/test/reporting/reporting/yardstick/img/gauge_100.png
index e199e1561..e199e1561 100644
--- a/utils/test/reporting/yardstick/img/gauge_100.png
+++ b/utils/test/reporting/reporting/yardstick/img/gauge_100.png
Binary files differ
diff --git a/utils/test/reporting/yardstick/img/gauge_16.7.png b/utils/test/reporting/reporting/yardstick/img/gauge_16.7.png
index 3e3993c3b..3e3993c3b 100644
--- a/utils/test/reporting/yardstick/img/gauge_16.7.png
+++ b/utils/test/reporting/reporting/yardstick/img/gauge_16.7.png
Binary files differ
diff --git a/utils/test/reporting/yardstick/img/gauge_25.png b/utils/test/reporting/reporting/yardstick/img/gauge_25.png
index 4923659b9..4923659b9 100644
--- a/utils/test/reporting/yardstick/img/gauge_25.png
+++ b/utils/test/reporting/reporting/yardstick/img/gauge_25.png
Binary files differ
diff --git a/utils/test/reporting/yardstick/img/gauge_33.3.png b/utils/test/reporting/reporting/yardstick/img/gauge_33.3.png
index 364574b4a..364574b4a 100644
--- a/utils/test/reporting/yardstick/img/gauge_33.3.png
+++ b/utils/test/reporting/reporting/yardstick/img/gauge_33.3.png
Binary files differ
diff --git a/utils/test/reporting/yardstick/img/gauge_41.7.png b/utils/test/reporting/reporting/yardstick/img/gauge_41.7.png
index 8c3e910fa..8c3e910fa 100644
--- a/utils/test/reporting/yardstick/img/gauge_41.7.png
+++ b/utils/test/reporting/reporting/yardstick/img/gauge_41.7.png
Binary files differ
diff --git a/utils/test/reporting/yardstick/img/gauge_50.png b/utils/test/reporting/reporting/yardstick/img/gauge_50.png
index 2874b9fcf..2874b9fcf 100644
--- a/utils/test/reporting/yardstick/img/gauge_50.png
+++ b/utils/test/reporting/reporting/yardstick/img/gauge_50.png
Binary files differ
diff --git a/utils/test/reporting/yardstick/img/gauge_58.3.png b/utils/test/reporting/reporting/yardstick/img/gauge_58.3.png
index beedc8aa9..beedc8aa9 100644
--- a/utils/test/reporting/yardstick/img/gauge_58.3.png
+++ b/utils/test/reporting/reporting/yardstick/img/gauge_58.3.png
Binary files differ
diff --git a/utils/test/reporting/yardstick/img/gauge_66.7.png b/utils/test/reporting/reporting/yardstick/img/gauge_66.7.png
index 93f44d133..93f44d133 100644
--- a/utils/test/reporting/yardstick/img/gauge_66.7.png
+++ b/utils/test/reporting/reporting/yardstick/img/gauge_66.7.png
Binary files differ
diff --git a/utils/test/reporting/yardstick/img/gauge_75.png b/utils/test/reporting/reporting/yardstick/img/gauge_75.png
index 9fc261ff8..9fc261ff8 100644
--- a/utils/test/reporting/yardstick/img/gauge_75.png
+++ b/utils/test/reporting/reporting/yardstick/img/gauge_75.png
Binary files differ
diff --git a/utils/test/reporting/yardstick/img/gauge_8.3.png b/utils/test/reporting/reporting/yardstick/img/gauge_8.3.png
index 59f86571e..59f86571e 100644
--- a/utils/test/reporting/yardstick/img/gauge_8.3.png
+++ b/utils/test/reporting/reporting/yardstick/img/gauge_8.3.png
Binary files differ
diff --git a/utils/test/reporting/yardstick/img/gauge_83.3.png b/utils/test/reporting/reporting/yardstick/img/gauge_83.3.png
index 27ae4ec54..27ae4ec54 100644
--- a/utils/test/reporting/yardstick/img/gauge_83.3.png
+++ b/utils/test/reporting/reporting/yardstick/img/gauge_83.3.png
Binary files differ
diff --git a/utils/test/reporting/yardstick/img/gauge_91.7.png b/utils/test/reporting/reporting/yardstick/img/gauge_91.7.png
index 280865714..280865714 100644
--- a/utils/test/reporting/yardstick/img/gauge_91.7.png
+++ b/utils/test/reporting/reporting/yardstick/img/gauge_91.7.png
Binary files differ
diff --git a/utils/test/reporting/yardstick/img/icon-nok.png b/utils/test/reporting/reporting/yardstick/img/icon-nok.png
index 526b5294b..526b5294b 100644
--- a/utils/test/reporting/yardstick/img/icon-nok.png
+++ b/utils/test/reporting/reporting/yardstick/img/icon-nok.png
Binary files differ
diff --git a/utils/test/reporting/yardstick/img/icon-ok.png b/utils/test/reporting/reporting/yardstick/img/icon-ok.png
index 3a9de2e89..3a9de2e89 100644
--- a/utils/test/reporting/yardstick/img/icon-ok.png
+++ b/utils/test/reporting/reporting/yardstick/img/icon-ok.png
Binary files differ
diff --git a/utils/test/reporting/yardstick/img/weather-clear.png b/utils/test/reporting/reporting/yardstick/img/weather-clear.png
index a0d967750..a0d967750 100644
--- a/utils/test/reporting/yardstick/img/weather-clear.png
+++ b/utils/test/reporting/reporting/yardstick/img/weather-clear.png
Binary files differ
diff --git a/utils/test/reporting/yardstick/img/weather-few-clouds.png b/utils/test/reporting/reporting/yardstick/img/weather-few-clouds.png
index acfa78398..acfa78398 100644
--- a/utils/test/reporting/yardstick/img/weather-few-clouds.png
+++ b/utils/test/reporting/reporting/yardstick/img/weather-few-clouds.png
Binary files differ
diff --git a/utils/test/reporting/yardstick/img/weather-overcast.png b/utils/test/reporting/reporting/yardstick/img/weather-overcast.png
index 4296246d0..4296246d0 100644
--- a/utils/test/reporting/yardstick/img/weather-overcast.png
+++ b/utils/test/reporting/reporting/yardstick/img/weather-overcast.png
Binary files differ
diff --git a/utils/test/reporting/yardstick/img/weather-storm.png b/utils/test/reporting/reporting/yardstick/img/weather-storm.png
index 956f0e20f..956f0e20f 100644
--- a/utils/test/reporting/yardstick/img/weather-storm.png
+++ b/utils/test/reporting/reporting/yardstick/img/weather-storm.png
Binary files differ
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..85c386bf1 100644
--- a/utils/test/reporting/yardstick/reporting-status.py
+++ b/utils/test/reporting/reporting/yardstick/reporting-status.py
@@ -106,7 +106,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
new file mode 100755
index 000000000..b83b550b8
--- /dev/null
+++ b/utils/test/reporting/run_test.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+tox
+exit $?
diff --git a/utils/test/reporting/run_unit_tests.sh b/utils/test/reporting/run_unit_tests.sh
deleted file mode 100755
index 6b0e3b2b1..000000000
--- a/utils/test/reporting/run_unit_tests.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/bash
-set -o errexit
-set -o pipefail
-
-# ******************************
-# prepare the env for the tests
-# ******************************
-# Either Workspace is set (CI)
-if [ -z $WORKSPACE ]
-then
- WORKSPACE="."
-fi
-
-export CONFIG_REPORTING_YAML=./reporting.yaml
-
-# ***************
-# Run unit tests
-# ***************
-echo "Running unit tests..."
-
-# start vitual env
-virtualenv $WORKSPACE/reporting_venv
-source $WORKSPACE/reporting_venv/bin/activate
-
-# install python packages
-easy_install -U setuptools
-easy_install -U pip
-pip install -r $WORKSPACE/docker/requirements.pip
-pip install -e $WORKSPACE
-
-python $WORKSPACE/setup.py develop
-
-# unit tests
-# TODO: remove cover-erase
-# To be deleted when all functest packages will be listed
-nosetests --with-xunit \
- --cover-package=utils \
- --with-coverage \
- --cover-xml \
- tests/unit
-rc=$?
-
-deactivate
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'"
diff --git a/utils/test/testapi/.gitignore b/utils/test/testapi/.gitignore
new file mode 100644
index 000000000..00f8a03d0
--- /dev/null
+++ b/utils/test/testapi/.gitignore
@@ -0,0 +1,7 @@
+AUTHORS
+ChangeLog
+setup.cfg-e
+opnfv_testapi/static
+build
+*.egg-info
+
diff --git a/utils/test/testapi/3rd_party/static/testapi-ui/app.js b/utils/test/testapi/3rd_party/static/testapi-ui/app.js
index 4a2f23af9..5f5b86159 100644
--- a/utils/test/testapi/3rd_party/static/testapi-ui/app.js
+++ b/utils/test/testapi/3rd_party/static/testapi-ui/app.js
@@ -26,6 +26,22 @@
.module('testapiApp')
.config(configureRoutes);
+ angular
+ .module('testapiApp')
+ .directive('dynamicModel', ['$compile', '$parse', function ($compile, $parse) {
+ return {
+ restrict: 'A',
+ terminal: true,
+ priority: 100000,
+ link: function (scope, elem) {
+ var name = $parse(elem.attr('dynamic-model'))(scope);
+ elem.removeAttr('dynamic-model');
+ elem.attr('ng-model', name);
+ $compile(elem)(scope);
+ }
+ };
+ }]);
+
configureRoutes.$inject = ['$stateProvider', '$urlRouterProvider'];
/**
@@ -37,46 +53,46 @@
$stateProvider.
state('home', {
url: '/',
- templateUrl: '/testapi-ui/components/home/home.html'
+ templateUrl: 'testapi-ui/components/home/home.html'
}).
state('about', {
url: '/about',
- templateUrl: '/testapi-ui/components/about/about.html'
+ templateUrl: 'testapi-ui/components/about/about.html'
}).
- state('guidelines', {
- url: '/guidelines',
- templateUrl: '/testapi-ui/components/guidelines/guidelines.html',
- controller: 'GuidelinesController as ctrl'
+ state('pods', {
+ url: '/pods',
+ templateUrl: 'testapi-ui/components/pods/pods.html',
+ controller: 'PodsController as ctrl'
}).
state('communityResults', {
url: '/community_results',
- templateUrl: '/testapi-ui/components/results/results.html',
+ templateUrl: 'testapi-ui/components/results/results.html',
controller: 'ResultsController as ctrl'
}).
state('userResults', {
url: '/user_results',
- templateUrl: '/testapi-ui/components/results/results.html',
+ templateUrl: 'testapi-ui/components/results/results.html',
controller: 'ResultsController as ctrl'
}).
state('resultsDetail', {
url: '/results/:testID',
- templateUrl: '/testapi-ui/components/results-report' +
+ templateUrl: 'testapi-ui/components/results-report' +
'/resultsReport.html',
controller: 'ResultsReportController as ctrl'
}).
state('profile', {
url: '/profile',
- templateUrl: '/testapi-ui/components/profile/profile.html',
+ templateUrl: 'testapi-ui/components/profile/profile.html',
controller: 'ProfileController as ctrl'
}).
state('authFailure', {
url: '/auth_failure',
- templateUrl: '/testapi-ui/components/home/home.html',
+ templateUrl: 'testapi-ui/components/home/home.html',
controller: 'AuthFailureController as ctrl'
}).
state('logout', {
url: '/logout',
- templateUrl: '/testapi-ui/components/logout/logout.html',
+ templateUrl: 'testapi-ui/components/logout/logout.html',
controller: 'LogoutController as ctrl'
}).
state('userVendors', {
diff --git a/utils/test/testapi/3rd_party/static/testapi-ui/components/guidelines/guidelines.html b/utils/test/testapi/3rd_party/static/testapi-ui/components/guidelines/guidelines.html
deleted file mode 100644
index 1dd39ff17..000000000
--- a/utils/test/testapi/3rd_party/static/testapi-ui/components/guidelines/guidelines.html
+++ /dev/null
@@ -1,80 +0,0 @@
-<h3>OpenStack Powered&#8482; Guidelines</h3>
-
-<!-- Guideline Filters -->
-<div class="row">
- <div class="col-md-3">
- <strong>Version:</strong>
- <!-- Slicing the version file name here gets rid of the '.json' file extension -->
- <select ng-model="ctrl.version"
- ng-change="ctrl.update()"
- class="form-control"
- ng-options="versionFile.slice(0,-5) for versionFile in ctrl.versionList">
- </select>
- </div>
- <div class="col-md-4">
- <strong>Target Program:</strong>
- <span class="program-about"><a target="_blank" href="http://www.openstack.org/brand/interop/">About</a></span>
- <select ng-model="ctrl.target" class="form-control" ng-change="ctrl.updateTargetCapabilities()">
- <option value="platform">OpenStack Powered Platform</option>
- <option value="compute">OpenStack Powered Compute</option>
- <option value="object">OpenStack Powered Object Storage</option>
- </select>
- </div>
-</div>
-
-<br />
-<div ng-if="ctrl.guidelines">
- <strong>Guideline Status:</strong>
- {{ctrl.guidelines.status | capitalize}}
-</div>
-
-<div ng-show="ctrl.guidelines">
- <strong>Corresponding OpenStack Releases:</strong>
- <ul class="list-inline">
- <li ng-repeat="release in ctrl.guidelines.releases">
- {{release | capitalize}}
- </li>
- </ul>
-</div>
-
-<strong>Capability Status:</strong>
-<div class="checkbox">
- <label>
- <input type="checkbox" ng-model="ctrl.status.required">
- <span class="required">Required</span>
- </label>
- <label>
- <input type="checkbox" ng-model="ctrl.status.advisory">
- <span class="advisory">Advisory</span>
- </label>
- <label>
- <input type="checkbox" ng-model="ctrl.status.deprecated">
- <span class="deprecated">Deprecated</span>
- </label>
- <label>
- <input type="checkbox" ng-model="ctrl.status.removed">
- <span class="removed">Removed</span>
- </label>
- <a class="test-list-dl pull-right"
- title="Get a test list for capabilities matching selected statuses."
- ng-click="ctrl.openTestListModal()">
-
- Test List <span class="glyphicon glyphicon-file"></span>
- </a>
-</div>
-<!-- End Capability Filters -->
-
-<p><small>Tests marked with <span class="glyphicon glyphicon-flag text-warning"></span> are tests flagged by Interop Working Group.</small></p>
-
-<!-- Loading animation divs -->
-<div cg-busy="{promise:ctrl.versionsRequest,message:'Loading versions'}"></div>
-<div cg-busy="{promise:ctrl.capsRequest,message:'Loading capabilities'}"></div>
-
-<!-- Get the version-specific template -->
-<div ng-include src="ctrl.detailsTemplate"></div>
-
-<div ng-show="ctrl.showError" class="alert alert-danger" role="alert">
- <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
- <span class="sr-only">Error:</span>
- {{ctrl.error}}
-</div>
diff --git a/utils/test/testapi/3rd_party/static/testapi-ui/components/guidelines/guidelinesController.js b/utils/test/testapi/3rd_party/static/testapi-ui/components/guidelines/guidelinesController.js
deleted file mode 100644
index a6f4258a2..000000000
--- a/utils/test/testapi/3rd_party/static/testapi-ui/components/guidelines/guidelinesController.js
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-(function () {
- 'use strict';
-
- angular
- .module('testapiApp')
- .controller('GuidelinesController', GuidelinesController);
-
- GuidelinesController.$inject = ['$http', '$uibModal', 'testapiApiUrl'];
-
- /**
- * TestAPI Guidelines Controller
- * This controller is for the '/guidelines' page where a user can browse
- * through tests belonging to Interop WG defined capabilities.
- */
- function GuidelinesController($http, $uibModal, testapiApiUrl) {
- var ctrl = this;
-
- ctrl.getVersionList = getVersionList;
- ctrl.update = update;
- ctrl.updateTargetCapabilities = updateTargetCapabilities;
- ctrl.filterStatus = filterStatus;
- ctrl.getObjectLength = getObjectLength;
- ctrl.openTestListModal = openTestListModal;
-
- /** The target OpenStack marketing program to show capabilities for. */
- ctrl.target = 'platform';
-
- /** The various possible capability statuses. */
- ctrl.status = {
- required: true,
- advisory: false,
- deprecated: false,
- removed: false
- };
-
- /**
- * The template to load for displaying capability details.
- */
- ctrl.detailsTemplate = 'components/guidelines/partials/' +
- 'guidelineDetails.html';
-
- /**
- * Retrieve an array of available guideline files from the TestAPI
- * API server, sort this array reverse-alphabetically, and store it in
- * a scoped variable. The scope's selected version is initialized to
- * the latest (i.e. first) version here as well. After a successful API
- * call, the function to update the capabilities is called.
- * Sample API return array: ["2015.03.json", "2015.04.json"]
- */
- function getVersionList() {
- var content_url = testapiApiUrl + '/guidelines';
- ctrl.versionsRequest =
- $http.get(content_url).success(function (data) {
- ctrl.versionList = data.sort().reverse();
- // Default to the first approved guideline which is expected
- // to be at index 1.
- ctrl.version = ctrl.versionList[1];
- ctrl.update();
- }).error(function (error) {
- ctrl.showError = true;
- ctrl.error = 'Error retrieving version list: ' +
- angular.toJson(error);
- });
- }
-
- /**
- * This will contact the TestAPI API server to retrieve the JSON
- * content of the guideline file corresponding to the selected
- * version.
- */
- function update() {
- var content_url = testapiApiUrl + '/guidelines/' + ctrl.version;
- ctrl.capsRequest =
- $http.get(content_url).success(function (data) {
- ctrl.guidelines = data;
- ctrl.updateTargetCapabilities();
- }).error(function (error) {
- ctrl.showError = true;
- ctrl.guidelines = null;
- ctrl.error = 'Error retrieving guideline content: ' +
- angular.toJson(error);
- });
- }
-
- /**
- * This will update the scope's 'targetCapabilities' object with
- * capabilities belonging to the selected OpenStack marketing program
- * (programs typically correspond to 'components' in the Interop WG
- * schema). Each capability will have its status mapped to it.
- */
- function updateTargetCapabilities() {
- ctrl.targetCapabilities = {};
- var components = ctrl.guidelines.components;
- var targetCaps = ctrl.targetCapabilities;
-
- // The 'platform' target is comprised of multiple components, so
- // we need to get the capabilities belonging to each of its
- // components.
- if (ctrl.target === 'platform') {
- var platform_components = ctrl.guidelines.platform.required;
-
- // This will contain status priority values, where lower
- // values mean higher priorities.
- var statusMap = {
- required: 1,
- advisory: 2,
- deprecated: 3,
- removed: 4
- };
-
- // For each component required for the platform program.
- angular.forEach(platform_components, function (component) {
- // Get each capability list belonging to each status.
- angular.forEach(components[component],
- function (caps, status) {
- // For each capability.
- angular.forEach(caps, function(cap) {
- // If the capability has already been added.
- if (cap in targetCaps) {
- // If the status priority value is less
- // than the saved priority value, update
- // the value.
- if (statusMap[status] <
- statusMap[targetCaps[cap]]) {
- targetCaps[cap] = status;
- }
- }
- else {
- targetCaps[cap] = status;
- }
- });
- });
- });
- }
- else {
- angular.forEach(components[ctrl.target],
- function (caps, status) {
- angular.forEach(caps, function(cap) {
- targetCaps[cap] = status;
- });
- });
- }
- }
-
- /**
- * This filter will check if a capability's status corresponds
- * to a status that is checked/selected in the UI. This filter
- * is meant to be used with the ng-repeat directive.
- * @param {Object} capability
- * @returns {Boolean} True if capability's status is selected
- */
- function filterStatus(capability) {
- var caps = ctrl.targetCapabilities;
- return (ctrl.status.required &&
- caps[capability.id] === 'required') ||
- (ctrl.status.advisory &&
- caps[capability.id] === 'advisory') ||
- (ctrl.status.deprecated &&
- caps[capability.id] === 'deprecated') ||
- (ctrl.status.removed &&
- caps[capability.id] === 'removed');
- }
-
- /**
- * This function will get the length of an Object/dict based on
- * the number of keys it has.
- * @param {Object} object
- * @returns {Number} length of object
- */
- function getObjectLength(object) {
- return Object.keys(object).length;
- }
-
- /**
- * This will open the modal that will show a list of all tests
- * belonging to capabilities with the selected status(es).
- */
- function openTestListModal() {
- $uibModal.open({
- templateUrl: '/components/guidelines/partials' +
- '/testListModal.html',
- backdrop: true,
- windowClass: 'modal',
- animation: true,
- controller: 'TestListModalController as modal',
- size: 'lg',
- resolve: {
- version: function () {
- return ctrl.version.slice(0, -5);
- },
- target: function () {
- return ctrl.target;
- },
- status: function () {
- return ctrl.status;
- }
- }
- });
- }
-
- ctrl.getVersionList();
- }
-
- angular
- .module('testapiApp')
- .controller('TestListModalController', TestListModalController);
-
- TestListModalController.$inject = [
- '$uibModalInstance', '$http', 'version',
- 'target', 'status', 'testapiApiUrl'
- ];
-
- /**
- * Test List Modal Controller
- * This controller is for the modal that appears if a user wants to see the
- * test list corresponding to Interop WG capabilities with the selected
- * statuses.
- */
- function TestListModalController($uibModalInstance, $http, version,
- target, status, testapiApiUrl) {
-
- var ctrl = this;
-
- ctrl.version = version;
- ctrl.target = target;
- ctrl.status = status;
- ctrl.close = close;
- ctrl.updateTestListString = updateTestListString;
-
- ctrl.aliases = true;
- ctrl.flagged = false;
-
- // Check if the API URL is absolute or relative.
- if (testapiApiUrl.indexOf('http') > -1) {
- ctrl.url = testapiApiUrl;
- }
- else {
- ctrl.url = location.protocol + '//' + location.host +
- testapiApiUrl;
- }
-
- /**
- * This function will close/dismiss the modal.
- */
- function close() {
- $uibModalInstance.dismiss('exit');
- }
-
- /**
- * This function will return a list of statuses based on which ones
- * are selected.
- */
- function getStatusList() {
- var statusList = [];
- angular.forEach(ctrl.status, function(value, key) {
- if (value) {
- statusList.push(key);
- }
- });
- return statusList;
- }
-
- /**
- * This will get the list of tests from the API and update the
- * controller's test list string variable.
- */
- function updateTestListString() {
- var statuses = getStatusList();
- if (!statuses.length) {
- ctrl.error = 'No tests matching selected criteria.';
- return;
- }
- ctrl.testListUrl = [
- ctrl.url, '/guidelines/', ctrl.version, '/tests?',
- 'target=', ctrl.target, '&',
- 'type=', statuses.join(','), '&',
- 'alias=', ctrl.aliases.toString(), '&',
- 'flag=', ctrl.flagged.toString()
- ].join('');
- ctrl.testListRequest =
- $http.get(ctrl.testListUrl).
- then(function successCallback(response) {
- ctrl.error = null;
- ctrl.testListString = response.data;
- if (!ctrl.testListString) {
- ctrl.testListCount = 0;
- }
- else {
- ctrl.testListCount =
- ctrl.testListString.split('\n').length;
- }
- }, function errorCallback(response) {
- ctrl.testListString = null;
- ctrl.testListCount = null;
- if (angular.isObject(response.data) &&
- response.data.message) {
- ctrl.error = 'Error retrieving test list: ' +
- response.data.message;
- }
- else {
- ctrl.error = 'Unknown error retrieving test list.';
- }
- });
- }
-
- updateTestListString();
- }
-})();
diff --git a/utils/test/testapi/3rd_party/static/testapi-ui/components/guidelines/partials/guidelineDetails.html b/utils/test/testapi/3rd_party/static/testapi-ui/components/guidelines/partials/guidelineDetails.html
deleted file mode 100644
index f020c9a09..000000000
--- a/utils/test/testapi/3rd_party/static/testapi-ui/components/guidelines/partials/guidelineDetails.html
+++ /dev/null
@@ -1,50 +0,0 @@
-<!--
-HTML for guidelines page for all OpenStack Powered (TM) guideline schemas
-This expects the JSON data of the guidelines file to be stored in scope
-variable 'guidelines'.
--->
-
-<ol ng-show="ctrl.guidelines" class="capabilities">
- <li class="capability-list-item" ng-repeat="capability in ctrl.guidelines.capabilities | arrayConverter | filter:ctrl.filterStatus | orderBy:'id'">
- <span class="capability-name">{{capability.id}}</span><br />
- <em>{{capability.description}}</em><br />
- Status: <span class="{{ctrl.targetCapabilities[capability.id]}}">{{ctrl.targetCapabilities[capability.id]}}</span><br />
- <span ng-if="capability.project">Project: {{capability.project | capitalize}}<br /></span>
- <a ng-click="showAchievements = !showAchievements">Achievements ({{capability.achievements.length}})</a><br />
- <ol uib-collapse="!showAchievements" class="list-inline">
- <li ng-repeat="achievement in capability.achievements">
- {{achievement}}
- </li>
- </ol>
-
- <a ng-click="showTests = !showTests">Tests ({{ctrl.getObjectLength(capability.tests)}})</a>
- <ul uib-collapse="!showTests">
- <li ng-if="ctrl.guidelines.schema === '1.2'" ng-repeat="test in capability.tests">
- <span ng-class="{'glyphicon glyphicon-flag text-warning': capability.flagged.indexOf(test) > -1}"></span>
- {{test}}
- </li>
- <li ng-if="ctrl.guidelines.schema > '1.2'" ng-repeat="(testName, testDetails) in capability.tests">
- <span ng-class="{'glyphicon glyphicon-flag text-warning': testDetails.flagged}" title="{{testDetails.flagged.reason}}"></span>
- {{testName}}
- <div class="test-detail" ng-if="testDetails.aliases">
- <strong>Aliases:</strong>
- <ul><li ng-repeat="alias in testDetails.aliases">{{alias}}</li></ul>
- </div>
- </li>
- </ul>
- </li>
-</ol>
-
-<div ng-show="ctrl.guidelines" class="criteria">
- <hr>
- <h4><a ng-click="showCriteria = !showCriteria">Criteria</a></h4>
- <div uib-collapse="showCriteria">
- <ul>
- <li ng-repeat="(key, criterion) in ctrl.guidelines.criteria">
- <span class="criterion-name">{{criterion.name}}</span><br />
- <em>{{criterion.Description}}</em><br />
- Weight: {{criterion.weight}}
- </li>
- </ul>
- </div>
-</div>
diff --git a/utils/test/testapi/3rd_party/static/testapi-ui/components/guidelines/partials/testListModal.html b/utils/test/testapi/3rd_party/static/testapi-ui/components/guidelines/partials/testListModal.html
deleted file mode 100644
index 5b1d698d5..000000000
--- a/utils/test/testapi/3rd_party/static/testapi-ui/components/guidelines/partials/testListModal.html
+++ /dev/null
@@ -1,46 +0,0 @@
-<div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" aria-hidden="true" ng-click="modal.close()">&times;</button>
- <h4>Test List ({{modal.testListCount}})</h4>
- <p>Use this test list with <a title="testapi-client" target="_blank"href="https://github.com/openstack/testapi-client">testapi-client</a>
- to run only tests in the {{modal.version}} OpenStack Powered&#8482; guideline from capabilities with the following statuses:
- </p>
- <ul class="list-inline">
- <li class="required" ng-if="modal.status.required"> Required</li>
- <li class="advisory" ng-if="modal.status.advisory"> Advisory</li>
- <li class="deprecated" ng-if="modal.status.deprecated"> Deprecated</li>
- <li class="removed" ng-if="modal.status.removed"> Removed</li>
- </ul>
- <div class="checkbox checkbox-test-list">
- <label><input type="checkbox" ng-model="modal.aliases" ng-change="modal.updateTestListString()">Aliases</label>
- <span class="glyphicon glyphicon-info-sign info-hover" aria-hidden="true"
- title="Include test aliases as tests may have been renamed over time. It does not hurt to include these."></span>
- &nbsp;
- <label><input type="checkbox" ng-model="modal.flagged" ng-change="modal.updateTestListString()">Flagged</label>
- <span class="glyphicon glyphicon-info-sign info-hover" aria-hidden="true"
- title="Include flagged tests.">
- </span>
- </div>
- <p ng-hide="modal.error"> Alternatively, get the test list directly from the API on your CLI:</p>
- <code ng-hide="modal.error">wget "{{modal.testListUrl}}" -O {{modal.version}}-test-list.txt</code>
- </div>
- <div class="modal-body tests-modal-content">
- <div cg-busy="{promise:modal.testListRequest,message:'Loading'}"></div>
- <div ng-show="modal.error" class="alert alert-danger" role="alert">
- <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
- <span class="sr-only">Error:</span>
- {{modal.error}}
- </div>
- <div class="form-group">
- <textarea class="form-control" rows="16" id="tests" wrap="off">{{modal.testListString}}</textarea>
- </div>
- </div>
- <div class="modal-footer">
- <a target="_blank" href="{{modal.testListUrl}}" download="{{modal.version + '-test-list.txt'}}">
- <button class="btn btn-primary" ng-if="modal.testListCount > 0" type="button">
- Download
- </button>
- </a>
- <button class="btn btn-primary" type="button" ng-click="modal.close()">Close</button>
- </div>
-</div>
diff --git a/utils/test/testapi/3rd_party/static/testapi-ui/components/pods/pods.html b/utils/test/testapi/3rd_party/static/testapi-ui/components/pods/pods.html
new file mode 100644
index 000000000..cdfcfaf36
--- /dev/null
+++ b/utils/test/testapi/3rd_party/static/testapi-ui/components/pods/pods.html
@@ -0,0 +1,71 @@
+<h3>{{ctrl.pageHeader}}</h3>
+<p>{{ctrl.pageParagraph}}</p>
+<div class="row" style="margin-bottom:24px;"></div>
+
+<div class="pod-create">
+ <h4>Create</h4>
+ <div class="row">
+ <div ng-repeat="require in ctrl.createRequirements">
+ <div class="create-pod" style="margin-left:24px;">
+ <p class="input-group">
+ <label for="cpid">{{require.label|capitalize}}: </label>
+ <a ng-if="require.type == 'select'">
+ <select dynamic-model="'ctrl.' + require.label" ng-options="option for option in require.selects"></select>
+ </a>
+ <a ng-if="require.type == 'text'">
+ <input type="text" dynamic-model="'ctrl.' + require.label"/>
+ </a>
+ <a ng-if="require.type == 'textarea'">
+ <textarea rows="2" cols="50" dynamic-model="'ctrl.' + require.label">
+ </textarea>
+ </a>
+ </p>
+ </div>
+ </div>
+
+ <div class="col-md-3" style="margin-top:12px; margin-left:8px;">
+ <button type="submit" class="btn btn-primary" ng-click="ctrl.create()">Create</button>
+ </div>
+ </div>
+</div>
+
+<div class="pods-filters" style="margin-top:36px;">
+ <h4>Filters</h4>
+ <div class="row">
+ <div class="col-md-3" style="margin-top:12px; margin-left:8px;">
+ <button type="submit" class="btn btn-primary" ng-click="ctrl.update()">Filter</button>
+ <button type="submit" class="btn btn-primary btn-danger" ng-click="ctrl.clearFilters()">Clear</button>
+ </div>
+ </div>
+</div>
+
+<div cg-busy="{promise:ctrl.authRequest,message:'Loading'}"></div>
+<div cg-busy="{promise:ctrl.podsRequest,message:'Loading'}"></div>
+
+<div ng-show="ctrl.data" class="pods-table" style="margin-top:24px; margin-left:8px;">
+ <table ng-data="ctrl.data.pods" ng-show="ctrl.data" class="table table-striped table-hover">
+ <tbody>
+ <tr ng-repeat-start="(index, pod) in ctrl.data.pods">
+ <td>
+ <a href="#" ng-click="showPod = !showPod">{{pod.name}}</a>
+ <div class="show-pod" ng-class="{ 'hidden': ! showPod }" style="margin-left:24px;">
+ <p>
+ role: {{pod.role}}<br>
+ mode: {{pod.mode}}<br>
+ create_date: {{pod.creation_date}}<br>
+ details: {{pod.details}}
+ </p>
+ </div>
+ </td>
+ </tr>
+ <tr ng-repeat-end=>
+ </tr>
+ </tbody>
+ </table>
+</div>
+
+<div ng-show="ctrl.showError" class="alert alert-danger" role="alert">
+ <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
+ <span class="sr-only">Error:</span>
+ {{ctrl.error}}
+</div>
diff --git a/utils/test/testapi/3rd_party/static/testapi-ui/components/pods/podsController.js b/utils/test/testapi/3rd_party/static/testapi-ui/components/pods/podsController.js
new file mode 100644
index 000000000..53e8b1eff
--- /dev/null
+++ b/utils/test/testapi/3rd_party/static/testapi-ui/components/pods/podsController.js
@@ -0,0 +1,119 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+(function () {
+ 'use strict';
+
+ angular
+ .module('testapiApp')
+ .controller('PodsController', PodsController);
+
+ PodsController.$inject = [
+ '$scope', '$http', '$filter', '$state', 'testapiApiUrl','raiseAlert'
+ ];
+
+ /**
+ * TestAPI Pods Controller
+ * This controller is for the '/pods' page where a user can browse
+ * through pods declared in TestAPI.
+ */
+ function PodsController($scope, $http, $filter, $state, testapiApiUrl,
+ raiseAlert) {
+ var ctrl = this;
+
+ ctrl.url = testapiApiUrl + '/pods';
+
+ ctrl.create = create;
+ ctrl.update = update;
+ ctrl.open = open;
+ ctrl.clearFilters = clearFilters;
+
+ ctrl.roles = ['community-ci', 'production-ci'];
+ ctrl.modes = ['metal', 'virtual'];
+ ctrl.createRequirements = [
+ {label: 'name', type: 'text', required: true},
+ {label: 'mode', type: 'select', selects: ctrl.modes},
+ {label: 'role', type: 'select', selects: ctrl.roles},
+ {label: 'details', type: 'textarea', required: false}
+ ];
+
+ ctrl.name = '';
+ ctrl.role = 'community-ci';
+ ctrl.mode = 'metal';
+ ctrl.details = '';
+
+ ctrl.pageHeader = 'Pods';
+ ctrl.pageParagraph = 'This page is used to create or query pods.';
+
+ /**
+ * This is called when the date filter calendar is opened. It
+ * does some event handling, and sets a scope variable so the UI
+ * knows which calendar was opened.
+ * @param {Object} $event - The Event object
+ * @param {String} openVar - Tells which calendar was opened
+ */
+ function open($event, openVar) {
+ $event.preventDefault();
+ $event.stopPropagation();
+ ctrl[openVar] = true;
+ }
+
+ /**
+ * This function will clear all filters and update the results
+ * listing.
+ */
+ function clearFilters() {
+ ctrl.update();
+ }
+
+ /**
+ * This will contact the TestAPI to create a new pod.
+ */
+ function create() {
+ ctrl.showError = false;
+ var pods_url = ctrl.url;
+ var body = {
+ name: ctrl.name,
+ mode: ctrl.mode,
+ role: ctrl.role,
+ details: ctrl.details
+ };
+
+ ctrl.podsRequest =
+ $http.post(pods_url, body).error(function (error) {
+ ctrl.showError = true;
+ ctrl.error =
+ 'Error creating the new pod from server: ' +
+ angular.toJson(error);
+ });
+ }
+
+ /**
+ * This will contact the TestAPI to get a listing of declared pods.
+ */
+ function update() {
+ ctrl.showError = false;
+ ctrl.podsRequest =
+ $http.get(ctrl.url).success(function (data) {
+ ctrl.data = data;
+ }).error(function (error) {
+ ctrl.data = null;
+ ctrl.showError = true;
+ ctrl.error =
+ 'Error retrieving pods from server: ' +
+ angular.toJson(error);
+ });
+ }
+ }
+})();
diff --git a/utils/test/testapi/3rd_party/static/testapi-ui/components/results/results.html b/utils/test/testapi/3rd_party/static/testapi-ui/components/results/results.html
index 3056e1dbe..2ae5339a0 100644
--- a/utils/test/testapi/3rd_party/static/testapi-ui/components/results/results.html
+++ b/utils/test/testapi/3rd_party/static/testapi-ui/components/results/results.html
@@ -1,6 +1,23 @@
<h3>{{ctrl.pageHeader}}</h3>
<p>{{ctrl.pageParagraph}}</p>
-
+<form class="form-inline" ng-show="ctrl.isUserResults">
+<h4>Upload Results</h4>
+<div class="form-group col-m-3">
+ <input class="form-contrl btn btn-default" type = "file" file-model = "resultFile"/>
+</div>
+<div class="checkbox col-m-1">
+ <label>
+ <input type="checkbox" ng-model="ctrl.isPublic">public
+ </label>
+</div>
+<div class="form-group col-m-3">
+ <button class="btn btn-primary" ng-click = "ctrl.uploadFile()">upload result</button>
+</div>
+<div>
+<lable>{{ctrl.uploadState}}</label>
+</div>
+</form>
+<div class="row" style="margin-bottom:24px;"></div>
<div class="result-filters">
<h4>Filters</h4>
<div class="row">
@@ -41,7 +58,6 @@
<div cg-busy="{promise:ctrl.authRequest,message:'Loading'}"></div>
<div cg-busy="{promise:ctrl.resultsRequest,message:'Loading'}"></div>
-
<div ng-show="ctrl.data" class="results-table">
<table ng-data="ctrl.data.result" ng-show="ctrl.data" class="table table-striped table-hover">
<thead>
diff --git a/utils/test/testapi/3rd_party/static/testapi-ui/components/results/resultsController.js b/utils/test/testapi/3rd_party/static/testapi-ui/components/results/resultsController.js
index 93a549a7f..cc6cc0b6e 100644
--- a/utils/test/testapi/3rd_party/static/testapi-ui/components/results/resultsController.js
+++ b/utils/test/testapi/3rd_party/static/testapi-ui/components/results/resultsController.js
@@ -19,6 +19,24 @@
.module('testapiApp')
.controller('ResultsController', ResultsController);
+ angular
+ .module('testapiApp')
+ .directive('fileModel', ['$parse', function ($parse) {
+ return {
+ restrict: 'A',
+ link: function(scope, element, attrs) {
+ var model = $parse(attrs.fileModel);
+ var modelSetter = model.assign;
+
+ element.bind('change', function(){
+ scope.$apply(function(){
+ modelSetter(scope, element[0].files[0]);
+ });
+ });
+ }
+ };
+ }]);
+
ResultsController.$inject = [
'$scope', '$http', '$filter', '$state', 'testapiApiUrl','raiseAlert'
];
@@ -32,6 +50,7 @@
raiseAlert) {
var ctrl = this;
+ ctrl.uploadFile=uploadFile;
ctrl.update = update;
ctrl.open = open;
ctrl.clearFilters = clearFilters;
@@ -76,6 +95,8 @@
ctrl.format = 'yyyy-MM-dd';
/** Check to see if this page should display user-specific results. */
+ // ctrl.isUserResults = $state.current.name === 'userResults';
+ // need auth to browse
ctrl.isUserResults = $state.current.name === 'userResults';
// Should only be on user-results-page if authenticated.
@@ -91,14 +112,49 @@
'The most recently uploaded community test results are listed ' +
'here.';
+ ctrl.uploadState = '';
+
+ ctrl.isPublic = false;
+
if (ctrl.isUserResults) {
ctrl.authRequest = $scope.auth.doSignCheck()
.then(ctrl.update);
- ctrl.getUserProducts();
+ // ctrl.getUserProducts();
} else {
ctrl.update();
}
+
+ function uploadFileToUrl(file, uploadUrl){
+ var fd = new FormData();
+ fd.append('file', file);
+ fd.append('public', ctrl.isPublic)
+
+ $http.post(uploadUrl, fd, {
+ transformRequest: angular.identity,
+ headers: {'Content-Type': undefined}
+ })
+
+ .success(function(data){
+ var id = data.href.substr(data.href.lastIndexOf('/')+1);
+ ctrl.uploadState = "Upload succeed. Result id is " + id;
+ ctrl.update();
+ })
+
+ .error(function(data, status){
+ ctrl.uploadState = "Upload failed. Error code is " + status;
+ });
+ }
+
+ function uploadFile(){
+ var file = $scope.resultFile;
+ console.log('file is ' );
+ console.dir(file);
+
+ var uploadUrl = testapiApiUrl + "/results/upload";
+ uploadFileToUrl(file, uploadUrl);
+ };
+
/**
* This will contact the TestAPI API to get a listing of test run
* results.
@@ -123,8 +179,8 @@
ctrl.resultsRequest =
$http.get(content_url).success(function (data) {
ctrl.data = data;
- ctrl.totalItems = 20 // ctrl.data.pagination.total_pages * ctrl.itemsPerPage;
- ctrl.currentPage = 1 // ctrl.data.pagination.current_page;
+ ctrl.totalItems = ctrl.data.pagination.total_pages * ctrl.itemsPerPage;
+ ctrl.currentPage = ctrl.data.pagination.current_page;
}).error(function (error) {
ctrl.data = null;
ctrl.totalItems = 0;
diff --git a/utils/test/testapi/3rd_party/static/testapi-ui/index.html b/utils/test/testapi/3rd_party/static/testapi-ui/index.html
index 46ccc61b8..2d7399f93 100644
--- a/utils/test/testapi/3rd_party/static/testapi-ui/index.html
+++ b/utils/test/testapi/3rd_party/static/testapi-ui/index.html
@@ -40,7 +40,7 @@
<script src="testapi-ui/shared/header/headerController.js"></script>
<script src="testapi-ui/shared/alerts/alertModalFactory.js"></script>
<script src="testapi-ui/shared/alerts/confirmModalFactory.js"></script>
- <script src="testapi-ui/components/guidelines/guidelinesController.js"></script>
+ <script src="testapi-ui/components/pods/podsController.js"></script>
<script src="testapi-ui/components/results/resultsController.js"></script>
<script src="testapi-ui/components/results-report/resultsReportController.js"></script>
<script src="testapi-ui/components/profile/profileController.js"></script>
diff --git a/utils/test/testapi/3rd_party/static/testapi-ui/shared/header/header.html b/utils/test/testapi/3rd_party/static/testapi-ui/shared/header/header.html
index f2c49e86f..f5b2414c4 100644
--- a/utils/test/testapi/3rd_party/static/testapi-ui/shared/header/header.html
+++ b/utils/test/testapi/3rd_party/static/testapi-ui/shared/header/header.html
@@ -17,7 +17,7 @@ TestAPI
<ul class="nav navbar-nav">
<li ng-class="{ active: header.isActive('/')}"><a ui-sref="home">Home</a></li>
<li ng-class="{ active: header.isActive('/about')}"><a ui-sref="about">About</a></li>
- <li ng-class="{ active: header.isActive('/guidelines')}"><a ui-sref="guidelines">OPNFV Powered&#8482; Guidelines</a></li>
+ <li ng-class="{ active: header.isActive('/pods')}"><a ui-sref="pods">Pods</a></li>
<li ng-class="{ active: header.isActive('/community_results')}"><a ui-sref="communityResults">Community Results</a></li>
<!--
<li ng-class="{ active: header.isCatalogActive('public')}" class="dropdown" uib-dropdown>
@@ -33,6 +33,7 @@ TestAPI
</ul>
<ul class="nav navbar-nav navbar-right">
<li ng-class="{ active: header.isActive('/user_results')}" ng-if="auth.isAuthenticated"><a ui-sref="userResults">My Results</a></li>
+ <!--
<li ng-if="auth.isAuthenticated" ng-class="{ active: header.isCatalogActive('user')}" class="dropdown" uib-dropdown>
<a role="button" class="dropdown-toggle" uib-dropdown-toggle>
My Catalog <strong class="caret"></strong>
@@ -42,6 +43,7 @@ TestAPI
<li><a ui-sref="userProducts">My Products</a></li>
</ul>
</li>
+ -->
<li ng-class="{ active: header.isActive('/profile')}" ng-if="auth.isAuthenticated"><a ui-sref="profile">Profile</a></li>
<li ng-if="auth.isAuthenticated"><a href="" ng-click="auth.doSignOut()">Sign Out</a></li>
<li ng-if="!auth.isAuthenticated"><a href="" ng-click="auth.doSignIn()">Sign In / Sign Up</a></li>
diff --git a/utils/test/testapi/deployment/deploy.py b/utils/test/testapi/deployment/deploy.py
index 748bd34f8..6433fa6b2 100644
--- a/utils/test/testapi/deployment/deploy.py
+++ b/utils/test/testapi/deployment/deploy.py
@@ -8,10 +8,10 @@ docker_compose_yml = './docker-compose.yml'
docker_compose_template = './docker-compose.yml.template'
-def render_docker_compose(port, swagger_url):
+def render_docker_compose(port, base_url):
vars = {
"expose_port": port,
- "swagger_url": swagger_url,
+ "base_url": base_url,
}
template = env.get_template(docker_compose_template)
yml = template.render(vars=vars)
@@ -22,7 +22,7 @@ def render_docker_compose(port, swagger_url):
def main(args):
- render_docker_compose(args.expose_port, args.swagger_url)
+ render_docker_compose(args.expose_port, args.base_url)
os.system('docker-compose -f {} up -d'.format(docker_compose_yml))
@@ -33,8 +33,8 @@ if __name__ == '__main__':
required=False,
default=8000,
help='testapi exposed port')
- parser.add_argument('-su', '--swagger-url',
+ parser.add_argument('-l', '--base-url',
type=str,
required=True,
- help='testapi exposed swagger-url')
+ help='testapi exposed base-url')
main(parser.parse_args())
diff --git a/utils/test/testapi/deployment/docker-compose.yml.template b/utils/test/testapi/deployment/docker-compose.yml.template
index 5b131f747..cd684048e 100644
--- a/utils/test/testapi/deployment/docker-compose.yml.template
+++ b/utils/test/testapi/deployment/docker-compose.yml.template
@@ -8,7 +8,7 @@ services:
container_name: opnfv-testapi
environment:
- mongodb_url=mongodb://mongo:27017/
- - swagger_url={{ vars.swagger_url }}
+ - base_url={{ vars.base_url }}
ports:
- "{{ vars.expose_port }}:8000"
links:
diff --git a/utils/test/testapi/docker/Dockerfile b/utils/test/testapi/docker/Dockerfile
index e031e194c..a46fce20a 100644
--- a/utils/test/testapi/docker/Dockerfile
+++ b/utils/test/testapi/docker/Dockerfile
@@ -9,7 +9,7 @@
#
# Execution:
# $ docker run -dti -p 8001:8000 \
-# -e "swagger_url=http://10.63.243.17:8001" \
+# -e "base_url=http://10.63.243.17:8001" \
# -e "mongodb_url=mongodb://10.63.243.17:27017/" \
# opnfv/testapi:tag
#
@@ -47,5 +47,5 @@ RUN git clone https://gerrit.opnfv.org/gerrit/releng /home/releng
WORKDIR /home/releng/utils/test/testapi/
RUN pip install -r requirements.txt
-RUN bash install.sh
+RUN python setup.py install
CMD ["bash", "docker/start-server.sh"]
diff --git a/utils/test/testapi/docker/prepare-env.sh b/utils/test/testapi/docker/prepare-env.sh
index 9f07efbd1..b14bc2448 100755
--- a/utils/test/testapi/docker/prepare-env.sh
+++ b/utils/test/testapi/docker/prepare-env.sh
@@ -6,6 +6,9 @@ if [ "$mongodb_url" != "" ]; then
sudo crudini --set --existing $FILE mongo url $mongodb_url
fi
-if [ "$swagger_url" != "" ]; then
- sudo crudini --set --existing $FILE swagger base_url $swagger_url
+if [ "$base_url" != "" ]; then
+ sudo crudini --set --existing $FILE api url $base_url/api/v1
+ sudo crudini --set --existing $FILE ui url $base_url
+ sudo echo "{\"testapiApiUrl\": \"$base_url/api/v1\"}" > \
+ /usr/local/lib/python2.7/dist-packages/opnfv_testapi/static/testapi-ui/config.json
fi
diff --git a/utils/test/testapi/etc/config.ini b/utils/test/testapi/etc/config.ini
index 692e48897..1ec899fcb 100644
--- a/utils/test/testapi/etc/config.ini
+++ b/utils/test/testapi/etc/config.ini
@@ -10,13 +10,14 @@ dbname = test_results_collection
# Listening port
url = http://localhost:8000/api/v1
port = 8000
+
+# Number of results for one page (integer value)
+results_per_page = 20
+
# With debug_on set to true, error traces will be shown in HTTP responses
debug = True
authenticate = False
-[swagger]
-base_url = http://localhost:8000
-
[ui]
url = http://localhost:8000
@@ -41,7 +42,7 @@ openid_ns = http://specs.openid.net/auth/2.0
# Return endpoint in Refstack's API. Value indicating the endpoint
# where the user should be returned to after signing in. Openstack Id
# Idp only supports HTTPS address types. (string value)
-openid_return_to = /api/v1/auth/signin_return
+openid_return_to = v1/auth/signin_return
# Claimed identifier. This value must be set to
# "http://specs.openid.net/auth/2.0/identifier_select". or to user
diff --git a/utils/test/testapi/htmlize/htmlize.py b/utils/test/testapi/htmlize/htmlize.py
index b8c4fb43f..da6a6cf91 100644
--- a/utils/test/testapi/htmlize/htmlize.py
+++ b/utils/test/testapi/htmlize/htmlize.py
@@ -33,6 +33,7 @@ def main(args):
else:
exit(1)
+
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Create \
Swagger Spec documentation')
@@ -40,13 +41,13 @@ if __name__ == '__main__':
type=str,
required=False,
default=('http://testresults.opnfv.org'
- '/test/swagger/spec.json'),
+ '/test/swagger/resources.json'),
help='Resource Listing Spec File')
parser.add_argument('-au', '--api-declaration-url',
type=str,
required=False,
default=('http://testresults.opnfv.org'
- '/test/swagger/spec'),
+ '/test/swagger/APIs'),
help='API Declaration Spec File')
parser.add_argument('-o', '--output-directory',
required=True,
diff --git a/utils/test/testapi/install.sh b/utils/test/testapi/install.sh
deleted file mode 100755
index d470e38c3..000000000
--- a/utils/test/testapi/install.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/bash
-
-usage="
-Script to install opnfv_tesgtapi automatically.
-This script should be run under root.
-
-usage:
- bash $(basename "$0") [-h|--help] [-t <test_name>]
-
-where:
- -h|--help show this help text"
-
-# Ref :- https://openstack.nimeyo.com/87286/openstack-packaging-all-definition-data-files-config-setup
-if [ -z "$VIRTUAL_ENV" ];
-then
- if [[ $(whoami) != "root" ]];
- then
- echo "Error: This script must be run as root!"
- exit 1
- fi
-else
- sed -i -e 's#/etc/opnfv_testapi =#etc/opnfv_testapi =#g' setup.cfg
-fi
-
-cp -fr 3rd_party/static opnfv_testapi/static
-python setup.py install
-rm -fr opnfv_testapi/static
-if [ ! -z "$VIRTUAL_ENV" ]; then
- sed -i -e 's#etc/opnfv_testapi =#/etc/opnfv_testapi =#g' setup.cfg
-fi \ No newline at end of file
diff --git a/utils/test/testapi/opnfv_testapi/cmd/server.py b/utils/test/testapi/opnfv_testapi/cmd/server.py
index 545d5e367..50ac049a0 100644
--- a/utils/test/testapi/opnfv_testapi/cmd/server.py
+++ b/utils/test/testapi/opnfv_testapi/cmd/server.py
@@ -29,40 +29,18 @@ TODOs :
"""
-import argparse
-import sys
-
-import motor
import tornado.ioloop
-from opnfv_testapi.common import config
+from opnfv_testapi.common.config import CONF
from opnfv_testapi.router import url_mappings
from opnfv_testapi.tornado_swagger import swagger
-CONF = None
-
-
-def parse_config(argv=[]):
- global CONF
- parser = argparse.ArgumentParser()
- parser.add_argument("-c", "--config-file", dest='config_file',
- help="Config file location")
- args = parser.parse_args(argv)
- if args.config_file:
- config.Config.CONFIG = args.config_file
- CONF = config.Config()
-
-
-def get_db():
- return motor.MotorClient(CONF.mongo_url)[CONF.mongo_dbname]
-
def make_app():
- swagger.docs(base_url=CONF.swagger_base_url,
+ swagger.docs(base_url=CONF.ui_url,
static_path=CONF.static_path)
return swagger.Application(
url_mappings.mappings,
- db=get_db(),
debug=CONF.api_debug,
auth=CONF.api_authenticate,
cookie_secret='opnfv-testapi',
@@ -70,7 +48,6 @@ def make_app():
def main():
- parse_config(sys.argv[1:])
application = make_app()
application.listen(CONF.api_port)
tornado.ioloop.IOLoop.current().start()
diff --git a/utils/test/testapi/opnfv_testapi/common/check.py b/utils/test/testapi/opnfv_testapi/common/check.py
index 67e8fbd40..24ba876a9 100644
--- a/utils/test/testapi/opnfv_testapi/common/check.py
+++ b/utils/test/testapi/opnfv_testapi/common/check.py
@@ -13,6 +13,7 @@ from tornado import web
from opnfv_testapi.common import message
from opnfv_testapi.common import raises
+from opnfv_testapi.db import api as dbapi
def authenticate(method):
@@ -26,7 +27,7 @@ def authenticate(method):
except KeyError:
raises.Unauthorized(message.unauthorized())
query = {'access_token': token}
- check = yield self._eval_db_find_one(query, 'tokens')
+ check = yield dbapi.db_find_one('tokens', query)
if not check:
raises.Forbidden(message.invalid_token())
ret = yield gen.coroutine(method)(self, *args, **kwargs)
@@ -38,7 +39,7 @@ def not_exist(xstep):
@functools.wraps(xstep)
def wrap(self, *args, **kwargs):
query = kwargs.get('query')
- data = yield self._eval_db_find_one(query)
+ data = yield dbapi.db_find_one(self.table, query)
if not data:
raises.NotFound(message.not_found(self.table, query))
ret = yield gen.coroutine(xstep)(self, data, *args, **kwargs)
@@ -78,7 +79,7 @@ def carriers_exist(xstep):
carriers = kwargs.pop('carriers', {})
if carriers:
for table, query in carriers:
- exist = yield self._eval_db_find_one(query(), table)
+ exist = yield dbapi.db_find_one(table, query())
if not exist:
raises.Forbidden(message.not_found(table, query()))
ret = yield gen.coroutine(xstep)(self, *args, **kwargs)
@@ -91,7 +92,7 @@ def new_not_exists(xstep):
def wrap(self, *args, **kwargs):
query = kwargs.get('query')
if query:
- to_data = yield self._eval_db_find_one(query())
+ to_data = yield dbapi.db_find_one(self.table, query())
if to_data:
raises.Forbidden(message.exist(self.table, query()))
ret = yield gen.coroutine(xstep)(self, *args, **kwargs)
@@ -105,7 +106,7 @@ def updated_one_not_exist(xstep):
db_keys = kwargs.pop('db_keys', [])
query = self._update_query(db_keys, data)
if query:
- to_data = yield self._eval_db_find_one(query)
+ to_data = yield dbapi.db_find_one(self.table, query)
if to_data:
raises.Forbidden(message.exist(self.table, query))
ret = yield gen.coroutine(xstep)(self, data, *args, **kwargs)
diff --git a/utils/test/testapi/opnfv_testapi/common/config.py b/utils/test/testapi/opnfv_testapi/common/config.py
index 46765ffd1..4cd53c619 100644
--- a/utils/test/testapi/opnfv_testapi/common/config.py
+++ b/utils/test/testapi/opnfv_testapi/common/config.py
@@ -8,26 +8,29 @@
# feng.xiaowei@zte.com.cn remove prepare_put_request 5-30-2016
##############################################################################
import ConfigParser
+import argparse
import os
+import sys
class Config(object):
- CONFIG = None
def __init__(self):
- self.file = self.CONFIG if self.CONFIG else self._default_config()
+ self.config_file = None
+ self._set_config_file()
self._parse()
+ self._parse_per_page()
self.static_path = os.path.join(
os.path.dirname(os.path.normpath(__file__)),
os.pardir,
'static')
def _parse(self):
- if not os.path.exists(self.file):
- raise Exception("%s not found" % self.file)
+ if not os.path.exists(self.config_file):
+ raise Exception("%s not found" % self.config_file)
config = ConfigParser.RawConfigParser()
- config.read(self.file)
+ config.read(self.config_file)
self._parse_section(config)
def _parse_section(self, config):
@@ -37,6 +40,10 @@ class Config(object):
[setattr(self, '{}_{}'.format(section, k), self._parse_value(v))
for k, v in config.items(section)]
+ def _parse_per_page(self):
+ if not hasattr(self, 'api_results_per_page'):
+ self.api_results_per_page = 20
+
@staticmethod
def _parse_value(value):
try:
@@ -48,8 +55,24 @@ class Config(object):
value = False
return value
- @staticmethod
- def _default_config():
+ def _set_config_file(self):
+ if not self._set_sys_config_file():
+ self._set_default_config_file()
+
+ def _set_sys_config_file(self):
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-c", "--config-file", dest='config_file',
+ help="Config file location", metavar="FILE")
+ args, _ = parser.parse_known_args(sys.argv)
+ try:
+ self.config_file = args.config_file
+ finally:
+ return self.config_file is not None
+
+ def _set_default_config_file(self):
is_venv = os.getenv('VIRTUAL_ENV')
- return os.path.join('/' if not is_venv else is_venv,
- 'etc/opnfv_testapi/config.ini')
+ self.config_file = os.path.join('/' if not is_venv else is_venv,
+ 'etc/opnfv_testapi/config.ini')
+
+
+CONF = Config()
diff --git a/utils/test/testapi/opnfv_testapi/common/message.py b/utils/test/testapi/opnfv_testapi/common/message.py
index 98536ff4b..951cbaf9c 100644
--- a/utils/test/testapi/opnfv_testapi/common/message.py
+++ b/utils/test/testapi/opnfv_testapi/common/message.py
@@ -10,6 +10,10 @@ not_found_base = 'Could Not Found'
exist_base = 'Already Exists'
+def key_error(key):
+ return "KeyError: '{}'".format(key)
+
+
def no_body():
return 'No Body'
diff --git a/utils/test/testapi/opnfv_testapi/common/raises.py b/utils/test/testapi/opnfv_testapi/common/raises.py
index ec6b8a564..55c58c9e2 100644
--- a/utils/test/testapi/opnfv_testapi/common/raises.py
+++ b/utils/test/testapi/opnfv_testapi/common/raises.py
@@ -26,6 +26,10 @@ class Forbidden(Raiser):
code = httplib.FORBIDDEN
+class Conflict(Raiser):
+ code = httplib.CONFLICT
+
+
class NotFound(Raiser):
code = httplib.NOT_FOUND
diff --git a/utils/test/testapi/opnfv_testapi/db/__init__.py b/utils/test/testapi/opnfv_testapi/db/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/utils/test/testapi/opnfv_testapi/db/__init__.py
diff --git a/utils/test/testapi/opnfv_testapi/db/api.py b/utils/test/testapi/opnfv_testapi/db/api.py
new file mode 100644
index 000000000..c057480d4
--- /dev/null
+++ b/utils/test/testapi/opnfv_testapi/db/api.py
@@ -0,0 +1,38 @@
+import motor
+
+from opnfv_testapi.common.config import CONF
+
+DB = motor.MotorClient(CONF.mongo_url)[CONF.mongo_dbname]
+
+
+def db_update(collection, query, update_req):
+ return _eval_db(collection, 'update', query, update_req, check_keys=False)
+
+
+def db_delete(collection, query):
+ return _eval_db(collection, 'remove', query)
+
+
+def db_aggregate(collection, pipelines):
+ return _eval_db(collection, 'aggregate', pipelines, allowDiskUse=True)
+
+
+def db_list(collection, query):
+ return _eval_db(collection, 'find', query)
+
+
+def db_save(collection, data):
+ return _eval_db(collection, 'insert', data, check_keys=False)
+
+
+def db_find_one(collection, query):
+ return _eval_db(collection, 'find_one', query)
+
+
+def _eval_db(collection, method, *args, **kwargs):
+ exec_collection = DB.__getattr__(collection)
+ return exec_collection.__getattribute__(method)(*args, **kwargs)
+
+
+def _eval_db_find_one(query, table=None):
+ return _eval_db(table, 'find_one', query)
diff --git a/utils/test/testapi/opnfv_testapi/resources/handlers.py b/utils/test/testapi/opnfv_testapi/resources/handlers.py
index 2fc31ca45..ed55c7028 100644
--- a/utils/test/testapi/opnfv_testapi/resources/handlers.py
+++ b/utils/test/testapi/opnfv_testapi/resources/handlers.py
@@ -20,8 +20,8 @@
# feng.xiaowei@zte.com.cn remove DashboardHandler 5-30-2016
##############################################################################
-from datetime import datetime
import json
+from datetime import datetime
from tornado import gen
from tornado import web
@@ -29,6 +29,7 @@ from tornado import web
from opnfv_testapi.common import check
from opnfv_testapi.common import message
from opnfv_testapi.common import raises
+from opnfv_testapi.db import api as dbapi
from opnfv_testapi.resources import models
from opnfv_testapi.tornado_swagger import swagger
@@ -38,7 +39,6 @@ DEFAULT_REPRESENTATION = "application/json"
class GenericApiHandler(web.RequestHandler):
def __init__(self, application, request, **kwargs):
super(GenericApiHandler, self).__init__(application, request, **kwargs)
- self.db = self.settings["db"]
self.json_args = None
self.table = None
self.table_cls = None
@@ -50,7 +50,7 @@ class GenericApiHandler(web.RequestHandler):
self.auth = self.settings["auth"]
def prepare(self):
- if self.request.method != "GET" and self.request.method != "DELETE":
+ if self.request.body:
if self.request.headers.get("Content-Type") is not None:
if self.request.headers["Content-Type"].startswith(
DEFAULT_REPRESENTATION):
@@ -90,8 +90,7 @@ class GenericApiHandler(web.RequestHandler):
if self.table != 'results':
data.creation_date = datetime.now()
- _id = yield self._eval_db(self.table, 'insert', data.format(),
- check_keys=False)
+ _id = yield dbapi.db_save(self.table, data.format())
if 'name' in self.json_args:
resource = data.name
else:
@@ -101,22 +100,72 @@ class GenericApiHandler(web.RequestHandler):
@web.asynchronous
@gen.coroutine
def _list(self, query=None, res_op=None, *args, **kwargs):
+ sort = kwargs.get('sort')
+ page = kwargs.get('page', 0)
+ last = kwargs.get('last', 0)
+ per_page = kwargs.get('per_page', 0)
if query is None:
query = {}
- data = []
- cursor = self._eval_db(self.table, 'find', query)
- if 'sort' in kwargs:
- cursor = cursor.sort(kwargs.get('sort'))
- if 'last' in kwargs:
- cursor = cursor.limit(kwargs.get('last'))
- while (yield cursor.fetch_next):
- data.append(self.format_data(cursor.next_object()))
+ pipelines = list()
+ pipelines.append({'$match': query})
+
+ total_pages = 0
+ data = list()
+ cursor = dbapi.db_list(self.table, query)
+ records_count = yield cursor.count()
+ if records_count > 0:
+ if page > 0:
+ total_pages, return_nr = self._calc_total_pages(records_count,
+ last,
+ page,
+ per_page)
+ pipelines = self._set_pipelines(pipelines,
+ sort,
+ return_nr,
+ page,
+ per_page)
+ cursor = dbapi.db_aggregate(self.table, pipelines)
+ while (yield cursor.fetch_next):
+ data.append(self.format_data(cursor.next_object()))
if res_op is None:
res = {self.table: data}
else:
res = res_op(data, *args)
+ if page > 0:
+ res.update({
+ 'pagination': {
+ 'current_page': kwargs.get('page'),
+ 'total_pages': total_pages
+ }
+ })
self.finish_request(res)
+ @staticmethod
+ def _calc_total_pages(records_count, last, page, per_page):
+ records_nr = records_count
+ if (records_count > last) and (last > 0):
+ records_nr = last
+
+ total_pages, remainder = divmod(records_nr, per_page)
+ if remainder > 0:
+ total_pages += 1
+ if page > 1 and page > total_pages:
+ raises.BadRequest(
+ 'Request page > total_pages [{}]'.format(total_pages))
+ return total_pages, records_nr
+
+ @staticmethod
+ def _set_pipelines(pipelines, sort, return_nr, page, per_page):
+ if sort:
+ pipelines.append({'$sort': sort})
+
+ over = (page - 1) * per_page
+ left = return_nr - over
+ pipelines.append({'$skip': over})
+ pipelines.append({'$limit': per_page if per_page < left else left})
+
+ return pipelines
+
@web.asynchronous
@gen.coroutine
@check.not_exist
@@ -126,7 +175,7 @@ class GenericApiHandler(web.RequestHandler):
@check.authenticate
@check.not_exist
def _delete(self, data, query=None):
- yield self._eval_db(self.table, 'remove', query)
+ yield dbapi.db_delete(self.table, query)
self.finish_request()
@check.authenticate
@@ -136,11 +185,20 @@ class GenericApiHandler(web.RequestHandler):
def _update(self, data, query=None, **kwargs):
data = self.table_cls.from_dict(data)
update_req = self._update_requests(data)
- yield self._eval_db(self.table, 'update', query, update_req,
- check_keys=False)
+ yield dbapi.db_update(self.table, query, update_req)
update_req['_id'] = str(data._id)
self.finish_request(update_req)
+ @check.authenticate
+ @check.no_body
+ @check.not_exist
+ @check.updated_one_not_exist
+ def pure_update(self, data, query=None, **kwargs):
+ data = self.table_cls.from_dict(data)
+ update_req = self._update_requests(data)
+ yield dbapi.db_update(self.table, query, update_req)
+ self.finish_request()
+
def _update_requests(self, data):
request = dict()
for k, v in self.json_args.iteritems():
@@ -180,23 +238,6 @@ class GenericApiHandler(web.RequestHandler):
query[key] = new
return query if not equal else dict()
- def _eval_db(self, table, method, *args, **kwargs):
- exec_collection = self.db.__getattr__(table)
- return exec_collection.__getattribute__(method)(*args, **kwargs)
-
- def _eval_db_find_one(self, query, table=None):
- if table is None:
- table = self.table
- return self._eval_db(table, 'find_one', query)
-
- def db_save(self, collection, data):
- self._eval_db(collection, 'insert', data, check_keys=False)
-
- def db_find_one(self, query, collection=None):
- if not collection:
- collection = self.table
- return self._eval_db(collection, 'find_one', query)
-
class VersionHandler(GenericApiHandler):
@swagger.operation(nickname='listAllVersions')
diff --git a/utils/test/testapi/opnfv_testapi/resources/models.py b/utils/test/testapi/opnfv_testapi/resources/models.py
index e8fc532b7..e70a6ed23 100644
--- a/utils/test/testapi/opnfv_testapi/resources/models.py
+++ b/utils/test/testapi/opnfv_testapi/resources/models.py
@@ -48,6 +48,29 @@ class ModelBase(object):
return t
+ @classmethod
+ def from_dict_with_raise(cls, a_dict):
+ if a_dict is None:
+ return None
+
+ attr_parser = cls.attr_parser()
+ t = cls()
+ for k, v in a_dict.iteritems():
+ if k not in t.__dict__:
+ raise AttributeError(
+ '{} has no attribute {}'.format(cls.__name__, k))
+ value = v
+ if isinstance(v, dict) and k in attr_parser:
+ value = attr_parser[k].from_dict_with_raise(v)
+ elif isinstance(v, list) and k in attr_parser:
+ value = []
+ for item in v:
+ value.append(attr_parser[k].from_dict_with_raise(item))
+
+ t.__setattr__(k, value)
+
+ return t
+
@staticmethod
def attr_parser():
return {}
diff --git a/utils/test/testapi/opnfv_testapi/resources/result_handlers.py b/utils/test/testapi/opnfv_testapi/resources/result_handlers.py
index 824a89e58..9389d266d 100644
--- a/utils/test/testapi/opnfv_testapi/resources/result_handlers.py
+++ b/utils/test/testapi/opnfv_testapi/resources/result_handlers.py
@@ -6,16 +6,20 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+import logging
from datetime import datetime
from datetime import timedelta
+import json
from bson import objectid
+from opnfv_testapi.common.config import CONF
from opnfv_testapi.common import message
from opnfv_testapi.common import raises
from opnfv_testapi.resources import handlers
from opnfv_testapi.resources import result_models
from opnfv_testapi.tornado_swagger import swagger
+from opnfv_testapi.ui.auth import constants as auth_const
class GenericResultHandler(handlers.GenericApiHandler):
@@ -37,6 +41,7 @@ class GenericResultHandler(handlers.GenericApiHandler):
query = dict()
date_range = dict()
+ query['public'] = {'$not': {'$eq': 'false'}}
for k in self.request.query_arguments.keys():
v = self.get_query_argument(k)
if k == 'project' or k == 'pod' or k == 'case':
@@ -53,10 +58,24 @@ class GenericResultHandler(handlers.GenericApiHandler):
date_range.update({'$gte': str(v)})
elif k == 'to':
date_range.update({'$lt': str(v)})
- elif k != 'last' and k != 'page':
+ elif k == 'signed':
+ openid = self.get_secure_cookie(auth_const.OPENID)
+ role = self.get_secure_cookie(auth_const.ROLE)
+ logging.info('role:%s', role)
+ if role:
+ del query['public']
+ if role != "reviewer":
+ query['user'] = openid
+ elif k not in ['last', 'page', 'descend']:
query[k] = v
if date_range:
query['start_date'] = date_range
+
+ # if $lt is not provided,
+ # empty/None/null/'' start_date will also be returned
+ if 'start_date' in query and '$lt' not in query['start_date']:
+ query['start_date'].update({'$lt': str(datetime.now())})
+
return query
@@ -81,9 +100,10 @@ class ResultsCLHandler(GenericResultHandler):
- criteria : the global criteria status passed or failed
- trust_indicator : evaluate the stability of the test case
to avoid running systematically long and stable test case
+ - signed : get logined user result
GET /results/project=functest&case=vPing&version=Arno-R1 \
- &pod=pod_name&period=15
+ &pod=pod_name&period=15&signed
@return 200: all test results consist with query,
empty list if no result is found
@rtype: L{TestResults}
@@ -135,22 +155,41 @@ class ResultsCLHandler(GenericResultHandler):
@type last: L{string}
@in last: query
@required last: False
+ @param page: which page to list, default to 1
+ @type page: L{int}
+ @in page: query
+ @required page: False
@param trust_indicator: must be float
@type trust_indicator: L{float}
@in trust_indicator: query
@required trust_indicator: False
+ @param signed: user results or all results
+ @type signed: L{string}
+ @in signed: query
+ @required signed: False
+ @param descend: true, newest2oldest; false, oldest2newest
+ @type descend: L{string}
+ @in descend: query
+ @required descend: False
"""
- last = self.get_query_argument('last', 0)
- if last is not None:
- last = self.get_int('last', last)
+ def descend_limit():
+ descend = self.get_query_argument('descend', 'true')
+ return -1 if descend.lower() == 'true' else 1
+
+ def last_limit():
+ return self.get_int('last', self.get_query_argument('last', 0))
- page = self.get_query_argument('page', 0)
- if page:
- last = 20
+ def page_limit():
+ return self.get_int('page', self.get_query_argument('page', 1))
- self._list(query=self.set_query(),
- sort=[('start_date', -1)],
- last=last)
+ limitations = {
+ 'sort': {'_id': descend_limit()},
+ 'last': last_limit(),
+ 'page': page_limit(),
+ 'per_page': CONF.api_results_per_page
+ }
+
+ self._list(query=self.set_query(), **limitations)
@swagger.operation(nickname="createTestResult")
def post(self):
@@ -164,6 +203,9 @@ class ResultsCLHandler(GenericResultHandler):
@raise 404: pod/project/testcase not exist
@raise 400: body/pod_name/project_name/case_name not provided
"""
+ self._post()
+
+ def _post(self):
def pod_query():
return {'name': self.json_args.get('pod_name')}
@@ -178,9 +220,39 @@ class ResultsCLHandler(GenericResultHandler):
carriers = [('pods', pod_query),
('projects', project_query),
('testcases', testcase_query)]
+
self._create(miss_fields=miss_fields, carriers=carriers)
+class ResultsUploadHandler(ResultsCLHandler):
+ @swagger.operation(nickname="uploadTestResult")
+ def post(self):
+ """
+ @description: upload and create a test result
+ @param body: result to be created
+ @type body: L{ResultCreateRequest}
+ @in body: body
+ @rtype: L{CreateResponse}
+ @return 200: result is created.
+ @raise 404: pod/project/testcase not exist
+ @raise 400: body/pod_name/project_name/case_name not provided
+ """
+ logging.info('file upload')
+ fileinfo = self.request.files['file'][0]
+ is_public = self.get_body_argument('public')
+ logging.warning('public:%s', is_public)
+ logging.info('results is :%s', fileinfo['filename'])
+ logging.info('results is :%s', fileinfo['body'])
+ self.json_args = json.loads(fileinfo['body']).copy()
+ self.json_args['public'] = is_public
+
+ openid = self.get_secure_cookie(auth_const.OPENID)
+ if openid:
+ self.json_args['user'] = openid
+
+ super(ResultsUploadHandler, self)._post()
+
+
class ResultsGURHandler(GenericResultHandler):
@swagger.operation(nickname='getTestResultById')
def get(self, result_id):
diff --git a/utils/test/testapi/opnfv_testapi/resources/result_models.py b/utils/test/testapi/opnfv_testapi/resources/result_models.py
index 62a6dacff..890bf8220 100644
--- a/utils/test/testapi/opnfv_testapi/resources/result_models.py
+++ b/utils/test/testapi/opnfv_testapi/resources/result_models.py
@@ -54,6 +54,8 @@ class ResultCreateRequest(models.ModelBase):
build_tag=None,
scenario=None,
criteria=None,
+ user=None,
+ public="true",
trust_indicator=None):
self.pod_name = pod_name
self.project_name = project_name
@@ -66,6 +68,8 @@ class ResultCreateRequest(models.ModelBase):
self.build_tag = build_tag
self.scenario = scenario
self.criteria = criteria
+ self.user = user
+ self.public = public
self.trust_indicator = trust_indicator if trust_indicator else TI(0)
@@ -89,7 +93,7 @@ class TestResult(models.ModelBase):
pod_name=None, installer=None, version=None,
start_date=None, stop_date=None, details=None,
build_tag=None, scenario=None, criteria=None,
- trust_indicator=None):
+ user=None, public="true", trust_indicator=None):
self._id = _id
self.case_name = case_name
self.project_name = project_name
@@ -102,6 +106,8 @@ class TestResult(models.ModelBase):
self.build_tag = build_tag
self.scenario = scenario
self.criteria = criteria
+ self.user = user
+ self.public = public
self.trust_indicator = trust_indicator
@staticmethod
diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
index 5d420a56e..e9c19a7a4 100644
--- a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
+++ b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
@@ -15,6 +15,24 @@ class GenericScenarioHandler(handlers.GenericApiHandler):
self.table = self.db_scenarios
self.table_cls = models.Scenario
+ def set_query(self, locators):
+ query = dict()
+ elem_query = dict()
+ for k, v in locators.iteritems():
+ if k == 'scenario':
+ query['name'] = v
+ elif k == 'installer':
+ elem_query["installer"] = v
+ elif k == 'version':
+ elem_query["versions.version"] = v
+ elif k == 'project':
+ elem_query["versions.projects.project"] = v
+ else:
+ query[k] = v
+ if elem_query:
+ query['installers'] = {'$elemMatch': elem_query}
+ return query
+
class ScenariosCLHandler(GenericScenarioHandler):
@swagger.operation(nickname="queryScenarios")
@@ -96,10 +114,10 @@ class ScenarioGURHandler(GenericScenarioHandler):
self._get_one(query={'name': name})
pass
- @swagger.operation(nickname="updateScenarioByName")
+ @swagger.operation(nickname="updateScenarioName")
def put(self, name):
"""
- @description: update a single scenario by name
+ @description: update scenario, only rename is supported currently
@param body: fields to be updated
@type body: L{ScenarioUpdateRequest}
@in body: body
@@ -119,164 +137,639 @@ class ScenarioGURHandler(GenericScenarioHandler):
@return 200: delete success
@raise 404: scenario not exist:
"""
-
self._delete(query={'name': name})
- def _update_query(self, keys, data):
- query = dict()
- if self._is_rename():
- new = self._term.get('name')
- if data.get('name') != new:
- query['name'] = new
- return query
+class ScenarioUpdater(object):
+ def __init__(self, data, body=None,
+ installer=None, version=None, project=None):
+ self.data = data
+ self.body = body
+ self.installer = installer
+ self.version = version
+ self.project = project
- def _update_requests(self, data):
+ def update(self, item, action):
updates = {
- ('name', 'update'): self._update_requests_rename,
- ('installer', 'add'): self._update_requests_add_installer,
- ('installer', 'delete'): self._update_requests_delete_installer,
- ('version', 'add'): self._update_requests_add_version,
- ('version', 'delete'): self._update_requests_delete_version,
- ('owner', 'update'): self._update_requests_change_owner,
- ('project', 'add'): self._update_requests_add_project,
- ('project', 'delete'): self._update_requests_delete_project,
- ('customs', 'add'): self._update_requests_add_customs,
+ ('scores', 'post'): self._update_requests_add_score,
+ ('trust_indicators', 'post'): self._update_requests_add_ti,
+ ('customs', 'post'): self._update_requests_add_customs,
+ ('customs', 'put'): self._update_requests_update_customs,
('customs', 'delete'): self._update_requests_delete_customs,
- ('score', 'add'): self._update_requests_add_score,
- ('trust_indicator', 'add'): self._update_requests_add_ti,
+ ('projects', 'post'): self._update_requests_add_projects,
+ ('projects', 'put'): self._update_requests_update_projects,
+ ('projects', 'delete'): self._update_requests_delete_projects,
+ ('owner', 'put'): self._update_requests_change_owner,
+ ('versions', 'post'): self._update_requests_add_versions,
+ ('versions', 'put'): self._update_requests_update_versions,
+ ('versions', 'delete'): self._update_requests_delete_versions,
+ ('installers', 'post'): self._update_requests_add_installers,
+ ('installers', 'put'): self._update_requests_update_installers,
+ ('installers', 'delete'): self._update_requests_delete_installers,
}
+ updates[(item, action)](self.data)
- updates[(self._field, self._op)](data)
-
- return data.format()
+ return self.data.format()
- def _iter_installers(xstep):
+ def iter_installers(xstep):
@functools.wraps(xstep)
def magic(self, data):
[xstep(self, installer)
for installer in self._filter_installers(data.installers)]
return magic
- def _iter_versions(xstep):
+ def iter_versions(xstep):
@functools.wraps(xstep)
def magic(self, installer):
[xstep(self, version)
for version in (self._filter_versions(installer.versions))]
return magic
- def _iter_projects(xstep):
+ def iter_projects(xstep):
@functools.wraps(xstep)
def magic(self, version):
[xstep(self, project)
for project in (self._filter_projects(version.projects))]
return magic
- def _update_requests_rename(self, data):
- data.name = self._term.get('name')
- if not data.name:
- raises.BadRequest(message.missing('name'))
-
- def _update_requests_add_installer(self, data):
- data.installers.append(models.ScenarioInstaller.from_dict(self._term))
-
- def _update_requests_delete_installer(self, data):
- data.installers = self._remove_installers(data.installers)
-
- @_iter_installers
- def _update_requests_add_version(self, installer):
- installer.versions.append(models.ScenarioVersion.from_dict(self._term))
-
- @_iter_installers
- def _update_requests_delete_version(self, installer):
- installer.versions = self._remove_versions(installer.versions)
-
- @_iter_installers
- @_iter_versions
- def _update_requests_change_owner(self, version):
- version.owner = self._term.get('owner')
-
- @_iter_installers
- @_iter_versions
- def _update_requests_add_project(self, version):
- version.projects.append(models.ScenarioProject.from_dict(self._term))
+ @iter_installers
+ @iter_versions
+ @iter_projects
+ def _update_requests_add_score(self, project):
+ project.scores.append(
+ models.ScenarioScore.from_dict(self.body))
- @_iter_installers
- @_iter_versions
- def _update_requests_delete_project(self, version):
- version.projects = self._remove_projects(version.projects)
+ @iter_installers
+ @iter_versions
+ @iter_projects
+ def _update_requests_add_ti(self, project):
+ project.trust_indicators.append(
+ models.ScenarioTI.from_dict(self.body))
- @_iter_installers
- @_iter_versions
- @_iter_projects
+ @iter_installers
+ @iter_versions
+ @iter_projects
def _update_requests_add_customs(self, project):
- project.customs = list(set(project.customs + self._term))
+ project.customs = list(set(project.customs + self.body))
- @_iter_installers
- @_iter_versions
- @_iter_projects
+ @iter_installers
+ @iter_versions
+ @iter_projects
+ def _update_requests_update_customs(self, project):
+ project.customs = list(set(self.body))
+
+ @iter_installers
+ @iter_versions
+ @iter_projects
def _update_requests_delete_customs(self, project):
project.customs = filter(
- lambda f: f not in self._term,
+ lambda f: f not in self.body,
project.customs)
- @_iter_installers
- @_iter_versions
- @_iter_projects
- def _update_requests_add_score(self, project):
- project.scores.append(
- models.ScenarioScore.from_dict(self._term))
+ @iter_installers
+ @iter_versions
+ def _update_requests_add_projects(self, version):
+ version.projects = self._update_with_body(models.ScenarioProject,
+ 'project',
+ version.projects)
+
+ @iter_installers
+ @iter_versions
+ def _update_requests_update_projects(self, version):
+ version.projects = self._update_with_body(models.ScenarioProject,
+ 'project',
+ list())
+
+ @iter_installers
+ @iter_versions
+ def _update_requests_delete_projects(self, version):
+ version.projects = self._remove_projects(version.projects)
- @_iter_installers
- @_iter_versions
- @_iter_projects
- def _update_requests_add_ti(self, project):
- project.trust_indicators.append(
- models.ScenarioTI.from_dict(self._term))
+ @iter_installers
+ @iter_versions
+ def _update_requests_change_owner(self, version):
+ version.owner = self.body.get('owner')
+
+ @iter_installers
+ def _update_requests_add_versions(self, installer):
+ installer.versions = self._update_with_body(models.ScenarioVersion,
+ 'version',
+ installer.versions)
+
+ @iter_installers
+ def _update_requests_update_versions(self, installer):
+ installer.versions = self._update_with_body(models.ScenarioVersion,
+ 'version',
+ list())
+
+ @iter_installers
+ def _update_requests_delete_versions(self, installer):
+ installer.versions = self._remove_versions(installer.versions)
+
+ def _update_requests_add_installers(self, scenario):
+ scenario.installers = self._update_with_body(models.ScenarioInstaller,
+ 'installer',
+ scenario.installers)
+
+ def _update_requests_update_installers(self, scenario):
+ scenario.installers = self._update_with_body(models.ScenarioInstaller,
+ 'installer',
+ list())
+
+ def _update_requests_delete_installers(self, scenario):
+ scenario.installers = self._remove_installers(scenario.installers)
+
+ def _update_with_body(self, clazz, field, withs):
+ exists = list()
+ malformat = list()
+ for new in self.body:
+ try:
+ format_new = clazz.from_dict_with_raise(new)
+ new_name = getattr(format_new, field)
+ if not any(getattr(o, field) == new_name for o in withs):
+ withs.append(format_new)
+ else:
+ exists.append(new_name)
+ except Exception as error:
+ malformat.append(error.message)
+ if malformat:
+ raises.BadRequest(message.bad_format(malformat))
+ elif exists:
+ raises.Conflict(message.exist('{}s'.format(field), exists))
+ return withs
- def _is_rename(self):
- return self._field == 'name' and self._op == 'update'
+ def _filter_installers(self, installers):
+ return self._filter('installer', installers)
def _remove_installers(self, installers):
return self._remove('installer', installers)
- def _filter_installers(self, installers):
- return self._filter('installer', installers)
+ def _filter_versions(self, versions):
+ return self._filter('version', versions)
def _remove_versions(self, versions):
return self._remove('version', versions)
- def _filter_versions(self, versions):
- return self._filter('version', versions)
+ def _filter_projects(self, projects):
+ return self._filter('project', projects)
def _remove_projects(self, projects):
return self._remove('project', projects)
- def _filter_projects(self, projects):
- return self._filter('project', projects)
+ def _filter(self, item, items):
+ return filter(
+ lambda f: getattr(f, item) == getattr(self, item),
+ items)
def _remove(self, field, fields):
return filter(
- lambda f: getattr(f, field) != self._locate.get(field),
+ lambda f: getattr(f, field) not in self.body,
fields)
- def _filter(self, field, fields):
- return filter(
- lambda f: getattr(f, field) == self._locate.get(field),
- fields)
- @property
- def _field(self):
- return self.json_args.get('field')
+class GenericScenarioUpdateHandler(GenericScenarioHandler):
+ def __init__(self, application, request, **kwargs):
+ super(GenericScenarioUpdateHandler, self).__init__(application,
+ request,
+ **kwargs)
+ self.installer = None
+ self.version = None
+ self.project = None
+ self.item = None
+ self.action = None
+
+ def do_update(self, item, action, locators):
+ self.item = item
+ self.action = action
+ for k, v in locators.iteritems():
+ if not v:
+ v = self.get_query_argument(k)
+ setattr(self, k, v)
+ locators[k] = v
+ self.pure_update(query=self.set_query(locators=locators))
+
+ def _update_requests(self, data):
+ return ScenarioUpdater(data,
+ self.json_args,
+ self.installer,
+ self.version,
+ self.project).update(self.item, self.action)
+
+
+class ScenarioScoresHandler(GenericScenarioUpdateHandler):
+ @swagger.operation(nickname="addScoreRecord")
+ def post(self, scenario):
+ """
+ @description: add a new score record
+ @notes: add a new score record to a project
+ POST /api/v1/scenarios/<scenario_name>/scores? \
+ installer=<installer_name>& \
+ version=<version_name>& \
+ project=<project_name>
+ @param body: score to be added
+ @type body: L{ScenarioScore}
+ @in body: body
+ @param installer: installer type
+ @type installer: L{string}
+ @in installer: query
+ @required installer: True
+ @param version: version
+ @type version: L{string}
+ @in version: query
+ @required version: True
+ @param project: project name
+ @type project: L{string}
+ @in project: query
+ @required project: True
+ @return 200: score is created.
+ @raise 404: scenario/installer/version/project not existed
+ """
+ self.do_update('scores',
+ 'post',
+ locators={'scenario': scenario,
+ 'installer': None,
+ 'version': None,
+ 'project': None})
+
+
+class ScenarioTIsHandler(GenericScenarioUpdateHandler):
+ @swagger.operation(nickname="addTrustIndicatorRecord")
+ def post(self, scenario):
+ """
+ @description: add a new trust indicator record
+ @notes: add a new trust indicator record to a project
+ POST /api/v1/scenarios/<scenario_name>/trust_indicators? \
+ installer=<installer_name>& \
+ version=<version_name>& \
+ project=<project_name>
+ @param body: trust indicator to be added
+ @type body: L{ScenarioTI}
+ @in body: body
+ @param installer: installer type
+ @type installer: L{string}
+ @in installer: query
+ @required installer: True
+ @param version: version
+ @type version: L{string}
+ @in version: query
+ @required version: True
+ @param project: project name
+ @type project: L{string}
+ @in project: query
+ @required project: True
+ @return 200: trust indicator is added.
+ @raise 404: scenario/installer/version/project not existed
+ """
+ self.do_update('trust_indicators',
+ 'post',
+ locators={'scenario': scenario,
+ 'installer': None,
+ 'version': None,
+ 'project': None})
+
+
+class ScenarioCustomsHandler(GenericScenarioUpdateHandler):
+ @swagger.operation(nickname="addCustomizedTestCases")
+ def post(self, scenario):
+ """
+ @description: add customized test cases
+ @notes: add several test cases to a project
+ POST /api/v1/scenarios/<scenario_name>/customs? \
+ installer=<installer_name>& \
+ version=<version_name>& \
+ project=<project_name>
+ @param body: test cases to be added
+ @type body: C{list} of L{string}
+ @in body: body
+ @param installer: installer type
+ @type installer: L{string}
+ @in installer: query
+ @required installer: True
+ @param version: version
+ @type version: L{string}
+ @in version: query
+ @required version: True
+ @param project: project name
+ @type project: L{string}
+ @in project: query
+ @required project: True
+ @return 200: test cases are added.
+ @raise 404: scenario/installer/version/project not existed
+ """
+ self.do_update('customs',
+ 'post',
+ locators={'scenario': scenario,
+ 'installer': None,
+ 'version': None,
+ 'project': None})
+
+ @swagger.operation(nickname="updateCustomizedTestCases")
+ def put(self, scenario):
+ """
+ @description: update customized test cases
+ @notes: substitute all the customized test cases
+ PUT /api/v1/scenarios/<scenario_name>/customs? \
+ installer=<installer_name>& \
+ version=<version_name>& \
+ project=<project_name>
+ @param body: new supported test cases
+ @type body: C{list} of L{string}
+ @in body: body
+ @param installer: installer type
+ @type installer: L{string}
+ @in installer: query
+ @required installer: True
+ @param version: version
+ @type version: L{string}
+ @in version: query
+ @required version: True
+ @param project: project name
+ @type project: L{string}
+ @in project: query
+ @required project: True
+ @return 200: substitute test cases success.
+ @raise 404: scenario/installer/version/project not existed
+ """
+ self.do_update('customs',
+ 'put',
+ locators={'scenario': scenario,
+ 'installer': None,
+ 'version': None,
+ 'project': None})
+
+ @swagger.operation(nickname="deleteCustomizedTestCases")
+ def delete(self, scenario):
+ """
+ @description: delete one or several customized test cases
+ @notes: delete one or some customized test cases
+ DELETE /api/v1/scenarios/<scenario_name>/customs? \
+ installer=<installer_name>& \
+ version=<version_name>& \
+ project=<project_name>
+ @param body: test case(s) to be deleted
+ @type body: C{list} of L{string}
+ @in body: body
+ @param installer: installer type
+ @type installer: L{string}
+ @in installer: query
+ @required installer: True
+ @param version: version
+ @type version: L{string}
+ @in version: query
+ @required version: True
+ @param project: project name
+ @type project: L{string}
+ @in project: query
+ @required project: True
+ @return 200: delete test case(s) success.
+ @raise 404: scenario/installer/version/project not existed
+ """
+ self.do_update('customs',
+ 'delete',
+ locators={'scenario': scenario,
+ 'installer': None,
+ 'version': None,
+ 'project': None})
- @property
- def _op(self):
- return self.json_args.get('op')
- @property
- def _locate(self):
- return self.json_args.get('locate')
+class ScenarioProjectsHandler(GenericScenarioUpdateHandler):
+ @swagger.operation(nickname="addProjectsUnderScenario")
+ def post(self, scenario):
+ """
+ @description: add projects to scenario
+ @notes: add one or multiple projects
+ POST /api/v1/scenarios/<scenario_name>/projects? \
+ installer=<installer_name>& \
+ version=<version_name>
+ @param body: projects to be added
+ @type body: C{list} of L{ScenarioProject}
+ @in body: body
+ @param installer: installer type
+ @type installer: L{string}
+ @in installer: query
+ @required installer: True
+ @param version: version
+ @type version: L{string}
+ @in version: query
+ @required version: True
+ @return 200: projects are added.
+ @raise 400: bad schema
+ @raise 409: conflict, project already exists
+ @raise 404: scenario/installer/version not existed
+ """
+ self.do_update('projects',
+ 'post',
+ locators={'scenario': scenario,
+ 'installer': None,
+ 'version': None})
+
+ @swagger.operation(nickname="updateScenarioProjects")
+ def put(self, scenario):
+ """
+ @description: replace all projects
+ @notes: substitute all projects, delete existed ones with new provides
+ PUT /api/v1/scenarios/<scenario_name>/projects? \
+ installer=<installer_name>& \
+ version=<version_name>
+ @param body: new projects
+ @type body: C{list} of L{ScenarioProject}
+ @in body: body
+ @param installer: installer type
+ @type installer: L{string}
+ @in installer: query
+ @required installer: True
+ @param version: version
+ @type version: L{string}
+ @in version: query
+ @required version: True
+ @return 200: replace projects success.
+ @raise 400: bad schema
+ @raise 404: scenario/installer/version not existed
+ """
+ self.do_update('projects',
+ 'put',
+ locators={'scenario': scenario,
+ 'installer': None,
+ 'version': None})
+
+ @swagger.operation(nickname="deleteProjectsUnderScenario")
+ def delete(self, scenario):
+ """
+ @description: delete one or multiple projects
+ @notes: delete one or multiple projects
+ DELETE /api/v1/scenarios/<scenario_name>/projects? \
+ installer=<installer_name>& \
+ version=<version_name>
+ @param body: projects(names) to be deleted
+ @type body: C{list} of L{string}
+ @in body: body
+ @param installer: installer type
+ @type installer: L{string}
+ @in installer: query
+ @required installer: True
+ @param version: version
+ @type version: L{string}
+ @in version: query
+ @required version: True
+ @return 200: delete project(s) success.
+ @raise 404: scenario/installer/version not existed
+ """
+ self.do_update('projects',
+ 'delete',
+ locators={'scenario': scenario,
+ 'installer': None,
+ 'version': None})
- @property
- def _term(self):
- return self.json_args.get('term')
+
+class ScenarioOwnerHandler(GenericScenarioUpdateHandler):
+ @swagger.operation(nickname="changeScenarioOwner")
+ def put(self, scenario):
+ """
+ @description: change scenario owner
+ @notes: substitute all projects, delete existed ones with new provides
+ PUT /api/v1/scenarios/<scenario_name>/owner? \
+ installer=<installer_name>& \
+ version=<version_name>
+ @param body: new owner
+ @type body: L{ScenarioChangeOwnerRequest}
+ @in body: body
+ @param installer: installer type
+ @type installer: L{string}
+ @in installer: query
+ @required installer: True
+ @param version: version
+ @type version: L{string}
+ @in version: query
+ @required version: True
+ @return 200: change owner success.
+ @raise 404: scenario/installer/version not existed
+ """
+ self.do_update('owner',
+ 'put',
+ locators={'scenario': scenario,
+ 'installer': None,
+ 'version': None})
+
+
+class ScenarioVersionsHandler(GenericScenarioUpdateHandler):
+ @swagger.operation(nickname="addVersionsUnderScenario")
+ def post(self, scenario):
+ """
+ @description: add versions to scenario
+ @notes: add one or multiple versions
+ POST /api/v1/scenarios/<scenario_name>/versions? \
+ installer=<installer_name>
+ @param body: versions to be added
+ @type body: C{list} of L{ScenarioVersion}
+ @in body: body
+ @param installer: installer type
+ @type installer: L{string}
+ @in installer: query
+ @required installer: True
+ @return 200: versions are added.
+ @raise 400: bad schema
+ @raise 409: conflict, version already exists
+ @raise 404: scenario/installer not exist
+ """
+ self.do_update('versions',
+ 'post',
+ locators={'scenario': scenario,
+ 'installer': None})
+
+ @swagger.operation(nickname="updateVersionsUnderScenario")
+ def put(self, scenario):
+ """
+ @description: replace all versions
+ @notes: substitute all versions as a totality
+ PUT /api/v1/scenarios/<scenario_name>/versions? \
+ installer=<installer_name>
+ @param body: new versions
+ @type body: C{list} of L{ScenarioVersion}
+ @in body: body
+ @param installer: installer type
+ @type installer: L{string}
+ @in installer: query
+ @required installer: True
+ @return 200: replace versions success.
+ @raise 400: bad schema
+ @raise 404: scenario/installer not exist
+ """
+ self.do_update('versions',
+ 'put',
+ locators={'scenario': scenario,
+ 'installer': None})
+
+ @swagger.operation(nickname="deleteVersionsUnderScenario")
+ def delete(self, scenario):
+ """
+ @description: delete one or multiple versions
+ @notes: delete one or multiple versions
+ DELETE /api/v1/scenarios/<scenario_name>/versions? \
+ installer=<installer_name>
+ @param body: versions(names) to be deleted
+ @type body: C{list} of L{string}
+ @in body: body
+ @param installer: installer type
+ @type installer: L{string}
+ @in installer: query
+ @required installer: True
+ @return 200: delete versions success.
+ @raise 404: scenario/installer not exist
+ """
+ self.do_update('versions',
+ 'delete',
+ locators={'scenario': scenario,
+ 'installer': None})
+
+
+class ScenarioInstallersHandler(GenericScenarioUpdateHandler):
+ @swagger.operation(nickname="addInstallersUnderScenario")
+ def post(self, scenario):
+ """
+ @description: add installers to scenario
+ @notes: add one or multiple installers
+ POST /api/v1/scenarios/<scenario_name>/installers
+ @param body: installers to be added
+ @type body: C{list} of L{ScenarioInstaller}
+ @in body: body
+ @return 200: installers are added.
+ @raise 400: bad schema
+ @raise 409: conflict, installer already exists
+ @raise 404: scenario not exist
+ """
+ self.do_update('installers',
+ 'post',
+ locators={'scenario': scenario})
+
+ @swagger.operation(nickname="updateInstallersUnderScenario")
+ def put(self, scenario):
+ """
+ @description: replace all installers
+ @notes: substitute all installers as a totality
+ PUT /api/v1/scenarios/<scenario_name>/installers
+ @param body: new installers
+ @type body: C{list} of L{ScenarioInstaller}
+ @in body: body
+ @return 200: replace versions success.
+ @raise 400: bad schema
+ @raise 404: scenario/installer not exist
+ """
+ self.do_update('installers',
+ 'put',
+ locators={'scenario': scenario})
+
+ @swagger.operation(nickname="deleteInstallersUnderScenario")
+ def delete(self, scenario):
+ """
+ @description: delete one or multiple installers
+ @notes: delete one or multiple installers
+ DELETE /api/v1/scenarios/<scenario_name>/installers
+ @param body: installers(names) to be deleted
+ @type body: C{list} of L{string}
+ @in body: body
+ @return 200: delete versions success.
+ @raise 404: scenario/installer not exist
+ """
+ self.do_update('installers',
+ 'delete',
+ locators={'scenario': scenario})
diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
index 467cff241..d950ed1d7 100644
--- a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
+++ b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
@@ -16,6 +16,13 @@ class ScenarioTI(models.ModelBase):
self.date = date
self.status = status
+ def __eq__(self, other):
+ return (self.date == other.date and
+ self.status == other.status)
+
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
@swagger.model()
class ScenarioScore(models.ModelBase):
@@ -23,6 +30,13 @@ class ScenarioScore(models.ModelBase):
self.date = date
self.score = score
+ def __eq__(self, other):
+ return (self.date == other.date and
+ self.score == other.score)
+
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
@swagger.model()
class ScenarioProject(models.ModelBase):
@@ -50,10 +64,10 @@ class ScenarioProject(models.ModelBase):
'trust_indicators': ScenarioTI}
def __eq__(self, other):
- return [self.project == other.project and
+ return (self.project == other.project and
self._customs_eq(other) and
self._scores_eq(other) and
- self._ti_eq(other)]
+ self._ti_eq(other))
def __ne__(self, other):
return not self.__eq__(other)
@@ -62,10 +76,10 @@ class ScenarioProject(models.ModelBase):
return set(self.customs) == set(other.customs)
def _scores_eq(self, other):
- return set(self.scores) == set(other.scores)
+ return self.scores == other.scores
def _ti_eq(self, other):
- return set(self.trust_indicators) == set(other.trust_indicators)
+ return self.trust_indicators == other.trust_indicators
@swagger.model()
@@ -74,7 +88,8 @@ class ScenarioVersion(models.ModelBase):
@property projects:
@ptype projects: C{list} of L{ScenarioProject}
"""
- def __init__(self, version=None, projects=None):
+ def __init__(self, owner=None, version=None, projects=None):
+ self.owner = owner
self.version = version
self.projects = list_default(projects)
@@ -83,7 +98,9 @@ class ScenarioVersion(models.ModelBase):
return {'projects': ScenarioProject}
def __eq__(self, other):
- return [self.version == other.version and self._projects_eq(other)]
+ return (self.version == other.version and
+ self.owner == other.owner and
+ self._projects_eq(other))
def __ne__(self, other):
return not self.__eq__(other)
@@ -113,7 +130,7 @@ class ScenarioInstaller(models.ModelBase):
return {'versions': ScenarioVersion}
def __eq__(self, other):
- return [self.installer == other.installer and self._versions_eq(other)]
+ return (self.installer == other.installer and self._versions_eq(other))
def __ne__(self, other):
return not self.__eq__(other)
@@ -144,18 +161,15 @@ class ScenarioCreateRequest(models.ModelBase):
@swagger.model()
+class ScenarioChangeOwnerRequest(models.ModelBase):
+ def __init__(self, owner=None):
+ self.owner = owner
+
+
+@swagger.model()
class ScenarioUpdateRequest(models.ModelBase):
- """
- @property field: update field
- @property op: add/delete/update
- @property locate: information used to locate the field
- @property term: new value
- """
- def __init__(self, field=None, op=None, locate=None, term=None):
- self.field = field
- self.op = op
- self.locate = dict_default(locate)
- self.term = dict_default(term)
+ def __init__(self, name=None):
+ self.name = name
@swagger.model()
@@ -178,7 +192,7 @@ class Scenario(models.ModelBase):
return not self.__eq__(other)
def __eq__(self, other):
- return [self.name == other.name and self._installers_eq(other)]
+ return (self.name == other.name and self._installers_eq(other))
def _installers_eq(self, other):
for s_install in self.installers:
diff --git a/utils/test/testapi/opnfv_testapi/router/url_mappings.py b/utils/test/testapi/opnfv_testapi/router/url_mappings.py
index a2312de09..3e3ab87aa 100644
--- a/utils/test/testapi/opnfv_testapi/router/url_mappings.py
+++ b/utils/test/testapi/opnfv_testapi/router/url_mappings.py
@@ -8,7 +8,7 @@
##############################################################################
import tornado.web
-from opnfv_testapi.common import config
+from opnfv_testapi.common.config import CONF
from opnfv_testapi.resources import handlers
from opnfv_testapi.resources import pod_handlers
from opnfv_testapi.resources import project_handlers
@@ -48,20 +48,36 @@ mappings = [
# Push results with mandatory request payload parameters
# (project, case, and pod)
(r"/api/v1/results", result_handlers.ResultsCLHandler),
+ (r'/api/v1/results/upload', result_handlers.ResultsUploadHandler),
(r"/api/v1/results/([^/]+)", result_handlers.ResultsGURHandler),
# scenarios
(r"/api/v1/scenarios", scenario_handlers.ScenariosCLHandler),
(r"/api/v1/scenarios/([^/]+)", scenario_handlers.ScenarioGURHandler),
+ (r"/api/v1/scenarios/([^/]+)/scores",
+ scenario_handlers.ScenarioScoresHandler),
+ (r"/api/v1/scenarios/([^/]+)/trust_indicators",
+ scenario_handlers.ScenarioTIsHandler),
+ (r"/api/v1/scenarios/([^/]+)/customs",
+ scenario_handlers.ScenarioCustomsHandler),
+ (r"/api/v1/scenarios/([^/]+)/projects",
+ scenario_handlers.ScenarioProjectsHandler),
+ (r"/api/v1/scenarios/([^/]+)/owner",
+ scenario_handlers.ScenarioOwnerHandler),
+ (r"/api/v1/scenarios/([^/]+)/versions",
+ scenario_handlers.ScenarioVersionsHandler),
+ (r"/api/v1/scenarios/([^/]+)/installers",
+ scenario_handlers.ScenarioInstallersHandler),
# static path
(r'/(.*\.(css|png|gif|js|html|json|map|woff2|woff|ttf))',
tornado.web.StaticFileHandler,
- {'path': config.Config().static_path}),
+ {'path': CONF.static_path}),
(r'/', root.RootHandler),
(r'/api/v1/auth/signin', sign.SigninHandler),
(r'/api/v1/auth/signin_return', sign.SigninReturnHandler),
(r'/api/v1/auth/signout', sign.SignoutHandler),
(r'/api/v1/profile', user.ProfileHandler),
+
]
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/common/noparam.ini b/utils/test/testapi/opnfv_testapi/tests/unit/common/noparam.ini
index fda2a09e9..be7f2b9f8 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/common/noparam.ini
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/common/noparam.ini
@@ -12,5 +12,5 @@ port = 8000
debug = True
authenticate = False
-[swagger]
-base_url = http://localhost:8000
+[ui]
+url = http://localhost:8000
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/common/normal.ini b/utils/test/testapi/opnfv_testapi/tests/unit/common/normal.ini
index 77cc6c6ee..c81c6c56a 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/common/normal.ini
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/common/normal.ini
@@ -13,5 +13,5 @@ port = 8000
debug = True
authenticate = False
-[swagger]
-base_url = http://localhost:8000
+[ui]
+url = http://localhost:8000
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/common/nosection.ini b/utils/test/testapi/opnfv_testapi/tests/unit/common/nosection.ini
index 9988fc0a4..a9ed49c5c 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/common/nosection.ini
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/common/nosection.ini
@@ -7,5 +7,5 @@ port = 8000
debug = True
authenticate = False
-[swagger]
-base_url = http://localhost:8000
+[ui]
+url = http://localhost:8000
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/common/notboolean.ini b/utils/test/testapi/opnfv_testapi/tests/unit/common/notboolean.ini
index b3f327670..3a11f9dd3 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/common/notboolean.ini
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/common/notboolean.ini
@@ -13,5 +13,5 @@ port = 8000
debug = True
authenticate = notboolean
-[swagger]
-base_url = http://localhost:8000
+[ui]
+url = http://localhost:8000
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/common/notint.ini b/utils/test/testapi/opnfv_testapi/tests/unit/common/notint.ini
index d1b752a34..8180719b8 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/common/notint.ini
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/common/notint.ini
@@ -13,5 +13,5 @@ port = notint
debug = True
authenticate = False
-[swagger]
-base_url = http://localhost:8000
+[ui]
+url = http://localhost:8000
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/common/test_config.py b/utils/test/testapi/opnfv_testapi/tests/unit/common/test_config.py
index 446b9442a..8cfc513be 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/common/test_config.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/common/test_config.py
@@ -1,16 +1,15 @@
-import os
+import argparse
-from opnfv_testapi.common import config
-
-def test_config_success():
- config_file = os.path.join(os.path.dirname(__file__),
- '../../../../etc/config.ini')
- config.Config.CONFIG = config_file
- conf = config.Config()
- assert conf.mongo_url == 'mongodb://127.0.0.1:27017/'
- assert conf.mongo_dbname == 'test_results_collection'
- assert conf.api_port == 8000
- assert conf.api_debug is True
- assert conf.api_authenticate is False
- assert conf.swagger_base_url == 'http://localhost:8000'
+def test_config_normal(mocker, config_normal):
+ mocker.patch(
+ 'argparse.ArgumentParser.parse_known_args',
+ return_value=(argparse.Namespace(config_file=config_normal), None))
+ from opnfv_testapi.common import config
+ CONF = config.Config()
+ assert CONF.mongo_url == 'mongodb://127.0.0.1:27017/'
+ assert CONF.mongo_dbname == 'test_results_collection'
+ assert CONF.api_port == 8000
+ assert CONF.api_debug is True
+ assert CONF.api_authenticate is False
+ assert CONF.ui_url == 'http://localhost:8000'
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/conftest.py b/utils/test/testapi/opnfv_testapi/tests/unit/conftest.py
new file mode 100644
index 000000000..feff1daaa
--- /dev/null
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/conftest.py
@@ -0,0 +1,8 @@
+from os import path
+
+import pytest
+
+
+@pytest.fixture
+def config_normal():
+ return path.join(path.dirname(__file__), 'common/normal.ini')
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/executor.py b/utils/test/testapi/opnfv_testapi/tests/unit/executor.py
index b30c3258b..b8f696caf 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/executor.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/executor.py
@@ -10,6 +10,20 @@ import functools
import httplib
+def upload(excepted_status, excepted_response):
+ def _upload(create_request):
+ @functools.wraps(create_request)
+ def wrap(self):
+ request = create_request(self)
+ status, body = self.upload(request)
+ if excepted_status == httplib.OK:
+ getattr(self, excepted_response)(body)
+ else:
+ self.assertIn(excepted_response, body)
+ return wrap
+ return _upload
+
+
def create(excepted_status, excepted_response):
def _create(create_request):
@functools.wraps(create_request)
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/fake_pymongo.py b/utils/test/testapi/opnfv_testapi/tests/unit/fake_pymongo.py
index ef74a0857..0ca83df62 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/fake_pymongo.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/fake_pymongo.py
@@ -6,9 +6,10 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+from operator import itemgetter
+
from bson.objectid import ObjectId
from concurrent.futures import ThreadPoolExecutor
-from operator import itemgetter
def thread_execute(method, *args, **kwargs):
@@ -20,38 +21,52 @@ def thread_execute(method, *args, **kwargs):
class MemCursor(object):
def __init__(self, collection):
self.collection = collection
- self.count = len(self.collection)
+ self.length = len(self.collection)
self.sorted = []
def _is_next_exist(self):
- return self.count != 0
+ return self.length != 0
@property
def fetch_next(self):
return thread_execute(self._is_next_exist)
def next_object(self):
- self.count -= 1
+ self.length -= 1
return self.collection.pop()
def sort(self, key_or_list):
- key = key_or_list[0][0]
- if key_or_list[0][1] == -1:
- reverse = True
- else:
- reverse = False
+ for k, v in key_or_list.iteritems():
+ if v == -1:
+ reverse = True
+ else:
+ reverse = False
- if key_or_list is not None:
self.collection = sorted(self.collection,
- key=itemgetter(key), reverse=reverse)
+ key=itemgetter(k), reverse=reverse)
return self
def limit(self, limit):
if limit != 0 and limit < len(self.collection):
- self.collection = self.collection[0:limit]
- self.count = limit
+ self.collection = self.collection[0: limit]
+ self.length = limit
return self
+ def skip(self, skip):
+ if skip < self.length and (skip > 0):
+ self.collection = self.collection[self.length - skip: -1]
+ self.length -= skip
+ elif skip >= self.length:
+ self.collection = []
+ self.length = 0
+ return self
+
+ def _count(self):
+ return self.length
+
+ def count(self):
+ return thread_execute(self._count)
+
class MemDb(object):
@@ -105,10 +120,14 @@ class MemDb(object):
@staticmethod
def _compare_date(spec, value):
+ gte = True
+ lt = False
for k, v in spec.iteritems():
- if k == '$gte' and value >= v:
- return True
- return False
+ if k == '$gte' and value < v:
+ gte = False
+ elif k == '$lt' and value < v:
+ lt = True
+ return gte and lt
def _in(self, content, *args):
if self.name == 'scenarios':
@@ -171,9 +190,8 @@ class MemDb(object):
elif k == 'trust_indicator.current':
if content.get('trust_indicator').get('current') != v:
return False
- elif content.get(k, None) != v:
+ elif not isinstance(v, dict) and content.get(k, None) != v:
return False
-
return True
def _find(self, *args):
@@ -187,6 +205,27 @@ class MemDb(object):
def find(self, *args):
return MemCursor(self._find(*args))
+ def _aggregate(self, *args, **kwargs):
+ res = self.contents
+ print args
+ for arg in args[0]:
+ for k, v in arg.iteritems():
+ if k == '$match':
+ res = self._find(v)
+ cursor = MemCursor(res)
+ for arg in args[0]:
+ for k, v in arg.iteritems():
+ if k == '$sort':
+ cursor = cursor.sort(v)
+ elif k == '$skip':
+ cursor = cursor.skip(v)
+ elif k == '$limit':
+ cursor = cursor.limit(v)
+ return cursor
+
+ def aggregate(self, *args, **kwargs):
+ return self._aggregate(*args, **kwargs)
+
def _update(self, spec, document, check_keys=True):
updated = False
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/__init__.py b/utils/test/testapi/opnfv_testapi/tests/unit/resources/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/__init__.py
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/scenario-c1.json b/utils/test/testapi/opnfv_testapi/tests/unit/resources/scenario-c1.json
index 187802215..187802215 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/scenario-c1.json
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/scenario-c1.json
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/scenario-c2.json b/utils/test/testapi/opnfv_testapi/tests/unit/resources/scenario-c2.json
index b6a3b83ab..980051c4f 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/scenario-c2.json
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/scenario-c2.json
@@ -8,7 +8,7 @@
[
{
"owner": "Lucky",
- "version": "colorado",
+ "version": "danube",
"projects":
[
{
@@ -29,7 +29,7 @@
"scores": [
{
"date": "2017-01-08 22:46:44",
- "score": "0"
+ "score": "0/1"
}
],
"trust_indicators": [
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/test_base.py b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_base.py
index 4d3445659..77a8d18c1 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/test_base.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_base.py
@@ -12,13 +12,9 @@ from os import path
import mock
from tornado import testing
-from opnfv_testapi.common import config
from opnfv_testapi.resources import models
from opnfv_testapi.tests.unit import fake_pymongo
-config.Config.CONFIG = path.join(path.dirname(__file__),
- '../../../etc/config.ini')
-
class TestBase(testing.AsyncHTTPTestCase):
headers = {'Content-Type': 'application/json; charset=UTF-8'}
@@ -37,20 +33,21 @@ class TestBase(testing.AsyncHTTPTestCase):
def tearDown(self):
self.db_patcher.stop()
+ self.config_patcher.stop()
def _patch_server(self):
- from opnfv_testapi.cmd import server
- server.parse_config([
- '--config-file',
- path.join(path.dirname(__file__), 'common/normal.ini')
- ])
- self.db_patcher = mock.patch('opnfv_testapi.cmd.server.get_db',
- self._fake_pymongo)
+ import argparse
+ config = path.join(path.dirname(__file__), '../common/normal.ini')
+ self.config_patcher = mock.patch(
+ 'argparse.ArgumentParser.parse_known_args',
+ return_value=(argparse.Namespace(config_file=config), None))
+ self.db_patcher = mock.patch('opnfv_testapi.db.api.DB',
+ fake_pymongo)
+ self.config_patcher.start()
self.db_patcher.start()
- @staticmethod
- def _fake_pymongo():
- return fake_pymongo
+ def set_config_file(self):
+ self.config_file = 'normal.ini'
def get_app(self):
from opnfv_testapi.cmd import server
@@ -66,9 +63,12 @@ class TestBase(testing.AsyncHTTPTestCase):
return self.create_help(self.basePath, req, *args)
def create_help(self, uri, req, *args):
+ return self.post_direct_url(self._update_uri(uri, *args), req)
+
+ def post_direct_url(self, url, req):
if req and not isinstance(req, str) and hasattr(req, 'format'):
req = req.format()
- res = self.fetch(self._update_uri(uri, *args),
+ res = self.fetch(url,
method='POST',
body=json.dumps(req),
headers=self.headers)
@@ -92,21 +92,35 @@ class TestBase(testing.AsyncHTTPTestCase):
headers=self.headers)
return self._get_return(res, self.list_res)
- def update(self, new=None, *args):
- if new:
+ def update_direct_url(self, url, new=None):
+ if new and hasattr(new, 'format'):
new = new.format()
- res = self.fetch(self._get_uri(*args),
+ res = self.fetch(url,
method='PUT',
body=json.dumps(new),
headers=self.headers)
return self._get_return(res, self.update_res)
- def delete(self, *args):
- res = self.fetch(self._get_uri(*args),
- method='DELETE',
- headers=self.headers)
+ def update(self, new=None, *args):
+ return self.update_direct_url(self._get_uri(*args), new)
+
+ def delete_direct_url(self, url, body):
+ if body:
+ res = self.fetch(url,
+ method='DELETE',
+ body=json.dumps(body),
+ headers=self.headers,
+ allow_nonstandard_methods=True)
+ else:
+ res = self.fetch(url,
+ method='DELETE',
+ headers=self.headers)
+
return res.code, res.body
+ def delete(self, *args):
+ return self.delete_direct_url(self._get_uri(*args), None)
+
@staticmethod
def _get_valid_args(*args):
new_args = tuple(['%s' % arg for arg in args if arg is not None])
@@ -132,7 +146,10 @@ class TestBase(testing.AsyncHTTPTestCase):
def _get_return(self, res, cls):
code = res.code
body = res.body
- return code, self._get_return_body(code, body, cls)
+ if body:
+ return code, self._get_return_body(code, body, cls)
+ else:
+ return code, None
@staticmethod
def _get_return_body(code, body, cls):
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/test_fake_pymongo.py b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_fake_pymongo.py
index 1ebc96f3b..1ebc96f3b 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/test_fake_pymongo.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_fake_pymongo.py
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/test_pod.py b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_pod.py
index 0ed348df9..cb4f1d92c 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/test_pod.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_pod.py
@@ -12,7 +12,7 @@ import unittest
from opnfv_testapi.common import message
from opnfv_testapi.resources import pod_models
from opnfv_testapi.tests.unit import executor
-from opnfv_testapi.tests.unit import test_base as base
+from opnfv_testapi.tests.unit.resources import test_base as base
class TestPodBase(base.TestBase):
@@ -85,5 +85,6 @@ class TestPodGet(TestPodBase):
else:
self.assert_get_body(pod, self.req_e)
+
if __name__ == '__main__':
unittest.main()
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/test_project.py b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_project.py
index 323a1168f..0622ba8d4 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/test_project.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_project.py
@@ -4,7 +4,7 @@ import unittest
from opnfv_testapi.common import message
from opnfv_testapi.resources import project_models
from opnfv_testapi.tests.unit import executor
-from opnfv_testapi.tests.unit import test_base as base
+from opnfv_testapi.tests.unit.resources import test_base as base
class TestProjectBase(base.TestBase):
@@ -132,5 +132,6 @@ class TestProjectDelete(TestProjectBase):
code, body = self.get(self.req_d.name)
self.assertEqual(code, httplib.NOT_FOUND)
+
if __name__ == '__main__':
unittest.main()
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/test_result.py b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_result.py
index ef2ce307e..1e83ed308 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/test_result.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_result.py
@@ -7,17 +7,18 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import copy
-from datetime import datetime, timedelta
import httplib
import unittest
+from datetime import datetime, timedelta
+import json
from opnfv_testapi.common import message
from opnfv_testapi.resources import pod_models
from opnfv_testapi.resources import project_models
from opnfv_testapi.resources import result_models
from opnfv_testapi.resources import testcase_models
-from opnfv_testapi.tests.unit import test_base as base
from opnfv_testapi.tests.unit import executor
+from opnfv_testapi.tests.unit.resources import test_base as base
class Details(object):
@@ -60,9 +61,9 @@ class TestResultBase(base.TestBase):
self.scenario = 'odl-l2'
self.criteria = 'passed'
self.trust_indicator = result_models.TI(0.7)
- self.start_date = "2016-05-23 07:16:09.477097"
- self.stop_date = "2016-05-23 07:16:19.477097"
- self.update_date = "2016-05-24 07:16:19.477097"
+ self.start_date = str(datetime.now())
+ self.stop_date = str(datetime.now() + timedelta(minutes=1))
+ self.update_date = str(datetime.now() + timedelta(days=1))
self.update_step = -0.05
super(TestResultBase, self).setUp()
self.details = Details(timestart='0', duration='9s', status='OK')
@@ -131,6 +132,22 @@ class TestResultBase(base.TestBase):
_, res = self.create_d()
return res.href.split('/')[-1]
+ def upload(self, req):
+ if req and not isinstance(req, str) and hasattr(req, 'format'):
+ req = req.format()
+ res = self.fetch(self.basePath + '/upload',
+ method='POST',
+ body=json.dumps(req),
+ headers=self.headers)
+
+ return self._get_return(res, self.create_res)
+
+
+class TestResultUpload(TestResultBase):
+ @executor.upload(httplib.BAD_REQUEST, message.key_error('file'))
+ def test_filenotfind(self):
+ return None
+
class TestResultCreate(TestResultBase):
@executor.create(httplib.BAD_REQUEST, message.no_body())
@@ -208,9 +225,9 @@ class TestResultCreate(TestResultBase):
class TestResultGet(TestResultBase):
def setUp(self):
super(TestResultGet, self).setUp()
+ self.req_10d_before = self._create_changed_date(days=-10)
self.req_d_id = self._create_d()
self.req_10d_later = self._create_changed_date(days=10)
- self.req_10d_before = self._create_changed_date(days=-10)
@executor.get(httplib.OK, 'assert_res')
def test_getOne(self):
@@ -256,9 +273,9 @@ class TestResultGet(TestResultBase):
def test_queryPeriodNotInt(self):
return self._set_query('period=a')
- @executor.query(httplib.OK, '_query_last_one', 1)
+ @executor.query(httplib.OK, '_query_period_one', 1)
def test_queryPeriodSuccess(self):
- return self._set_query('period=1')
+ return self._set_query('period=5')
@executor.query(httplib.BAD_REQUEST, message.must_int('last'))
def test_queryLastNotInt(self):
@@ -268,7 +285,17 @@ class TestResultGet(TestResultBase):
def test_queryLast(self):
return self._set_query('last=1')
- @executor.query(httplib.OK, '_query_last_one', 1)
+ @executor.query(httplib.OK, '_query_success', 4)
+ def test_queryPublic(self):
+ self._create_public_data()
+ return self._set_query('')
+
+ @executor.query(httplib.OK, '_query_success', 1)
+ def test_queryPrivate(self):
+ self._create_private_data()
+ return self._set_query('public=false')
+
+ @executor.query(httplib.OK, '_query_period_one', 1)
def test_combination(self):
return self._set_query('pod',
'project',
@@ -279,7 +306,7 @@ class TestResultGet(TestResultBase):
'scenario',
'trust_indicator',
'criteria',
- 'period=1')
+ 'period=5')
@executor.query(httplib.OK, '_query_success', 0)
def test_notFound(self):
@@ -294,6 +321,14 @@ class TestResultGet(TestResultBase):
'criteria',
'period=1')
+ @executor.query(httplib.OK, '_query_success', 1)
+ def test_filterErrorStartdate(self):
+ self._create_error_start_date(None)
+ self._create_error_start_date('None')
+ self._create_error_start_date('null')
+ self._create_error_start_date('')
+ return self._set_query('period=5')
+
def _query_success(self, body, number):
self.assertEqual(number, len(body.results))
@@ -301,6 +336,16 @@ class TestResultGet(TestResultBase):
self.assertEqual(number, len(body.results))
self.assert_res(body.results[0], self.req_10d_later)
+ def _query_period_one(self, body, number):
+ self.assertEqual(number, len(body.results))
+ self.assert_res(body.results[0], self.req_d)
+
+ def _create_error_start_date(self, start_date):
+ req = copy.deepcopy(self.req_d)
+ req.start_date = start_date
+ self.create(req)
+ return req
+
def _create_changed_date(self, **kwargs):
req = copy.deepcopy(self.req_d)
req.start_date = datetime.now() + timedelta(**kwargs)
@@ -309,16 +354,29 @@ class TestResultGet(TestResultBase):
self.create(req)
return req
+ def _create_public_data(self, **kwargs):
+ req = copy.deepcopy(self.req_d)
+ req.public = 'true'
+ self.create(req)
+ return req
+
+ def _create_private_data(self, **kwargs):
+ req = copy.deepcopy(self.req_d)
+ req.public = 'false'
+ self.create(req)
+ return req
+
def _set_query(self, *args):
def get_value(arg):
return self.__getattribute__(arg) \
if arg != 'trust_indicator' else self.trust_indicator.current
uri = ''
for arg in args:
- if '=' in arg:
- uri += arg + '&'
- else:
- uri += '{}={}&'.format(arg, get_value(arg))
+ if arg:
+ if '=' in arg:
+ uri += arg + '&'
+ else:
+ uri += '{}={}&'.format(arg, get_value(arg))
return uri[0: -1]
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py
new file mode 100644
index 000000000..1367fc669
--- /dev/null
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py
@@ -0,0 +1,449 @@
+import functools
+import httplib
+import json
+import os
+
+from datetime import datetime
+
+from opnfv_testapi.common import message
+import opnfv_testapi.resources.scenario_models as models
+from opnfv_testapi.tests.unit.resources import test_base as base
+
+
+def _none_default(check, default):
+ return check if check else default
+
+
+class TestScenarioBase(base.TestBase):
+ def setUp(self):
+ super(TestScenarioBase, self).setUp()
+ self.get_res = models.Scenario
+ self.list_res = models.Scenarios
+ self.basePath = '/api/v1/scenarios'
+ self.req_d = self._load_request('scenario-c1.json')
+ self.req_2 = self._load_request('scenario-c2.json')
+
+ def tearDown(self):
+ pass
+
+ def assert_body(self, project, req=None):
+ pass
+
+ @staticmethod
+ def _load_request(f_req):
+ abs_file = os.path.join(os.path.dirname(__file__), f_req)
+ with open(abs_file, 'r') as f:
+ loader = json.load(f)
+ f.close()
+ return loader
+
+ def create_return_name(self, req):
+ _, res = self.create(req)
+ return res.href.split('/')[-1]
+
+ def assert_res(self, code, scenario, req=None):
+ self.assertEqual(code, httplib.OK)
+ if req is None:
+ req = self.req_d
+ self.assertIsNotNone(scenario._id)
+ self.assertIsNotNone(scenario.creation_date)
+ self.assertEqual(scenario, models.Scenario.from_dict(req))
+
+ @staticmethod
+ def set_query(*args):
+ uri = ''
+ for arg in args:
+ uri += arg + '&'
+ return uri[0: -1]
+
+ def get_and_assert(self, name):
+ code, body = self.get(name)
+ self.assert_res(code, body, self.req_d)
+
+
+class TestScenarioCreate(TestScenarioBase):
+ def test_withoutBody(self):
+ (code, body) = self.create()
+ self.assertEqual(code, httplib.BAD_REQUEST)
+
+ def test_emptyName(self):
+ req_empty = models.ScenarioCreateRequest('')
+ (code, body) = self.create(req_empty)
+ self.assertEqual(code, httplib.BAD_REQUEST)
+ self.assertIn(message.missing('name'), body)
+
+ def test_noneName(self):
+ req_none = models.ScenarioCreateRequest(None)
+ (code, body) = self.create(req_none)
+ self.assertEqual(code, httplib.BAD_REQUEST)
+ self.assertIn(message.missing('name'), body)
+
+ def test_success(self):
+ (code, body) = self.create_d()
+ self.assertEqual(code, httplib.OK)
+ self.assert_create_body(body)
+
+ def test_alreadyExist(self):
+ self.create_d()
+ (code, body) = self.create_d()
+ self.assertEqual(code, httplib.FORBIDDEN)
+ self.assertIn(message.exist_base, body)
+
+
+class TestScenarioGet(TestScenarioBase):
+ def setUp(self):
+ super(TestScenarioGet, self).setUp()
+ self.scenario_1 = self.create_return_name(self.req_d)
+ self.scenario_2 = self.create_return_name(self.req_2)
+
+ def test_getByName(self):
+ self.get_and_assert(self.scenario_1)
+
+ def test_getAll(self):
+ self._query_and_assert(query=None, reqs=[self.req_d, self.req_2])
+
+ def test_queryName(self):
+ query = self.set_query('name=nosdn-nofeature-ha')
+ self._query_and_assert(query, reqs=[self.req_d])
+
+ def test_queryInstaller(self):
+ query = self.set_query('installer=apex')
+ self._query_and_assert(query, reqs=[self.req_d])
+
+ def test_queryVersion(self):
+ query = self.set_query('version=master')
+ self._query_and_assert(query, reqs=[self.req_d])
+
+ def test_queryProject(self):
+ query = self.set_query('project=functest')
+ self._query_and_assert(query, reqs=[self.req_d, self.req_2])
+
+ # close due to random fail, open again after solve it in another patch
+ # def test_queryCombination(self):
+ # query = self._set_query('name=nosdn-nofeature-ha',
+ # 'installer=apex',
+ # 'version=master',
+ # 'project=functest')
+ #
+ # self._query_and_assert(query, reqs=[self.req_d])
+
+ def _query_and_assert(self, query, found=True, reqs=None):
+ code, body = self.query(query)
+ if not found:
+ self.assertEqual(code, httplib.OK)
+ self.assertEqual(0, len(body.scenarios))
+ else:
+ self.assertEqual(len(reqs), len(body.scenarios))
+ for req in reqs:
+ for scenario in body.scenarios:
+ if req['name'] == scenario.name:
+ self.assert_res(code, scenario, req)
+
+
+class TestScenarioDelete(TestScenarioBase):
+ def test_notFound(self):
+ code, body = self.delete('notFound')
+ self.assertEqual(code, httplib.NOT_FOUND)
+
+ def test_success(self):
+ scenario = self.create_return_name(self.req_d)
+ code, _ = self.delete(scenario)
+ self.assertEqual(code, httplib.OK)
+ code, _ = self.get(scenario)
+ self.assertEqual(code, httplib.NOT_FOUND)
+
+
+class TestScenarioUpdate(TestScenarioBase):
+ def setUp(self):
+ super(TestScenarioUpdate, self).setUp()
+ self.scenario = self.create_return_name(self.req_d)
+ self.scenario_2 = self.create_return_name(self.req_2)
+ self.update_url = ''
+ self.scenario_url = '/api/v1/scenarios/{}'.format(self.scenario)
+ self.installer = self.req_d['installers'][0]['installer']
+ self.version = self.req_d['installers'][0]['versions'][0]['version']
+ self.locate_project = 'installer={}&version={}&project={}'.format(
+ self.installer,
+ self.version,
+ 'functest')
+
+ def update_url_fixture(item):
+ def _update_url_fixture(xstep):
+ def wrapper(self, *args, **kwargs):
+ self.update_url = '{}/{}'.format(self.scenario_url, item)
+ locator = None
+ if item in ['projects', 'owner']:
+ locator = 'installer={}&version={}'.format(
+ self.installer,
+ self.version)
+ elif item in ['versions']:
+ locator = 'installer={}'.format(
+ self.installer)
+ elif item in ['rename']:
+ self.update_url = self.scenario_url
+
+ if locator:
+ self.update_url = '{}?{}'.format(self.update_url, locator)
+
+ xstep(self, *args, **kwargs)
+ return wrapper
+ return _update_url_fixture
+
+ def update_partial(operate, expected):
+ def _update_partial(set_update):
+ @functools.wraps(set_update)
+ def wrapper(self):
+ update = set_update(self)
+ code, body = getattr(self, operate)(update)
+ getattr(self, expected)(code)
+ return wrapper
+ return _update_partial
+
+ @update_partial('_add', '_success')
+ def test_addScore(self):
+ add = models.ScenarioScore(date=str(datetime.now()), score='11/12')
+ projects = self.req_d['installers'][0]['versions'][0]['projects']
+ functest = filter(lambda f: f['project'] == 'functest', projects)[0]
+ functest['scores'].append(add.format())
+ self.update_url = '{}/scores?{}'.format(self.scenario_url,
+ self.locate_project)
+
+ return add
+
+ @update_partial('_add', '_success')
+ def test_addTrustIndicator(self):
+ add = models.ScenarioTI(date=str(datetime.now()), status='gold')
+ projects = self.req_d['installers'][0]['versions'][0]['projects']
+ functest = filter(lambda f: f['project'] == 'functest', projects)[0]
+ functest['trust_indicators'].append(add.format())
+ self.update_url = '{}/trust_indicators?{}'.format(self.scenario_url,
+ self.locate_project)
+
+ return add
+
+ @update_partial('_add', '_success')
+ def test_addCustoms(self):
+ adds = ['odl', 'parser', 'vping_ssh']
+ projects = self.req_d['installers'][0]['versions'][0]['projects']
+ functest = filter(lambda f: f['project'] == 'functest', projects)[0]
+ functest['customs'] = list(set(functest['customs'] + adds))
+ self.update_url = '{}/customs?{}'.format(self.scenario_url,
+ self.locate_project)
+ return adds
+
+ @update_partial('_update', '_success')
+ def test_updateCustoms(self):
+ updates = ['odl', 'parser', 'vping_ssh']
+ projects = self.req_d['installers'][0]['versions'][0]['projects']
+ functest = filter(lambda f: f['project'] == 'functest', projects)[0]
+ functest['customs'] = updates
+ self.update_url = '{}/customs?{}'.format(self.scenario_url,
+ self.locate_project)
+
+ return updates
+
+ @update_partial('_delete', '_success')
+ def test_deleteCustoms(self):
+ deletes = ['vping_ssh']
+ projects = self.req_d['installers'][0]['versions'][0]['projects']
+ functest = filter(lambda f: f['project'] == 'functest', projects)[0]
+ functest['customs'] = ['healthcheck']
+ self.update_url = '{}/customs?{}'.format(self.scenario_url,
+ self.locate_project)
+
+ return deletes
+
+ @update_url_fixture('projects')
+ @update_partial('_add', '_success')
+ def test_addProjects_succ(self):
+ add = models.ScenarioProject(project='qtip').format()
+ self.req_d['installers'][0]['versions'][0]['projects'].append(add)
+ return [add]
+
+ @update_url_fixture('projects')
+ @update_partial('_add', '_conflict')
+ def test_addProjects_already_exist(self):
+ add = models.ScenarioProject(project='functest').format()
+ return [add]
+
+ @update_url_fixture('projects')
+ @update_partial('_add', '_bad_request')
+ def test_addProjects_bad_schema(self):
+ add = models.ScenarioProject(project='functest').format()
+ add['score'] = None
+ return [add]
+
+ @update_url_fixture('projects')
+ @update_partial('_update', '_success')
+ def test_updateProjects_succ(self):
+ update = models.ScenarioProject(project='qtip').format()
+ self.req_d['installers'][0]['versions'][0]['projects'] = [update]
+ return [update]
+
+ @update_url_fixture('projects')
+ @update_partial('_update', '_conflict')
+ def test_updateProjects_duplicated(self):
+ update = models.ScenarioProject(project='qtip').format()
+ return [update, update]
+
+ @update_url_fixture('projects')
+ @update_partial('_update', '_bad_request')
+ def test_updateProjects_bad_schema(self):
+ update = models.ScenarioProject(project='functest').format()
+ update['score'] = None
+ return [update]
+
+ @update_url_fixture('projects')
+ @update_partial('_delete', '_success')
+ def test_deleteProjects(self):
+ deletes = ['functest']
+ projects = self.req_d['installers'][0]['versions'][0]['projects']
+ self.req_d['installers'][0]['versions'][0]['projects'] = filter(
+ lambda f: f['project'] != 'functest',
+ projects)
+ return deletes
+
+ @update_url_fixture('owner')
+ @update_partial('_update', '_success')
+ def test_changeOwner(self):
+ new_owner = 'new_owner'
+ update = models.ScenarioChangeOwnerRequest(new_owner).format()
+ self.req_d['installers'][0]['versions'][0]['owner'] = new_owner
+ return update
+
+ @update_url_fixture('versions')
+ @update_partial('_add', '_success')
+ def test_addVersions_succ(self):
+ add = models.ScenarioVersion(version='Euphrates').format()
+ self.req_d['installers'][0]['versions'].append(add)
+ return [add]
+
+ @update_url_fixture('versions')
+ @update_partial('_add', '_conflict')
+ def test_addVersions_already_exist(self):
+ add = models.ScenarioVersion(version='master').format()
+ return [add]
+
+ @update_url_fixture('versions')
+ @update_partial('_add', '_bad_request')
+ def test_addVersions_bad_schema(self):
+ add = models.ScenarioVersion(version='euphrates').format()
+ add['notexist'] = None
+ return [add]
+
+ @update_url_fixture('versions')
+ @update_partial('_update', '_success')
+ def test_updateVersions_succ(self):
+ update = models.ScenarioVersion(version='euphrates').format()
+ self.req_d['installers'][0]['versions'] = [update]
+ return [update]
+
+ @update_url_fixture('versions')
+ @update_partial('_update', '_conflict')
+ def test_updateVersions_duplicated(self):
+ update = models.ScenarioVersion(version='euphrates').format()
+ return [update, update]
+
+ @update_url_fixture('versions')
+ @update_partial('_update', '_bad_request')
+ def test_updateVersions_bad_schema(self):
+ update = models.ScenarioVersion(version='euphrates').format()
+ update['not_owner'] = 'Iam'
+ return [update]
+
+ @update_url_fixture('versions')
+ @update_partial('_delete', '_success')
+ def test_deleteVersions(self):
+ deletes = ['master']
+ versions = self.req_d['installers'][0]['versions']
+ self.req_d['installers'][0]['versions'] = filter(
+ lambda f: f['version'] != 'master',
+ versions)
+ return deletes
+
+ @update_url_fixture('installers')
+ @update_partial('_add', '_success')
+ def test_addInstallers_succ(self):
+ add = models.ScenarioInstaller(installer='daisy').format()
+ self.req_d['installers'].append(add)
+ return [add]
+
+ @update_url_fixture('installers')
+ @update_partial('_add', '_conflict')
+ def test_addInstallers_already_exist(self):
+ add = models.ScenarioInstaller(installer='apex').format()
+ return [add]
+
+ @update_url_fixture('installers')
+ @update_partial('_add', '_bad_request')
+ def test_addInstallers_bad_schema(self):
+ add = models.ScenarioInstaller(installer='daisy').format()
+ add['not_exist'] = 'not_exist'
+ return [add]
+
+ @update_url_fixture('installers')
+ @update_partial('_update', '_success')
+ def test_updateInstallers_succ(self):
+ update = models.ScenarioInstaller(installer='daisy').format()
+ self.req_d['installers'] = [update]
+ return [update]
+
+ @update_url_fixture('installers')
+ @update_partial('_update', '_conflict')
+ def test_updateInstallers_duplicated(self):
+ update = models.ScenarioInstaller(installer='daisy').format()
+ return [update, update]
+
+ @update_url_fixture('installers')
+ @update_partial('_update', '_bad_request')
+ def test_updateInstallers_bad_schema(self):
+ update = models.ScenarioInstaller(installer='daisy').format()
+ update['not_exist'] = 'not_exist'
+ return [update]
+
+ @update_url_fixture('installers')
+ @update_partial('_delete', '_success')
+ def test_deleteInstallers(self):
+ deletes = ['apex']
+ installers = self.req_d['installers']
+ self.req_d['installers'] = filter(
+ lambda f: f['installer'] != 'apex',
+ installers)
+ return deletes
+
+ @update_url_fixture('rename')
+ @update_partial('_update', '_success')
+ def test_renameScenario(self):
+ new_name = 'new_scenario_name'
+ update = models.ScenarioUpdateRequest(name=new_name)
+ self.req_d['name'] = new_name
+ return update
+
+ @update_url_fixture('rename')
+ @update_partial('_update', '_forbidden')
+ def test_renameScenario_exist(self):
+ new_name = self.req_d['name']
+ update = models.ScenarioUpdateRequest(name=new_name)
+ return update
+
+ def _add(self, update_req):
+ return self.post_direct_url(self.update_url, update_req)
+
+ def _update(self, update_req):
+ return self.update_direct_url(self.update_url, update_req)
+
+ def _delete(self, update_req):
+ return self.delete_direct_url(self.update_url, update_req)
+
+ def _success(self, status):
+ self.assertEqual(status, httplib.OK)
+ self.get_and_assert(self.req_d['name'])
+
+ def _forbidden(self, status):
+ self.assertEqual(status, httplib.FORBIDDEN)
+
+ def _bad_request(self, status):
+ self.assertEqual(status, httplib.BAD_REQUEST)
+
+ def _conflict(self, status):
+ self.assertEqual(status, httplib.CONFLICT)
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/test_testcase.py b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_testcase.py
index e28eaf5b8..4f2bc2ad1 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/test_testcase.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_testcase.py
@@ -13,8 +13,8 @@ import unittest
from opnfv_testapi.common import message
from opnfv_testapi.resources import project_models
from opnfv_testapi.resources import testcase_models
-from opnfv_testapi.tests.unit import test_base as base
from opnfv_testapi.tests.unit import executor
+from opnfv_testapi.tests.unit.resources import test_base as base
class TestCaseBase(base.TestBase):
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/test_token.py b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_token.py
index ca247a3b7..940e256c6 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/test_token.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_token.py
@@ -10,14 +10,14 @@ from tornado import web
from opnfv_testapi.common import message
from opnfv_testapi.resources import project_models
-from opnfv_testapi.router import url_mappings
from opnfv_testapi.tests.unit import executor
from opnfv_testapi.tests.unit import fake_pymongo
-from opnfv_testapi.tests.unit import test_base as base
+from opnfv_testapi.tests.unit.resources import test_base as base
class TestToken(base.TestBase):
def get_app(self):
+ from opnfv_testapi.router import url_mappings
return web.Application(
url_mappings.mappings,
db=fake_pymongo,
@@ -109,5 +109,6 @@ class TestTokenUpdateProject(TestToken):
def _update_success(self, request, body):
self.assertIn(request.name, body)
+
if __name__ == '__main__':
unittest.main()
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/test_version.py b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_version.py
index fff802ac8..51fed11ea 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/test_version.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_version.py
@@ -11,7 +11,7 @@ import unittest
from opnfv_testapi.resources import models
from opnfv_testapi.tests.unit import executor
-from opnfv_testapi.tests.unit import test_base as base
+from opnfv_testapi.tests.unit.resources import test_base as base
class TestVersionBase(base.TestBase):
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/test_scenario.py b/utils/test/testapi/opnfv_testapi/tests/unit/test_scenario.py
deleted file mode 100644
index b232bc168..000000000
--- a/utils/test/testapi/opnfv_testapi/tests/unit/test_scenario.py
+++ /dev/null
@@ -1,360 +0,0 @@
-from copy import deepcopy
-from datetime import datetime
-import functools
-import httplib
-import json
-import os
-
-from opnfv_testapi.common import message
-import opnfv_testapi.resources.scenario_models as models
-from opnfv_testapi.tests.unit import test_base as base
-
-
-class TestScenarioBase(base.TestBase):
- def setUp(self):
- super(TestScenarioBase, self).setUp()
- self.get_res = models.Scenario
- self.list_res = models.Scenarios
- self.basePath = '/api/v1/scenarios'
- self.req_d = self._load_request('scenario-c1.json')
- self.req_2 = self._load_request('scenario-c2.json')
-
- def tearDown(self):
- pass
-
- def assert_body(self, project, req=None):
- pass
-
- @staticmethod
- def _load_request(f_req):
- abs_file = os.path.join(os.path.dirname(__file__), f_req)
- with open(abs_file, 'r') as f:
- loader = json.load(f)
- f.close()
- return loader
-
- def create_return_name(self, req):
- _, res = self.create(req)
- return res.href.split('/')[-1]
-
- def assert_res(self, code, scenario, req=None):
- self.assertEqual(code, httplib.OK)
- if req is None:
- req = self.req_d
- self.assertIsNotNone(scenario._id)
- self.assertIsNotNone(scenario.creation_date)
-
- scenario == models.Scenario.from_dict(req)
-
- @staticmethod
- def _set_query(*args):
- uri = ''
- for arg in args:
- uri += arg + '&'
- return uri[0: -1]
-
- def _get_and_assert(self, name, req=None):
- code, body = self.get(name)
- self.assert_res(code, body, req)
-
-
-class TestScenarioCreate(TestScenarioBase):
- def test_withoutBody(self):
- (code, body) = self.create()
- self.assertEqual(code, httplib.BAD_REQUEST)
-
- def test_emptyName(self):
- req_empty = models.ScenarioCreateRequest('')
- (code, body) = self.create(req_empty)
- self.assertEqual(code, httplib.BAD_REQUEST)
- self.assertIn(message.missing('name'), body)
-
- def test_noneName(self):
- req_none = models.ScenarioCreateRequest(None)
- (code, body) = self.create(req_none)
- self.assertEqual(code, httplib.BAD_REQUEST)
- self.assertIn(message.missing('name'), body)
-
- def test_success(self):
- (code, body) = self.create_d()
- self.assertEqual(code, httplib.OK)
- self.assert_create_body(body)
-
- def test_alreadyExist(self):
- self.create_d()
- (code, body) = self.create_d()
- self.assertEqual(code, httplib.FORBIDDEN)
- self.assertIn(message.exist_base, body)
-
-
-class TestScenarioGet(TestScenarioBase):
- def setUp(self):
- super(TestScenarioGet, self).setUp()
- self.scenario_1 = self.create_return_name(self.req_d)
- self.scenario_2 = self.create_return_name(self.req_2)
-
- def test_getByName(self):
- self._get_and_assert(self.scenario_1, self.req_d)
-
- def test_getAll(self):
- self._query_and_assert(query=None, reqs=[self.req_d, self.req_2])
-
- def test_queryName(self):
- query = self._set_query('name=nosdn-nofeature-ha')
- self._query_and_assert(query, reqs=[self.req_d])
-
- def test_queryInstaller(self):
- query = self._set_query('installer=apex')
- self._query_and_assert(query, reqs=[self.req_d])
-
- def test_queryVersion(self):
- query = self._set_query('version=master')
- self._query_and_assert(query, reqs=[self.req_d])
-
- def test_queryProject(self):
- query = self._set_query('project=functest')
- self._query_and_assert(query, reqs=[self.req_d, self.req_2])
-
- def test_queryCombination(self):
- query = self._set_query('name=nosdn-nofeature-ha',
- 'installer=apex',
- 'version=master',
- 'project=functest')
-
- self._query_and_assert(query, reqs=[self.req_d])
-
- def _query_and_assert(self, query, found=True, reqs=None):
- code, body = self.query(query)
- if not found:
- self.assertEqual(code, httplib.OK)
- self.assertEqual(0, len(body.scenarios))
- else:
- self.assertEqual(len(reqs), len(body.scenarios))
- for req in reqs:
- for scenario in body.scenarios:
- if req['name'] == scenario.name:
- self.assert_res(code, scenario, req)
-
-
-class TestScenarioUpdate(TestScenarioBase):
- def setUp(self):
- super(TestScenarioUpdate, self).setUp()
- self.scenario = self.create_return_name(self.req_d)
- self.scenario_2 = self.create_return_name(self.req_2)
-
- def _execute(set_update):
- @functools.wraps(set_update)
- def magic(self):
- update, scenario = set_update(self, deepcopy(self.req_d))
- self._update_and_assert(update, scenario)
- return magic
-
- def _update(expected):
- def _update(set_update):
- @functools.wraps(set_update)
- def wrap(self):
- update, scenario = set_update(self, deepcopy(self.req_d))
- code, body = self.update(update, self.scenario)
- getattr(self, expected)(code, scenario)
- return wrap
- return _update
-
- @_update('_success')
- def test_renameScenario(self, scenario):
- new_name = 'nosdn-nofeature-noha'
- scenario['name'] = new_name
- update_req = models.ScenarioUpdateRequest(field='name',
- op='update',
- locate={},
- term={'name': new_name})
- return update_req, scenario
-
- @_update('_forbidden')
- def test_renameScenario_exist(self, scenario):
- new_name = self.scenario_2
- scenario['name'] = new_name
- update_req = models.ScenarioUpdateRequest(field='name',
- op='update',
- locate={},
- term={'name': new_name})
- return update_req, scenario
-
- @_update('_bad_request')
- def test_renameScenario_noName(self, scenario):
- new_name = self.scenario_2
- scenario['name'] = new_name
- update_req = models.ScenarioUpdateRequest(field='name',
- op='update',
- locate={},
- term={})
- return update_req, scenario
-
- @_execute
- def test_addInstaller(self, scenario):
- add = models.ScenarioInstaller(installer='daisy', versions=list())
- scenario['installers'].append(add.format())
- update = models.ScenarioUpdateRequest(field='installer',
- op='add',
- locate={},
- term=add.format())
- return update, scenario
-
- @_execute
- def test_deleteInstaller(self, scenario):
- scenario['installers'] = filter(lambda f: f['installer'] != 'apex',
- scenario['installers'])
-
- update = models.ScenarioUpdateRequest(field='installer',
- op='delete',
- locate={'installer': 'apex'})
- return update, scenario
-
- @_execute
- def test_addVersion(self, scenario):
- add = models.ScenarioVersion(version='danube', projects=list())
- scenario['installers'][0]['versions'].append(add.format())
- update = models.ScenarioUpdateRequest(field='version',
- op='add',
- locate={'installer': 'apex'},
- term=add.format())
- return update, scenario
-
- @_execute
- def test_deleteVersion(self, scenario):
- scenario['installers'][0]['versions'] = filter(
- lambda f: f['version'] != 'master',
- scenario['installers'][0]['versions'])
-
- update = models.ScenarioUpdateRequest(field='version',
- op='delete',
- locate={'installer': 'apex',
- 'version': 'master'})
- return update, scenario
-
- @_execute
- def test_changeOwner(self, scenario):
- scenario['installers'][0]['versions'][0]['owner'] = 'lucy'
-
- update = models.ScenarioUpdateRequest(field='owner',
- op='update',
- locate={'installer': 'apex',
- 'version': 'master'},
- term={'owner': 'lucy'})
- return update, scenario
-
- @_execute
- def test_addProject(self, scenario):
- add = models.ScenarioProject(project='qtip').format()
- scenario['installers'][0]['versions'][0]['projects'].append(add)
- update = models.ScenarioUpdateRequest(field='project',
- op='add',
- locate={'installer': 'apex',
- 'version': 'master'},
- term=add)
- return update, scenario
-
- @_execute
- def test_deleteProject(self, scenario):
- scenario['installers'][0]['versions'][0]['projects'] = filter(
- lambda f: f['project'] != 'functest',
- scenario['installers'][0]['versions'][0]['projects'])
-
- update = models.ScenarioUpdateRequest(field='project',
- op='delete',
- locate={
- 'installer': 'apex',
- 'version': 'master',
- 'project': 'functest'})
- return update, scenario
-
- @_execute
- def test_addCustoms(self, scenario):
- add = ['odl', 'parser', 'vping_ssh']
- projects = scenario['installers'][0]['versions'][0]['projects']
- functest = filter(lambda f: f['project'] == 'functest', projects)[0]
- functest['customs'] = ['healthcheck', 'odl', 'parser', 'vping_ssh']
- update = models.ScenarioUpdateRequest(field='customs',
- op='add',
- locate={
- 'installer': 'apex',
- 'version': 'master',
- 'project': 'functest'},
- term=add)
- return update, scenario
-
- @_execute
- def test_deleteCustoms(self, scenario):
- projects = scenario['installers'][0]['versions'][0]['projects']
- functest = filter(lambda f: f['project'] == 'functest', projects)[0]
- functest['customs'] = ['healthcheck']
- update = models.ScenarioUpdateRequest(field='customs',
- op='delete',
- locate={
- 'installer': 'apex',
- 'version': 'master',
- 'project': 'functest'},
- term=['vping_ssh'])
- return update, scenario
-
- @_execute
- def test_addScore(self, scenario):
- add = models.ScenarioScore(date=str(datetime.now()), score='11/12')
- projects = scenario['installers'][0]['versions'][0]['projects']
- functest = filter(lambda f: f['project'] == 'functest', projects)[0]
- functest['scores'].append(add.format())
- update = models.ScenarioUpdateRequest(field='score',
- op='add',
- locate={
- 'installer': 'apex',
- 'version': 'master',
- 'project': 'functest'},
- term=add.format())
- return update, scenario
-
- @_execute
- def test_addTi(self, scenario):
- add = models.ScenarioTI(date=str(datetime.now()), status='gold')
- projects = scenario['installers'][0]['versions'][0]['projects']
- functest = filter(lambda f: f['project'] == 'functest', projects)[0]
- functest['trust_indicators'].append(add.format())
- update = models.ScenarioUpdateRequest(field='trust_indicator',
- op='add',
- locate={
- 'installer': 'apex',
- 'version': 'master',
- 'project': 'functest'},
- term=add.format())
- return update, scenario
-
- def _update_and_assert(self, update_req, new_scenario, name=None):
- code, _ = self.update(update_req, self.scenario)
- self.assertEqual(code, httplib.OK)
- self._get_and_assert(_none_default(name, self.scenario),
- new_scenario)
-
- def _success(self, status, new_scenario):
- self.assertEqual(status, httplib.OK)
- self._get_and_assert(new_scenario.get('name'), new_scenario)
-
- def _forbidden(self, status, new_scenario):
- self.assertEqual(status, httplib.FORBIDDEN)
-
- def _bad_request(self, status, new_scenario):
- self.assertEqual(status, httplib.BAD_REQUEST)
-
-
-class TestScenarioDelete(TestScenarioBase):
- def test_notFound(self):
- code, body = self.delete('notFound')
- self.assertEqual(code, httplib.NOT_FOUND)
-
- def test_success(self):
- scenario = self.create_return_name(self.req_d)
- code, _ = self.delete(scenario)
- self.assertEqual(code, httplib.OK)
- code, _ = self.get(scenario)
- self.assertEqual(code, httplib.NOT_FOUND)
-
-
-def _none_default(check, default):
- return check if check else default
diff --git a/utils/test/testapi/opnfv_testapi/tornado_swagger/swagger.py b/utils/test/testapi/opnfv_testapi/tornado_swagger/swagger.py
index 83f389a6b..6125c9554 100644
--- a/utils/test/testapi/opnfv_testapi/tornado_swagger/swagger.py
+++ b/utils/test/testapi/opnfv_testapi/tornado_swagger/swagger.py
@@ -94,11 +94,18 @@ class DocParser(object):
def _parse_type(self, **kwargs):
arg = kwargs.get('arg', None)
- body = self._get_body(**kwargs)
- self.params.setdefault(arg, {}).update({
- 'name': arg,
- 'dataType': body
- })
+ code = self._parse_epytext_para('code', **kwargs)
+ link = self._parse_epytext_para('link', **kwargs)
+ if code is None:
+ self.params.setdefault(arg, {}).update({
+ 'name': arg,
+ 'type': link
+ })
+ elif code == 'list':
+ self.params.setdefault(arg, {}).update({
+ 'type': 'array',
+ 'items': {'type': link}
+ })
def _parse_in(self, **kwargs):
arg = kwargs.get('arg', None)
diff --git a/utils/test/testapi/opnfv_testapi/ui/auth/constants.py b/utils/test/testapi/opnfv_testapi/ui/auth/constants.py
index 43f69d7f5..44ccb46d7 100644
--- a/utils/test/testapi/opnfv_testapi/ui/auth/constants.py
+++ b/utils/test/testapi/opnfv_testapi/ui/auth/constants.py
@@ -1,4 +1,6 @@
OPENID = 'openid'
+ROLE = 'role'
+DEFAULT_ROLE = 'user'
# OpenID parameters
OPENID_MODE = 'openid.mode'
diff --git a/utils/test/testapi/opnfv_testapi/ui/auth/sign.py b/utils/test/testapi/opnfv_testapi/ui/auth/sign.py
index 6a9d94eb2..462395225 100644
--- a/utils/test/testapi/opnfv_testapi/ui/auth/sign.py
+++ b/utils/test/testapi/opnfv_testapi/ui/auth/sign.py
@@ -1,11 +1,12 @@
from six.moves.urllib import parse
+from tornado import gen
+from tornado import web
-from opnfv_testapi.common import config
+from opnfv_testapi.common.config import CONF
+from opnfv_testapi.db import api as dbapi
from opnfv_testapi.ui.auth import base
from opnfv_testapi.ui.auth import constants as const
-CONF = config.Config()
-
class SigninHandler(base.BaseHandler):
def get(self):
@@ -31,20 +32,30 @@ class SigninHandler(base.BaseHandler):
class SigninReturnHandler(base.BaseHandler):
+ @web.asynchronous
+ @gen.coroutine
def get(self):
if self.get_query_argument(const.OPENID_MODE) == 'cancel':
self._auth_failure('Authentication canceled.')
openid = self.get_query_argument(const.OPENID_CLAIMED_ID)
- user_info = {
+ role = const.DEFAULT_ROLE
+ new_user_info = {
'openid': openid,
'email': self.get_query_argument(const.OPENID_NS_SREG_EMAIL),
- 'fullname': self.get_query_argument(const.OPENID_NS_SREG_FULLNAME)
+ 'fullname': self.get_query_argument(const.OPENID_NS_SREG_FULLNAME),
+ const.ROLE: role
}
+ user = yield dbapi.db_find_one(self.table, {'openid': openid})
+ if not user:
+ dbapi.db_save(self.table, new_user_info)
+ else:
+ role = user.get(const.ROLE)
- self.db_save(self.table, user_info)
- if not self.get_secure_cookie('openid'):
- self.set_secure_cookie('openid', openid)
+ self.clear_cookie(const.OPENID)
+ self.clear_cookie(const.ROLE)
+ self.set_secure_cookie(const.OPENID, openid)
+ self.set_secure_cookie(const.ROLE, role)
self.redirect(url=CONF.ui_url)
def _auth_failure(self, message):
@@ -57,9 +68,8 @@ class SigninReturnHandler(base.BaseHandler):
class SignoutHandler(base.BaseHandler):
def get(self):
"""Handle signout request."""
- openid = self.get_secure_cookie(const.OPENID)
- if openid:
- self.clear_cookie(const.OPENID)
+ self.clear_cookie(const.OPENID)
+ self.clear_cookie(const.ROLE)
params = {'openid_logout': CONF.osid_openid_logout_endpoint}
url = parse.urljoin(CONF.ui_url,
'/#/logout?' + parse.urlencode(params))
diff --git a/utils/test/testapi/opnfv_testapi/ui/auth/user.py b/utils/test/testapi/opnfv_testapi/ui/auth/user.py
index 140bca51c..955cdeead 100644
--- a/utils/test/testapi/opnfv_testapi/ui/auth/user.py
+++ b/utils/test/testapi/opnfv_testapi/ui/auth/user.py
@@ -2,6 +2,7 @@ from tornado import gen
from tornado import web
from opnfv_testapi.common import raises
+from opnfv_testapi.db import api as dbapi
from opnfv_testapi.ui.auth import base
@@ -12,12 +13,12 @@ class ProfileHandler(base.BaseHandler):
openid = self.get_secure_cookie('openid')
if openid:
try:
- user = yield self.db_find_one({'openid': openid})
+ user = yield dbapi.db_find_one(self.table, {'openid': openid})
self.finish_request({
"openid": user.get('openid'),
"email": user.get('email'),
"fullname": user.get('fullname'),
- "is_admin": False
+ "role": user.get('role', 'user')
})
except Exception:
pass
diff --git a/utils/test/testapi/opnfv_testapi/ui/root.py b/utils/test/testapi/opnfv_testapi/ui/root.py
index bba7a8632..5b2c922d7 100644
--- a/utils/test/testapi/opnfv_testapi/ui/root.py
+++ b/utils/test/testapi/opnfv_testapi/ui/root.py
@@ -1,10 +1,10 @@
from opnfv_testapi.resources.handlers import GenericApiHandler
-from opnfv_testapi.common import config
+from opnfv_testapi.common.config import CONF
class RootHandler(GenericApiHandler):
def get_template_path(self):
- return config.Config().static_path
+ return CONF.static_path
def get(self):
self.render('testapi-ui/index.html')
diff --git a/utils/test/testapi/requirements.txt b/utils/test/testapi/requirements.txt
index 955ffc853..4b6f75c10 100644
--- a/utils/test/testapi/requirements.txt
+++ b/utils/test/testapi/requirements.txt
@@ -2,9 +2,9 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
-pbr>=1.6
-setuptools>=16.0
-tornado>=3.1,<=4.3
+pbr>=2.0.0,!=2.1.0 # Apache-2.0
+setuptools>=16.0,!=24.0.0,!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2 # PSF/ZPL
+tornado>=3.1,<=4.3 # Apache-2.0
epydoc>=0.3.1
-six>=1.9.0
-motor
+six>=1.9.0 # MIT
+motor # Apache-2.0
diff --git a/utils/test/testapi/run_test.sh b/utils/test/testapi/run_test.sh
deleted file mode 100755
index 1e05dd6ba..000000000
--- a/utils/test/testapi/run_test.sh
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/bash
-
-set -o errexit
-
-# Get script directory
-SCRIPTDIR=`dirname $0`
-
-echo "Running unit tests..."
-
-# Creating virtual environment
-if [ ! -z $VIRTUAL_ENV ]; then
- venv=$VIRTUAL_ENV
-else
- venv=$SCRIPTDIR/.venv
- virtualenv $venv
-fi
-source $venv/bin/activate
-
-# Install requirements
-pip install -r $SCRIPTDIR/requirements.txt
-pip install -r $SCRIPTDIR/test-requirements.txt
-
-find . -type f -name "*.pyc" -delete
-
-nosetests --with-xunit \
- --with-coverage \
- --cover-erase \
- --cover-package=$SCRIPTDIR/opnfv_testapi/cmd \
- --cover-package=$SCRIPTDIR/opnfv_testapi/common \
- --cover-package=$SCRIPTDIR/opnfv_testapi/resources \
- --cover-package=$SCRIPTDIR/opnfv_testapi/router \
- --cover-xml \
- --cover-html \
- $SCRIPTDIR/opnfv_testapi/tests
-
-exit_code=$?
-
-deactivate
-
-exit $exit_code
diff --git a/utils/test/testapi/setup.py b/utils/test/testapi/setup.py
index 15dda961f..dd52373fd 100644
--- a/utils/test/testapi/setup.py
+++ b/utils/test/testapi/setup.py
@@ -1,9 +1,20 @@
-import setuptools
+import os
+import subprocess
+import setuptools
__author__ = 'serena'
+try:
+ import multiprocessing # noqa
+except ImportError:
+ pass
+
+dirpath = os.path.dirname(os.path.abspath(__file__))
+subprocess.call(['ln', '-s',
+ '{}/3rd_party/static'.format(dirpath),
+ '{}/opnfv_testapi/static'.format(dirpath)])
setuptools.setup(
- setup_requires=['pbr>=1.8'],
+ setup_requires=['pbr==2.0.0'],
pbr=True)
diff --git a/utils/test/testapi/test-requirements.txt b/utils/test/testapi/test-requirements.txt
index 645687b14..233f4652b 100644
--- a/utils/test/testapi/test-requirements.txt
+++ b/utils/test/testapi/test-requirements.txt
@@ -2,7 +2,9 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
-mock
-pytest
-coverage
-nose>=1.3.1
+coverage>=4.0,!=4.4 # Apache-2.0
+mock>=2.0 # BSD
+nose # LGPL
+pytest # MIT
+pytest-cov # MIT
+pytest-mock # MIT
diff --git a/utils/test/testapi/tox.ini b/utils/test/testapi/tox.ini
index 81c9dfab1..d300f1a61 100644
--- a/utils/test/testapi/tox.ini
+++ b/utils/test/testapi/tox.ini
@@ -4,7 +4,7 @@
# and then run "tox" from this directory.
[tox]
-envlist = py27,pep8
+envlist = pep8,py27
skipsdist = True
sitepackages = True
@@ -16,9 +16,11 @@ deps =
-rtest-requirements.txt
commands=
py.test \
- --basetemp={envtmpdir} \
- --cov \
- {posargs}
+ --basetemp={envtmpdir} \
+ --cov \
+ --cov-report term-missing \
+ --cov-report xml \
+ {posargs}
setenv=
HOME = {envtmpdir}
PYTHONPATH = {toxinidir}
diff --git a/utils/test/testapi/update/templates/backup_mongodb.py b/utils/test/testapi/update/templates/backup_mongodb.py
index 7e0dd5545..9c2437764 100644
--- a/utils/test/testapi/update/templates/backup_mongodb.py
+++ b/utils/test/testapi/update/templates/backup_mongodb.py
@@ -40,5 +40,6 @@ def backup(args):
cmd = ['mongodump', '-o', '%s' % out]
execute(cmd, args)
+
if __name__ == '__main__':
main(backup, parser)
diff --git a/utils/test/testapi/update/templates/update_mongodb.py b/utils/test/testapi/update/templates/update_mongodb.py
index ba4334aa3..f75959281 100644
--- a/utils/test/testapi/update/templates/update_mongodb.py
+++ b/utils/test/testapi/update/templates/update_mongodb.py
@@ -85,5 +85,6 @@ def update(args):
rename_fields(fields_old2New)
rename_collections(collections_old2New)
+
if __name__ == '__main__':
main(update, parser)
diff --git a/utils/upload-artifact.sh b/utils/upload-artifact.sh
new file mode 100644
index 000000000..b66cdb7e1
--- /dev/null
+++ b/utils/upload-artifact.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2016 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
+##############################################################################
+set -e
+set -o pipefail
+
+export PATH=$PATH:/usr/local/bin/
+
+# 2 paramters
+# - $1: the source directory where the files to be uploaded are located
+# - $2: the target on artifact http://artifact.opnfv.org/<project>/$2
+# if not set, default value is <project>/docs
+project=$PROJECT
+if [ -z "$2" ]
+ then
+ artifact_dir="$project/docs"
+ else
+ artifact_dir="$project/$2"
+fi
+DIRECTORY="$1"
+
+
+# check that the API doc directory does exist before pushing it to artifact
+if [ ! -d "$DIRECTORY" ]; then
+ echo "Directory to be uploaded "$DIRECTORY" does not exist"
+ exit 1
+fi
+set +e
+gsutil&>/dev/null
+if [ $? != 0 ]; then
+ echo "Not possible to push results to artifact: gsutil not installed"
+ exit 1
+else
+ gsutil ls gs://artifacts.opnfv.org/"$project"/ &>/dev/null
+ if [ $? != 0 ]; then
+ echo "Not possible to push results to artifact: gsutil not installed."
+ exit 1
+ else
+ echo "Uploading file(s) to artifact $artifact_dir"
+ gsutil -m cp -r "$DIRECTORY"/* gs://artifacts.opnfv.org/"$artifact_dir"/ >/dev/null 2>&1
+ fi
+fi