spanner/spec/spanner_samples_spec.rb
# Creates or return existing temporary backup with random ID (will be dropped
# after test)
Creates or return existing temporary backup with random ID (will be dropped
after test)
Creates or return existing temporary backup with random ID ( will be dropped after test )
def create_backup_with_data
    @test_backup = @instance.backup @backup_id
    return @test_backup if @test_backup
    database = create_singers_albums_database
    capture do
      write_using_dml project_id:  @project_id,
                      instance_id: @instance.instance_id,
                      database_id: database.database_id
    end
    client = @spanner.client @instance.instance_id, database.database_id
    version_time = client.execute("SELECT CURRENT_TIMESTAMP() as timestamp").rows.first[:timestamp]
    capture do
      create_backup project_id:   @project_id,
                    instance_id:  @instance.instance_id,
                    database_id:  database.database_id,
                    backup_id:    @backup_id,
                    version_time: version_time
      @test_backup = @instance.backup @backup_id
    end
    @test_backup
  end
def create_backup_with_data @test_backup = @instance . backup @backup_id return @test_backup if @test_backup database = create_singers_albums_database capture do write_using_dml project_id : @project_id , instance_id : @instance . instance_id , database_id : database . database_id end client = @spanner . client @instance . instance_id , database . database_id version_time = client . execute ( "SELECT CURRENT_TIMESTAMP() as timestamp" ) . rows . first [ :timestamp ] capture do create_backup project_id : @project_id , instance_id : @instance . instance_id , database_id : database . database_id , backup_id : @backup_id , version_time : version_time @test_backup = @instance . backup @backup_id end @test_backup end
Creates or return existing temporary backup with random ID (will be dropped
after test)
Creates or return existing temporary backup with random ID ( will be dropped after test )