testing/buildbot/scripts/upload_test_result_artifacts.py
def upload_artifacts(data, artifact_root, dry_run, bucket):
  """Uploads artifacts to google storage.

  Args:
    * data: The test results data to upload. Assumed to include 'tests' and
      'artifact_type_info' top level keys.
    * artifact_root: The local directory where artifact locations are relative
      to.
    * dry_run: If true, this run is a test run, and no actual changes should be
      made. This includes no uploading any data to cloud storage.
  Returns:
    The test results data, with rewritten artifact locations.
  """
  local_data = copy.deepcopy(data)
  type_info = local_data['artifact_type_info']

  # Put the hashing algorithm as part of the filename, so that it's
  # easier to change the algorithm if we need to in the future.
  gs_path = 'sha1'

  tests = get_tests(local_data['tests'])
  # Do a validation pass first. Makes sure no filesystem operations occur if
  # there are invalid artifacts.
  for test_obj in tests.values():
    for artifact_name in test_obj.get('artifacts', {}):
      if artifact_name not in type_info:
        raise ValueError(
            'Artifact %r type information not present' % artifact_name)

  tempdir = tempfile.mkdtemp(prefix='upload_test_artifacts')
  try:
    hashed_artifacts = hash_artifacts(tests, artifact_root)
    prep_artifacts_for_gs_upload(hashed_artifacts, tempdir)

    # Add * to include all files in that directory.
    upload_directory_to_gs(
        os.path.join(tempdir, '*'), bucket, gs_path, dry_run)

    local_data['artifact_permanent_location'] = 'gs://%s/%s' % (
        bucket, gs_path)
    return local_data
  finally:
    shutil.rmtree(tempdir)
Uploads artifacts to google storage.

  Args:
    * data: The test results data to upload. Assumed to include 'tests' and
      'artifact_type_info' top level keys.
    * artifact_root: The local directory where artifact locations are relative
      to.
    * dry_run: If true, this run is a test run, and no actual changes should be
      made. This includes no uploading any data to cloud storage.
  Returns:
    The test results data, with rewritten artifact locations.
  
Uploads artifacts to google storage.
Uploads artifacts to google storage .
def upload_artifacts(data, artifact_root, dry_run, bucket):
  local_data = copy.deepcopy(data)
  type_info = local_data['artifact_type_info']
  gs_path = 'sha1'
  tests = get_tests(local_data['tests'])
  for test_obj in tests.values():
    for artifact_name in test_obj.get('artifacts', {}):
      if artifact_name not in type_info:
        raise ValueError(
            'Artifact %r type information not present' % artifact_name)
  tempdir = tempfile.mkdtemp(prefix='upload_test_artifacts')
  try:
    hashed_artifacts = hash_artifacts(tests, artifact_root)
    prep_artifacts_for_gs_upload(hashed_artifacts, tempdir)
    upload_directory_to_gs(
        os.path.join(tempdir, '*'), bucket, gs_path, dry_run)
    local_data['artifact_permanent_location'] = 'gs://%s/%s' % (
        bucket, gs_path)
    return local_data
  finally:
    shutil.rmtree(tempdir)
def upload_artifacts ( data , artifact_root , dry_run , bucket ) : local_data = copy . deepcopy ( data ) type_info = local_data [ 'artifact_type_info' ] gs_path = 'sha1' tests = get_tests ( local_data [ 'tests' ] ) for test_obj in tests . values ( ) : for artifact_name in test_obj . get ( 'artifacts' , { } ) : if artifact_name not in type_info : raise ValueError ( 'Artifact %r type information not present' % artifact_name ) tempdir = tempfile . mkdtemp ( prefix = 'upload_test_artifacts' ) try : hashed_artifacts = hash_artifacts ( tests , artifact_root ) prep_artifacts_for_gs_upload ( hashed_artifacts , tempdir ) upload_directory_to_gs ( os . path . join ( tempdir , '*' ) , bucket , gs_path , dry_run ) local_data [ 'artifact_permanent_location' ] = 'gs://%s/%s' % ( bucket , gs_path ) return local_data finally : shutil . rmtree ( tempdir )
Uploads artifacts to google storage.
Uploads artifacts to google storage .
"""Uploads artifacts to google storage.

  Args:
    * data: The test results data to upload. Assumed to include 'tests' and
      'artifact_type_info' top level keys.
    * artifact_root: The local directory where artifact locations are relative
      to.
    * dry_run: If true, this run is a test run, and no actual changes should be
      made. This includes no uploading any data to cloud storage.
  Returns:
    The test results data, with rewritten artifact locations.
  """ # Put the hashing algorithm as part of the filename, so that it's # easier to change the algorithm if we need to in the future. # Do a validation pass first. Makes sure no filesystem operations occur if # there are invalid artifacts. # Add * to include all files in that directory.
The test results data, with rewritten artifact locations.
The test results data with rewritten artifact locations .
data
artifact_root
dry_run
bucket
* data
The test results data to upload. Assumed to include 'tests' and
'artifact_type_info' top level keys.
The test results data to upload . Assumed to include ' tests ' and ' artifact_type_info ' top level keys .
* artifact_root
The local directory where artifact locations are relative
to.
The local directory where artifact locations are relative to .
* dry_run
If true, this run is a test run, and no actual changes should be
made. This includes no uploading any data to cloud storage.
If true this run is a test run and no actual changes should be made . This includes no uploading any data to cloud storage .