From 46126a761681cf5ae4bd98f20916048db3cd278e Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Thu, 15 Mar 2018 10:14:13 +0800 Subject: delete useless trust_indicator in result model this field aims to mark testcase status in CI evolution, it is a little bit abused, since results is used to save real-time testing result, when CI evolution is talked about again, another collection(let's say testcase_status) will be developed. Change-Id: Id797591a419b097899362ffa82010bff2e6d6cd3 Signed-off-by: SerenaFeng --- testapi/opnfv_testapi/handlers/result_handlers.py | 24 -------- testapi/opnfv_testapi/models/result_models.py | 67 ++-------------------- .../tests/UI/e2e/resultsControllerSpec.js | 3 - .../tests/unit/handlers/test_result.py | 41 ------------- .../tests/unit/templates/test_result.json | 4 -- .../ui/components/results/result/result.html | 22 ------- .../components/results/result/resultController.js | 8 --- 7 files changed, 4 insertions(+), 165 deletions(-) (limited to 'testapi/opnfv_testapi') diff --git a/testapi/opnfv_testapi/handlers/result_handlers.py b/testapi/opnfv_testapi/handlers/result_handlers.py index 74acb2e..edcac6e 100644 --- a/testapi/opnfv_testapi/handlers/result_handlers.py +++ b/testapi/opnfv_testapi/handlers/result_handlers.py @@ -48,8 +48,6 @@ class GenericResultHandler(base_handlers.GenericApiHandler): period = datetime.now() - timedelta(days=v) obj = {"$gte": str(period)} query['start_date'] = obj - elif k == 'trust_indicator': - query[k + '.current'] = float(v) elif k == 'from': date_range.update({'$gte': str(v)}) elif k == 'to': @@ -108,8 +106,6 @@ class ResultsCLHandler(GenericResultHandler): - to : ending time in 2016-01-01 or 2016-01-01 00:01:23 - scenario : the test scenario (previously version) - 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 GET /results/project=functest&case=vPing&version=Arno-R1 \ &pod=pod_name&period=15 @@ -168,10 +164,6 @@ class ResultsCLHandler(GenericResultHandler): @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 descend: true, newest2oldest; false, oldest2newest @type descend: L{string} @in descend: query @@ -228,19 +220,3 @@ class ResultsGURHandler(GenericResultHandler): query = dict() query["_id"] = objectid.ObjectId(result_id) self._get_one(query=query) - - @swagger.operation(nickname="updateTestResultById") - def put(self, result_id): - """ - @description: update a single result by _id - @param body: fields to be updated - @type body: L{ResultUpdateRequest} - @in body: body - @rtype: L{Result} - @return 200: update success - @raise 404: result not exist - @raise 403: nothing to update - """ - query = {'_id': objectid.ObjectId(result_id)} - db_keys = [] - self._update(query=query, db_keys=db_keys) diff --git a/testapi/opnfv_testapi/models/result_models.py b/testapi/opnfv_testapi/models/result_models.py index f8379d8..602318a 100644 --- a/testapi/opnfv_testapi/models/result_models.py +++ b/testapi/opnfv_testapi/models/result_models.py @@ -10,46 +10,8 @@ from opnfv_testapi.models import base_models from opnfv_testapi.tornado_swagger import swagger -@swagger.model() -class TIHistory(base_models.ModelBase): - """ - @ptype step: L{float} - """ - def __init__(self, date=None, step=0): - self.date = date - self.step = step - - -@swagger.model() -class TI(base_models.ModelBase): - """ - @property histories: trust_indicator update histories - @ptype histories: C{list} of L{TIHistory} - @ptype current: L{float} - """ - def __init__(self, current=0): - self.current = current - self.histories = list() - - def __eq__(self, other): - return (self.current == other.current and self._histories_eq(other)) - - def _histories_eq(self, other): - hs_equal = all(self.histories[i] == other.histories[i] - for i in range(len(self.histories))) - return len(self.histories) == len(other.histories) and hs_equal - - @staticmethod - def attr_parser(): - return {'histories': TIHistory} - - @swagger.model() class ResultCreateRequest(base_models.ModelBase): - """ - @property trust_indicator: - @ptype trust_indicator: L{TI} - """ def __init__(self, pod_name=None, project_name=None, @@ -61,8 +23,7 @@ class ResultCreateRequest(base_models.ModelBase): details=None, build_tag=None, scenario=None, - criteria=None, - trust_indicator=None): + criteria=None): self.pod_name = pod_name self.project_name = project_name self.case_name = case_name @@ -74,35 +35,15 @@ class ResultCreateRequest(base_models.ModelBase): self.build_tag = build_tag self.scenario = scenario self.criteria = criteria - self.trust_indicator = trust_indicator if trust_indicator else TI(0) def __eq__(self, other): - simple_equal = all(getattr(self, k) == getattr(other, k) - for k in self.format().keys() - if k not in ['_id', 'trust_indicator']) - return simple_equal and self.trust_indicator == other.trust_indicator - - @staticmethod - def attr_parser(): - return {'trust_indicator': TI} - - -@swagger.model() -class ResultUpdateRequest(base_models.ModelBase): - """ - @property trust_indicator: - @ptype trust_indicator: L{TI} - """ - def __init__(self, trust_indicator=None): - self.trust_indicator = trust_indicator + return all(getattr(self, k) == getattr(other, k) + for k in self.format().keys() + if k not in ['_id']) @swagger.model() class TestResult(ResultCreateRequest): - """ - @property trust_indicator: used for long duration test case - @ptype trust_indicator: L{TI} - """ def __init__(self, _id=None, **kwargs): super(TestResult, self).__init__(**kwargs) self._id = _id diff --git a/testapi/opnfv_testapi/tests/UI/e2e/resultsControllerSpec.js b/testapi/opnfv_testapi/tests/UI/e2e/resultsControllerSpec.js index 132f77d..d091a38 100644 --- a/testapi/opnfv_testapi/tests/UI/e2e/resultsControllerSpec.js +++ b/testapi/opnfv_testapi/tests/UI/e2e/resultsControllerSpec.js @@ -30,7 +30,6 @@ describe('testing the result page for anonymous user', function () { "user": null, "installer": "fuel", "scenario": "test-scenario", - "trust_indicator": null, "public": "true", "version": "euphrates", "details": "", @@ -107,7 +106,6 @@ describe('testing the result page for anonymous user', function () { "user": null, "installer": "fuel", "scenario": "test-scenario", - "trust_indicator": null, "public": "true", "version": "euphrates", "details": "", @@ -254,7 +252,6 @@ describe('testing the result page for user', function () { "user": null, "installer": "fuel", "scenario": "test-scenario", - "trust_indicator": null, "public": "true", "version": "euphrates", "details": "", diff --git a/testapi/opnfv_testapi/tests/unit/handlers/test_result.py b/testapi/opnfv_testapi/tests/unit/handlers/test_result.py index 892256a..6435367 100644 --- a/testapi/opnfv_testapi/tests/unit/handlers/test_result.py +++ b/testapi/opnfv_testapi/tests/unit/handlers/test_result.py @@ -105,18 +105,6 @@ class TestResultCreate(TestResultBase): req.details = {'1.name': 'dot_name'} return req - @executor.create(httplib.OK, '_assert_no_ti') - def test_no_ti(self): - req = copy.deepcopy(self.req_d) - req.trust_indicator = rm.TI(0) - self.actual_req = req - return req - - def _assert_no_ti(self, body): - _id = body.href.split('/')[-1] - code, body = self.get(_id) - self.assert_res(body, self.actual_req) - class TestResultGet(TestResultBase): def setUp(self): @@ -157,10 +145,6 @@ class TestResultGet(TestResultBase): def test_queryScenario(self): return self._set_query('scenario') - @executor.query(httplib.OK, '_query_success', 3) - def test_queryTrustIndicator(self): - return self._set_query('trust_indicator') - @executor.query(httplib.OK, '_query_success', 3) def test_queryCriteria(self): return self._set_query('criteria') @@ -190,7 +174,6 @@ class TestResultGet(TestResultBase): 'installer', 'build_tag', 'scenario', - 'trust_indicator', 'criteria', period=5) @@ -202,7 +185,6 @@ class TestResultGet(TestResultBase): 'installer', 'build_tag', 'scenario', - 'trust_indicator', 'criteria', pod='notExistPod', period=1) @@ -244,8 +226,6 @@ class TestResultGet(TestResultBase): def get_value(arg): if arg in ['pod', 'project', 'case']: return getattr(self.req_d, arg + '_name') - elif arg == 'trust_indicator': - return self.req_d.trust_indicator.current else: return getattr(self.req_d, arg) @@ -255,24 +235,3 @@ class TestResultGet(TestResultBase): for k, v in kwargs.iteritems(): query.append((k, v)) return urllib.urlencode(query) - - -class TestResultUpdate(TestResultBase): - def setUp(self): - super(TestResultUpdate, self).setUp() - self.req_d_id = self._create_d() - - @executor.update(httplib.OK, '_assert_update_ti') - def test_success(self): - update_date = str(datetime.now() + timedelta(days=1)) - update_step = -0.05 - self.after_update = copy.deepcopy(self.req_d) - self.after_update.trust_indicator.current += update_step - self.after_update.trust_indicator.histories.append( - rm.TIHistory(update_date, update_step)) - update = rm.ResultUpdateRequest( - trust_indicator=self.after_update.trust_indicator) - return update, self.req_d_id - - def _assert_update_ti(self, request, body): - self.assert_res(body, self.after_update) diff --git a/testapi/opnfv_testapi/tests/unit/templates/test_result.json b/testapi/opnfv_testapi/tests/unit/templates/test_result.json index b7cb910..8f1d5fa 100644 --- a/testapi/opnfv_testapi/tests/unit/templates/test_result.json +++ b/testapi/opnfv_testapi/tests/unit/templates/test_result.json @@ -1,10 +1,6 @@ { "project_name": "functest", "scenario": "odl-l2", - "trust_indicator": { - "current": 0.7, - "histories": [] - }, "case_name": "vPing", "build_tag": "v3.0", "public": "true", diff --git a/testapi/opnfv_testapi/ui/components/results/result/result.html b/testapi/opnfv_testapi/ui/components/results/result/result.html index b435dce..52d794e 100644 --- a/testapi/opnfv_testapi/ui/components/results/result/result.html +++ b/testapi/opnfv_testapi/ui/components/results/result/result.html @@ -47,28 +47,6 @@ Stop Date : {{ctrl.data.stop_date}} - - Trust Indicator : - - -

Hide

-

Show

-
- - - - - - - - - - - - -
Current :{{ctrl.data.trust_indicator.current}}
Histories :{{ctrl.data.trust_indicator.histories}}
- - Details : diff --git a/testapi/opnfv_testapi/ui/components/results/result/resultController.js b/testapi/opnfv_testapi/ui/components/results/result/resultController.js index 028e5d8..cb5dd28 100644 --- a/testapi/opnfv_testapi/ui/components/results/result/resultController.js +++ b/testapi/opnfv_testapi/ui/components/results/result/resultController.js @@ -54,14 +54,6 @@ }); } - function showTrustIndicator(){ - if(ctrl.trust_indicator){ - ctrl.trust_indicator = false - }else{ - ctrl.trust_indicator = true - } - } - function showDetails(){ if(ctrl.details){ ctrl.details = false -- cgit 1.2.3-korg