コード例 #1
0
    def test_getBuildersWithPendingBuildsByProject(self):
        yield self.setupProject(builders={'builder-02': 'Katana'})
        self.request.args['pending_builds'] = ['1']
        project_json = status_json.SingleProjectJsonResource(
            self.master_status, self.project)
        project_dict = yield project_json.asDict(self.request)

        def getSource(url=True):
            source = {
                'revision': 'az',
                'revision_short': 'az',
                'hasPatch': False,
                'branch': 'master',
                'changes': [],
                'project': 'proj',
                'repository': 'z',
                'codebase': 'cb',
                'totalChanges': 0
            }
            if url:
                source['url'] = None
            return source

        pending = [{
            'brid': 1,
            'source': getSource(),
            'sources': [getSource(url=False)],
            'properties': [],
            'priority': 20,
            'builderName': 'builder-02',
            'reason': 'because',
            'slaves': ['build-slave-01'],
            'submittedAt': 1450171024,
            'builderFriendlyName': 'builder-02',
            'builderURL':
            'http://localhost:8080/projects/Katana/builders/builder-02?katana-buildbot_branch=katana',
            'results': -1,
            'builds': [],
            'lastBuildNumber': None
        }]

        expected_project = self.expectedProjectDict(builders=[
            self.jsonBuilders('builder-02',
                              pendingBuilds=len(pending),
                              pendingBuildRequests=pending)
        ])

        self.assertEquals(project_dict, expected_project)
コード例 #2
0
    def test_getBuildersByProject(self):
        builders = {
            'builder-01': 'project-01',
            "builder-02": 'Katana',
            "builder-03": 'Katana',
            "builder-04": 'Katana',
            "builder-05": 'project-02',
        }

        yield self.setupProject(builders=builders)

        project_json = status_json.SingleProjectJsonResource(
            self.master_status, self.project)

        latestRevisions = {
            'https://github.com/Unity-Technologies/buildbot.git': {
                'codebase': 'katana-buildbot',
                'display_repository':
                'https://github.com/Unity-Technologies/buildbot.git',
                'branch': 'Katana',
                'revision': u'0:835be7494fb4'
            }
        }

        def getObjectStateByKey(objects, filteredKey, storedKey):
            return latestRevisions

        project_json.status.master.db.state.getObjectStateByKey = getObjectStateByKey

        self.assertEqual(project_json.children.keys(),
                         ['builder-02', 'builder-03', 'builder-04'])

        project_dict = yield project_json.asDict(self.request)

        expected_project_dict = self.expectedProjectDict(
            builders=[
                self.jsonBuilders('builder-02', pendingBuilds=1),
                self.jsonBuilders('builder-03'),
                self.jsonBuilders('builder-04')
            ],
            latestRevisions=latestRevisions)

        self.assertEqual(project_dict, expected_project_dict)
コード例 #3
0
    def test_getBuildersByProjectWithLatestBuilds(self):
        self.master.botmaster.builderNames = ["builder-01"]

        builder = mockBuilder(self.master, self.master_status, "builder-01",
                              "Katana")
        self.master.botmaster.builders = {'builder-01': builder}

        def mockFinishedBuildsAsync(branches=[],
                                    codebases={},
                                    num_builds=None,
                                    max_buildnum=None,
                                    finished_before=None,
                                    results=None,
                                    max_search=2000,
                                    useCache=False):
            return defer.succeed([fakeBuildStatus(self.master, builder, 1)])

        builder.builder_status.generateFinishedBuildsAsync = mockFinishedBuildsAsync

        project_json = status_json.SingleProjectJsonResource(
            self.master_status, self.project)

        self.assertEqual(project_json.children.keys(), ['builder-01'])

        project_dict = yield project_json.asDict(self.request)

        expected_project_dict = \
            {'comparisonURL': '../../projects/Katana/comparison?builders0=katana-buildbot%3Dkatana',
             'builders':
                 [{'latestBuild': {
                     'results_text': 'success',
                     'slave': 'build-slave-01',
                     'slave_url': None,
                     'builderName': 'builder-01',
                     'builder_tags': ['tag1', 'tag2'],
                     'build_tags': [
                         {'description': 'buildtag1', 'title': 'buildtag1'},
                         {'description': 'buildtag2desc', 'title': 'buildtag2'},
                     ],
                     'url':
                         {'path':
                              'http://*****:*****@localhost',
                     'eta': None, 'builderFriendlyName': 'builder-01',
                     'failure_url': None, 'slave_friendly_name': 'build-slave-01',
                     'times': (1422441500, 1422441501.21)},
                   'name': 'builder-01', 'tags': ['tag1', 'tag2'],
                   'url': 'http://localhost:8080/projects/Katana/builders/builder-01?katana-buildbot_branch=katana',
                   'description': 'Describing my builder',
                   'friendly_name': 'builder-01', 'startSlavenames ': [],
                   'project': 'Katana', 'state': 'offline', 'slaves': ['build-slave-01'],
                   'currentBuilds': [], 'pendingBuilds': 0}],
             'latestRevisions': {},
             'regex_branches': ['^(trunk)',
                                '^(20[0-9][0-9].[0-9])\\/',
                                '^([0-9].[0-9])\\/',
                                '^release\\/([0-9].[0-9])/'],
             'tag_as_branch_regex': '^(20[0-9][0-9].[0-9]|[0-9].[0-9]|trunk)$',
             }

        self.assertEqual(project_dict, expected_project_dict)