Exemple #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.Master(id=88),
         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.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=32,
                      buildrequestid=42,
                      number=9,
                      masterid=88,
                      builderid=88,
                      workerid=47),
         fakedb.BuildData(id=91,
                          buildid=30,
                          name='name1',
                          value=b'value1',
                          source='source1'),
         fakedb.BuildData(id=92,
                          buildid=30,
                          name='name2',
                          value=b'value2',
                          source='source2'),
         fakedb.BuildData(id=93,
                          buildid=31,
                          name='name3',
                          value=b'value3',
                          source='source3'),
     ])
Exemple #2
0
    def test_get_all_build_data_no_values(self):
        yield self.insertTestData(self.common_data + [
            fakedb.BuildData(id=91,
                             buildid=30,
                             name='name1',
                             value=b'value1',
                             source='source1'),
            fakedb.BuildData(id=92,
                             buildid=30,
                             name='name2',
                             value=b'value2',
                             source='source2'),
            fakedb.BuildData(id=93,
                             buildid=31,
                             name='name3',
                             value=b'value3',
                             source='source3'),
        ])

        data_dicts = yield self.db.build_data.getAllBuildDataNoValues(30)
        self.assertEqual([d['name'] for d in data_dicts], ['name1', 'name2'])
        for d in data_dicts:
            validation.verifyDbDict(self, 'build_datadict', d)

        # note that value is not in dict, but length is
        self.assertEqual(
            data_dicts[0], {
                'buildid': 30,
                'name': 'name1',
                'value': None,
                'length': 6,
                'source': 'source1'
            })

        data_dicts = yield self.db.build_data.getAllBuildDataNoValues(31)
        self.assertEqual([d['name'] for d in data_dicts], ['name3'])
        data_dicts = yield self.db.build_data.getAllBuildDataNoValues(32)
        self.assertEqual([d['name'] for d in data_dicts], [])
Exemple #3
0
    def test_remove_old_build_data(self, older_than_timestamp, exp_num_deleted,
                                   exp_remaining_names):
        yield self.insertTestData(self.common_data + [
            fakedb.Build(id=50,
                         buildrequestid=41,
                         number=17,
                         masterid=88,
                         builderid=88,
                         workerid=47,
                         complete_at=None),
            fakedb.Build(id=51,
                         buildrequestid=42,
                         number=18,
                         masterid=88,
                         builderid=88,
                         workerid=47,
                         complete_at=1000001),
            fakedb.Build(id=52,
                         buildrequestid=43,
                         number=19,
                         masterid=88,
                         builderid=89,
                         workerid=47,
                         complete_at=1000002),
            fakedb.Build(id=53,
                         buildrequestid=43,
                         number=20,
                         masterid=88,
                         builderid=89,
                         workerid=47,
                         complete_at=1000003),
            fakedb.BuildData(id=91,
                             buildid=50,
                             name='name1',
                             value=b'value1',
                             source='src1'),
            fakedb.BuildData(id=92,
                             buildid=50,
                             name='name2',
                             value=b'value2',
                             source='src2'),
            fakedb.BuildData(id=93,
                             buildid=51,
                             name='name3',
                             value=b'value3',
                             source='src3'),
            fakedb.BuildData(id=94,
                             buildid=51,
                             name='name4',
                             value=b'value4',
                             source='src4'),
            fakedb.BuildData(id=95,
                             buildid=52,
                             name='name5',
                             value=b'value5',
                             source='src5'),
            fakedb.BuildData(id=96,
                             buildid=53,
                             name='name6',
                             value=b'value6',
                             source='src6'),
        ])

        num_deleted = yield self.db.build_data.deleteOldBuildData(
            older_than_timestamp)
        self.assertEqual(num_deleted, exp_num_deleted)

        remaining_names = []
        for buildid in [50, 51, 52, 53]:
            data_dicts = yield self.db.build_data.getAllBuildDataNoValues(
                buildid)
            remaining_names += [d['name'] for d in data_dicts]

        self.assertEqual(sorted(remaining_names), sorted(exp_remaining_names))