예제 #1
0
 def test_sourceStamp(self):
     ss = dict(revision=9876, branch='dev')
     self.setupStep(trigger.Trigger(schedulerNames=['b'], sourceStamp=ss))
     self.expectOutcome(result=SUCCESS)
     self.expectTriggeredWith(b=(False, [ss], {}))
     return self.runStep()
예제 #2
0
 def test_no_schedulerNames(self):
     self.assertRaises(config.ConfigErrors, lambda:
                       trigger.Trigger())
예제 #3
0
 def test_sourceStamp_and_updateSourceStamp(self):
     with self.assertRaises(config.ConfigErrors):
         trigger.Trigger(schedulerNames=['c'],
                         sourceStamp=dict(x=1),
                         updateSourceStamp=True)
예제 #4
0
 def test_sourceStamp_and_alwaysUseLatest(self):
     with self.assertRaises(config.ConfigErrors):
         trigger.Trigger(schedulerNames=['c'],
                         sourceStamp=dict(x=1),
                         alwaysUseLatest=True)
예제 #5
0
    def addSimpleProject(self, name, category, repourl, builderconfigs):
        """Private.
        Add a project which builds when the source changes or when Force is clicked.

        """

        # FACTORIES
        # FIXME: get list of steps from buildshim here
        #factory = BuildFactory()
        # check out the source
        # This fails with git-1.8 and up unless you specify the branch, so do this down lower where we now the branch
        #factory.addStep(Git(repourl=repourl, mode='full', method='copy'))
        # for step in ["patch", "install_deps", "configure", "compile", "check", "package", "upload", "uninstall_deps"]:
        #    factory.addStep(ShellCommand(command=["../../srclink/" + name + "/buildshim", step], description=step))

        # BUILDERS AND SCHEDULERS
        # For each builder in config file, see what OS they want to
        # run on, and assign them to suitable slaves.
        # Also create a force scheduler that knows about all the builders.
        branchnames = []
        buildernames = []
        for builderconfig in builderconfigs:
            bparams = ''
            if "params" in builderconfig:
                bparams = builderconfig["params"].encode('ascii', 'ignore')
            bsuffix = ''
            if "suffix" in builderconfig:
                bsuffix = builderconfig["suffix"].encode('ascii', 'ignore')
            sbranch = builderconfig["branch"].encode('ascii', 'ignore')
            if sbranch not in branchnames:
                branchnames.append(sbranch)
            sosses = builderconfig["os"].encode('ascii', 'ignore').split('>')
            sosses.reverse()

            # The first OS in the list triggers when there's a source change
            sos = sosses.pop()
            buildername = name + '-' + sos + '-' + sbranch + bsuffix

            factory = self.addSimpleBuilder(name, buildername, category,
                                            repourl, builderconfig, sos,
                                            sbranch, bparams)
            self['schedulers'].append(
                SingleBranchScheduler(
                    name=buildername,
                    change_filter=filter.ChangeFilter(branch=sbranch,
                                                      repository=repourl),
                    treeStableTimer=1 *
                    60,  # Set this just high enough so you don't swamp the slaves, or to None if you don't want changes batched
                    builderNames=[buildername]))
            buildernames.append(buildername)

            # The rest of the OSes in the list, if any, are triggered when the previous OS in the list finishes
            while len(sosses) > 0:
                prev_factory = factory
                sos = sosses.pop()
                buildername = name + '-' + sos + '-' + sbranch + bsuffix
                factory = self.addSimpleBuilder(name, buildername, category,
                                                repourl, builderconfig, sos,
                                                sbranch, bparams)
                self['schedulers'].append(
                    triggerable.Triggerable(name=buildername,
                                            builderNames=[buildername]))
                prev_factory.addStep(
                    trigger.Trigger(schedulerNames=[buildername],
                                    waitForFinish=False))

        self['schedulers'].append(
            ForceScheduler(
                name=name + "-force",
                builderNames=buildernames,
                branch=FixedParameter(name="branch", default=""),
                revision=FixedParameter(name="revision", default=""),
                repository=FixedParameter(name="repository", default=""),
                project=FixedParameter(name="project", default=""),
                properties=[],
            ))

        # CHANGESOURCES
        # It's a git git git git git world
        already = False
        for cs in self['change_source']:
            if cs.repourl == repourl:
                log.msg(
                    "There's already a changesource for %s.  Hope it has the branch you wanted."
                    % cs.repourl)
                already = True
        if not already:
            self['change_source'].append(
                # Fuzz the interval to avoid slamming the git server and hitting the MaxStartups or MaxSessions limits
                # If you hit them, twistd.log will have lots of "ssh_exchange_identification: Connection closed by remote host" errors
                # See http://trac.buildbot.net/ticket/2480
                GitPoller(repourl,
                          branches=branchnames,
                          workdir='gitpoller-workdir-' + name,
                          pollinterval=60 + random.uniform(-10, 10)))
예제 #6
0
 def test_unimportantSchedulerNames_not_in_schedulerNames_but_rendered(
         self):
     # should not raise
     trigger.Trigger(schedulerNames=[properties.Interpolate('a')],
                     unimportantSchedulerNames=['b'])
예제 #7
0
 def test_sourceStamp(self):
     ss = dict(revision=9876, branch='dev')
     self.setupStep(trigger.Trigger(schedulerNames=['b'], sourceStamp=ss))
     self.expectOutcome(result=SUCCESS, status_text=['triggered', 'b'])
     self.expectTriggeredWith(b=({'': ss}, {}))
     return self.runStep()
예제 #8
0
 def test_sourceStamps_and_alwaysUseLatest(self):
     self.assertRaises(config.ConfigErrors, lambda:
                       trigger.Trigger(schedulerNames=['c'],
                                       sourceStamps=[dict(x=1), dict(x=2)],
                                       alwaysUseLatest=True))
예제 #9
0
 def test_simple(self):
     self.setupStep(trigger.Trigger(schedulerNames=['a'], sourceStamps={}))
     self.expectOutcome(result=SUCCESS, status_text=['triggered', 'a'])
     self.expectTriggeredWith(a=({}, {}))
     return self.runStep()
예제 #10
0
 def test_bogus_scheduler(self):
     self.setupStep(trigger.Trigger(schedulerNames=['a', 'x']))
     self.expectOutcome(result=FAILURE,
                        status_text=['not valid scheduler:', 'x'])
     self.expectTriggeredWith(a=None)  # a is not triggered!
     return self.runStep()
예제 #11
0
 def test_bogus_scheduler(self):
     self.setupStep(trigger.Trigger(schedulerNames=['a', 'x']))
     # bogus scheduler is an exception, not a failure (dont blame the patch)
     self.expectOutcome(result=EXCEPTION)
     self.expectTriggeredWith(a=None)  # a is not triggered!
     return self.runStep()
예제 #12
0
 def test_alwaysUseLatest(self):
     self.setupStep(
         trigger.Trigger(schedulerNames=['b'], alwaysUseLatest=True))
     self.expectOutcome(result=SUCCESS, status_text=['triggered', 'b'])
     self.expectTriggeredWith(b=(None, {}))
     return self.runStep()
예제 #13
0
 def test_updateSourceStamp_no_prop(self):
     self.setupStep(
         trigger.Trigger(schedulerNames=['a'], updateSourceStamp=True))
     self.expectOutcome(result=SUCCESS, status_text=['triggered', 'a'])
     self.expectTriggeredWith(a=(self.THIS_SS_SETID, {}))
     return self.runStep()
예제 #14
0
 def test_sourceStamps_and_updateSourceStamp(self):
     self.assertRaises(config.ConfigErrors, lambda:
                       trigger.Trigger(schedulerNames=['c'],
                                       sourceStamps=[dict(x=1), dict(x=2)],
                                       updateSourceStamp=True))
예제 #15
0
 def __init__(self, platform, configuration, architectures, triggers=None, additionalArguments=None, SVNMirror=None, **kwargs):
     TestFactory.__init__(self, platform, configuration, architectures, additionalArguments, SVNMirror, **kwargs)
     if triggers:
         self.addStep(ArchiveBuiltProduct())
         self.addStep(UploadBuiltProduct())
         self.addStep(trigger.Trigger(schedulerNames=triggers))
예제 #16
0
 def test_updateSourceStamp_and_alwaysUseLatest(self):
     self.assertRaises(config.ConfigErrors, lambda:
                       trigger.Trigger(schedulerNames=['c'],
                                       updateSourceStamp=True, alwaysUseLatest=True))
예제 #17
0
 def test_no_schedulerNames(self):
     with self.assertRaises(config.ConfigErrors):
         trigger.Trigger()
예제 #18
0
 def test_simple(self):
     self.setupStep(trigger.Trigger(schedulerNames=['a'], sourceStamps={}))
     self.expectOutcome(result=SUCCESS, state_string='triggered a')
     self.expectTriggeredWith(a=(False, [], {}))
     return self.runStep()
예제 #19
0
 def test_unimportantSchedulerNames_not_in_schedulerNames(self):
     with self.assertRaises(config.ConfigErrors):
         trigger.Trigger(schedulerNames=['a'],
                         unimportantsShedulerNames=['b'])
예제 #20
0
def getLLDBScriptCommandsFactory(
    downloadBinary=True,
    buildAndroid=False,
    runTest=True,
    scriptExt='.sh',
    extra_cmake_args=None,
    depends_on_projects=None,
):
    if scriptExt is '.bat':
        pathSep = '.\\'
    else:
        pathSep = './'

    if extra_cmake_args is None:
        extra_cmake_args = []

    if depends_on_projects is None:
        f = buildbot.process.factory.BuildFactory()
    else:
        f = LLVMBuildFactory(depends_on_projects=depends_on_projects)

    # Update scripts
    getShellCommandStep(f,
                        name='update scripts',
                        command=['updateScripts' + scriptExt])

    # Acquire lock
    if downloadBinary:
        getShellCommandStep(
            f,
            name='acquire lock',
            command=[pathSep + 'acquireLock' + scriptExt, 'totBuild'],
            description='get')

    # Checkout source code
    getShellCommandStep(f,
                        name='checkout source code',
                        command=[
                            pathSep + 'checkoutSource' + scriptExt,
                            WithProperties('%(revision)s')
                        ])

    # Set source revision
    f.addStep(
        SetProperty(name="set revision",
                    command=[pathSep + 'getRevision' + scriptExt],
                    property="got_revision",
                    workdir="scripts"))

    # Configure
    getShellCommandStep(f,
                        name='cmake local',
                        command=[pathSep + 'cmake' + scriptExt] +
                        extra_cmake_args)

    # Build
    getShellCommandStep(f,
                        name='ninja build local',
                        command=[pathSep + 'buildLocal' + scriptExt])
    if buildAndroid:
        getShellCommandStep(f,
                            name='build android',
                            command=[pathSep + 'buildAndroid' + scriptExt])

    # Get lldb-server binaries
    if downloadBinary:
        getShellCommandStep(f,
                            name='get lldb-server binaries',
                            command=[
                                pathSep + 'downloadBinaries' + scriptExt,
                                WithProperties('%(got_revision)s')
                            ])

    # Test
    if runTest:
        f.addStep(
            LitTestCommand(name="run unit tests",
                           command=[pathSep + 'testUnit' + scriptExt],
                           description=["testing"],
                           descriptionDone=["unit test"],
                           workdir='scripts'))
        getTestSteps(f, scriptExt, pathSep)
        # upload test traces
        getShellCommandStep(f,
                            name='upload test traces',
                            command=[
                                pathSep + 'uploadTestTrace' + scriptExt,
                                WithProperties('%(buildnumber)s'),
                                WithProperties('%(buildername)s')
                            ],
                            flunkOnFailure=False)

    # Upload lldb-server binaries and trigger android builders
    if buildAndroid:
        getShellCommandStep(f,
                            name='upload lldb-server binaries',
                            command=[pathSep + 'uploadBinaries' + scriptExt])
        f.addStep(
            trigger.Trigger(schedulerNames=['lldb_android_scheduler'],
                            updateSourceStamp=False,
                            waitForFinish=False))
    # Release lock
    if downloadBinary:
        getShellCommandStep(
            f,
            name='release lock',
            command=[pathSep + 'releaseLock' + scriptExt, 'totBuild'],
            description='release',
            alwaysRun=True)
    return f
예제 #21
0
    def test_interruptConnectionLostShouldRetry(self):
        self.master = fakemaster.FakeMaster()
        self.master.maybeStartBuildsForSlave = lambda slave: True

        self.master.db = fakedb.FakeDBConnector(self)

        rows = [fakedb.SourceStampSet(id=1),
                fakedb.SourceStamp(id=1, sourcestampsetid=1, codebase='c', branch="az", repository="xz", revision="ww"),
                fakedb.Buildset(id=1, reason='because', sourcestampsetid=1),
                fakedb.BuildRequest(id=1, buildsetid=1, buildername="bldr", submitted_at=130000)]

        yield self.master.db.insertTestData(rows)

        self.master.status = master.Status(self.master)
        self.master.config.buildbotURL = "baseurl/"

        self.scheduler_a = a = FakeTriggerable(name='a')
        self.scheduler_b = b = FakeTriggerable(name='b')
        def allSchedulers():
            return [a, b]
        self.master.allSchedulers = allSchedulers

        self.factory = factory.BuildFactory()
        self.step = trigger.Trigger(schedulerNames=['a'], waitForFinish=True)
        self.step.addCompleteLog = lambda x,y: True


        self.factory.addStep(self.step)
        config_args = dict(name="bldr", slavename="slv", builddir="bdir",
                     slavebuilddir="sbdir", project='default', factory=self.factory)
        builder_config = config.BuilderConfig(**config_args)

        self.bldr = Builder(builder_config.name, _addServices=False)
        self.bldr.master = self.master
        self.bldr.botmaster = self.master.botmaster

        mastercfg = config.MasterConfig()
        mastercfg.builders = [ builder_config ]

        self.bldr.startService()
        yield self.bldr.reconfigService(mastercfg)

        def newBuild(buildrequests):
            self.build = Build(buildrequests)
            self.build.setStepFactories([fakebuild.FakeStepFactory(self.step)])
            return self.build

        self.bldr.config.factory.newBuild = newBuild

        self.bldr.notifyRequestsRemoved = lambda x: True

        sb = Mock(spec=['isAvailable'], name='test-slave-1')
        sb.name = 'test-slave-1'
        sb.isAvailable.return_value = 1
        sb.slave = Mock()
        sb.slave.updateStatusBuildFinished = lambda result, build: result
        sb.slave.properties = properties.Properties()
        sb.prepare = lambda x, y: True
        sb.ping = lambda timeout: True
        sb.buildStarted = lambda: True
        sb.buildFinished = lambda _: False
        sb.setSlaveIdle = lambda: False
        sb.remote = Mock()
        self.bldr.slaves.append(sb)

        self.assertEqual(self.master.db.buildrequests.claims, {})
        from buildbot.process import buildrequestdistributor
        self.brd = buildrequestdistributor.BuildRequestDistributor(self.master.botmaster)
        self.brd.startService()

        yield self.brd._maybeStartBuildsOnBuilder(self.bldr)

        self.assertEqual(self.master.db.buildrequests.claims[1].brid, 1)
        self.build.build_status.saveYourself = lambda: True
        self.build.currentStep.start()
        self.build.lostRemote()
        self.assertEqual(self.master.db.buildrequests.claims, {})

        if self.brd.running:
            self.brd.stopService()