Ejemplo n.º 1
0
 def setUp(self):
     self.setUpEndpoint()
     self.db.insertTestData([
         fakedb.Worker(id=47, name='linux'),
         fakedb.Buildset(id=20),
         fakedb.Builder(id=88, name='b1'),
         fakedb.BuildRequest(id=41, buildsetid=20, builderid=88),
         fakedb.Master(id=88),
         fakedb.Build(id=30,
                      buildrequestid=41,
                      number=7,
                      masterid=88,
                      builderid=88,
                      workerid=47),
         fakedb.Step(id=131, number=132, name='step132', buildid=30),
         fakedb.TestResultSet(id=13,
                              builderid=88,
                              buildid=30,
                              stepid=131,
                              description='desc',
                              category='cat',
                              value_unit='ms',
                              complete=1),
         fakedb.TestResultSet(id=14,
                              builderid=88,
                              buildid=30,
                              stepid=131,
                              description='desc',
                              category='cat',
                              value_unit='ms',
                              complete=1),
     ])
Ejemplo n.º 2
0
 def setUp(self):
     self.setUpEndpoint()
     self.db.insertTestData([
         fakedb.Worker(id=47, name='linux'),
         fakedb.Buildset(id=20),
         fakedb.Builder(id=88, name='b1'),
         fakedb.BuildRequest(id=41, buildsetid=20, builderid=88),
         fakedb.Master(id=88),
         fakedb.Build(id=30,
                      buildrequestid=41,
                      number=7,
                      masterid=88,
                      builderid=88,
                      workerid=47),
         fakedb.Step(id=131, number=132, name='step132', buildid=30),
         fakedb.TestResultSet(id=13,
                              builderid=88,
                              buildid=30,
                              stepid=131,
                              description='desc',
                              category='cat',
                              value_unit='ms',
                              complete=1),
         fakedb.TestName(id=301, builderid=88, name='name301'),
         fakedb.TestName(id=302, builderid=88, name='name302'),
         fakedb.TestCodePath(id=401, builderid=88, path='path401'),
         fakedb.TestCodePath(id=402, builderid=88, path='path402'),
         fakedb.TestResult(id=101,
                           builderid=88,
                           test_result_setid=13,
                           line=400,
                           value='v101'),
         fakedb.TestResult(id=102,
                           builderid=88,
                           test_result_setid=13,
                           test_nameid=301,
                           test_code_pathid=401,
                           line=401,
                           value='v102'),
         fakedb.TestResult(id=103,
                           builderid=88,
                           test_result_setid=13,
                           test_nameid=302,
                           test_code_pathid=402,
                           line=402,
                           duration_ns=1012,
                           value='v103'),
     ])
Ejemplo n.º 3
0
class Tests(interfaces.InterfaceTests):

    common_data = [
        fakedb.Worker(id=47, name='linux'),
        fakedb.Buildset(id=20),
        fakedb.Builder(id=88, name='b1'),
        fakedb.Builder(id=89, name='b2'),
        fakedb.BuildRequest(id=41, buildsetid=20, builderid=88),
        fakedb.BuildRequest(id=42, buildsetid=20, builderid=88),
        fakedb.BuildRequest(id=43, buildsetid=20, builderid=88),
        fakedb.Master(id=88),
        fakedb.Build(id=30,
                     buildrequestid=41,
                     number=7,
                     masterid=88,
                     builderid=88,
                     workerid=47),
        fakedb.Build(id=31,
                     buildrequestid=42,
                     number=8,
                     masterid=88,
                     builderid=88,
                     workerid=47),
        fakedb.Build(id=40,
                     buildrequestid=43,
                     number=9,
                     masterid=88,
                     builderid=89,
                     workerid=47),
        fakedb.Step(id=131, number=231, name='step231', buildid=30),
        fakedb.Step(id=132, number=232, name='step232', buildid=30),
        fakedb.Step(id=141, number=241, name='step241', buildid=31),
        fakedb.Step(id=142, number=242, name='step242', buildid=40),
    ]

    common_test_result_set_data = [
        fakedb.TestResultSet(id=91,
                             builderid=88,
                             buildid=30,
                             stepid=131,
                             description='desc1',
                             category='cat',
                             value_unit='ms',
                             tests_failed=None,
                             tests_passed=None,
                             complete=0),
        fakedb.TestResultSet(id=92,
                             builderid=88,
                             buildid=30,
                             stepid=131,
                             description='desc2',
                             category='cat',
                             value_unit='ms',
                             tests_failed=None,
                             tests_passed=None,
                             complete=1),
    ]

    def test_signature_add_test_result_set(self):
        @self.assertArgSpecMatches(self.db.test_result_sets.addTestResultSet)
        def addTestResultSet(self, builderid, buildid, stepid, description,
                             category, value_unit):
            pass

    def test_signature_get_test_result_set(self):
        @self.assertArgSpecMatches(self.db.test_result_sets.getTestResultSet)
        def getTestResultSet(self, test_result_setid):
            pass

    def test_signature_get_test_result_sets(self):
        @self.assertArgSpecMatches(self.db.test_result_sets.getTestResultSets)
        def getTestResultSets(self,
                              builderid,
                              buildid=None,
                              stepid=None,
                              complete=None,
                              result_spec=None):
            pass

    def test_signature_complete_test_result_set(self):
        @self.assertArgSpecMatches(
            self.db.test_result_sets.completeTestResultSet)
        def completeTestResultSet(self,
                                  test_result_setid,
                                  tests_passed=None,
                                  tests_failed=None):
            pass

    @defer.inlineCallbacks
    def test_add_set_get_set(self):
        yield self.insertTestData(self.common_data)
        set_id = yield self.db.test_result_sets.addTestResultSet(
            builderid=88,
            buildid=30,
            stepid=131,
            description='desc',
            category='cat',
            value_unit='ms')
        set_dict = yield self.db.test_result_sets.getTestResultSet(set_id)
        validation.verifyDbDict(self, 'test_result_setdict', set_dict)
        self.assertEqual(
            set_dict, {
                'id': set_id,
                'builderid': 88,
                'buildid': 30,
                'stepid': 131,
                'description': 'desc',
                'category': 'cat',
                'value_unit': 'ms',
                'tests_failed': None,
                'tests_passed': None,
                'complete': False
            })

    @defer.inlineCallbacks
    def test_get_sets(self):
        yield self.insertTestData(self.common_data + [
            fakedb.TestResultSet(id=91,
                                 builderid=88,
                                 buildid=30,
                                 stepid=131,
                                 description='desc1',
                                 category='cat',
                                 value_unit='ms',
                                 tests_failed=None,
                                 tests_passed=None,
                                 complete=0),
            fakedb.TestResultSet(id=92,
                                 builderid=89,
                                 buildid=40,
                                 stepid=142,
                                 description='desc2',
                                 category='cat',
                                 value_unit='ms',
                                 tests_failed=None,
                                 tests_passed=None,
                                 complete=1),
            fakedb.TestResultSet(id=93,
                                 builderid=88,
                                 buildid=31,
                                 stepid=141,
                                 description='desc3',
                                 category='cat',
                                 value_unit='ms',
                                 tests_failed=None,
                                 tests_passed=None,
                                 complete=1),
            fakedb.TestResultSet(id=94,
                                 builderid=88,
                                 buildid=30,
                                 stepid=132,
                                 description='desc4',
                                 category='cat',
                                 value_unit='ms',
                                 tests_failed=None,
                                 tests_passed=None,
                                 complete=1),
            fakedb.TestResultSet(id=95,
                                 builderid=88,
                                 buildid=30,
                                 stepid=131,
                                 description='desc4',
                                 category='cat',
                                 value_unit='ms',
                                 tests_failed=None,
                                 tests_passed=None,
                                 complete=0),
        ])

        set_dicts = yield self.db.test_result_sets.getTestResultSets(
            builderid=88)
        self.assertEqual([d['id'] for d in set_dicts], [91, 93, 94, 95])
        for d in set_dicts:
            validation.verifyDbDict(self, 'test_result_setdict', d)

        set_dicts = yield self.db.test_result_sets.getTestResultSets(
            builderid=89)
        self.assertEqual([d['id'] for d in set_dicts], [92])
        set_dicts = yield self.db.test_result_sets.getTestResultSets(
            builderid=88, buildid=30)
        self.assertEqual([d['id'] for d in set_dicts], [91, 94, 95])
        set_dicts = yield self.db.test_result_sets.getTestResultSets(
            builderid=88, buildid=31)
        self.assertEqual([d['id'] for d in set_dicts], [93])
        set_dicts = yield self.db.test_result_sets.getTestResultSets(
            builderid=88, stepid=131)
        self.assertEqual([d['id'] for d in set_dicts], [91, 95])
        set_dicts = yield self.db.test_result_sets.getTestResultSets(
            builderid=88, stepid=132)
        self.assertEqual([d['id'] for d in set_dicts], [94])
        set_dicts = yield self.db.test_result_sets.getTestResultSets(
            builderid=88, complete=True)
        self.assertEqual([d['id'] for d in set_dicts], [93, 94])
        set_dicts = yield self.db.test_result_sets.getTestResultSets(
            builderid=88, complete=False)
        self.assertEqual([d['id'] for d in set_dicts], [91, 95])

    @defer.inlineCallbacks
    def test_get_set_from_data(self):
        yield self.insertTestData(self.common_data +
                                  self.common_test_result_set_data)

        set_dict = yield self.db.test_result_sets.getTestResultSet(91)
        self.assertEqual(
            set_dict, {
                'id': 91,
                'builderid': 88,
                'buildid': 30,
                'stepid': 131,
                'description': 'desc1',
                'category': 'cat',
                'value_unit': 'ms',
                'tests_failed': None,
                'tests_passed': None,
                'complete': False
            })

    @defer.inlineCallbacks
    def test_get_non_existing_set(self):
        set_dict = yield self.db.test_result_sets.getTestResultSet(91)
        self.assertEqual(set_dict, None)

    @defer.inlineCallbacks
    def test_complete_already_completed_set(self):
        yield self.insertTestData(self.common_data +
                                  self.common_test_result_set_data)
        with self.assertRaises(test_result_sets.TestResultSetAlreadyCompleted):
            yield self.db.test_result_sets.completeTestResultSet(92)
        self.flushLoggedErrors(test_result_sets.TestResultSetAlreadyCompleted)

    @defer.inlineCallbacks
    def test_complete_set_with_test_counts(self):
        yield self.insertTestData(self.common_data +
                                  self.common_test_result_set_data)

        yield self.db.test_result_sets.completeTestResultSet(91,
                                                             tests_passed=12,
                                                             tests_failed=2)

        set_dict = yield self.db.test_result_sets.getTestResultSet(91)
        self.assertEqual(
            set_dict, {
                'id': 91,
                'builderid': 88,
                'buildid': 30,
                'stepid': 131,
                'description': 'desc1',
                'category': 'cat',
                'value_unit': 'ms',
                'tests_failed': 2,
                'tests_passed': 12,
                'complete': True
            })

    @defer.inlineCallbacks
    def test_complete_set_without_test_counts(self):
        yield self.insertTestData(self.common_data +
                                  self.common_test_result_set_data)

        yield self.db.test_result_sets.completeTestResultSet(91)

        set_dict = yield self.db.test_result_sets.getTestResultSet(91)
        self.assertEqual(
            set_dict, {
                'id': 91,
                'builderid': 88,
                'buildid': 30,
                'stepid': 131,
                'description': 'desc1',
                'category': 'cat',
                'value_unit': 'ms',
                'tests_failed': None,
                'tests_passed': None,
                'complete': True
            })
Ejemplo n.º 4
0
    def test_get_sets(self):
        yield self.insertTestData(self.common_data + [
            fakedb.TestResultSet(id=91,
                                 builderid=88,
                                 buildid=30,
                                 stepid=131,
                                 description='desc1',
                                 category='cat',
                                 value_unit='ms',
                                 tests_failed=None,
                                 tests_passed=None,
                                 complete=0),
            fakedb.TestResultSet(id=92,
                                 builderid=89,
                                 buildid=40,
                                 stepid=142,
                                 description='desc2',
                                 category='cat',
                                 value_unit='ms',
                                 tests_failed=None,
                                 tests_passed=None,
                                 complete=1),
            fakedb.TestResultSet(id=93,
                                 builderid=88,
                                 buildid=31,
                                 stepid=141,
                                 description='desc3',
                                 category='cat',
                                 value_unit='ms',
                                 tests_failed=None,
                                 tests_passed=None,
                                 complete=1),
            fakedb.TestResultSet(id=94,
                                 builderid=88,
                                 buildid=30,
                                 stepid=132,
                                 description='desc4',
                                 category='cat',
                                 value_unit='ms',
                                 tests_failed=None,
                                 tests_passed=None,
                                 complete=1),
            fakedb.TestResultSet(id=95,
                                 builderid=88,
                                 buildid=30,
                                 stepid=131,
                                 description='desc4',
                                 category='cat',
                                 value_unit='ms',
                                 tests_failed=None,
                                 tests_passed=None,
                                 complete=0),
        ])

        set_dicts = yield self.db.test_result_sets.getTestResultSets(
            builderid=88)
        self.assertEqual([d['id'] for d in set_dicts], [91, 93, 94, 95])
        for d in set_dicts:
            validation.verifyDbDict(self, 'test_result_setdict', d)

        set_dicts = yield self.db.test_result_sets.getTestResultSets(
            builderid=89)
        self.assertEqual([d['id'] for d in set_dicts], [92])
        set_dicts = yield self.db.test_result_sets.getTestResultSets(
            builderid=88, buildid=30)
        self.assertEqual([d['id'] for d in set_dicts], [91, 94, 95])
        set_dicts = yield self.db.test_result_sets.getTestResultSets(
            builderid=88, buildid=31)
        self.assertEqual([d['id'] for d in set_dicts], [93])
        set_dicts = yield self.db.test_result_sets.getTestResultSets(
            builderid=88, stepid=131)
        self.assertEqual([d['id'] for d in set_dicts], [91, 95])
        set_dicts = yield self.db.test_result_sets.getTestResultSets(
            builderid=88, stepid=132)
        self.assertEqual([d['id'] for d in set_dicts], [94])
        set_dicts = yield self.db.test_result_sets.getTestResultSets(
            builderid=88, complete=True)
        self.assertEqual([d['id'] for d in set_dicts], [93, 94])
        set_dicts = yield self.db.test_result_sets.getTestResultSets(
            builderid=88, complete=False)
        self.assertEqual([d['id'] for d in set_dicts], [91, 95])
Ejemplo n.º 5
0
class Tests(interfaces.InterfaceTests):

    common_data = [
        fakedb.Worker(id=47, name='linux'),
        fakedb.Buildset(id=20),
        fakedb.Builder(id=88, name='b1'),
        fakedb.BuildRequest(id=41, buildsetid=20, builderid=88),
        fakedb.Master(id=88),
        fakedb.Build(id=30,
                     buildrequestid=41,
                     number=7,
                     masterid=88,
                     builderid=88,
                     workerid=47),
        fakedb.Step(id=131, number=132, name='step132', buildid=30),
        fakedb.TestResultSet(id=13,
                             builderid=88,
                             buildid=30,
                             stepid=131,
                             description='desc',
                             category='cat',
                             value_unit='ms',
                             complete=1),
    ]

    def test_signature_get_test_code_paths(self):
        @self.assertArgSpecMatches(self.db.test_results.getTestCodePaths)
        def getTestCodePaths(self,
                             builderid,
                             path_prefix=None,
                             result_spec=None):
            pass

    def test_signature_get_test_names(self):
        @self.assertArgSpecMatches(self.db.test_results.getTestNames)
        def getTestNames(self, builderid, name_prefix=None, result_spec=None):
            pass

    def test_signature_add_test_results(self):
        @self.assertArgSpecMatches(self.db.test_results.addTestResults)
        def addTestResults(self, builderid, test_result_setid, result_values):
            pass

    def test_signature_get_test_result(self):
        @self.assertArgSpecMatches(self.db.test_results.getTestResult)
        def getTestResult(self, test_resultid):
            pass

    def test_signature_get_test_results(self):
        @self.assertArgSpecMatches(self.db.test_results.getTestResults)
        def getTestResults(self,
                           builderid,
                           test_result_setid,
                           result_spec=None):
            pass

    @defer.inlineCallbacks
    def test_add_set_results(self):
        yield self.insertTestData(self.common_data)

        result_values = [
            {
                'test_name': 'name1',
                'value': '1'
            },
            {
                'test_name': 'name1',
                'duration_ns': 1000,
                'value': '2'
            },
            {
                'test_name': 'name2',
                'test_code_path': 'path2',
                'value': '3'
            },
            {
                'test_name': 'name3',
                'test_code_path': 'path3',
                'value': '4'
            },
            {
                'test_name': 'name4',
                'test_code_path': 'path4',
                'line': 4,
                'value': '5'
            },
            {
                'test_code_path': 'path5',
                'line': 5,
                'value': '6'
            },
        ]

        yield self.db.test_results.addTestResults(builderid=88,
                                                  test_result_setid=13,
                                                  result_values=result_values)

        result_dicts = yield self.db.test_results.getTestResults(
            builderid=88, test_result_setid=13)
        for d in result_dicts:
            validation.verifyDbDict(self, 'test_resultdict', d)

        result_dicts = sorted(result_dicts, key=lambda x: x['id'])
        resultid = result_dicts[0]['id']
        self.assertEqual(result_dicts, [
            {
                'id': resultid,
                'builderid': 88,
                'test_result_setid': 13,
                'test_name': 'name1',
                'test_code_path': None,
                'line': None,
                'duration_ns': None,
                'value': '1'
            },
            {
                'id': resultid + 1,
                'builderid': 88,
                'test_result_setid': 13,
                'test_name': 'name1',
                'test_code_path': None,
                'line': None,
                'duration_ns': 1000,
                'value': '2'
            },
            {
                'id': resultid + 2,
                'builderid': 88,
                'test_result_setid': 13,
                'test_name': 'name2',
                'test_code_path': 'path2',
                'line': None,
                'duration_ns': None,
                'value': '3'
            },
            {
                'id': resultid + 3,
                'builderid': 88,
                'test_result_setid': 13,
                'test_name': 'name3',
                'test_code_path': 'path3',
                'line': None,
                'duration_ns': None,
                'value': '4'
            },
            {
                'id': resultid + 4,
                'builderid': 88,
                'test_result_setid': 13,
                'test_name': 'name4',
                'test_code_path': 'path4',
                'line': 4,
                'duration_ns': None,
                'value': '5'
            },
            {
                'id': resultid + 5,
                'builderid': 88,
                'test_result_setid': 13,
                'test_name': None,
                'test_code_path': 'path5',
                'line': 5,
                'duration_ns': None,
                'value': '6'
            },
        ])

        result_dict = yield self.db.test_results.getTestResult(
            test_resultid=resultid)
        self.assertEqual(
            result_dict, {
                'id': resultid,
                'builderid': 88,
                'test_result_setid': 13,
                'test_name': 'name1',
                'test_code_path': None,
                'line': None,
                'duration_ns': None,
                'value': '1'
            })

    @defer.inlineCallbacks
    def test_get_names(self):
        yield self.insertTestData(self.common_data + [
            fakedb.TestName(id=103, builderid=88, name='name103'),
            fakedb.TestName(id=104, builderid=88, name='name104'),
            fakedb.TestName(id=105, builderid=88, name='name105'),
            fakedb.TestName(id=116, builderid=88, name='name116'),
            fakedb.TestName(id=117, builderid=88, name='name117'),
        ])

        name_dicts = yield self.db.test_results.getTestNames(builderid=88)
        self.assertEqual(
            name_dicts,
            ['name103', 'name104', 'name105', 'name116', 'name117'])

        name_dicts = yield self.db.test_results.getTestNames(
            builderid=88, name_prefix='non_existing')
        self.assertEqual(name_dicts, [])

        name_dicts = yield self.db.test_results.getTestNames(
            builderid=88, name_prefix='name10')
        self.assertEqual(name_dicts, ['name103', 'name104', 'name105'])

        name_dicts = yield self.db.test_results.getTestNames(
            builderid=88, name_prefix='name11')
        self.assertEqual(name_dicts, ['name116', 'name117'])

    @defer.inlineCallbacks
    def test_get_code_paths(self):
        yield self.insertTestData(self.common_data + [
            fakedb.TestCodePath(id=103, builderid=88, path='path103'),
            fakedb.TestCodePath(id=104, builderid=88, path='path104'),
            fakedb.TestCodePath(id=105, builderid=88, path='path105'),
            fakedb.TestCodePath(id=116, builderid=88, path='path116'),
            fakedb.TestCodePath(id=117, builderid=88, path='path117'),
        ])

        path_dicts = yield self.db.test_results.getTestCodePaths(builderid=88)
        self.assertEqual(
            path_dicts,
            ['path103', 'path104', 'path105', 'path116', 'path117'])

        path_dicts = yield self.db.test_results.getTestCodePaths(
            builderid=88, path_prefix='non_existing')
        self.assertEqual(path_dicts, [])

        path_dicts = yield self.db.test_results.getTestCodePaths(
            builderid=88, path_prefix='path10')
        self.assertEqual(path_dicts, ['path103', 'path104', 'path105'])

        path_dicts = yield self.db.test_results.getTestCodePaths(
            builderid=88, path_prefix='path11')
        self.assertEqual(path_dicts, ['path116', 'path117'])