delete useless trust_indicator in result model 23/53823/2
authorSerenaFeng <feng.xiaowei@zte.com.cn>
Thu, 15 Mar 2018 02:14:13 +0000 (10:14 +0800)
committerSerenaFeng <feng.xiaowei@zte.com.cn>
Thu, 15 Mar 2018 02:25:47 +0000 (10:25 +0800)
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 <feng.xiaowei@zte.com.cn>
testapi/opnfv_testapi/handlers/result_handlers.py
testapi/opnfv_testapi/models/result_models.py
testapi/opnfv_testapi/tests/UI/e2e/resultsControllerSpec.js
testapi/opnfv_testapi/tests/unit/handlers/test_result.py
testapi/opnfv_testapi/tests/unit/templates/test_result.json
testapi/opnfv_testapi/ui/components/results/result/result.html
testapi/opnfv_testapi/ui/components/results/result/resultController.js

index 74acb2e..edcac6e 100644 (file)
@@ -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)
index f8379d8..602318a 100644 (file)
@@ -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
index 132f77d..d091a38 100644 (file)
@@ -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": "",
index 892256a..6435367 100644 (file)
@@ -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)
index b7cb910..8f1d5fa 100644 (file)
@@ -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",
index b435dce..52d794e 100644 (file)
                     <td class="podsTableTd">Stop&nbsp;Date&nbsp;:</td>
                     <td width="90%"  class="podsTableLeftTd">{{ctrl.data.stop_date}}</td>
                 </tr>
-                <tr style="padding:9px">
-                    <td class="podsTableTd">Trust&nbsp;Indicator&nbsp;:</td>
-                    <td width="90%"  class="podsTableLeftTd">
-                        <a ng-click="ctrl.showTrustIndicator()">
-                            <p ng-if="ctrl.trust_indicator">Hide</p>
-                            <p ng-if="!ctrl.trust_indicator">Show</p>
-                        </a>
-                        <table class="table" ng-class="{'hidden' : !ctrl.trust_indicator}" style="margin:10px">
-                            <tbody>
-                                <tr style="padding:9px"></tr>
-                                <tr style="padding:9px" >
-                                    <td class="podsTableTd">Current&nbsp;:</td>
-                                    <td width="90%"  class="podsTableLeftTd">{{ctrl.data.trust_indicator.current}}</td>
-                                </tr>
-                                <tr style="padding:9px" >
-                                    <td class="podsTableTd">Histories&nbsp;:</td>
-                                    <td width="90%"  class="podsTableLeftTd">{{ctrl.data.trust_indicator.histories}}</td>
-                                </tr>
-                            </tbody>
-                        </table>
-                    </td>
-                </tr>
                 <tr style="padding:9px">
                     <td class="podsTableTd">Details&nbsp;:</td>
                     <td width="90%" class="podsTableLeftTd">
index 028e5d8..cb5dd28 100644 (file)
                 });
         }
 
-        function showTrustIndicator(){
-            if(ctrl.trust_indicator){
-                ctrl.trust_indicator = false
-            }else{
-                ctrl.trust_indicator = true
-            }
-        }
-
         function showDetails(){
             if(ctrl.details){
                 ctrl.details = false