Exemplo n.º 1
0
    def test_addBuildsetForSourceStamp_list_of_renderable_builderNames(self):
        names = ['a', 'b', properties.Interpolate('%(prop:extra_builder)s')]
        sched = self.makeScheduler(name='n', builderNames=names)

        self.master.db.insertTestData([
            fakedb.Builder(id=1, name='a'),
            fakedb.Builder(id=2, name='b'),
            fakedb.Builder(id=3, name='c'),
            fakedb.SourceStamp(id=98, branch='stable'),
            fakedb.Change(changeid=25, sourcestampid=98, branch='stable'),
            fakedb.ChangeProperty(changeid=25, property_name='extra_builder',
                                  property_value='["c","Change"]'),
        ])

        bsid, brids = yield sched.addBuildsetForSourceStamps(reason='whynot',
                                                             waited_for=False,
                                                             sourcestamps=[98])
        self.assertEqual((bsid, brids), self.exp_bsid_brids)
        self.master.data.updates.addBuildset.assert_called_with(
            waited_for=False,
            builderids=[1, 2, 3],
            external_idstring=None,
            properties={
                'scheduler': ('n', 'Scheduler'),
                'extra_builder': ('c', 'Change')},
            reason='whynot',
            scheduler='n',
            sourcestamps=[98])
Exemplo n.º 2
0
 def test_renderable_workdir(self):
     self.setupStep(
         shell.SetPropertyFromCommand(
             property="res",
             command="cmd",
             workdir=properties.Interpolate('wkdir')))
     self.expectCommands(
         ExpectShell(workdir='wkdir', usePTY='slave-config', command="cmd")
         + ExpectShell.log('stdio', stdout='\n\nabcdef\n') + 0)
     self.expectOutcome(result=SUCCESS, state_string="property 'res' set")
     self.expectProperty("res", "abcdef")  # note: stripped
     self.expectLogfile('property changes', r"res: u'abcdef'")
     return self.runStep()
Exemplo n.º 3
0
 def test_renderable_workdir(self):
     self.setup_step(
         shell.SetPropertyFromCommand(
             property="res",
             command="cmd",
             workdir=properties.Interpolate('wkdir')))
     self.expect_commands(
         ExpectShell(workdir='wkdir',
                     command="cmd").stdout('\n\nabcdef\n').exit(0))
     self.expect_outcome(result=SUCCESS, state_string="property 'res' set")
     self.expect_property("res", "abcdef")  # note: stripped
     self.expect_log_file('property changes', r"res: " + repr('abcdef'))
     return self.run_step()
Exemplo n.º 4
0
    def __init__(self, workdir=None, mode='update', alwaysUseLatest=False,
                 timeout=20 * 60, retry=None, env=None, logEnviron=True,
                 description=None, descriptionDone=None, descriptionSuffix=None,
                 codebase='', **kwargs):
        """
        @type  workdir: string
        @param workdir: local directory (relative to the Builder's root)
                        where the tree should be placed

        @type  alwaysUseLatest: boolean
        @param alwaysUseLatest: whether to always update to the most
        recent available sources for this build.

        Normally the Source step asks its Build for a list of all
        Changes that are supposed to go into the build, then computes a
        'source stamp' (revision number or timestamp) that will cause
        exactly that set of changes to be present in the checked out
        tree. This is turned into, e.g., 'cvs update -D timestamp', or
        'svn update -r revnum'. If alwaysUseLatest=True, bypass this
        computation and always update to the latest available sources
        for each build.

        The source stamp helps avoid a race condition in which someone
        commits a change after the master has decided to start a build
        but before the worker finishes checking out the sources. At best
        this results in a build which contains more changes than the
        buildmaster thinks it has (possibly resulting in the wrong
        person taking the blame for any problems that result), at worst
        is can result in an incoherent set of sources (splitting a
        non-atomic commit) which may not build at all.

        @type logEnviron: boolean
        @param logEnviron: If this option is true (the default), then the
                           step's logfile will describe the environment
                           variables on the worker. In situations where the
                           environment is not relevant and is long, it may
                           be easier to set logEnviron=False.

        @type codebase: string
        @param codebase: Specifies which changes in a build are processed by
        the step. The default codebase value is ''. The codebase must correspond
        to a codebase assigned by the codebaseGenerator. If no codebaseGenerator
        is defined in the master then codebase doesn't need to be set, the
        default value will then match all changes.
        """

        descriptions_for_mode = {
            "clobber": "checkout",
            "export": "exporting"}
        descriptionDones_for_mode = {
            "clobber": "checkout",
            "export": "export"}

        if not description:
            description = [descriptions_for_mode.get(mode, "updating")]
        if not descriptionDone:
            descriptionDone = [descriptionDones_for_mode.get(mode, "update")]
        if not descriptionSuffix and codebase:
            descriptionSuffix = [codebase]

        LoggingBuildStep.__init__(self, description=description,
                                  descriptionDone=descriptionDone, descriptionSuffix=descriptionSuffix,
                                  **kwargs)

        # This will get added to args later, after properties are rendered
        self.workdir = workdir

        self.sourcestamp = None

        self.codebase = codebase
        if self.codebase:
            self.name = properties.Interpolate(
                "%(kw:name)s-%(kw:codebase)s",
                name=self.name, codebase=self.codebase)

        self.alwaysUseLatest = alwaysUseLatest

        self.logEnviron = logEnviron
        self.env = env
        self.timeout = timeout
        self.retry = retry
Exemplo n.º 5
0
 def test_unimportantSchedulerNames_not_in_schedulerNames_but_rendered(
         self):
     # should not raise
     trigger.Trigger(schedulerNames=[properties.Interpolate('a')],
                     unimportantSchedulerNames=['b'])