Пример #1
0
    def setUp(self):
        self.root = self.tempdir
        self.buildroot = self.MakeTestRootDir('build_root')
        self.sourceroot = self.MakeTestRootDir('source_root')
        self.trybot_root = self.MakeTestRootDir('trybot')
        self.trybot_internal_root = self.MakeTestRootDir('trybot-internal')
        self.external_marker = os.path.join(self.trybot_root, '.trybot')
        self.internal_marker = os.path.join(self.trybot_internal_root,
                                            '.trybot')

        os.makedirs(os.path.join(self.sourceroot, '.repo', 'manifests'))
        os.makedirs(os.path.join(self.sourceroot, '.repo', 'repo'))

        # Create the parser before we stub out os.path.exists() - which the parser
        # creation code actually uses.
        parser = cbuildbot._CreateParser()

        # Stub out all relevant methods regardless of whether they are called in the
        # specific test case.  We can do this because we don't run VerifyAll() at
        # the end of every test.
        self.mox.StubOutWithMock(optparse.OptionParser, 'error')
        self.mox.StubOutWithMock(cros_build_lib, 'IsInsideChroot')
        self.mox.StubOutWithMock(cbuildbot, '_CreateParser')
        self.mox.StubOutWithMock(sys, 'exit')
        self.mox.StubOutWithMock(cros_build_lib, 'GetInput')
        self.mox.StubOutWithMock(cbuildbot, '_RunBuildStagesWrapper')

        parser.error(mox.IgnoreArg()).InAnyOrder().AndRaise(
            TestExitedException())
        cros_build_lib.IsInsideChroot().InAnyOrder().AndReturn(False)
        cbuildbot._CreateParser().InAnyOrder().AndReturn(parser)
        sys.exit(mox.IgnoreArg()).InAnyOrder().AndRaise(TestExitedException())
        cbuildbot._RunBuildStagesWrapper(
            mox.IgnoreArg(), mox.IgnoreArg()).InAnyOrder().AndReturn(True)
Пример #2
0
  def setUp(self):
    self.root = self.tempdir
    self.buildroot = self.MakeTestRootDir('build_root')
    self.sourceroot = self.MakeTestRootDir('source_root')
    self.trybot_root = self.MakeTestRootDir('trybot')
    self.trybot_internal_root = self.MakeTestRootDir('trybot-internal')
    self.external_marker = os.path.join(self.trybot_root, '.trybot')
    self.internal_marker = os.path.join(self.trybot_internal_root, '.trybot')

    os.makedirs(os.path.join(self.sourceroot, '.repo', 'manifests'))
    os.makedirs(os.path.join(self.sourceroot, '.repo', 'repo'))

    # Create the parser before we stub out os.path.exists() - which the parser
    # creation code actually uses.
    parser = cbuildbot._CreateParser()

    # Stub out all relevant methods regardless of whether they are called in the
    # specific test case.  We can do this because we don't run VerifyAll() at
    # the end of every test.
    self.mox.StubOutWithMock(optparse.OptionParser, 'error')
    self.mox.StubOutWithMock(cros_build_lib, 'IsInsideChroot')
    self.mox.StubOutWithMock(cbuildbot, '_CreateParser')
    self.mox.StubOutWithMock(sys, 'exit')
    self.mox.StubOutWithMock(cros_build_lib, 'GetInput')
    self.mox.StubOutWithMock(cbuildbot, '_RunBuildStagesWrapper')

    parser.error(mox.IgnoreArg()).InAnyOrder().AndRaise(TestExitedException())
    cros_build_lib.IsInsideChroot().InAnyOrder().AndReturn(False)
    cbuildbot._CreateParser().InAnyOrder().AndReturn(parser)
    sys.exit(mox.IgnoreArg()).InAnyOrder().AndRaise(TestExitedException())
    cbuildbot._RunBuildStagesWrapper(
        mox.IgnoreArg(),
        mox.IgnoreArg()).InAnyOrder().AndReturn(True)
    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)
Пример #4
0
  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.bot_id = 'x86-generic-paladin'
    self.build_config = config.config[self.bot_id]
    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',
            'x86-generic-paladin']
    (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.mox.StubOutWithMock(stages.SyncStage, 'HandleSkip')
    stages.SyncStage.HandleSkip()
Пример #5
0
    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.bot_id = 'x86-generic-paladin'
        self.build_config = config.config[self.bot_id]
        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',
            'x86-generic-paladin'
        ]
        (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.mox.StubOutWithMock(stages.SyncStage, 'HandleSkip')
        stages.SyncStage.HandleSkip()
Пример #6
0
  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.bot_id = 'x86-generic-paladin'
    self.build_config = copy.deepcopy(cbuildbot_config.GetConfig()[self.bot_id])
    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',
            'x86-generic-paladin']
    (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.build_config,
                                        self._manager)

    self.rc.AddCmdResult(
        [constants.PATH_TO_CBUILDBOT, '--reexec-api-version'],
        output=constants.REEXEC_API_VERSION)
Пример #7
0
    def testIsDistributedBuilder(self):
        """Tests for _IsDistributedBuilder() under various configurations."""
        parser = cbuildbot._CreateParser()
        argv = ['--buildroot', '/foo', 'amd64-generic-paladin']
        options = cbuildbot.ParseCommandLine(parser, argv)
        options.buildbot = False

        build_config = dict(manifest_version=False)
        chrome_rev = None

        def _TestConfig(expected):
            self.assertEqual(
                expected,
                cbuildbot._IsDistributedBuilder(options=options,
                                                chrome_rev=chrome_rev,
                                                build_config=build_config))

        # Default options.
        _TestConfig(False)

        build_config['manifest_version'] = True
        # Not running in buildbot mode even though manifest_version=True.
        _TestConfig(False)
        options.buildbot = True
        _TestConfig(True)

        for chrome_rev in (constants.CHROME_REV_TOT,
                           constants.CHROME_REV_LOCAL,
                           constants.CHROME_REV_SPEC):
            _TestConfig(False)
Пример #8
0
    def _initConfig(self,
                    bot_id,
                    extra_argv=None,
                    override_hw_test_config=None):
        """Return normal options/build_config for |bot_id|"""
        site_config = chromeos_config.GetConfig()
        build_config = copy.deepcopy(site_config[bot_id])
        build_config['master'] = False
        build_config['important'] = False

        # Use the cbuildbot parser to create properties and populate default values.
        parser = cbuildbot._CreateParser()
        argv = (
            ['-r', self.buildroot, '--buildbot', '--debug', '--nochromesdk'] +
            (extra_argv if extra_argv else []) + [bot_id])
        options, _ = cbuildbot._ParseCommandLine(parser, argv)

        # Yikes.
        options.managed_chrome = build_config['sync_chrome']

        # Iterate through override and update HWTestConfig attributes.
        if override_hw_test_config:
            for key, val in override_hw_test_config.iteritems():
                for hw_test in build_config.hw_tests:
                    setattr(hw_test, key, val)

        return cbuildbot_run.BuilderRun(options, site_config, build_config,
                                        self._manager)
    def _initConfig(self, bot_id, extra_argv=None, override_hw_test_config=None):
        """Return normal options/build_config for |bot_id|"""
        site_config = chromeos_config.GetConfig()
        build_config = copy.deepcopy(site_config[bot_id])
        build_config["master"] = False
        build_config["important"] = False

        # Use the cbuildbot parser to create properties and populate default values.
        parser = cbuildbot._CreateParser()
        argv = (
            ["-r", self.buildroot, "--buildbot", "--debug", "--nochromesdk"]
            + (extra_argv if extra_argv else [])
            + [bot_id]
        )
        options, _ = cbuildbot._ParseCommandLine(parser, argv)

        # Yikes.
        options.managed_chrome = build_config["sync_chrome"]

        # Iterate through override and update HWTestConfig attributes.
        if override_hw_test_config:
            for key, val in override_hw_test_config.iteritems():
                for hw_test in build_config.hw_tests:
                    setattr(hw_test, key, val)

        return cbuildbot_run.BuilderRun(options, site_config, build_config, self._manager)
  def testIsDistributedBuilder(self):
    """Tests for _IsDistributedBuilder() under various configurations."""
    parser = cbuildbot._CreateParser()
    argv = ['x86-generic-paladin']
    (options, _) = cbuildbot._ParseCommandLine(parser, argv)
    options.buildbot = False

    build_config = dict(pre_cq=False,
                        manifest_version=False)
    chrome_rev = None

    def _TestConfig(expected):
      self.assertEquals(expected,
                        cbuildbot._IsDistributedBuilder(
                            options=options,
                            chrome_rev=chrome_rev,
                            build_config=build_config))

    # Default options.
    _TestConfig(False)

    build_config['pre_cq'] = True
    _TestConfig(True)

    build_config['pre_cq'] = False
    build_config['manifest_version'] = True
    # Not running in buildbot mode even though manifest_version=True.
    _TestConfig(False)
    options.buildbot = True
    _TestConfig(True)

    for chrome_rev in (constants.CHROME_REV_TOT,
                       constants.CHROME_REV_LOCAL,
                       constants.CHROME_REV_SPEC):
      _TestConfig(False)
  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.bot_id = 'x86-generic-paladin'
    self.build_config = copy.deepcopy(config.config[self.bot_id])
    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',
            'x86-generic-paladin']
    (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 = cbuildbot.parallel.Manager()
    self._manager.__enter__()
    self.run = cbuildbot_run.BuilderRun(self.options, self.build_config,
                                        self._manager)

    self.StartPatcher(BuilderRunMock())
    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)
Пример #13
0
 def setUp(self):
   self.parser = cbuildbot._CreateParser()
   args = ['-r', '/tmp/test_build1', '-g', '5555', '-g',
           '6666', '--remote']
   args.extend(self.BOTS)
   self.options, args = cbuildbot._ParseCommandLine(self.parser, args)
   self.checkout_dir = os.path.join(self.tempdir, 'test_checkout')
   self.int_mirror, self.ext_mirror = None, None
Пример #14
0
 def setUp(self):
     # pylint: disable=protected-access
     self.parser = cbuildbot._CreateParser()
     args = ["-r", "/tmp/test_build1", "-g", "5555", "-g", "6666", "--remote"]
     args.extend(self.BOTS)
     self.options, args = cbuildbot._ParseCommandLine(self.parser, args)
     self.options.cache_dir = self.tempdir
     self.checkout_dir = os.path.join(self.tempdir, "test_checkout")
     self.int_mirror, self.ext_mirror = None, None
Пример #15
0
 def setUp(self):
     self.parser = cbuildbot._CreateParser()
     args = [
         '-r', '/tmp/test_build1', '-g', '5555', '-g', '6666', '--remote'
     ]
     args.extend(self.BOTS)
     self.options, args = cbuildbot._ParseCommandLine(self.parser, args)
     self.checkout_dir = os.path.join(self.tempdir, 'test_checkout')
     self.int_mirror, self.ext_mirror = None, None
 def setUp(self):
   # pylint: disable=protected-access
   self.site_config = config_lib_unittest.MockSiteConfig()
   self.parser = cbuildbot._CreateParser()
   args = ['-r', '/tmp/test_build1', '-g', '5555', '-g',
           '6666', '--remote']
   args.extend(self.BOTS)
   self.options, args = cbuildbot._ParseCommandLine(self.parser, args)
   self.options.cache_dir = self.tempdir
   self.checkout_dir = os.path.join(self.tempdir, 'test_checkout')
   self.int_mirror, self.ext_mirror = None, None
Пример #17
0
 def setUp(self):
   # pylint: disable=protected-access
   self.site_config = config_lib_unittest.MockSiteConfig()
   self.parser = cbuildbot._CreateParser()
   args = ['-r', '/tmp/test_build1', '-g', '5555', '-g',
           '6666', '--remote']
   args.extend(self.BOTS)
   self.options, args = cbuildbot._ParseCommandLine(self.parser, args)
   self.options.cache_dir = self.tempdir
   self.checkout_dir = os.path.join(self.tempdir, 'test_checkout')
   self.int_mirror, self.ext_mirror = None, None
  def _InitConfig(self, bot_id, extra_argv=None):
    """Return normal options/build_config for |bot_id|"""
    build_config = self.site_config[bot_id]

    # Use the cbuildbot parser to create properties and populate default values.
    parser = cbuildbot._CreateParser()
    argv = (['--buildbot',
             '--buildroot', self.buildroot,
             '--workspace', self.workspace] +
            (extra_argv if extra_argv else []) + [bot_id])
    options = cbuildbot.ParseCommandLine(parser, argv)

    return cbuildbot_run.BuilderRun(
        options, self.site_config, build_config, self._manager)
  def _initConfig(self, bot_id, extra_argv=None):
    """Return normal options/build_config for |bot_id|"""
    build_config = copy.deepcopy(config.config[bot_id])
    build_config['master'] = False
    build_config['important'] = False

    # Use the cbuildbot parser to create properties and populate default values.
    parser = cbuildbot._CreateParser()
    argv = (['-r', self.buildroot, '--buildbot', '--debug', '--nochromesdk'] +
            (extra_argv if extra_argv else []) + [bot_id])
    (options, _) = cbuildbot._ParseCommandLine(parser, argv)

    # Yikes.
    options.managed_chrome = build_config['sync_chrome']

    return cbuildbot_run.BuilderRun(options, build_config, self._manager)
    def _Prepare(self,
                 bot_id=None,
                 extra_config=None,
                 cmd_args=None,
                 extra_cmd_args=None,
                 build_id=DEFAULT_BUILD_ID,
                 master_build_id=None,
                 buildbucket_id=None,
                 site_config=None):
        """Prepare a BuilderRun at self._run for this test.

    This method must allow being called more than once.  Subclasses can
    override this method, but those subclass methods should also call this one.

    The idea is that all test preparation that falls out from the choice of
    build config and cbuildbot options should go in _Prepare.

    This will populate the following attributes on self:
      run: A BuilderRun object.
      bot_id: The bot id (name) that was used from the site_config.
      self._boards: Same as self._run.config.boards.  TODO(mtennant): remove.
      self._current_board: First board in list, if there is one.

    Args:
      bot_id: Name of build config to use, defaults to self.BOT_ID.
      extra_config: Dict used to add to the build config for the given
        bot_id.  Example: {'push_image': True}.
      cmd_args: List to override the default cbuildbot command args, including
        the bot_id.
      extra_cmd_args: List to add to default cbuildbot command args.  This
        is a good way to adjust an options value for your test.
        Example: ['branch-name', 'some-branch-name'] will effectively cause
        self._run.options.branch_name to be set to 'some-branch-name'.
      build_id: mock build id
      buildbucket_id: mock buildbucket_id
      master_build_id: mock build id of master build.
      site_config: SiteConfig to use (or MockSiteConfig)
    """
        assert not bot_id or not cmd_args

        # Use cbuildbot parser to create options object and populate default values.
        if not cmd_args:
            # Fill in default command args.
            cmd_args = [
                '-r', self.build_root, '--buildbot', '--noprebuilts',
                '--buildnumber',
                str(DEFAULT_BUILD_NUMBER), '--branch',
                self.TARGET_MANIFEST_BRANCH, bot_id or self.BOT_ID
            ]
        if extra_cmd_args:
            cmd_args += extra_cmd_args

        parser = cbuildbot._CreateParser()
        options = cbuildbot.ParseCommandLine(parser, cmd_args)
        self._bot_id = options.build_config_name

        if site_config is None:
            site_config = config_lib.GetConfig()

        # Populate build_config corresponding to self._bot_id.
        build_config = copy.deepcopy(site_config[self._bot_id])
        build_config['manifest_repo_url'] = 'fake_url'
        if extra_config:
            build_config.update(extra_config)
        options.managed_chrome = build_config['sync_chrome']

        self._boards = build_config['boards']
        self._current_board = self._boards[0] if self._boards else None
        self._model = self._current_board

        # Some preliminary sanity checks.
        self.assertEqual(options.buildroot, self.build_root)

        # Construct a real BuilderRun using options and build_config.
        self._run = cbuildbot_run.BuilderRun(options, site_config,
                                             build_config, self._manager)

        if build_id is not None:
            self._run.attrs.metadata.UpdateWithDict({'build_id': build_id})

        if buildbucket_id is not None:
            self._run.options.buildbucket_id = buildbucket_id

        if master_build_id is not None:
            self._run.options.master_build_id = master_build_id

        if self.RELEASE_TAG is not None:
            self._run.attrs.release_tag = self.RELEASE_TAG

        portage_util._OVERLAY_LIST_CMD = '/bin/true'
  def _Prepare(self, bot_id=None, extra_config=None, cmd_args=None,
               extra_cmd_args=None):
    """Prepare a BuilderRun at self._run for this test.

    This method must allow being called more than once.  Subclasses can
    override this method, but those subclass methods should also call this one.

    The idea is that all test preparation that falls out from the choice of
    build config and cbuildbot options should go in _Prepare.

    This will populate the following attributes on self:
      run: A BuilderRun object.
      bot_id: The bot id (name) that was used from config.config.
      self._boards: Same as self._run.config.boards.  TODO(mtennant): remove.
      self._current_board: First board in list, if there is one.

    Args:
      bot_id: Name of build config to use, defaults to self.BOT_ID.
      extra_config: Dict used to add to the build config for the given
        bot_id.  Example: {'push_image': True}.
      cmd_args: List to override the default cbuildbot command args.
      extra_cmd_args: List to add to default cbuildbot command args.  This
        is a good way to adjust an options value for your test.
        Example: ['branch-name', 'some-branch-name'] will effectively cause
        self._run.options.branch_name to be set to 'some-branch-name'.
    """
    # Use cbuildbot parser to create options object and populate default values.
    parser = cbuildbot._CreateParser()
    if not cmd_args:
      # Fill in default command args.
      cmd_args = [
          '-r', self.build_root, '--buildbot', '--noprebuilts',
          '--buildnumber', str(DEFAULT_BUILD_NUMBER),
          '--branch', self.TARGET_MANIFEST_BRANCH,
      ]
    if extra_cmd_args:
      cmd_args += extra_cmd_args
    (options, args) = parser.parse_args(cmd_args)

    # The bot_id can either be specified as arg to _Prepare method or in the
    # cmd_args (as cbuildbot normally accepts it from command line).
    if args:
      self._bot_id = args[0]
      if bot_id:
        # This means bot_id was specified as _Prepare arg and in cmd_args.
        # Make sure they are the same.
        self.assertEquals(self._bot_id, bot_id)
    else:
      self._bot_id = bot_id or self.BOT_ID
      args = [self._bot_id]
    cbuildbot._FinishParsing(options, args)

    # Populate build_config corresponding to self._bot_id.
    build_config = copy.deepcopy(config.config[self._bot_id])
    build_config['manifest_repo_url'] = 'fake_url'
    if extra_config:
      build_config.update(extra_config)
    if options.remote_trybot:
      build_config = config.OverrideConfigForTrybot(build_config, options)

    self._boards = build_config['boards']
    self._current_board = self._boards[0] if self._boards else None

    # Some preliminary sanity checks.
    self.assertEquals(options.buildroot, self.build_root)

    # Construct a real BuilderRun using options and build_config.
    self._run = cbuildbot_run.BuilderRun(options, build_config, self._manager)

    if self.RELEASE_TAG is not None:
      self._run.attrs.release_tag = self.RELEASE_TAG

    portage_utilities._OVERLAY_LIST_CMD = '/bin/true'
Пример #22
0
  def _Prepare(self, bot_id=None, extra_config=None, cmd_args=None,
               extra_cmd_args=None, build_id=DEFAULT_BUILD_ID,
               waterfall=constants.WATERFALL_INTERNAL,
               waterfall_url=constants.BUILD_INT_DASHBOARD,
               master_build_id=None,
               site_config=None):
    """Prepare a BuilderRun at self._run for this test.

    This method must allow being called more than once.  Subclasses can
    override this method, but those subclass methods should also call this one.

    The idea is that all test preparation that falls out from the choice of
    build config and cbuildbot options should go in _Prepare.

    This will populate the following attributes on self:
      run: A BuilderRun object.
      bot_id: The bot id (name) that was used from the site_config.
      self._boards: Same as self._run.config.boards.  TODO(mtennant): remove.
      self._current_board: First board in list, if there is one.

    Args:
      bot_id: Name of build config to use, defaults to self.BOT_ID.
      extra_config: Dict used to add to the build config for the given
        bot_id.  Example: {'push_image': True}.
      cmd_args: List to override the default cbuildbot command args.
      extra_cmd_args: List to add to default cbuildbot command args.  This
        is a good way to adjust an options value for your test.
        Example: ['branch-name', 'some-branch-name'] will effectively cause
        self._run.options.branch_name to be set to 'some-branch-name'.
      build_id: mock build id
      waterfall: Name of the current waterfall.
                 Possibly from constants.CIDB_KNOWN_WATERFALLS.
      waterfall_url: Url for the current waterfall.
      master_build_id: mock build id of master build.
      site_config: SiteConfig to use (or MockSiteConfig)
    """
    # Use cbuildbot parser to create options object and populate default values.
    parser = cbuildbot._CreateParser()
    if not cmd_args:
      # Fill in default command args.
      cmd_args = [
          '-r', self.build_root, '--buildbot', '--noprebuilts',
          '--buildnumber', str(DEFAULT_BUILD_NUMBER),
          '--branch', self.TARGET_MANIFEST_BRANCH,
      ]
    if extra_cmd_args:
      cmd_args += extra_cmd_args
    (options, args) = parser.parse_args(cmd_args)

    # The bot_id can either be specified as arg to _Prepare method or in the
    # cmd_args (as cbuildbot normally accepts it from command line).
    if args:
      self._bot_id = args[0]
      if bot_id:
        # This means bot_id was specified as _Prepare arg and in cmd_args.
        # Make sure they are the same.
        self.assertEquals(self._bot_id, bot_id)
    else:
      self._bot_id = bot_id or self.BOT_ID
      args = [self._bot_id]
    cbuildbot._FinishParsing(options, args)

    if site_config is None:
      site_config = chromeos_config.GetConfig()

    # Populate build_config corresponding to self._bot_id.
    build_config = copy.deepcopy(site_config[self._bot_id])
    build_config['manifest_repo_url'] = 'fake_url'
    if extra_config:
      build_config.update(extra_config)
    if options.remote_trybot:
      build_config = config_lib.OverrideConfigForTrybot(
          build_config, options)
    options.managed_chrome = build_config['sync_chrome']

    self._boards = build_config['boards']
    self._current_board = self._boards[0] if self._boards else None

    # Some preliminary sanity checks.
    self.assertEquals(options.buildroot, self.build_root)

    # Construct a real BuilderRun using options and build_config.
    self._run = cbuildbot_run.BuilderRun(
        options, site_config, build_config, self._manager)

    if build_id is not None:
      self._run.attrs.metadata.UpdateWithDict({'build_id': build_id})

    if master_build_id is not None:
      self._run.options.master_build_id = master_build_id

    self._run.attrs.metadata.UpdateWithDict({'buildbot-master-name': waterfall})
    self._run.attrs.metadata.UpdateWithDict({'buildbot-url': waterfall_url})

    if self.RELEASE_TAG is not None:
      self._run.attrs.release_tag = self.RELEASE_TAG

    portage_util._OVERLAY_LIST_CMD = '/bin/true'
Пример #23
0
 def setUp(self):
     self.parser = cbuildbot._CreateParser()
 def setUp(self):
     self.parser = cbuildbot._CreateParser()
     self.site_config = config_lib_unittest.MockSiteConfig()
Пример #25
0
 def setUp(self):
   self.parser = cbuildbot._CreateParser()
 def setUp(self):
     self.parser = cbuildbot._CreateParser()
     self.site_config = config_lib_unittest.MockSiteConfig()