def _add_message(self, test, err=None, status=None):
        data = {'status': status, 'time_taken': self.taken}
        data['title'], data['description'], data['duration'] = \
            nose_utils.get_description(test)
        if err:
            exc_type, exc_value, exc_traceback = err
            data['step'], data['message'] = None, u''
            if not status == 'error':
                data['step'], data['message'] = \
                    nose_utils.format_failure_message(exc_value)
            data['traceback'] = u''
        else:
            data['step'], data['message'] = None, u''
            data['traceback'] = u''

        session = engine.get_session()

        with session.begin(subtransactions=True):

            if isinstance(test, ContextSuite):
                for sub_test in test._tests:
                    data['title'], data['description'], data['duration'] = \
                        nose_utils.get_description(test)
                    models.Test.add_result(session, self.test_run_id,
                                           sub_test.id(), data)
            else:
                models.Test.add_result(session, self.test_run_id, test.id(),
                                       data)
    def _add_message(
            self, test, err=None, status=None):
        data = {
            'status': status,
            'time_taken': self.taken
        }
        data['title'], data['description'], data['duration'] = \
            nose_utils.get_description(test)
        if err:
            exc_type, exc_value, exc_traceback = err
            data['step'], data['message'] = None, u''
            if not status == 'error':
                data['step'], data['message'] = \
                    nose_utils.format_failure_message(exc_value)
            data['traceback'] = u''
        else:
            data['step'], data['message'] = None, u''
            data['traceback'] = u''

        session = engine.get_session()

        with session.begin(subtransactions=True):

            if isinstance(test, ContextSuite):
                for sub_test in test._tests:
                    data['title'], data['description'], data['duration'] = \
                        nose_utils.get_description(test)
                    models.Test.add_result(
                        session, self.test_run_id, sub_test.id(), data)
            else:
                models.Test.add_result(
                    session, self.test_run_id, test.id(), data)
Пример #3
0
    def addSuccess(self, test):
        test_id = test.id()
        for test_set_id in self.test_sets.keys():
            if self.test_belongs_to_testset(test_id, test_set_id):
                test_kwargs = {
                    "title": "",
                    "description": "",
                    "duration": "",
                    "deployment_tags": [],
                    "available_since_release": "",
                    "test_set_id": test_set_id,
                    "name": test_id,
                }

                test_kwargs.update(nose_utils.get_description(test))

                try:
                    test_obj = models.Test(**test_kwargs)
                    self.session.merge(test_obj)

                    # flush tests data into db
                    self.session.commit()
                except Exception as e:
                    LOG.error(
                        ('An error has occured while '
                         'processing data entity for '
                         'test with name %s. Error message: %s'),
                        test_id,
                        e.message
                    )
                LOG.info('%s added for %s', test_id, test_set_id)
Пример #4
0
    def addSuccess(self, test):
        test_id = test.id()
        for test_set_id in self.test_sets.keys():
            if test_set_id in test_id:
                with self.session.begin(subtransactions=True):

                    data = dict()

                    (data['title'], data['description'],
                     data['duration'], data['deployment_tags']) = \
                        nose_utils.get_description(test)

                    data.update(
                        {
                            'test_set_id': test_set_id,
                            'name': test_id
                        }
                    )

                    try:
                        test_obj = models.Test(**data)
                        self.session.merge(test_obj)
                    except Exception as e:
                        LOG.error(
                            ('An error has occured while '
                             'processing data entity for '
                             'test with name %s. Error message: %s'),
                            test_id,
                            e.message
                        )
                    LOG.info('%s added for %s', test_id, test_set_id)
Пример #5
0
    def _add_test_results(self, test, data):
        test_id = test.id()

        models.Test.add_result(self.session, self.test_run_id, test_id, data)
        if data['status'] != 'running':
            test_name = nose_utils.get_description(test)[0]
            self.results_log.log_results(
                test_id,
                test_name=test_name,
                status=data['status'],
                message=data['message'],
                traceback=data['traceback'],
            )
Пример #6
0
    def addSuccess(self, test):
        test_id = test.id()
        for test_set_id in self.test_sets.keys():
            if test_set_id in test_id:
                with self.session.begin(subtransactions=True):

                    data = dict()

                    (data['title'], data['description'],
                     data['duration'], data['deployment_tags']) = \
                        nose_utils.get_description(test)

                    data.update({'test_set_id': test_set_id, 'name': test_id})

                    LOG.info('%s added for %s', test_id, test_set_id)
                    test_obj = models.Test(**data)
                    self.session.merge(test_obj)
Пример #7
0
    def _add_test_results(self, test, data):
        test_id = test.id()

        models.Test.add_result(
            self.session,
            self.test_run_id,
            test_id,
            data
        )
        if data['status'] != consts.TEST_STATUSES.running:
            test_name = nose_utils.get_description(test)["title"]
            self.results_log.log_results(
                test_id,
                test_name=test_name,
                status=data['status'],
                message=data['message'],
                traceback=data['traceback'],
            )
 def addSuccess(self, test):
     test_id = test.id()
     for test_set_id in self.test_sets.keys():
         if test_set_id in test_id:
             session = engine.get_session()
             with session.begin(subtransactions=True):
                 LOG.info('%s added for %s', test_id, test_set_id)
                 data = dict()
                 data['title'], data['description'], data['duration'] = \
                     nose_utils.get_description(test)
                 old_test_obj = session.query(models.Test).filter_by(
                     name=test_id, test_set_id=test_set_id,
                     test_run_id=None).\
                     update(data, synchronize_session=False)
                 if not old_test_obj:
                     data.update({'test_set_id': test_set_id,
                                  'name': test_id})
                     test_obj = models.Test(**data)
                     session.add(test_obj)
 def addSuccess(self, test):
     test_id = test.id()
     for test_set_id in self.test_sets.keys():
         if test_set_id in test_id:
             session = engine.get_session()
             with session.begin(subtransactions=True):
                 LOG.info('%s added for %s', test_id, test_set_id)
                 data = dict()
                 data['title'], data['description'], data['duration'] = \
                     nose_utils.get_description(test)
                 old_test_obj = session.query(models.Test).filter_by(
                     name=test_id, test_set_id=test_set_id,
                     test_run_id=None).\
                     update(data, synchronize_session=False)
                 if not old_test_obj:
                     data.update({
                         'test_set_id': test_set_id,
                         'name': test_id
                     })
                     test_obj = models.Test(**data)
                     session.add(test_obj)
Пример #10
0
    def addSuccess(self, test):
        test_id = test.id()
        for test_set_id in self.test_sets.keys():
            if test_set_id in test_id:
                with self.session.begin(subtransactions=True):

                    data = dict()

                    (data['title'], data['description'],
                     data['duration'], data['deployment_tags']) = \
                        nose_utils.get_description(test)

                    data.update(
                        {
                            'test_set_id': test_set_id,
                            'name': test_id
                        }
                    )

                    LOG.info('%s added for %s', test_id, test_set_id)
                    test_obj = models.Test(**data)
                    self.session.merge(test_obj)
Пример #11
0
    def addSuccess(self, test):
        test_id = test.id()
        for test_set_id in self.test_sets.keys():
            if test_set_id in test_id:
                session = engine.get_session()
                with session.begin(subtransactions=True):

                    data = dict()
                    data['cluster_id'] = self.deployment_info['cluster_id']
                    (data['title'], data['description'],
                     data['duration'], data['deployment_tags']) = \
                        nose_utils.get_description(test)

                    if set(data['deployment_tags'])\
                       .issubset(self.deployment_info['deployment_tags']):

                        data.update(
                            {
                                'test_set_id': test_set_id,
                                'name': test_id
                            }
                        )

                        #merge doesn't work here so we must check
                        #tests existing with such test_set_id and cluster_id
                        #so we won't ended up with dublicating data upon tests
                        #in db.
                        tests = session.query(models.Test)\
                            .filter_by(cluster_id=self.test_sets[test_set_id].cluster_id)\
                            .filter_by(test_set_id=test_set_id)\
                            .filter_by(test_run_id=None)\
                            .filter_by(name=data['name'])\
                            .first()

                        if not tests:
                            LOG.info('%s added for %s', test_id, test_set_id)
                            test_obj = models.Test(**data)
                            session.add(test_obj)
Пример #12
0
    def test_description_parsing(self):
        test_obj = Mock(spec=case.Test(Mock()))

        test_obj.test._testMethodDoc = """
        Dummy Test
        Available since release: 2014.2-6.1
        Duration: 180 s.
        Scenario:
            1. Step 1
        Deployment tags: Dummy Tags
        """

        data = nose_utils.get_description(test_obj)
        expected = {
            'duration': '180 s.',
            'title': '',
            'deployment_tags': ['dummy tags'],
            'available_since_release': '2014.2-6.1'
        }

        for key in expected:
            self.assertEqual(data[key], expected[key])

        self.assertNotIn('Duration', data['description'])
Пример #13
0
    def addSuccess(self, test):
        test_id = test.id()
        for test_set_id in self.test_sets.keys():
            if test_set_id in test_id:
                data = dict()

                (data['title'], data['description'],
                 data['duration'], data['deployment_tags']) = \
                    nose_utils.get_description(test)

                data.update({'test_set_id': test_set_id, 'name': test_id})

                try:
                    test_obj = models.Test(**data)
                    self.session.merge(test_obj)

                    # flush tests data into db
                    self.session.commit()
                except Exception as e:
                    LOG.error(('An error has occured while '
                               'processing data entity for '
                               'test with name %s. Error message: %s'),
                              test_id, e.message)
                LOG.info('%s added for %s', test_id, test_set_id)