Exemple #1
0
def local_workers():
    workers = []
    for i in range(util.env.MAX_LOCAL_WORKERS):
        worker_ = LocalWorker('lw%03d-%s' % (i, util.env.SUFFIX))
        # Hack to fix a bug stating that LocalWorkers
        # do not have a valid path_module
        worker_.path_module = namedModule('posixpath')
        workers.append(worker_)
    return workers
def masterConfig():
    global path_to_repo
    from buildbot_travis import TravisConfigurator
    path_to_repo = os.path.dirname(buildbot.__file__)
    while not os.path.exists(os.path.join(path_to_repo, ".git")) and len(path_to_repo) > 1:
        path_to_repo = os.path.dirname(path_to_repo)
    with open("sample.yml", "w") as f:
        f.write(sample_yml % dict(path_to_repo=path_to_repo))
    c = {}
    c['workers'] = [LocalWorker("local2"), LocalWorker("local3")]
    TravisConfigurator(c, os.getcwd()).fromYaml("sample.yml")
    return c
Exemple #3
0
    def configure(self, config_dict):
        if self.logHorizon is None:
            return
        logHorizon = self.logHorizon
        hour = self.hour
        kwargs = self.kwargs

        ConfiguratorBase.configure(self, config_dict)
        nightly_kwargs = {}

        # we take the defaults of Nightly, except for hour
        for arg in ('minute', 'dayOfMonth', 'month', 'dayOfWeek'):
            if arg in kwargs:
                nightly_kwargs[arg] = kwargs[arg]

        self.schedulers.append(
            Nightly(name=JANITOR_NAME,
                    builderNames=[JANITOR_NAME],
                    hour=hour,
                    **nightly_kwargs))

        self.builders.append(
            BuilderConfig(
                name=JANITOR_NAME,
                workername=JANITOR_NAME,
                factory=BuildFactory(
                    steps=[LogChunksJanitor(logHorizon=logHorizon)])))
        self.protocols.setdefault('null', {})
        self.workers.append(LocalWorker(JANITOR_NAME))
Exemple #4
0
    def configure(self, config_dict):
        steps = []
        if self.logHorizon is not None:
            steps.append(LogChunksJanitor(logHorizon=self.logHorizon))
        if self.build_data_horizon is not None:
            steps.append(BuildDataJanitor(build_data_horizon=self.build_data_horizon))

        if not steps:
            return

        hour = self.hour
        kwargs = self.kwargs

        super().configure(config_dict)
        nightly_kwargs = {}

        # we take the defaults of Nightly, except for hour
        for arg in ('minute', 'dayOfMonth', 'month', 'dayOfWeek'):
            if arg in kwargs:
                nightly_kwargs[arg] = kwargs[arg]

        self.schedulers.append(Nightly(
            name=JANITOR_NAME, builderNames=[JANITOR_NAME], hour=hour, **nightly_kwargs))

        self.schedulers.append(ForceScheduler(
            name=JANITOR_NAME + "_force",
            builderNames=[JANITOR_NAME]))

        self.builders.append(BuilderConfig(
            name=JANITOR_NAME, workername=JANITOR_NAME, factory=BuildFactory(steps=steps)
        ))
        self.protocols.setdefault('null', {})
        self.workers.append(LocalWorker(JANITOR_NAME))
Exemple #5
0
    def test_local_worker_max_builds(self):
        """
        If max_builds is set, only one build is started on a worker
        at a time.
        """
        step_controller = StepController()
        config_dict = {
            'builders': [
                BuilderConfig(
                    name="testy-1",
                    workernames=["local"],
                    factory=BuildFactory([step_controller]),
                ),
                BuilderConfig(
                    name="testy-2",
                    workernames=["local"],
                    factory=BuildFactory([step_controller]),
                ),
            ],
            'workers': [LocalWorker('local', max_builds=1)],
            'protocols': {
                'null': {}
            },
            'multiMaster':
            True,
        }
        self.master = master = self.successResultOf(
            getMaster(self, self.reactor, config_dict))
        builder_ids = [
            self.successResultOf(master.data.updates.findBuilderId('testy-1')),
            self.successResultOf(master.data.updates.findBuilderId('testy-2')),
        ]

        started_builds = []
        self.successResultOf(
            master.mq.startConsuming(
                lambda key, build: started_builds.append(build),
                ('builds', None, 'new')))

        # Trigger a buildrequest
        bsid, brids = self.successResultOf(
            master.data.updates.addBuildset(
                waited_for=False,
                builderids=builder_ids,
                sourcestamps=[
                    {
                        'codebase': '',
                        'repository': '',
                        'branch': None,
                        'revision': None,
                        'project': ''
                    },
                ],
            ))

        self.assertEqual(len(started_builds), 1)
Exemple #6
0
 def createLocalWorker(self, name, **kwargs):
     workdir = FilePath(self.mktemp())
     workdir.createDirectory()
     return LocalWorker(name, workdir.path, **kwargs)