def Prepare(benchmark_spec):
    """Prepare the virtual machines to run cloud spanner benchmarks.

  Args:
    benchmark_spec: The benchmark specification. Contains all data that is
        required to run the benchmark.
  """
    benchmark_spec.always_call_cleanup = True

    benchmark_spec.spanner_instance = gcp_spanner.GcpSpannerInstance(
        name=BENCHMARK_INSTANCE_PREFIX + FLAGS.run_uri,
        description=BENCHMARK_DESCRIPTION,
        database=BENCHMARK_DATABASE,
        ddl=BENCHMARK_SCHEMA)
    if benchmark_spec.spanner_instance._Exists(instance_only=True):
        logging.warning('Cloud Spanner instance %s exists, delete it first.' %
                        FLAGS.cloud_spanner_ycsb_instance)
        benchmark_spec.spanner_instance.Delete()
    benchmark_spec.spanner_instance.Create()
    if not benchmark_spec.spanner_instance._Exists():
        logging.warning(
            'Failed to create Cloud Spanner instance and database.')
        benchmark_spec.spanner_instance.Delete()

    if FLAGS.cloud_spanner_ycsb_client_type != 'java':
        ycsb.SetYcsbTarUrl(
            CLIENT_TAR_URL[FLAGS.cloud_spanner_ycsb_client_type])

    vms = benchmark_spec.vms

    # Install required packages and copy credential files
    vm_util.RunThreaded(_Install, vms)

    benchmark_spec.executor = ycsb.YCSBExecutor('cloudspanner')
예제 #2
0
  def testCalculateStartingThroughput(self, write_proportion, read_proportion,
                                      expected_qps):
    # Arrange
    test_spanner = gcp_spanner.GcpSpannerInstance(nodes=3)

    # Act
    actual_qps = test_spanner.CalculateRecommendedThroughput(
        read_proportion, write_proportion)

    # Assert
    self.assertEqual(expected_qps, actual_qps)
def Prepare(benchmark_spec):
    """Prepare the virtual machines to run cloud spanner benchmarks.

  Args:
    benchmark_spec: The benchmark specification. Contains all data that is
        required to run the benchmark.
  """

    benchmark_spec.always_call_cleanup = True if not FLAGS.cloud_spanner_instance_name else False

    instance_name = FLAGS.cloud_spanner_instance_name or BENCHMARK_INSTANCE_PREFIX + FLAGS.run_uri
    instance_description = FLAGS.cloud_spanner_instance_description or BENCHMARK_DESCRIPTION
    benchmark_spec.spanner_instance = gcp_spanner.GcpSpannerInstance(
        name=instance_name,
        description=instance_description,
        database=BENCHMARK_DATABASE,
        ddl=BENCHMARK_SCHEMA)

    # If instance name is provided, we might re-use an existing instance
    if FLAGS.cloud_spanner_instance_name:
        benchmark_spec.always_call_cleanup = False
        if benchmark_spec.spanner_instance._Exists(instance_only=True):
            logging.info("Re-using existing instance %s", instance_name)
        else:
            logging.info("Creating new instance %s", instance_name)
            benchmark_spec.spanner_instance.Create()

    # If instance name is not provided, we delete the existing instance before creating
    elif benchmark_spec.spanner_instance._Exists(instance_only=True):
        logging.warning('Cloud Spanner instance %s exists, delete it first.' %
                        instance_name)
        benchmark_spec.spanner_instance.Delete()
        logging.info("Creating new instance %s", instance_name)
        benchmark_spec.spanner_instance.Create()

    if not benchmark_spec.spanner_instance._Exists():
        logging.warning(
            'Failed to create Cloud Spanner instance and database.')
        benchmark_spec.spanner_instance.Delete()

    if FLAGS.cloud_spanner_ycsb_client_type != 'java':
        ycsb.SetYcsbTarUrl(
            CLIENT_TAR_URL[FLAGS.cloud_spanner_ycsb_client_type])

    vms = benchmark_spec.vms

    # Install required packages and copy credential files
    vm_util.RunThreaded(_Install, vms)

    benchmark_spec.executor = ycsb.YCSBExecutor('cloudspanner')
def Prepare(benchmark_spec):
    """Prepare the virtual machines to run cloud spanner benchmarks.

  Args:
    benchmark_spec: The benchmark specification. Contains all data that is
        required to run the benchmark.
  """
    benchmark_spec.always_call_cleanup = True

    benchmark_spec.spanner_instance = gcp_spanner.GcpSpannerInstance(
        name=BENCHMARK_INSTANCE_PREFIX + FLAGS.run_uri,
        description=BENCHMARK_DESCRIPTION,
        database=BENCHMARK_DATABASE,
        ddl=BENCHMARK_SCHEMA)
    if benchmark_spec.spanner_instance._Exists(instance_only=True):
        logging.warning('Cloud Spanner instance %s exists, delete it first.' %
                        FLAGS.cloud_spanner_ycsb_instance)
        benchmark_spec.spanner_instance.Delete()
    benchmark_spec.spanner_instance.Create()
    if not benchmark_spec.spanner_instance._Exists():
        logging.warning(
            'Failed to create Cloud Spanner instance and database.')
        benchmark_spec.spanner_instance.Delete()

    default_ycsb_tar_url = ycsb.YCSB_TAR_URL

    # TODO: figure out a less hacky way to override.
    # Override so that we only need to download the required binding.
    if FLAGS.cloud_spanner_ycsb_custom_release:
        ycsb.YCSB_TAR_URL = FLAGS.cloud_spanner_ycsb_custom_release
    else:
        ycsb.YCSB_TAR_URL = YCSB_BINDING_TAR_URL

    logging.info('YCSB tar url: ' + ycsb.YCSB_TAR_URL)

    vms = benchmark_spec.vms

    # Install required packages and copy credential files
    vm_util.RunThreaded(_Install, vms)

    # Restore YCSB_TAR_URL
    ycsb.YCSB_TAR_URL = default_ycsb_tar_url
    benchmark_spec.executor = ycsb.YCSBExecutor('cloudspanner')
def GetTestSpannerInstance():
    return gcp_spanner.GcpSpannerInstance(name='test_instance',
                                          database='test_database')