summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2018-02-26 10:11:50 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2018-02-26 10:26:11 +0800
commitc3e868997d30bb907aca48abdb99b2ada2f70c1c (patch)
tree645e66031170cd1034f823f1a06f881b1d1fdc74 /testapi/opnfv_testapi
parente2bbce72ca32d3bfdde04149b9d702b0a82d3279 (diff)
remove deprecated upload-related codes
upload result file is used by dovetail, since now dovetail has leveraged its own cvp repo, and TestAPI is mostly and should be used as a realtime results collecting, no need to keep such function. Change-Id: Ibd56035d5d63020e224a382c8040705f63b63386 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'testapi/opnfv_testapi')
-rw-r--r--testapi/opnfv_testapi/common/constants.py1
-rw-r--r--testapi/opnfv_testapi/common/message.py4
-rw-r--r--testapi/opnfv_testapi/handlers/result_handlers.py50
-rw-r--r--testapi/opnfv_testapi/models/result_models.py4
-rw-r--r--testapi/opnfv_testapi/router/url_mappings.py1
-rw-r--r--testapi/opnfv_testapi/tests/unit/executor.py14
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/test_result.py39
7 files changed, 2 insertions, 111 deletions
diff --git a/testapi/opnfv_testapi/common/constants.py b/testapi/opnfv_testapi/common/constants.py
index 70c9223..c7f82d9 100644
--- a/testapi/opnfv_testapi/common/constants.py
+++ b/testapi/opnfv_testapi/common/constants.py
@@ -1,4 +1,3 @@
TESTAPI_ID = 'testapi_id'
CSRF_TOKEN = 'csrf_token'
-ROLE = 'role'
TESTAPI_USERS = ['opnfv-testapi-users']
diff --git a/testapi/opnfv_testapi/common/message.py b/testapi/opnfv_testapi/common/message.py
index b92b7f0..c82d5dc 100644
--- a/testapi/opnfv_testapi/common/message.py
+++ b/testapi/opnfv_testapi/common/message.py
@@ -10,10 +10,6 @@ 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/testapi/opnfv_testapi/handlers/result_handlers.py b/testapi/opnfv_testapi/handlers/result_handlers.py
index 2d4280f..74acb2e 100644
--- a/testapi/opnfv_testapi/handlers/result_handlers.py
+++ b/testapi/opnfv_testapi/handlers/result_handlers.py
@@ -8,12 +8,9 @@
##############################################################################
from datetime import datetime
from datetime import timedelta
-import json
-import logging
from bson import objectid
-from opnfv_testapi.common import constants
from opnfv_testapi.common import message
from opnfv_testapi.common import raises
from opnfv_testapi.common.config import CONF
@@ -41,7 +38,6 @@ class GenericResultHandler(base_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':
@@ -60,13 +56,6 @@ class GenericResultHandler(base_handlers.GenericApiHandler):
date_range.update({'$lt': str(v)})
elif 'build_id' in k:
query[k] = self.get_int(k, v)
- elif k == 'signed':
- username = self.get_secure_cookie(constants.TESTAPI_ID)
- role = self.get_secure_cookie(constants.ROLE)
- if role:
- del query['public']
- if role != "reviewer":
- query['user'] = username
elif k not in ['last', 'page', 'descend']:
query[k] = v
if date_range:
@@ -121,10 +110,9 @@ 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&signed
+ &pod=pod_name&period=15
@return 200: all test results consist with query,
empty list if no result is found
@rtype: L{TestResults}
@@ -184,10 +172,6 @@ class ResultsCLHandler(GenericResultHandler):
@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
@@ -231,38 +215,8 @@ class ResultsCLHandler(GenericResultHandler):
values_check=values_check)
-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')
- if not self.request.files:
- raises.NotFound(message.key_error('file'))
- 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(constants.TESTAPI_ID)
- 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/testapi/opnfv_testapi/models/result_models.py b/testapi/opnfv_testapi/models/result_models.py
index 1dbe729..f8379d8 100644
--- a/testapi/opnfv_testapi/models/result_models.py
+++ b/testapi/opnfv_testapi/models/result_models.py
@@ -62,8 +62,6 @@ class ResultCreateRequest(base_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
@@ -76,8 +74,6 @@ class ResultCreateRequest(base_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)
def __eq__(self, other):
diff --git a/testapi/opnfv_testapi/router/url_mappings.py b/testapi/opnfv_testapi/router/url_mappings.py
index b9dd231..8f01a66 100644
--- a/testapi/opnfv_testapi/router/url_mappings.py
+++ b/testapi/opnfv_testapi/router/url_mappings.py
@@ -49,7 +49,6 @@ 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),
(r"/api/v1/deployresults", deploy_handlers.DeployResultsHandler),
(r"/api/v1/deployresults/([^/]+)", deploy_handlers.DeployResultHandler),
diff --git a/testapi/opnfv_testapi/tests/unit/executor.py b/testapi/opnfv_testapi/tests/unit/executor.py
index 743c076..d08782c 100644
--- a/testapi/opnfv_testapi/tests/unit/executor.py
+++ b/testapi/opnfv_testapi/tests/unit/executor.py
@@ -43,20 +43,6 @@ def mock_valid_lfid():
return _mock_valid_lfid
-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/testapi/opnfv_testapi/tests/unit/handlers/test_result.py b/testapi/opnfv_testapi/tests/unit/handlers/test_result.py
index f1f055e..c07d792 100644
--- a/testapi/opnfv_testapi/tests/unit/handlers/test_result.py
+++ b/testapi/opnfv_testapi/tests/unit/handlers/test_result.py
@@ -10,7 +10,6 @@ import copy
from datetime import datetime
from datetime import timedelta
import httplib
-import json
import urllib
from opnfv_testapi.common import message
@@ -46,22 +45,6 @@ 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())
@@ -197,16 +180,6 @@ class TestResultGet(TestResultBase):
def test_queryLast(self):
return self._set_query(last=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',
@@ -266,18 +239,6 @@ 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, **kwargs):
def get_value(arg):
if arg in ['pod', 'project', 'case']: