Search in sources :

Example 1 with UpdateDatabaseDdlMetadata

use of com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata in project google-cloud-java by GoogleCloudPlatform.

the class ITDatabaseAdminTest method updateDdlRetry.

@Test
public void updateDdlRetry() throws Exception {
    String dbId = testHelper.getUniqueDatabaseId();
    String instanceId = testHelper.getInstanceId().getInstance();
    String statement1 = "CREATE TABLE T (\n" + "  K STRING(MAX),\n" + ") PRIMARY KEY(K)";
    Operation<Database, CreateDatabaseMetadata> op = dbAdminClient.createDatabase(instanceId, dbId, ImmutableList.of(statement1));
    op = op.waitFor();
    Database db = op.getResult();
    dbs.add(db);
    String statement2 = "CREATE TABLE T2 (\n" + "  K2 STRING(MAX),\n" + ") PRIMARY KEY(K2)";
    Operation<Void, UpdateDatabaseDdlMetadata> op1 = dbAdminClient.updateDatabaseDdl(instanceId, dbId, ImmutableList.of(statement2), "myop");
    Operation<Void, UpdateDatabaseDdlMetadata> op2 = dbAdminClient.updateDatabaseDdl(instanceId, dbId, ImmutableList.of(statement2), "myop");
    op1 = op1.waitFor();
    op2 = op2.waitFor();
    assertThat(op1.getMetadata()).isEqualTo(op2.getMetadata());
}
Also used : UpdateDatabaseDdlMetadata(com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata) Database(com.google.cloud.spanner.Database) CreateDatabaseMetadata(com.google.spanner.admin.database.v1.CreateDatabaseMetadata) IntegrationTest(com.google.cloud.spanner.IntegrationTest) Test(org.junit.Test)

Aggregations

Database (com.google.cloud.spanner.Database)1 IntegrationTest (com.google.cloud.spanner.IntegrationTest)1 CreateDatabaseMetadata (com.google.spanner.admin.database.v1.CreateDatabaseMetadata)1 UpdateDatabaseDdlMetadata (com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata)1 Test (org.junit.Test)1