Esempio n. 1
0
    def _add_build_and_remove_changes(self, t, important, unimportant):
        # the changes are segregated into important and unimportant
        # changes, but we need it ordered earliest to latest, based
        # on change number, since the SourceStamp will be created
        # based on the final change.
        all_changes = sorted(important + unimportant, key=lambda c: c.number)

        db = self.parent.db
        if self.treeStableTimer is None:
            # each *important* Change gets a separate build.  Unimportant
            # builds get ignored.
            for c in sorted(important, key=lambda c: c.number):
                ss = SourceStamp(changes=[c])
                ssid = db.get_sourcestampid(ss, t)
                self.create_buildset(ssid, "scheduler", t)
        else:
            # if we had a treeStableTimer, then trigger a build for the
            # whole pile - important or not.  There's at least one important
            # change in the list, or we wouldn't have gotten here.
            ss = SourceStamp(changes=all_changes)
            ssid = db.get_sourcestampid(ss, t)
            self.create_buildset(ssid, "scheduler", t)

        # and finally retire all of the changes from scheduler_changes, regardless
        # of importance level
        changeids = [c.number for c in all_changes]
        db.scheduler_retire_changes(self.schedulerid, changeids, t)
Esempio n. 2
0
    def getSourceStampNumberedNow(self, ssid, t=None, old_res=None):
        assert isinstance(ssid, (int, long))
        ss = self._sourcestamp_cache.get(ssid)
        if ss:
            return ss

        assert isinstance(ssid, (int, long))
        sstamp_obj = rpc.RpcProxy('software_dev.commit')

        if not old_res:
            res = sstamp_obj.read(ssid)
        else:
            res = old_res
        if not res:
            return None

        branch = None  # res['branch_url']
        revision = res.get('revno', False) or res.get('hash', '')

        patch = None
        #if patchid is not None:
        #    raise NotImplementedError

        changes = None

        changeid = ssid
        changes = [
            self.getChangeNumberedNow(changeid, t),
        ]
        ss = SourceStamp(branch, revision, patch, changes)
        # project=project, repository=repository)
        ss.ssid = ssid
        self._sourcestamp_cache.add(ssid, ss)
        return ss
Esempio n. 3
0
    def getSourceStampNumberedNow(self, ssid, t=None, old_res=None):
        assert isinstance(ssid, (int, long))
        ss = self._sourcestamp_cache.get(ssid)
        if ss:
            return ss
        
        assert isinstance(ssid, (int, long))
        sstamp_obj = rpc.RpcProxy('software_dev.commit')
        
        if not old_res:
            res = sstamp_obj.read(ssid)
        else:
            res = old_res
        if not res:
            return None

        branch = None # res['branch_url']
        revision = res.get('revno', False) or res.get('hash', '')

        patch = None
        #if patchid is not None:
        #    raise NotImplementedError

        changes = None
        
        changeid = ssid
        changes = [self.getChangeNumberedNow(changeid, t), ]
        ss = SourceStamp(branch, revision, patch, changes )
            # project=project, repository=repository)
        ss.ssid = ssid
        self._sourcestamp_cache.add(ssid, ss)
        return ss
Esempio n. 4
0
    def _txn_getSourceStampNumbered(self, t, ssid):
        assert isinstance(ssid, (int, long))
        t.execute(
            self.quoteq("SELECT branch,revision,patchid,project,repository" " FROM sourcestamps WHERE id=?"), (ssid,)
        )
        r = t.fetchall()
        if not r:
            return None
        (branch_u, revision_u, patchid, project, repository) = r[0]
        branch = str_or_none(branch_u)
        revision = str_or_none(revision_u)

        patch = None
        if patchid is not None:
            t.execute(self.quoteq("SELECT patchlevel,patch_base64,subdir" " FROM patches WHERE id=?"), (patchid,))
            r = t.fetchall()
            assert len(r) == 1
            (patch_level, patch_text_base64, subdir_u) = r[0]
            patch_text = base64.b64decode(patch_text_base64)
            if subdir_u:
                patch = (patch_level, patch_text, str(subdir_u))
            else:
                patch = (patch_level, patch_text)

        t.execute(
            self.quoteq("SELECT changeid FROM sourcestamp_changes" " WHERE sourcestampid=?" " ORDER BY changeid ASC"),
            (ssid,),
        )
        r = t.fetchall()
        changes = None
        if r:
            changes = [self.getChangeNumberedNow(changeid, t) for (changeid,) in r]
        ss = SourceStamp(branch, revision, patch, changes, project=project, repository=repository)
        ss.ssid = ssid
        return ss
Esempio n. 5
0
    def __iter__(self):
        if self.tag:
            revision = "tag:" + self.tag
        else:
            revision = "-1"

        for prj in self.projects:
            if prj in self.indep_prj:
                archs = [self.indep_arch]
            else:
                archs = self.archs

            # XXX: SDK builds are hybrids, so we should allow them
            #      to be tagged to both builders and archs.  To avoid
            #      confusion, we just trigger the SDK build for devchk
            #      builders as part of the devchk build itself.  We should
            #      probably make this more consistent.
            if prj == "devchk":
                for build in ["build-sdk", "devchk"]:
                    repo = self.get_repo(build)
                    for builder in self.devchk_builders:
                        builderNames = ["%s-%s" % (build, builder)]
                        branch = "lsb/%s/%s" % (self.branch_name, repo)
                        ss = SourceStamp(branch, revision, None, None)
                        yield (ss, builderNames, self.properties,
                               "MultiScheduler job")
            else:
                repo = self.get_repo(prj)
                for arch in archs:
                    builderNames = ["%s-%s" % (prj, arch)]
                    branch = "lsb/%s/%s" % (self.branch_name, repo)
                    ss = SourceStamp(branch, revision, None, None)
                    yield (ss, builderNames, self.properties,
                           "MultiScheduler job")
Esempio n. 6
0
        def do_add_build_and_remove_changes(t, buildersPerChange):
            log.msg("Adding request for %s" % buildersPerChange)
            if not buildersPerChange:
                return

            db = self.parent.db
            for i in range(self.numberOfBuildsToTrigger):
                if self.treeStableTimer is None:
                    # each Change gets a separate build
                    for c in all_changes:
                        if c not in buildersPerChange:
                            continue
                        ss = SourceStamp(changes=[c])
                        ssid = db.get_sourcestampid(ss, t)
                        self.create_buildset(ssid, "scheduler", t, builderNames=buildersPerChange[c])
                else:
                    # Grab all builders
                    builderNames = set()
                    for names in buildersPerChange.values():
                        builderNames.update(names)
                    builderNames = list(builderNames)
                    ss = SourceStamp(changes=all_changes)
                    ssid = db.get_sourcestampid(ss, t)
                    self.create_buildset(ssid, "scheduler", t, builderNames=builderNames)

            # and finally retire the changes from scheduler_changes
            changeids = [c.number for c in all_changes]
            db.scheduler_retire_changes(self.schedulerid, changeids, t)
            return None
Esempio n. 7
0
    def _connected(self, *args):
        # Our fake source stamp
        # we override canBeMergedWith so that our requests don't get merged together
        ss = SourceStamp()
        ss.canBeMergedWith = lambda x: False

        # Send one request to tie up the slave before sending future requests
        req0 = BuildRequest("reason", ss, "test_builder")
        self.master.botmaster.builders['quick1'].submitBuildRequest(req0)

        # Send 10 requests to alternating builders
        # We fudge the submittedAt field after submitting since they're all
        # getting submitted so close together according to time.time()
        # and all we care about is what order they're run in.
        reqs = []
        self.finish_order = []
        for i in range(10):
            req = BuildRequest(str(i), ss, "test_builder")
            j = i % 2 + 1
            self.master.botmaster.builders['quick%i' % j].submitBuildRequest(req)
            req.submittedAt = i
            # Keep track of what order the builds finished in
            def append(item, arg):
                self.finish_order.append(item)
            req.waitUntilFinished().addCallback(append, req)
            reqs.append(req.waitUntilFinished())

        dl = defer.DeferredList(reqs)
        dl.addCallback(self._all_finished)

        # After our first build finishes, we should wait for the rest to finish
        d = req0.waitUntilFinished()
        d.addCallback(lambda x: dl)
        return d
Esempio n. 8
0
    def __init__(self, branch=None, revision=None, patch=None,
                 changes=None):
        SourceStamp.__init__(self, branch=branch, revision=revision, patch=patch,
                 changes=changes)

        if self.changes:
            self.revision = self.changes[0].revision
Esempio n. 9
0
 def addRebuild(t):
     c3 = Change(who='me!', branch='b1', revision='r1', files=['http://path/to/build'],
             comments='really important', properties={'buildid': '20110214000001'}, when=6)
     self.dbc.addChangeToDatabase(c3)
     ss = SourceStamp(branch='b1', changes=[c3], revision='r1')
     ss1 = ss.getAbsoluteSourceStamp('r1')
     ssid = self.dbc.get_sourcestampid(ss, t)
     bsid = self.dbc.create_buildset(ssid, "rebuild", Properties(), ["b1"], t)
Esempio n. 10
0
 def testAsDictBranch(self):
     s = SourceStamp(branch='Br', revision='Rev')
     r = s.asDict()
     self.assertEqual(r, {
         'revision': 'Rev',
         'patch': None,
         'branch':  'Br',
         'changes': [],
       })
Esempio n. 11
0
 def testAsDictEmpty(self):
     s = SourceStamp()
     r = s.asDict()
     self.assertEqual(r, {
         'revision': None,
         'patch': None,
         'branch':  None,
         'changes': [],
       })
Esempio n. 12
0
    def __init__(self, branch=None, revision=None, patch=None, changes=None):
        SourceStamp.__init__(self,
                             branch=branch,
                             revision=revision,
                             patch=patch,
                             changes=changes)

        if self.changes:
            self.revision = self.changes[0].revision
Esempio n. 13
0
    def testPriority(self):
        self.rmtree("basedir")
        os.mkdir("basedir")
        self.master.loadConfig(config_priority)
        self.master.readConfig = True
        self.master.startService()

        # Our fake source stamp
        # we override canBeMergedWith so that our requests don't get merged together
        ss = SourceStamp()
        ss.canBeMergedWith = lambda x: False

        # Send 10 requests to alternating builders
        # We fudge the submittedAt field after submitting since they're all
        # getting submitted so close together according to time.time()
        # and all we care about is what order they're run in.
        reqs = []
        self.start_order = []
        for i in range(10):
            req = BuildRequest(str(i), ss, "test_builder")
            j = i % 2 + 1
            self.master.botmaster.builders['quick%i' %
                                           j].submitBuildRequest(req)
            req.submittedAt = i

            # Keep track of what order the builds start in
            def append(build):
                self.start_order.append(int(build.reason))

            req.subscribe(append)
            reqs.append(req.waitUntilFinished())

        dl = defer.DeferredList(reqs)
        dl.addCallback(self._all_finished)

        def _delay(res):
            d1 = defer.Deferred()
            reactor.callLater(0.5, d1.callback, None)
            # this test depends upon this 0.5s delay landing us in the middle
            # of one of the builds.
            return d1

        def _connect(res, i):
            return self.connectSlave(slavename="bot%i" % i,
                                     builders=["quick1", "quick2"])

        # Now add the slaves
        d = self.connectSlave(slavename="bot0", builders=["quick1", "quick2"])
        for i in range(1, 5):
            d.addCallback(_delay)
            d.addCallback(_connect, i)

        d.addCallback(lambda x: dl)

        return d
Esempio n. 14
0
 def testAsDictChanges(self):
     changes = [
         Change('nobody', [], 'Comment', branch='br2', revision='rev2'),
         Change('nob', ['file2', 'file3'],
                'Com',
                branch='br3',
                revision='rev3'),
     ]
     s = SourceStamp(branch='Br',
                     revision='Rev',
                     patch=(1, 'Pat'),
                     changes=changes)
     r = s.asDict()
     del r['changes'][0]['when']
     del r['changes'][1]['when']
     EXPECTED = {
         'revision':
         'rev3',
         'branch':
         'br3',
         'hasPatch':
         True,
         'project':
         '',
         'repository':
         '',
         'changes': [{
             'branch': 'br2',
             'category': None,
             'comments': 'Comment',
             'files': [],
             'number': None,
             'properties': [],
             'revision': 'rev2',
             'revlink': '',
             'project': '',
             'repository': '',
             'who': 'nobody'
         }, {
             'branch': 'br3',
             'category': None,
             'comments': 'Com',
             'files': ['file2', 'file3'],
             'number': None,
             'properties': [],
             'revision': 'rev3',
             'revlink': '',
             'who': 'nob',
             'project': '',
             'repository': '',
         }],
     }
     self.assertEqual(EXPECTED, r)
Esempio n. 15
0
    def testPriority(self):
        self.rmtree("basedir")
        os.mkdir("basedir")
        self.master.loadConfig(config_priority)
        self.master.readConfig = True
        self.master.startService()

        # Our fake source stamp
        # we override canBeMergedWith so that our requests don't get merged together
        ss = SourceStamp()
        ss.canBeMergedWith = lambda x: False

        # Send 10 requests to alternating builders
        # We fudge the submittedAt field after submitting since they're all
        # getting submitted so close together according to time.time()
        # and all we care about is what order they're run in.
        reqs = []
        self.start_order = []
        for i in range(10):
            req = BuildRequest(str(i), ss, "test_builder")
            j = i % 2 + 1
            self.master.botmaster.builders['quick%i' % j].submitBuildRequest(req)
            req.submittedAt = i
            # Keep track of what order the builds start in
            def append(build):
                self.start_order.append(int(build.reason))
            req.subscribe(append)
            reqs.append(req.waitUntilFinished())

        dl = defer.DeferredList(reqs)
        dl.addCallback(self._all_finished)

        def _delay(res):
            d1 = defer.Deferred()
            reactor.callLater(0.5, d1.callback, None)
            # this test depends upon this 0.5s delay landing us in the middle
            # of one of the builds.
            return d1

        def _connect(res, i):
            return self.connectSlave(slavename="bot%i" % i, builders=["quick1", "quick2"])

        # Now add the slaves
        d = self.connectSlave(slavename="bot0", builders=["quick1", "quick2"])
        for i in range(1,5):
            d.addCallback(_delay)
            d.addCallback(_connect, i)

        d.addCallback(lambda x: dl)

        return d
Esempio n. 16
0
 def addRebuild(t):
     c3 = Change(who='me!',
                 branch='b1',
                 revision='r1',
                 files=['http://path/to/build'],
                 comments='really important',
                 properties={'buildid': '20110214000001'},
                 when=6)
     self.dbc.addChangeToDatabase(c3)
     ss = SourceStamp(branch='b1', changes=[c3], revision='r1')
     ss1 = ss.getAbsoluteSourceStamp('r1')
     ssid = self.dbc.get_sourcestampid(ss, t)
     bsid = self.dbc.create_buildset(ssid, "rebuild", Properties(),
                                     ["b1"], t)
Esempio n. 17
0
 def setUp(self):
     RunMixin.setUp(self)
     self.req1 = req1 = BuildRequest("forced build", SourceStamp())
     req1.number = 1
     self.req2 = req2 = BuildRequest("forced build", SourceStamp())
     req2.number = 2
     self.req3 = req3 = BuildRequest("forced build", SourceStamp())
     req3.number = 3
     req1.events = req2.events = req3.events = self.events = []
     d = self.master.loadConfig(config_1)
     d.addCallback(lambda res: self.master.startService())
     d.addCallback(lambda res: self.connectSlaves(["bot1", "bot2"], [
         "full1a", "full1b", "full1c", "full1d", "full2a", "full2b"
     ]))
     return d
Esempio n. 18
0
 def testAsDictChanges(self):
     changes = [
         Change('nobody', [], 'Comment', branch='br2', revision='rev2'),
         Change('nob', ['file2', 'file3'], 'Com', branch='br3',
                revision='rev3'),
     ]
     s = SourceStamp(branch='Br', revision='Rev', patch=(1,'Pat'),
                     changes=changes)
     r = s.asDict()
     r['changes'][0]['when'] = 23
     r['changes'][1]['when'] = 42
     self.assertEqual(r, {
         'revision': 'rev3',
         'patch': (1,'Pat'),
         'branch': 'br3',
         'project': '',
         'repository':'',
         'changes': [
             {
                 'branch': 'br2',
                 'category': None,
                 'comments': 'Comment',
                 'files': [],
                 'number': None,
                 'properties': [],
                 'revision': 'rev2',
                 'revlink': '',
                 'when': 23,
                 'who': 'nobody',
                 'project' : '',
                 'repository' : '',
             },
             {
                 'branch': 'br3',
                 'category': None,
                 'comments': 'Com',
                 'files': ['file2', 'file3'],
                 'number': None,
                 'properties': [],
                 'revision': 'rev3',
                 'revlink': '',
                 'when': 42,
                 'who': 'nob',
                 'project' : '',
                 'repository' : '',
             }
         ],
       })
Esempio n. 19
0
    def _add_build_and_remove_changes(self, t, all_changes):
        db = self.parent.db
        if self.treeStableTimer is None:
            # each Change gets a separate build
            for c in all_changes:
                ss = SourceStamp(changes=[c])
                ssid = db.get_sourcestampid(ss, t)
                self.create_buildset(ssid, "scheduler", t)
        else:
            ss = SourceStamp(changes=all_changes)
            ssid = db.get_sourcestampid(ss, t)
            self.create_buildset(ssid, "scheduler", t)

        # and finally retire the changes from scheduler_changes
        changeids = [c.number for c in all_changes]
        db.scheduler_retire_changes(self.schedulerid, changeids, t)
    def perspective_try(self, branch, revision, patch, builderNames, properties={}):
        log.msg("user %s requesting build on builders %s" % (self.username,
                                                             builderNames))
        for b in builderNames:
            if not b in self.parent.builderNames:
                log.msg("%s got job with builder %s" % (self, b))
                log.msg(" but that wasn't in our list: %s"
                        % (self.parent.builderNames,))
                return
        ss = SourceStamp(branch, revision, patch)
        reason = "'try' job from user %s" % self.username

        # roll the specified props in with our inherited props
        combined_props = Properties()
        combined_props.updateFromProperties(self.parent.properties)
        combined_props.update(properties, "try build")

        bs = buildset.BuildSet(builderNames, 
                               ss,
                               reason=reason, 
                               properties=combined_props)

        self.parent.submitBuildSet(bs)

        # return a remotely-usable BuildSetStatus object
        from buildbot.status.client import makeRemote
        return makeRemote(bs.status)
 def parseJob(self, f):
     # jobfiles are serialized build requests. Each is a list of
     # serialized netstrings, in the following order:
     #  "1", the version number of this format
     #  buildsetID, arbitrary string, used to find the buildSet later
     #  branch name, "" for default-branch
     #  base revision, "" for HEAD
     #  patchlevel, usually "1"
     #  patch
     #  builderNames...
     p = JobFileScanner()
     p.dataReceived(f.read())
     if p.error:
         raise BadJobfile("unable to parse netstrings")
     s = p.strings
     ver = s.pop(0)
     if ver != "1":
         raise BadJobfile("unknown version '%s'" % ver)
     buildsetID, branch, baserev, patchlevel, diff = s[:5]
     builderNames = s[5:]
     if branch == "":
         branch = None
     if baserev == "":
         baserev = None
     patchlevel = int(patchlevel)
     patch = (patchlevel, diff)
     ss = SourceStamp(branch, baserev, patch)
     return builderNames, ss, buildsetID
Esempio n. 22
0
 def _cbLoadedLocales(self, t, locales, reason, set_props):
     """
     This is the callback function that gets called once the list
     of locales are ready to be processed
     Let's fill the queues per builder and submit the BuildSets per each locale
     """
     log.msg("L10nMixin:: loaded locales' list")
     db = self.parent.db
     for locale in locales:
         # Ignore en-US. It appears in locales files but we do not repack it.
         if locale == "en-US":
             continue
         # Some locales should only be built on certain platforms, make sure to
         # obey those rules.
         if len(locales[locale]) > 0:
             if self.platform not in locales[locale]:
                 continue
         props = properties.Properties()
         props.updateFromProperties(self.properties)
         if set_props:
             props.updateFromProperties(set_props)
         #I do not know exactly what to pass as the source parameter
         props.update(dict(locale=locale), "Scheduler")
         props.setProperty("en_revision", self.baseTag, "L10nMixin")
         props.setProperty("l10n_revision", self.baseTag, "L10nMixin")
         log.msg('Submitted ' + locale + ' locale')
         # let's submit the BuildSet for this locale
         # Create a sourcestamp
         ss = SourceStamp(branch=self.branch)
         ssid = db.get_sourcestampid(ss, t)
         self.create_buildset(ssid, reason, t, props=props)
Esempio n. 23
0
    def fireTimer(self):
        # clear out our state
        self.timer = None
        self.nextBuildTime = None
        # Only build changes that are deemed important by self.fileIsImportant
        changes = self.importantChanges
        self.importantChanges = []
        self.unimportantChanges = []

        # Only add builders to the buildset that are currently online
        buildset_builderNames = []
        for builder_name in self.builderNames:
            # Get a builder from the BotMaster:
            try:
                builder = self.parent.botmaster.builders.get(builder_name)
            except AttributeError:
                # when this scheduler is used by the AnyBranchScheduler, botmaster is one level up from normal
                builder = self.parent.parent.botmaster.builders.get(builder_name)
                
            if builder.builder_status.getState()[0] == 'idle':
                buildset_builderNames.append(builder_name)

        # create a BuildSet, submit it to the BuildMaster
        bs = buildset.BuildSet(buildset_builderNames,
                               SourceStamp(changes=changes),
                               properties=self.properties)
        self.submitBuildSet(bs)
Esempio n. 24
0
    def processRequest(self, t):
        db = self.parent.db
        state = self.get_state(t)
        # Check for new builds completed since lastCheck
        lastCheck = state['lastCheck']
        remainingBuilders = state['remainingBuilders']

        n = now()
        newBuilds = self.findNewBuilds(db, t, lastCheck)
        state['lastCheck'] = n

        for builder, ssid in newBuilds:
            if builder in remainingBuilders:
                remainingBuilders.remove(builder)

        if remainingBuilders:
            state['remainingBuilders'] = remainingBuilders
        else:
            ss = SourceStamp(branch=self.branch)
            ssid = db.get_sourcestampid(ss, t)

            # Start a build!
            log.msg(
                '%s: new buildset: branch=%s, ssid=%s, builders: %s' \
                % (self.log_prefix, self.branch, ssid,
                   ', '.join(self.builderNames)))
            self.create_buildset(ssid, "downstream", t)

            # Reset the list of builders we're waiting for
            state = self.get_initial_state(None)

        self.set_state(t, state)
Esempio n. 25
0
 def startService(self):
     BaseUpstreamScheduler.startService(self)
     log.msg("starting l10n scheduler")
     if self.inipath is None:
         # testing, don't trigger tree builds
         return
     # trigger tree builds for our trees, clear() first
     cp = ConfigParser()
     cp.read(self.inipath)
     self.trees.clear()
     _ds = []
     for tree in cp.sections():
         # create a BuildSet, submit it to the BuildMaster
         props = properties.Properties()
         props.update({
                 'tree': tree,
                 'l10nbuilds': self.inipath,
                 },
                      "Scheduler")
         bs = buildset.BuildSet([self.treebuilder],
                                SourceStamp(),
                                properties=props)
         self.submitBuildSet(bs)
         _ds.append(bs.waitUntilFinished())
     d = defer.DeferredList(_ds)
     d.addCallback(self.onTreesBuilt)
     self.waitOnTree = d
Esempio n. 26
0
    def canBeMergedWith(self, other):
        if self.revision != other.revision:
            return False
        return SourceStamp.canBeMergedWith(self, other)


# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
Esempio n. 27
0
    def canBeMergedWith(self, other):
        if self.revision != other.revision:
            return False
        return SourceStamp.canBeMergedWith(self, other)


# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
Esempio n. 28
0
 def done(self, res):
     if not self.repository:
         self.repository = self.treetop
     # TODO: figure out the branch and project too
     ss = SourceStamp(self.branch, self.baserev, self.patch,
                      repository=self.repository)
     return ss
Esempio n. 29
0
        def send(res):
            # send some build requests
            ss = SourceStamp()
            reqs = []

            def append(buildstatus):
                builder_names.append(buildstatus.builder.name)

            for i in range(5):
                r = str(i)
                bss1 = self.control.submitBuildSet(["dummy1"], ss, reason=r)
                brs1 = bss1.getBuildRequests()[0]
                brs1.subscribe(append)
                complete_reqs.append(brs1)

                bss2 = self.control.submitBuildSet(["dummy2"], ss, reason=r)
                brs2 = bss2.getBuildRequests()[0]
                brs2.subscribe(append)
                incomplete_reqs.append(brs2)

                reqs.append(bss1.waitUntilFinished())  # only bss1, not bss2

            # now that all the requests are queued, connect the slave
            d = self.connectSlave(slavename='bot1',
                                  builders=['dummy1', 'dummy2'])
            # after they connect, wait for the builds to finish
            d.addCallback(lambda ign: defer.DeferredList(reqs))
            return d
Esempio n. 30
0
 def testMultipleStepInstances(self):
     steps = [
         (source.CVS, {
             'cvsroot': "root",
             'cvsmodule': "module"
         }),
         (shell.Configure, {
             'command': "./configure"
         }),
         (shell.Compile, {
             'command': "make"
         }),
         (shell.Compile, {
             'command': "make more"
         }),
         (shell.Compile, {
             'command': "make evenmore"
         }),
         (shell.Test, {
             'command': "make test"
         }),
         (shell.Test, {
             'command': "make testharder"
         }),
     ]
     f = factory.ConfigurableBuildFactory(steps)
     req = BuildRequest("reason", SourceStamp(), 'test_builder',
                        Properties())
     f.newBuild([req])
Esempio n. 31
0
    def ssFunc(scheduler, t):
        #### NOTE: called in a thread!
        db = scheduler.parent.db

        c = lastChange(db, t, branch)
        if not c:
            return None

        rev = c.revision
        log.msg("lastChange returned %s" % (rev))

        # Find the last revisions our scheduler's builders have built.  This can
        # include forced builds.
        last_built_revs = getLastBuiltRevisions(db, t, branch,
                                                scheduler.builderNames)
        log.msg("lastBuiltRevisions: %s" % last_built_revs)

        if last_built_revs:
            # Make sure that rev is newer than the last revision we built.
            later_rev = getLatestRev(db, t, branch, [rev] + last_built_revs)
            if later_rev in last_built_revs and not triggerBuildIfNoChanges:
                log.msg(
                    "lastGoodRev: Skipping %s since we've already built it" %
                    rev)
                return None
        return SourceStamp(branch=scheduler.branch, revision=rev)
Esempio n. 32
0
    def force(self, req, auth_ok=False):
        name = req.args.get("username", ["<unknown>"])[0]
        reason = req.args.get("comments", ["<no reason specified>"])[0]
        branch = req.args.get("branch", [""])[0]
        revision = req.args.get("revision", [""])[0]
        repository = req.args.get("repository", [""])[0]
        project = req.args.get("project", [""])[0]

        r = "The web-page 'force build' button was pressed by '%s': %s\n" \
            % (html.escape(name), html.escape(reason))
        log.msg("web forcebuild of builder '%s', branch='%s', revision='%s',"
                " repository='%s', project='%s' by user '%s'" %
                (self.builder_status.getName(), branch, revision, repository,
                 project, name))

        # check if this is allowed
        if not auth_ok:
            if not self.getAuthz(req).actionAllowed('forceBuild', req,
                                                    self.builder_status):
                log.msg("..but not authorized")
                return Redirect(path_to_authfail(req))

        # keep weird stuff out of the branch revision, and property strings.
        # TODO: centralize this somewhere.
        if not re.match(r'^[\w.+/~-]*$', branch):
            log.msg("bad branch '%s'" % branch)
            return Redirect(path_to_builder(req, self.builder_status))
        if not re.match(r'^[ \w\.\-\/]*$', revision):
            log.msg("bad revision '%s'" % revision)
            return Redirect(path_to_builder(req, self.builder_status))
        properties = getAndCheckProperties(req)
        if properties is None:
            return Redirect(path_to_builder(req, self.builder_status))
        if not branch:
            branch = None
        if not revision:
            revision = None

        # TODO: if we can authenticate that a particular User pushed the
        # button, use their name instead of None, so they'll be informed of
        # the results.
        # TODO2: we can authenticate that a particular User pushed the button
        # now, so someone can write this support. but it requires a
        # buildbot.changes.changes.Change instance which is tedious at this
        # stage to compute
        s = SourceStamp(branch=branch,
                        revision=revision,
                        project=project,
                        repository=repository)
        try:
            c = interfaces.IControl(self.getBuildmaster(req))
            bc = c.getBuilder(self.builder_status.getName())
            bc.submitBuildRequest(s, r, properties)
        except interfaces.NoSlaveError:
            # TODO: tell the web user that their request could not be
            # honored
            pass
        # send the user back to the builder page
        return Redirect(path_to_builder(req, self.builder_status))
Esempio n. 33
0
 def doBuild(self, buildername, reason="forced"):
     # we need to prevent these builds from being merged, so we create
     # each of them with a different revision specifier. The revision is
     # ignored because our build process does not have a source checkout
     # step.
     self.revision += 1
     ss = SourceStamp(revision=self.revision)
     return self.requestBuild(buildername, ss, reason)
Esempio n. 34
0
 def testAsDictEmpty(self):
     EXPECTED = {
         'revision': None,
         'branch':  None,
         'hasPatch': False,
         'changes': [],
       }
     self.assertEqual(EXPECTED, SourceStamp().asDict())
Esempio n. 35
0
    def doPeriodicBuild(self):
        # Schedule the next run
        self.setTimer()

        # And trigger a build
        bs = buildset.BuildSet(self.builderNames,
                               SourceStamp(branch=self.branch), self.reason)
        self.submit(bs)
Esempio n. 36
0
 def perspective_requestBuild(self, buildername, reason, branch, revision, properties={}):
     from buildbot.sourcestamp import SourceStamp
     c = interfaces.IControl(self.master)
     bc = c.getBuilder(buildername)
     ss = SourceStamp(branch, revision)
     bpr = Properties()
     bpr.update(properties, "remote requestBuild")
     return bc.submitBuildRequest(ss, reason, bpr)
Esempio n. 37
0
 def _send(res):
     # send some build requests
     reqs = []
     ss = SourceStamp()
     for i in range(5):
         bss = self.control.submitBuildSet(["dummy"], ss, reason=str(i))
         reqs.append(bss.waitUntilFinished())
     return defer.DeferredList(reqs)
Esempio n. 38
0
 def testAsDictBranch(self):
     EXPECTED = {
         'revision': 'Rev',
         'branch':  'Br',
         'hasPatch': False,
         'changes': [],
       }
     self.assertEqual(EXPECTED,
                      SourceStamp(branch='Br', revision='Rev').asDict())
Esempio n. 39
0
 def _triggerUpstream(self, res):
     log.msg("trigger upstream")
     ss = SourceStamp()
     upstream = [
         s for s in self.master.allSchedulers() if s.name == 's_upstream'
     ][0]
     d = upstream.trigger(ss)
     d.addCallback(self._gotBuild)
     return d
    def testNoRevision(self):
        c = Change(who="catlee",
                   files=["foo"],
                   comments="",
                   branch="b1",
                   revision=None)
        ss = SourceStamp(changes=[c])

        self.assertEquals(ss.revision, None)