aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Xu <xudan16@huawei.com>2019-09-02 01:58:14 +0000
committerGerrit Code Review <gerrit@opnfv.org>2019-09-02 01:58:14 +0000
commit762021d415b95479bce8a7d65f1f31b0dcc409fd (patch)
treedd033d757e94172721083c4a7245ace6f649969e
parent6f69c36f312efe9c2e2367aafce451d1e5d3152a (diff)
parenta12fc6f6871c751fade287c2cc2d763b8193cf37 (diff)
Merge "API validation only for NFVI and gets from results.json"
-rw-r--r--3rd_party/static/onap-ui/components/results-report/resultsReport.html2
-rw-r--r--opnfv_testapi/resources/test_handlers.py49
2 files changed, 35 insertions, 16 deletions
diff --git a/3rd_party/static/onap-ui/components/results-report/resultsReport.html b/3rd_party/static/onap-ui/components/results-report/resultsReport.html
index e66b293..236ebfd 100644
--- a/3rd_party/static/onap-ui/components/results-report/resultsReport.html
+++ b/3rd_party/static/onap-ui/components/results-report/resultsReport.html
@@ -24,8 +24,6 @@
<strong>Total: {{ctrl.statistics.total}}, Pass: {{ ctrl.statistics.pass}}, Rate: {{ ctrl.statistics.pass / ctrl.statistics.total * 100 | number:2 }}%</strong><br>
<strong>Mandatory Total: {{ctrl.statistics.mandatory.total}}, Pass: {{ ctrl.statistics.mandatory.pass }}, Rate: {{ ctrl.statistics.mandatory.pass / ctrl.statistics.mandatory.total * 100 | number:2 }}%</strong><br>
<strong>Optional Total: {{ctrl.statistics.optional.total}}, Pass: {{ ctrl.statistics.optional.pass }}, Rate: {{ ctrl.statistics.optional.pass / ctrl.statistics.optional.total * 100 | number:2 }}%</strong><br>
- <hr>
- <strong>{{ ctrl.validation }}</strong><br>
<div>
<hr>
diff --git a/opnfv_testapi/resources/test_handlers.py b/opnfv_testapi/resources/test_handlers.py
index 7c5078a..babce7d 100644
--- a/opnfv_testapi/resources/test_handlers.py
+++ b/opnfv_testapi/resources/test_handlers.py
@@ -23,6 +23,7 @@ from opnfv_testapi.tornado_swagger import swagger
from opnfv_testapi.ui.auth import constants as auth_const
from opnfv_testapi.db import api as dbapi
+DOVETAIL_RESULTS_PATH = '/home/testapi/logs/{}/results/results.json'
DOVETAIL_LOG_PATH = '/home/testapi/logs/{}/results/dovetail.log'
@@ -147,26 +148,46 @@ class TestsGURHandler(GenericTestHandler):
if not data:
raises.NotFound(message.not_found(self.table, query))
- validation = yield self._check_api_response_validation(data['id'])
-
- data.update({'validation': validation})
+ # only do this when it's nfvi not vnf
+ if 'is_onap' not in data.keys() or data['is_onap'] != 'true':
+ validation = yield self._check_api_response_validation(data['id'])
+ data.update({'validation': validation})
self.finish_request(self.format_data(data))
@gen.coroutine
def _check_api_response_validation(self, test_id):
+ results_path = DOVETAIL_RESULTS_PATH.format(test_id)
log_path = DOVETAIL_LOG_PATH.format(test_id)
- if not os.path.exists(log_path):
- raises.Forbidden('dovetail.log not found, please check')
-
- with open(log_path) as f:
- log_content = f.read()
-
- warning_keyword = 'Strict API response validation DISABLED'
- if warning_keyword in log_content:
- raise gen.Return('API response validation disabled')
- else:
- raise gen.Return('API response validation enabled')
+ res = None
+
+ # For release after 2018.09
+ # Dovetail adds 'validation' directly into results.json
+ if os.path.exists(results_path):
+ with open(results_path) as f:
+ try:
+ data = json.load(f)
+ if data['validation'] == 'enabled':
+ res = 'API response validation enabled'
+ else:
+ res = 'API response validation disabled'
+ except Exception:
+ pass
+ if res:
+ raise gen.Return(res)
+
+ # For 2018.01 and 2018.09
+ # Need to check dovetail.log for this info
+ if os.path.exists(log_path):
+ with open(log_path) as f:
+ log_content = f.read()
+ warning_keyword = 'Strict API response validation DISABLED'
+ if warning_keyword in log_content:
+ raise gen.Return('API response validation disabled')
+ else:
+ raise gen.Return('API response validation enabled')
+
+ raises.Forbidden('neither results.json nor dovetail.log are found')
@swagger.operation(nickname="deleteTestById")
@gen.coroutine