summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cvp/3rd_party/static/testapi-ui/components/results-report/resultsReport.html2
-rw-r--r--cvp/3rd_party/static/testapi-ui/components/results-report/resultsReportController.js2
-rw-r--r--cvp/opnfv_testapi/resources/test_handlers.py32
3 files changed, 35 insertions, 1 deletions
diff --git a/cvp/3rd_party/static/testapi-ui/components/results-report/resultsReport.html b/cvp/3rd_party/static/testapi-ui/components/results-report/resultsReport.html
index 16cfa65d..bc049f31 100644
--- a/cvp/3rd_party/static/testapi-ui/components/results-report/resultsReport.html
+++ b/cvp/3rd_party/static/testapi-ui/components/results-report/resultsReport.html
@@ -14,6 +14,8 @@
<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/cvp/3rd_party/static/testapi-ui/components/results-report/resultsReportController.js b/cvp/3rd_party/static/testapi-ui/components/results-report/resultsReportController.js
index b0061f61..65ce151d 100644
--- a/cvp/3rd_party/static/testapi-ui/components/results-report/resultsReportController.js
+++ b/cvp/3rd_party/static/testapi-ui/components/results-report/resultsReportController.js
@@ -52,6 +52,7 @@
/** The testID extracted from the URL route. */
ctrl.testId = $stateParams.testID;
ctrl.innerId = $stateParams.innerID;
+ ctrl.validation = '';
/** The HTML template that all accordian groups will use. */
ctrl.detailsTemplate = 'testapi-ui/components/results-report/partials/' +
@@ -158,6 +159,7 @@
function generate_format_data() {
var test_url = testapiApiUrl + '/tests/' + ctrl.innerId;
$http.get(test_url).then(function(test_resp){
+ ctrl.validation = test_resp.data.validation;
angular.forEach(test_resp.data.results, function(result, index){
var result_url = testapiApiUrl + '/results/' + result;
$http.get(result_url).then(function(result_resp){
diff --git a/cvp/opnfv_testapi/resources/test_handlers.py b/cvp/opnfv_testapi/resources/test_handlers.py
index 77656ae9..9adc0d82 100644
--- a/cvp/opnfv_testapi/resources/test_handlers.py
+++ b/cvp/opnfv_testapi/resources/test_handlers.py
@@ -7,6 +7,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import logging
+import os
import json
from tornado import web
@@ -15,12 +16,15 @@ 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 test_models
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_LOG_PATH = '/home/testapi/logs/{}/results/dovetail.log'
+
class GenericTestHandler(handlers.GenericApiHandler):
def __init__(self, application, request, **kwargs):
@@ -109,10 +113,36 @@ class TestsCLHandler(GenericTestHandler):
class TestsGURHandler(GenericTestHandler):
@swagger.operation(nickname="getTestById")
+ @web.asynchronous
+ @gen.coroutine
def get(self, test_id):
query = dict()
query["_id"] = objectid.ObjectId(test_id)
- self._get_one(query=query)
+
+ data = yield dbapi.db_find_one(self.table, query)
+ if not data:
+ raises.NotFound(message.not_found(self.table, query))
+
+ 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):
+ 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 disable')
+ else:
+ raise gen.Return('API response validation enable')
@swagger.operation(nickname="deleteTestById")
def delete(self, test_id):