aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2019-08-21 06:13:05 -0400
committerxudan <xudan16@huawei.com>2019-08-21 22:26:48 -0400
commita12fc6f6871c751fade287c2cc2d763b8193cf37 (patch)
treeed8409d55791955cbcf150971b9123c347acc5e0
parent590ffcdc7732b700f054fb45aad262a4b95f8f3e (diff)
API validation only for NFVI and gets from results.json
Change-Id: Ia84d67098d7fc2f5e8da88900a2a8846f718f085 Signed-off-by: xudan <xudan16@huawei.com>
-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