Пример #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 setUp(self):
    self.mox.StubOutWithMock(prebuilt, '_GsUpload')
    self.mox.StubOutWithMock(prebuilt, 'UpdateBinhostConfFile')

    self.acl = 'magic-acl'

    # All these args pretty much get ignored.  Whee.
    self.uploader = prebuilt.PrebuiltUploader(
        'gs://foo', self.acl, 'prebuilt', [], '/', [],
        False, 'foo', False, 'x86-foo', [])
 def testSuccessfulGsUpload(self):
   uploads = {'/packages/private.tbz2': 'gs://foo/private.tbz2'}
   self.mox.StubOutWithMock(prebuilt, 'GenerateUploadDict')
   prebuilt.GenerateUploadDict('/packages', 'gs://foo/suffix',
       PRIVATE_PACKAGES).AndReturn(uploads)
   uploads = uploads.copy()
   uploads['fake'] = 'gs://foo/suffix/Packages'
   acl = 'public-read'
   prebuilt.RemoteUpload(acl, uploads)
   self.mox.ReplayAll()
   uri = self.pkgindex.header['URI']
   uploader = prebuilt.PrebuiltUploader('gs://foo', acl, uri, [], '/', [],
                                        False, 'foo', False, 'x86-foo', [])
   uploader._UploadPrebuilt('/packages', 'suffix')
Пример #4
0
    def setUp(self):
        self.PatchObject(prebuilt,
                         '_GsUpload',
                         side_effect=Exception('should not get called'))
        self.PatchObject(prebuilt,
                         'UpdateBinhostConfFile',
                         side_effect=Exception('should not get called'))
        self.upload_mock = self.PatchObject(prebuilt.PrebuiltUploader,
                                            '_Upload')

        self.acl = 'magic-acl'

        # All these args pretty much get ignored.  Whee.
        self.uploader = prebuilt.PrebuiltUploader('gs://foo', self.acl,
                                                  'prebuilt', [], '/', [],
                                                  False, 'foo', False,
                                                  'x86-foo', [], 'chroot-1234')
Пример #5
0
 def testSuccessfulGsUpload(self):
     uploads = {
         os.path.join(self.tempdir, 'private.tbz2'): 'gs://foo/private.tbz2'
     }
     packages = list(PRIVATE_PACKAGES)
     packages.append({'CPV': 'dev-only-extras'})
     osutils.Touch(os.path.join(self.tempdir, 'dev-only-extras.tbz2'))
     self.PatchObject(prebuilt, 'GenerateUploadDict', return_value=uploads)
     uploads = uploads.copy()
     uploads['fake'] = 'gs://foo/suffix/Packages'
     acl = 'public-read'
     uri = self.pkgindex.header['URI']
     uploader = prebuilt.PrebuiltUploader('gs://foo', acl, uri, [], '/', [],
                                          False, 'foo', False, 'x86-foo',
                                          [], '')
     uploader._UploadPrebuilt(self.tempdir, 'suffix')
     self.remote_up_mock.assert_called_once_with(mock.ANY, acl, uploads)
     self.assertTrue(self.gs_up_mock.called)
Пример #6
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)