def setUp(self): self.buildroot = os.path.join(self.tempdir, 'buildroot') osutils.SafeMakedirs(self.buildroot) # Always stub RunCommmand out as we use it in every method. self.site_config = config_lib_unittest.MockSiteConfig() self.build_config = config_lib_unittest.MockBuildConfig() self.bot_id = self.build_config.name self.build_config['master'] = False self.build_config['important'] = False # Use the cbuildbot parser to create properties and populate default values. self.parser = cbuildbot._CreateParser() argv = ['-r', self.buildroot, '--buildbot', '--debug', self.bot_id] self.options, _ = cbuildbot._ParseCommandLine(self.parser, argv) self.options.bootstrap = False self.options.clean = False self.options.resume = False self.options.sync = False self.options.build = False self.options.uprev = False self.options.tests = False self.options.archive = False self.options.remote_test_status = False self.options.patches = None self.options.prebuilts = False self._manager = parallel.Manager() self._manager.__enter__() self.run = cbuildbot_run.BuilderRun(self.options, self.site_config, self.build_config, self._manager) self.rc.AddCmdResult( [constants.PATH_TO_CBUILDBOT, '--reexec-api-version'], output=constants.REEXEC_API_VERSION)
def testGenSchedulerJob(self): """Test the job creation helper.""" build_config = config_lib_unittest.MockBuildConfig().apply( schedule='funky schedule' ) expected = """ job { id: "amd64-generic-release" acl_sets: "default" schedule: "funky schedule" buildbucket: { server: "cr-buildbucket.appspot.com" bucket: "luci.chromeos.general" builder: "LegacyRelease" tags: "cbb_branch:master" tags: "cbb_config:amd64-generic-release" tags: "cbb_display_label:MockLabel" properties: "cbb_branch:master" properties: "cbb_config:amd64-generic-release" properties: "cbb_display_label:MockLabel" properties: "cbb_extra_args:[\\"--buildbot\\"]" } } """ result = gen_luci_scheduler.genSchedulerJob(build_config) self.assertEqual(result, expected)