Search in sources :

Example 1 with UpdateBackupRequest

use of com.google.cloud.bigtable.admin.v2.models.UpdateBackupRequest in project java-bigtable by googleapis.

the class BigtableTableAdminClientTest method testUpdateBackup.

@Test
public void testUpdateBackup() {
    // Setup
    Mockito.when(mockStub.updateBackupCallable()).thenReturn(mockUpdateBackupCallable);
    Timestamp expireTime = Timestamp.newBuilder().setSeconds(123456789).build();
    long sizeBytes = 12345L;
    UpdateBackupRequest req = UpdateBackupRequest.of(CLUSTER_ID, BACKUP_ID);
    Mockito.when(mockUpdateBackupCallable.futureCall(req.toProto(PROJECT_ID, INSTANCE_ID))).thenReturn(ApiFutures.immediateFuture(com.google.bigtable.admin.v2.Backup.newBuilder().setName(NameUtil.formatBackupName(PROJECT_ID, INSTANCE_ID, CLUSTER_ID, BACKUP_ID)).setSourceTable(NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, TABLE_ID)).setExpireTime(expireTime).setSizeBytes(sizeBytes).build()));
    // Execute
    Backup actualResult = adminClient.updateBackup(req);
    // Verify
    assertThat(actualResult.getId()).isEqualTo(BACKUP_ID);
    assertThat(actualResult.getSourceTableId()).isEqualTo(TABLE_ID);
    assertThat(actualResult.getExpireTime()).isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(expireTime)));
    assertThat(actualResult.getSizeBytes()).isEqualTo(sizeBytes);
}
Also used : Backup(com.google.cloud.bigtable.admin.v2.models.Backup) UpdateBackupRequest(com.google.cloud.bigtable.admin.v2.models.UpdateBackupRequest) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 2 with UpdateBackupRequest

use of com.google.cloud.bigtable.admin.v2.models.UpdateBackupRequest in project java-bigtable by googleapis.

the class BigtableBackupIT method updateBackupTest.

@Test
public void updateBackupTest() {
    String backupId = prefixGenerator.newPrefix();
    tableAdmin.createBackup(createBackupRequest(backupId));
    Instant expireTime = Instant.now().plus(Duration.ofDays(20));
    UpdateBackupRequest req = UpdateBackupRequest.of(targetCluster, backupId).setExpireTime(expireTime);
    try {
        Backup backup = tableAdmin.updateBackup(req);
        assertWithMessage("Incorrect expire time").that(backup.getExpireTime()).isEqualTo(expireTime);
    } finally {
        tableAdmin.deleteBackup(targetCluster, backupId);
    }
}
Also used : Instant(org.threeten.bp.Instant) Backup(com.google.cloud.bigtable.admin.v2.models.Backup) UpdateBackupRequest(com.google.cloud.bigtable.admin.v2.models.UpdateBackupRequest) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

Backup (com.google.cloud.bigtable.admin.v2.models.Backup)2 UpdateBackupRequest (com.google.cloud.bigtable.admin.v2.models.UpdateBackupRequest)2 Test (org.junit.Test)2 ByteString (com.google.protobuf.ByteString)1 Timestamp (com.google.protobuf.Timestamp)1 Instant (org.threeten.bp.Instant)1