Пример #1
0
    def testBadPin(self):
        """Tests that generating a guest images tarball with a bad pin file."""
        pin_file = os.path.join(self.pin_dir, 'file1.json')
        with open(pin_file, 'w') as f:
            pin = {
                'gsuri': 'gs://%s' % 'file1',
            }
            json.dump(pin, f)

        pins = artifacts.FetchPinnedGuestImages(self.chroot, self.sysroot)
        self.assertFalse(pins)
Пример #2
0
def FetchPinnedGuestImages(input_proto, output_proto, _config):
  """Get the pinned guest image information."""
  sysroot_path = input_proto.sysroot.path

  chroot = controller_util.ParseChroot(input_proto.chroot)
  sysroot = sysroot_lib.Sysroot(sysroot_path)

  if not chroot.exists():
    cros_build_lib.Die('Chroot does not exist: %s', chroot.path)
  elif not sysroot.Exists(chroot=chroot):
    cros_build_lib.Die('Sysroot does not exist: %s',
                       chroot.full_path(sysroot.path))

  pins = artifacts.FetchPinnedGuestImages(chroot, sysroot)

  for pin in pins:
    pinned_image = output_proto.pinned_images.add()
    pinned_image.filename = pin.filename
    pinned_image.uri = pin.uri
Пример #3
0
    def testSuccess(self):
        """Tests that generating a guest images tarball."""
        for filename in ('file1', 'file2'):
            pin_file = os.path.join(self.pin_dir, filename + '.json')
            with open(pin_file, 'w') as f:
                pin = {
                    'filename': filename + '.tar.gz',
                    'gsuri': 'gs://%s' % filename,
                }
                json.dump(pin, f)

        expected = [
            artifacts.PinnedGuestImage(filename='file1.tar.gz',
                                       uri='gs://file1'),
            artifacts.PinnedGuestImage(filename='file2.tar.gz',
                                       uri='gs://file2'),
        ]

        pins = artifacts.FetchPinnedGuestImages(self.chroot, self.sysroot)
        self.assertCountEqual(expected, pins)
Пример #4
0
 def testNoPins(self):
     """Tests that generating a guest images tarball with no pins."""
     pins = artifacts.FetchPinnedGuestImages(self.chroot, self.sysroot)
     self.assertFalse(pins)