Beispiel #1
0
 def testArtifactFactory(self):
     """Tests that BuildArtifact works for both named and file artifacts."""
     name_artifact = 'test_suites'  # This file is in every real GS dir.
     file_artifact = 'metadata.json'  # This file is in every real GS dir.
     factory = build_artifact.ChromeOSArtifactFactory(
         self.work_dir, [name_artifact], [file_artifact], _VERSION)
     artifacts = factory.RequiredArtifacts()
     self.assertEqual(len(artifacts), 2)
     expected_installed_files_0 = [
         os.path.join(self.work_dir, filename)
         for filename in ([build_artifact.TEST_SUITES_FILE] +
                          _TEST_GOLO_ARCHIVE_TEST_TARBALL_CONTENT)
     ]
     expected_installed_files_1 = [
         os.path.join(self.work_dir, file_artifact)
     ]
     dl = downloader.GoogleStorageDownloader(self.work_dir,
                                             _TEST_GOLO_ARCHIVE,
                                             _TEST_GOLO_BUILD_ID)
     artifacts[0].Process(dl, False)
     artifacts[1].Process(dl, False)
     self.assertEqual(artifacts[0].installed_files,
                      expected_installed_files_0)
     self.assertEqual(artifacts[1].installed_files,
                      expected_installed_files_1)
     # Test suites directory exists.
     self.assertExists(
         os.path.join(self.work_dir, 'autotest', 'test_suites'))
     # File artifact was staged.
     self.assertExists(os.path.join(self.work_dir, file_artifact))
     self._CheckMarker(artifacts[0].marker_name,
                       artifacts[0].installed_files)
     self._CheckMarker(artifacts[1].marker_name,
                       artifacts[1].installed_files)
Beispiel #2
0
  def _DownloadSymbolsHelper(self, downloader_instance, bg_mock, serial_mock):
    """Basic symbols download."""
    factory = build_artifact.ChromeOSArtifactFactory(
        downloader_instance.GetBuildDir(), ['symbols'],
        None, downloader_instance.GetBuild())

    # Should not get called but mocking so that we know it wasn't called.
    downloader_instance.Download(factory)
    serial_mock.assert_called()
    bg_mock.assert_not_called()
Beispiel #3
0
  def _DownloadFullPayload(self):
    """Full payload download."""
    downloader_instance = downloader.GoogleStorageDownloader(
        self._work_dir, self.archive_url,
        downloader.GoogleStorageDownloader.GetBuildIdFromArchiveURL(
            self.archive_url))
    factory = build_artifact.ChromeOSArtifactFactory(
        downloader_instance.GetBuildDir(), ['full_payload'],
        None, downloader_instance.GetBuild())

    full_dev = os.path.join(self.dest_dir, self.payload)
    self.downloaded = [full_dev, full_dev + '.json']

    return downloader_instance, factory
Beispiel #4
0
  def _Download(self, gs_url, artifacts, build_id):
    """Download the artifacts from the given gs_url.

    Raises:
      build_artifact.ArtifactDownloadError: If we failed to download the
                                            artifact.
    """
    with XBuddy._staging_thread_count_lock:
      XBuddy._staging_thread_count += 1
    try:
      _Log('Downloading %s from %s', artifacts, gs_url)
      dl = downloader.GoogleStorageDownloader(self.static_dir, gs_url, build_id)
      factory = build_artifact.ChromeOSArtifactFactory(
          dl.GetBuildDir(), artifacts, [], dl.GetBuild())
      dl.Download(factory)
    finally:
      with XBuddy._staging_thread_count_lock:
        XBuddy._staging_thread_count -= 1
Beispiel #5
0
  def _SimpleDownloadOfTestSuites(self, downloader_instance, bg_mock,
                                  serial_mock):
    """Helper to verify test_suites are downloaded correctly.

    Args:
      downloader_instance: Downloader object to test with.
      bg_mock: background download method mock.
      serial_mock: serial download method mock.
    """
    factory = build_artifact.ChromeOSArtifactFactory(
        downloader_instance.GetBuildDir(), ['test_suites'],
        None, downloader_instance.GetBuild())

    downloader_instance.Download(factory)
    # Sanity check the timestamp file exists.
    install_dir = os.path.join(self._work_dir, self.board, self.build)
    self.assertExists(
        os.path.join(install_dir, downloader.Downloader._TIMESTAMP_FILENAME))
    serial_mock.assert_called()
    bg_mock.assert_called()