예제 #1
0
 def testSyncHostPrebuilts(self):
     board = 'x86-foo'
     target = prebuilt.BuildTarget(board, 'aura')
     slave_targets = [prebuilt.BuildTarget('x86-bar', 'aura')]
     package_path = os.path.join(self.build_path,
                                 prebuilt._HOST_PACKAGES_PATH)
     url_suffix = prebuilt._REL_HOST_PATH % {
         'version': self.version,
         'host_arch': prebuilt._HOST_ARCH,
         'target': target,
     }
     packages_url_suffix = '%s/packages' % url_suffix.rstrip('/')
     url_value = '%s/%s/' % (self.binhost.rstrip('/'),
                             packages_url_suffix.rstrip('/'))
     urls = [url_value.replace('foo', 'bar'), url_value]
     binhost = ' '.join(urls)
     uploader = prebuilt.PrebuiltUploader(self.upload_location,
                                          'public-read', self.binhost, [],
                                          self.build_path, [], False, 'foo',
                                          False, target, slave_targets,
                                          self.version)
     uploader.SyncHostPrebuilts(self.key, True, True)
     self.upload_mock.assert_called_once_with(package_path,
                                              packages_url_suffix)
     self.rev_mock.assert_called_once_with(mock.ANY, {self.key: binhost},
                                           dryrun=False)
     self.update_binhost_mock.assert_called_once_with(
         mock.ANY, self.key, binhost)
 def testMain(self):
   """Test that the main function works."""
   options = mox.MockObject(object)
   old_binhost = 'http://prebuilt/1'
   options.previous_binhost_url = [old_binhost]
   options.board = 'x86-foo'
   options.profile = None
   target = prebuilt.BuildTarget(options.board, options.profile)
   options.build_path = '/trunk'
   options.debug = False
   options.private = True
   options.packages = []
   options.sync_host = True
   options.git_sync = True
   options.upload_board_tarball = True
   options.prepackaged_tarball = None
   options.toolchain_tarballs = []
   options.toolchain_upload_path = ''
   options.upload = 'gs://upload/'
   options.binhost_base_url = options.upload
   options.prepend_version = True
   options.set_version = None
   options.skip_upload = False
   options.filters = True
   options.key = 'PORTAGE_BINHOST'
   options.binhost_conf_dir = 'foo'
   options.sync_binhost_conf = True
   options.slave_targets = [prebuilt.BuildTarget('x86-bar', 'aura')]
   self.mox.StubOutWithMock(prebuilt, 'ParseOptions')
   prebuilt.ParseOptions().AndReturn(tuple([options, target]))
   self.mox.StubOutWithMock(binpkg, 'GrabRemotePackageIndex')
   binpkg.GrabRemotePackageIndex(old_binhost).AndReturn(True)
   self.mox.StubOutWithMock(prebuilt.PrebuiltUploader, '__init__')
   self.mox.StubOutWithMock(prebuilt, 'GetBoardOverlay')
   fake_overlay_path = '/fake_path'
   prebuilt.GetBoardOverlay(
       options.build_path, options.board).AndReturn(fake_overlay_path)
   expected_gs_acl_path = os.path.join(fake_overlay_path,
                                       prebuilt._GOOGLESTORAGE_ACL_FILE)
   prebuilt.PrebuiltUploader.__init__(options.upload, expected_gs_acl_path,
                                      options.upload, mox.IgnoreArg(),
                                      options.build_path, options.packages,
                                      False, options.binhost_conf_dir, False,
                                      target, options.slave_targets)
   self.mox.StubOutWithMock(prebuilt.PrebuiltUploader, 'SyncHostPrebuilts')
   prebuilt.PrebuiltUploader.SyncHostPrebuilts(mox.IgnoreArg(), options.key,
       options.git_sync, options.sync_binhost_conf)
   self.mox.StubOutWithMock(prebuilt.PrebuiltUploader, 'SyncBoardPrebuilts')
   prebuilt.PrebuiltUploader.SyncBoardPrebuilts(
       mox.IgnoreArg(), options.key, options.git_sync,
       options.sync_binhost_conf, options.upload_board_tarball, None, [], '')
   self.mox.ReplayAll()
   prebuilt.main([])
예제 #3
0
 def testSyncBoardPrebuilts(self):
     board = 'x86-foo'
     target = prebuilt.BuildTarget(board, 'aura')
     slave_targets = [prebuilt.BuildTarget('x86-bar', 'aura')]
     board_path = os.path.join(self.build_path,
                               prebuilt._BOARD_PATH % {'board': board})
     package_path = os.path.join(board_path, 'packages')
     url_suffix = prebuilt._REL_BOARD_PATH % {
         'version': self.version,
         'target': target,
     }
     packages_url_suffix = '%s/packages' % url_suffix.rstrip('/')
     url_value = '%s/%s/' % (self.binhost.rstrip('/'),
                             packages_url_suffix.rstrip('/'))
     bar_binhost = url_value.replace('foo', 'bar')
     determine_mock = self.PatchObject(prebuilt,
                                       'DeterminePrebuiltConfFile',
                                       side_effect=('bar', 'foo'))
     self.PatchObject(prebuilt.PrebuiltUploader, '_UploadSdkTarball')
     with parallel_unittest.ParallelMock():
         multiprocessing.Process.exitcode = 0
         uploader = prebuilt.PrebuiltUploader(self.upload_location,
                                              'public-read', self.binhost,
                                              [], self.build_path, [],
                                              False, 'foo', False, target,
                                              slave_targets, self.version)
         uploader.SyncBoardPrebuilts(self.key, True, True, True, None, None,
                                     None, None, None)
     determine_mock.assert_has_calls([
         mock.call(self.build_path, slave_targets[0]),
         mock.call(self.build_path, target),
     ])
     self.upload_mock.assert_called_once_with(package_path,
                                              packages_url_suffix)
     self.rev_mock.assert_has_calls([
         mock.call('bar', {self.key: bar_binhost}, dryrun=False),
         mock.call('foo', {self.key: url_value}, dryrun=False),
     ])
     self.update_binhost_mock.assert_has_calls([
         mock.call(mock.ANY, self.key, bar_binhost),
         mock.call(mock.ANY, self.key, url_value),
     ])
 def testSyncHostPrebuilts(self):
   board = 'x86-foo'
   target = prebuilt.BuildTarget(board, 'aura')
   slave_targets = [prebuilt.BuildTarget('x86-bar', 'aura')]
   package_path = os.path.join(self.build_path,
                               prebuilt._HOST_PACKAGES_PATH)
   url_suffix = prebuilt._REL_HOST_PATH % {'version': self.version,
       'host_arch': prebuilt._HOST_ARCH, 'target': target}
   packages_url_suffix = '%s/packages' % url_suffix.rstrip('/')
   prebuilt.PrebuiltUploader._UploadPrebuilt(package_path,
       packages_url_suffix).AndReturn(True)
   url_value = '%s/%s/' % (self.binhost.rstrip('/'),
                           packages_url_suffix.rstrip('/'))
   urls = [url_value.replace('foo', 'bar'), url_value]
   binhost = ' '.join(urls)
   prebuilt.RevGitFile(mox.IgnoreArg(), {self.key: binhost}, dryrun=False)
   prebuilt.UpdateBinhostConfFile(mox.IgnoreArg(), self.key, binhost)
   self.mox.ReplayAll()
   uploader = prebuilt.PrebuiltUploader(
       self.upload_location, 'public-read', self.binhost, [],
       self.build_path, [], False, 'foo', False, target, slave_targets)
   uploader.SyncHostPrebuilts(self.version, self.key, True, True)
 def testSyncBoardPrebuilts(self):
   board = 'x86-foo'
   target = prebuilt.BuildTarget(board, 'aura')
   slave_targets = [prebuilt.BuildTarget('x86-bar', 'aura')]
   board_path = os.path.join(self.build_path,
       prebuilt._BOARD_PATH % {'board': board})
   package_path = os.path.join(board_path, 'packages')
   url_suffix = prebuilt._REL_BOARD_PATH % {'version': self.version,
       'target': target}
   packages_url_suffix = '%s/packages' % url_suffix.rstrip('/')
   self.mox.StubOutWithMock(multiprocessing.Process, '__init__')
   self.mox.StubOutWithMock(multiprocessing.Process, 'exitcode')
   self.mox.StubOutWithMock(multiprocessing.Process, 'start')
   self.mox.StubOutWithMock(multiprocessing.Process, 'join')
   multiprocessing.Process.__init__(target=mox.IgnoreArg(),
       args=(board_path, url_suffix, self.version, None, None, None))
   multiprocessing.Process.start()
   prebuilt.PrebuiltUploader._UploadPrebuilt(package_path,
       packages_url_suffix).AndReturn(True)
   multiprocessing.Process.join()
   multiprocessing.Process.exitcode = 0
   url_value = '%s/%s/' % (self.binhost.rstrip('/'),
                           packages_url_suffix.rstrip('/'))
   bar_binhost = url_value.replace('foo', 'bar')
   prebuilt.DeterminePrebuiltConfFile(self.build_path,
       slave_targets[0]).AndReturn('bar')
   prebuilt.RevGitFile('bar', {self.key: bar_binhost}, dryrun=False)
   prebuilt.UpdateBinhostConfFile(mox.IgnoreArg(), self.key, bar_binhost)
   prebuilt.DeterminePrebuiltConfFile(self.build_path, target).AndReturn('foo')
   prebuilt.RevGitFile('foo', {self.key: url_value}, dryrun=False)
   prebuilt.UpdateBinhostConfFile(mox.IgnoreArg(), self.key, url_value)
   self.mox.ReplayAll()
   uploader = prebuilt.PrebuiltUploader(
       self.upload_location, 'public-read', self.binhost, [],
       self.build_path, [], False, 'foo', False, target, slave_targets)
   uploader.SyncBoardPrebuilts(self.version, self.key, True, True, True, None,
                               None, None)
예제 #6
0
    def testMain(self):
        """Test that the main function works."""
        options = mock.MagicMock()
        old_binhost = 'http://prebuilt/1'
        options.previous_binhost_url = [old_binhost]
        options.board = 'x86-foo'
        options.profile = None
        target = prebuilt.BuildTarget(options.board, options.profile)
        options.build_path = '/trunk'
        options.dryrun = False
        options.private = True
        options.packages = []
        options.sync_host = True
        options.git_sync = True
        options.upload_board_tarball = True
        options.prepackaged_tarball = None
        options.toolchains_overlay_tarballs = []
        options.toolchains_overlay_upload_path = ''
        options.toolchain_tarballs = []
        options.toolchain_upload_path = ''
        options.upload = 'gs://upload/'
        options.binhost_base_url = options.upload
        options.prepend_version = True
        options.set_version = None
        options.skip_upload = False
        options.filters = True
        options.key = 'PORTAGE_BINHOST'
        options.binhost_conf_dir = None
        options.sync_binhost_conf = True
        options.slave_targets = [prebuilt.BuildTarget('x86-bar', 'aura')]
        self.PatchObject(prebuilt,
                         'ParseOptions',
                         return_value=tuple([options, target]))
        self.PatchObject(binpkg, 'GrabRemotePackageIndex', return_value=True)
        init_mock = self.PatchObject(prebuilt.PrebuiltUploader,
                                     '__init__',
                                     return_value=None)
        expected_gs_acl_path = os.path.join(
            '/fake_path', prebuilt._GOOGLESTORAGE_GSUTIL_FILE)
        self.PatchObject(portage_util,
                         'FindOverlayFile',
                         return_value=expected_gs_acl_path)
        host_mock = self.PatchObject(prebuilt.PrebuiltUploader,
                                     'SyncHostPrebuilts',
                                     return_value=None)
        board_mock = self.PatchObject(prebuilt.PrebuiltUploader,
                                      'SyncBoardPrebuilts',
                                      return_value=None)

        prebuilt.main([])

        init_mock.assert_called_once_with(options.upload, expected_gs_acl_path,
                                          options.upload, mock.ANY,
                                          options.build_path, options.packages,
                                          False, None, False, target,
                                          options.slave_targets, mock.ANY)
        board_mock.assert_called_once_with(options.key, options.git_sync,
                                           options.sync_binhost_conf,
                                           options.upload_board_tarball, None,
                                           [], '', [], '')
        host_mock.assert_called_once_with(options.key, options.git_sync,
                                          options.sync_binhost_conf)