示例#1
0
    def setUp(self):
        self.old_image = gspaths.Image(
            channel='dev-channel',
            board='x86-alex',
            version='1620.0.0',
            key='mp-v3',
            uri=('gs://chromeos-releases-test/dev-channel/x86-alex/1620.0.0/'
                 'chromeos_1620.0.0_x86-alex_recovery_dev-channel_mp-v3.bin'))

        self.old_base_image = gspaths.Image(
            channel='dev-channel',
            board='x86-alex',
            version='1620.0.0',
            key='mp-v3',
            image_type='base',
            uri=('gs://chromeos-releases-test/dev-channel/x86-alex/1620.0.0/'
                 'chromeos_1620.0.0_x86-alex_base_dev-channel_mp-v3.bin'))

        self.new_image = gspaths.Image(
            channel='dev-channel',
            board='x86-alex',
            version='4171.0.0',
            key='mp-v3',
            uri=('gs://chromeos-releases-test/dev-channel/x86-alex/4171.0.0/'
                 'chromeos_4171.0.0_x86-alex_recovery_dev-channel_mp-v3.bin'))

        self.old_test_image = gspaths.UnsignedImageArchive(
            channel='dev-channel',
            board='x86-alex',
            version='1620.0.0',
            uri=('gs://chromeos-releases-test/dev-channel/x86-alex/1620.0.0/'
                 'chromeos_1620.0.0_x86-alex_recovery_dev-channel_test.bin'))

        self.new_test_image = gspaths.Image(
            channel='dev-channel',
            board='x86-alex',
            version='4171.0.0',
            uri=('gs://chromeos-releases-test/dev-channel/x86-alex/4171.0.0/'
                 'chromeos_4171.0.0_x86-alex_recovery_dev-channel_test.bin'))

        self.full_payload = gspaths.Payload(tgt_image=self.old_base_image,
                                            src_image=None,
                                            uri='gs://full_old_foo/boo')

        self.delta_payload = gspaths.Payload(tgt_image=self.new_image,
                                             src_image=self.old_image,
                                             uri='gs://delta_new_old/boo')

        self.full_test_payload = gspaths.Payload(
            tgt_image=self.old_test_image,
            src_image=None,
            uri='gs://full_old_foo/boo-test')

        self.delta_test_payload = gspaths.Payload(
            tgt_image=self.new_test_image,
            src_image=self.old_test_image,
            uri='gs://delta_new_old/boo-test')
示例#2
0
    def addTestImage(self, build):
        for i in xrange(len(self.testResults)):
            if build == self.testResults[i][0]:
                self.testResults.pop(i)
                break

        image = gspaths.UnsignedImageArchive(**build)
        self.testResults.append((build, image))
        return image
示例#3
0
    def setUp(self):
        self.maxDiff = None

        self.prev_build = gspaths.Build(bucket='crt',
                                        channel='foo-channel',
                                        board='foo-board',
                                        version='1.0.0')

        self.prev_image = gspaths.Image(key='mp', **self.prev_build)
        self.prev_premp_image = gspaths.Image(key='premp', **self.prev_build)
        self.prev_test_image = gspaths.UnsignedImageArchive(image_type='test',
                                                            **self.prev_build)

        self.target_build = gspaths.Build(bucket='crt',
                                          channel='foo-channel',
                                          board='foo-board',
                                          version='1.2.3')

        # Create an additional 'special' image like NPO that isn't NPO,
        # and keyed with a weird key. It should match none of the filters.
        self.special_image = gspaths.Image(bucket='crt',
                                           channel='foo-channel',
                                           board='foo-board',
                                           version='1.2.3',
                                           key='foo-key',
                                           image_channel='special-channel')

        self.basic_image = gspaths.Image(key='mp-v2', **self.target_build)
        self.premp_image = gspaths.Image(key='premp', **self.target_build)
        self.test_image = gspaths.UnsignedImageArchive(image_type='test',
                                                       **self.target_build)

        self.mp_full_payload = gspaths.Payload(tgt_image=self.basic_image)
        self.test_full_payload = gspaths.Payload(tgt_image=self.test_image)
        self.mp_delta_payload = gspaths.Payload(tgt_image=self.basic_image,
                                                src_image=self.prev_image)
        self.test_delta_payload = gspaths.Payload(
            tgt_image=self.test_image, src_image=self.prev_test_image)

        self.full_payload_test = paygen_build_lib.PayloadTest(
            self.test_full_payload, self.target_build.channel,
            self.target_build.version)
        self.delta_payload_test = paygen_build_lib.PayloadTest(
            self.test_delta_payload)
  def testParseUnsignedImageUri(self):
    attr_dict = dict(self.unsigned_image_archive_attrs)
    attr_dict['uri'] = uri = (
        self._GS_UNSIGNED_IMAGE_ARCHIVE_PATH_TEMPLATE % attr_dict)

    expected = gspaths.UnsignedImageArchive(build=self.build,
                                            milestone=self.milestone,
                                            image_type=self.unsigned_image_type,
                                            uri=uri)
    expected_str = gspaths.ChromeosReleases.UnsignedImageArchiveName(
        expected.build.board, expected.build.version, expected.milestone,
        expected.image_type)

    image = gspaths.ChromeosReleases.ParseUnsignedImageUri(uri)
    self.assertEqual(image, expected)
    self.assertEqual(str(image), expected_str)
  def _DoPrepareImageTest(self, image_type):
    """Test _PrepareImage via mox."""
    download_uri = 'gs://bucket/foo/image.bin'
    image_file = '/work/image.bin'
    test_work_dir = tempfile.gettempdir()  # for testing purposes
    gen = self._GetStdGenerator(work_dir=test_work_dir)

    if image_type == 'Image':
      image_obj = gspaths.Image(
          channel='dev-channel',
          board='x86-alex',
          version='4171.0.0',
          key='mp-v3',
          uri=download_uri)
      test_extract_file = None
    elif image_type == 'UnsignedImageArchive':
      image_obj = gspaths.UnsignedImageArchive(
          channel='dev-channel',
          board='x86-alex',
          version='4171.0.0',
          image_type='test',
          uri=download_uri)
      test_extract_file = paygen_payload_lib._PaygenPayload.TEST_IMAGE_NAME
    else:
      raise ValueError('invalid image type descriptor (%s)' % image_type)

    # Stub out and record the expected function calls.
    self.mox.StubOutWithMock(download_cache.DownloadCache,
                             'GetFileCopy')
    if test_extract_file:
      download_file = mox.IsA(str)
    else:
      download_file = image_file
    self.cache.GetFileCopy(download_uri, download_file)

    if test_extract_file:
      self.mox.StubOutWithMock(cros_build_lib, 'RunCommand')
      cros_build_lib.RunCommand(['tar', '-xJf', download_file,
                                 test_extract_file], cwd=test_work_dir)
      self.mox.StubOutWithMock(shutil, 'move')
      shutil.move(os.path.join(test_work_dir, test_extract_file), image_file)

    # Run the test.
    self.mox.ReplayAll()
    gen._PrepareImage(image_obj, image_file)
示例#6
0
    def _DoPrepareImageTest(self, image_type):
        """Test _PrepareImage."""
        download_uri = 'gs://bucket/foo/image.bin'
        image_file = '/work/image.bin'
        gen = self._GetStdGenerator(work_dir=self.tempdir)

        if image_type == 'Image':
            image_obj = gspaths.Image(build=self.new_build,
                                      key='mp-v3',
                                      uri=download_uri)
            test_extract_file = None
        elif image_type == 'UnsignedImageArchive':
            image_obj = gspaths.UnsignedImageArchive(build=self.new_build,
                                                     image_type='test',
                                                     uri=download_uri)
            test_extract_file = paygen_payload_lib.PaygenPayload.TEST_IMAGE_NAME
        else:
            raise ValueError('invalid image type descriptor (%s)' % image_type)

        # Stub out and Check the expected function calls.
        copy_mock = self.PatchObject(download_cache.DownloadCache,
                                     'GetFileCopy')
        if test_extract_file:
            download_file = mock.ANY
        else:
            download_file = image_file

        if test_extract_file:
            run_mock = self.PatchObject(cros_build_lib, 'run')
            move_mock = self.PatchObject(shutil, 'move')

        # Run the test.
        gen._PrepareImage(image_obj, image_file)

        copy_mock.assert_called_once_with(download_uri, download_file)

        if test_extract_file:
            run_mock.assert_called_once_with(
                ['tar', '-xJf', download_file, test_extract_file],
                cwd=self.tempdir)
            move_mock.assert_called_once_with(
                os.path.join(self.tempdir, test_extract_file), image_file)
示例#7
0
    def testDiscoverTestImages(self):
        """Test _DiscoverTestImages (success)."""
        paygen = self._GetPaygenBuildInstance()

        uri_base = 'gs://crt/foo-channel/foo-board/1.2.3'

        uri_test_archive = os.path.join(
            uri_base, 'ChromeOS-test-R12-1.2.3-foo-board.tar.xz')
        self.mockUriList.return_value = [uri_test_archive]

        # Run the test.
        result = paygen._DiscoverTestImage(self.target_build)

        expected_test_archive = gspaths.UnsignedImageArchive(
            channel='foo-channel',
            board='foo-board',
            version='1.2.3',
            bucket='crt',
            uri=uri_test_archive,
            milestone='R12',
            image_type='test')

        self.assertEqual(result, expected_test_archive)
示例#8
0
def _GenUnsignedGSPath(image, image_type):
  """Take a UnsignedImage_pb2 and return a gspaths.UnsignedImageArchive.

  Args:
    image (UnsignedImage_pb2): The build to create the gspath from.
    image_type (string): The image type, either "recovery" or "test".

  Returns:
    A gspaths.UnsignedImageArchive instance.
  """
  build = gspaths.Build(board=image.build.build_target.name,
                        version=image.build.version,
                        channel=image.build.channel,
                        bucket=image.build.bucket)

  build_uri = gspaths.ChromeosReleases.UnsignedImageUri(
      build, image.milestone, image_type)

  build.uri = build_uri

  return gspaths.UnsignedImageArchive(build=build,
                                      milestone=image.milestone,
                                      image_type=image_type,
                                      uri=build_uri)
 def testIsUnsignedImageArchive(self):
   a = float(3.14)
   self.assertFalse(gspaths.IsUnsignedImageArchive(a))
   b = gspaths.UnsignedImageArchive()
   self.assertTrue(gspaths.IsUnsignedImageArchive(b))
示例#10
0
    def setUp(self):
        self.old_build = gspaths.Build(channel='dev-channel',
                                       board='x86-alex',
                                       version='1620.0.0',
                                       bucket='chromeos-releases')

        self.old_image = gspaths.Image(
            build=self.old_build,
            key='mp-v3',
            uri=('gs://chromeos-releases/dev-channel/x86-alex/1620.0.0/'
                 'chromeos_1620.0.0_x86-alex_recovery_dev-channel_mp-v3.bin'))

        self.old_base_image = gspaths.Image(
            build=self.old_build,
            key='mp-v3',
            image_type='base',
            uri=('gs://chromeos-releases/dev-channel/x86-alex/1620.0.0/'
                 'chromeos_1620.0.0_x86-alex_base_dev-channel_mp-v3.bin'))

        self.new_build = gspaths.Build(channel='dev-channel',
                                       board='x86-alex',
                                       version='4171.0.0',
                                       bucket='chromeos-releases')

        self.new_image = gspaths.Image(
            build=self.new_build,
            key='mp-v3',
            uri=('gs://chromeos-releases/dev-channel/x86-alex/4171.0.0/'
                 'chromeos_4171.0.0_x86-alex_recovery_dev-channel_mp-v3.bin'))

        self.new_dlc_image = gspaths.DLCImage(
            build=self.new_build,
            key='dlc',
            dlc_id='dummy-dlc',
            dlc_package='dummy-package',
            uri=('gs://chromeos-releases/dev-channel/x86-alex/4171.0.0/dlc/'
                 'dummy-dlc/dummy-package/dlc.img'))

        self.old_dlc_image = gspaths.DLCImage(
            build=self.old_build,
            key='dlc',
            dlc_id='dummy-dlc',
            dlc_package='dummy-package',
            uri=('gs://chromeos-releases/dev-channel/x86-alex/1620.0.0/dlc/'
                 'dummy-dlc/dummy-package/dlc.img'))

        self.old_test_image = gspaths.UnsignedImageArchive(
            build=self.old_build,
            uri=('gs://chromeos-releases/dev-channel/x86-alex/1620.0.0/'
                 'chromeos_1620.0.0_x86-alex_recovery_dev-channel_test.bin'))

        self.new_test_image = gspaths.Image(
            build=self.new_build,
            uri=('gs://chromeos-releases/dev-channel/x86-alex/4171.0.0/'
                 'chromeos_4171.0.0_x86-alex_recovery_dev-channel_test.bin'))

        self.full_payload = gspaths.Payload(tgt_image=self.old_base_image,
                                            src_image=None,
                                            uri='gs://full_old_foo/boo')

        self.full_dlc_payload = gspaths.Payload(tgt_image=self.new_dlc_image,
                                                src_image=None,
                                                uri='gs://full_old_foo/boo')

        self.delta_payload = gspaths.Payload(tgt_image=self.new_image,
                                             src_image=self.old_image,
                                             uri='gs://delta_new_old/boo')

        self.delta_dlc_payload = gspaths.Payload(tgt_image=self.new_dlc_image,
                                                 src_image=self.old_dlc_image,
                                                 uri='gs://full_old_foo/boo')

        self.full_test_payload = gspaths.Payload(
            tgt_image=self.old_test_image,
            src_image=None,
            uri='gs://full_old_foo/boo-test')

        self.delta_test_payload = gspaths.Payload(
            tgt_image=self.new_test_image,
            src_image=self.old_test_image,
            uri='gs://delta_new_old/boo-test')