Exemple #1
0
def _AddStorageMetadata(vm, metadata):
    """Updates the metadata with object storage metadata."""
    storage_metadata = {
        'test_instance_id': '',
        'test_region':
        cloud_harmony_util.GetRegionFromZone(ENDPOINT_ZONE.value),
        'meta_instance_id': vm.machine_type,
        'meta_region': cloud_harmony_util.GetRegionFromZone(vm.zone),
        'meta_zone': vm.zone,
    }
    metadata.update(storage_metadata)
Exemple #2
0
def _AddComputeMetadata(client, server, metadata):
    """Updates the metadata with network compute metadata."""
    compute_metadata = {
        # test_instance_id, test_region and meta_os_info are informational and
        # used in conjunction with saving results.
        'test_instance_id': server.machine_type,
        'test_region': cloud_harmony_util.GetRegionFromZone(server.zone),
        'meta_instance_id': client.machine_type,
        'meta_region': cloud_harmony_util.GetRegionFromZone(client.zone),
        'meta_zone': client.zone,
    }
    metadata.update(compute_metadata)
Exemple #3
0
def _PrepareBucket(benchmark_spec):
    """Prepares the GCS bucket for object storage test.

  First creates a bucket in the specified bucket region. Then populates the test
  bucket with contents of https://github.com/cloudharmony/web-probe as well as
  larger generated test files. The new bucket is saved to later be set as the
  test endpoint for the object storage test.

  Args:
    benchmark_spec: the benchmark specification. Contains all data that is
      required to run the benchmark.
  """
    # set up Google Cloud Service
    service = gcs.GoogleCloudStorageService()
    location = cloud_harmony_util.GetRegionFromZone(ENDPOINT_ZONE.value)
    service.PrepareService(location)
    # create bucket in specified bucket region
    bucket = f'ch-{location}-{FLAGS.run_uri}'
    bucket_uri = f'gs://{bucket}'
    service.MakeBucket(bucket)
    # set default permissions to allow cloudharmony test file access
    perm_cmd = ['gsutil', 'defacl', 'set', 'public-read', bucket_uri]
    vm_util.IssueCommand(perm_cmd)
    # set bucket lifecyle to ensure bucket deletion after 30 days
    lifecyle_config_file = data.ResourcePath(
        'cloudharmony_network_gcp_lifecycle.json')
    lc_cmd = ['gsutil', 'lifecycle', 'set', lifecyle_config_file, bucket_uri]
    vm_util.IssueCommand(lc_cmd)
    # prepare preprovisioned test data
    tmp_dir = vm_util.GetTempDir()
    tmp_probe_file = posixpath.join(tmp_dir,
                                    cloud_harmony_network.WEB_PROBE_TAR)
    wget_install_cmd = ['sudo', 'apt-get', 'install', 'wget']
    vm_util.IssueCommand(wget_install_cmd)
    wget_cmd = ['wget', '-O', tmp_probe_file, cloud_harmony_network.WEB_PROBE]
    vm_util.IssueCommand(wget_cmd)
    tar_cmd = ['tar', 'zxf', tmp_probe_file, '-C', tmp_dir]
    vm_util.IssueCommand(tar_cmd)
    remote_probe_dir = posixpath.join(tmp_dir, 'probe')
    dd_cmd = [
        'dd', 'if=/dev/urandom', f'of={remote_probe_dir}/test10gb.bin',
        'bs=10240', 'count=1048576'
    ]
    vm_util.IssueCommand(dd_cmd)
    # copy preprovisioned test data to test bucket
    src_path = posixpath.join(remote_probe_dir, '*')
    dst_url = f'{bucket_uri}/probe'
    cp_cmd = ['gsutil', 'cp', '-r', src_path, dst_url]
    vm_util.IssueCommand(cp_cmd, raise_on_timeout=False)
    # save the service and the bucket name
    benchmark_spec.service = service
    benchmark_spec.bucket = bucket