use of com.palantir.atlasdb.cassandra.backup.RangesForRepair in project atlasdb by palantir.
the class AtlasRestoreServiceTest method restoresToNewNamespaceCorrectly.
@Test
public void restoresToNewNamespaceCorrectly() {
RestoreRequest restoreRequest = RestoreRequest.builder().oldNamespace(WITH_BACKUP).newNamespace(NO_BACKUP).build();
// prepare
DisableNamespacesResponse successfulDisable = DisableNamespacesResponse.successful(SuccessfulDisableNamespacesResponse.of(BACKUP_ID));
DisableNamespacesRequest request = DisableNamespacesRequest.of(ImmutableSet.of(NO_BACKUP), BACKUP_ID);
when(timeLockManagementService.disableTimelock(authHeader, request)).thenReturn(successfulDisable);
Set<Namespace> disabledNamespaces = atlasRestoreService.prepareRestore(ImmutableSet.of(restoreRequest), BACKUP_ID);
assertThat(disabledNamespaces).containsExactly(NO_BACKUP);
// repair
BiConsumer<String, RangesForRepair> doNothingConsumer = (_unused1, _unused2) -> {
};
Set<Namespace> repairedNamespaces = atlasRestoreService.repairInternalTables(ImmutableSet.of(restoreRequest), doNothingConsumer);
assertThat(repairedNamespaces).containsExactly(NO_BACKUP);
verify(cassandraRepairHelper).repairInternalTables(NO_BACKUP, doNothingConsumer);
verify(cassandraRepairHelper).repairTransactionsTables(eq(NO_BACKUP), anyList(), eq(doNothingConsumer));
verify(cassandraRepairHelper).cleanTransactionsTables(eq(NO_BACKUP), eq(BACKUP_START_TIMESTAMP), anyList());
verifyNoMoreInteractions(cassandraRepairHelper);
// complete
CompletedBackup completedBackup = backupPersister.getCompletedBackup(WITH_BACKUP).orElseThrow();
CompleteRestoreRequest completeRestoreRequest = CompleteRestoreRequest.of(ImmutableMap.of(NO_BACKUP, completedBackup));
when(atlasRestoreClient.completeRestore(authHeader, completeRestoreRequest)).thenReturn(CompleteRestoreResponse.of(ImmutableSet.of(NO_BACKUP)));
ReenableNamespacesRequest reenableRequest = ReenableNamespacesRequest.of(ImmutableSet.of(NO_BACKUP), BACKUP_ID);
Set<Namespace> completedNamespaces = atlasRestoreService.completeRestore(ImmutableSet.of(restoreRequest), BACKUP_ID);
assertThat(completedNamespaces).containsExactly(NO_BACKUP);
verify(atlasRestoreClient).completeRestore(authHeader, completeRestoreRequest);
verify(timeLockManagementService).reenableTimelock(authHeader, reenableRequest);
}
use of com.palantir.atlasdb.cassandra.backup.RangesForRepair in project atlasdb by palantir.
the class CassandraRepairEteTest method tokenRangesToRepairShouldBeSubsetsOfTokenMap.
@Test
public void tokenRangesToRepairShouldBeSubsetsOfTokenMap() {
Map<CassandraServer, Set<Range<LightweightOppToken>>> fullTokenMap = getFullTokenMap();
RangesForRepair rangesToRepair = CassandraRepairHelper.getRangesToRepair(cqlCluster, ATLAS_SERVICE, TABLE_1);
KeyedStream.stream(rangesToRepair.tokenMap()).forEach((address, cqlRangesForHost) -> assertRangesToRepairAreSubsetsOfRangesFromTokenMap(fullTokenMap, address, cqlRangesForHost));
}
use of com.palantir.atlasdb.cassandra.backup.RangesForRepair in project atlasdb by palantir.
the class CassandraRepairEteTest method testRepairBothTxnTables.
@Test
public void testRepairBothTxnTables() {
List<String> tablesRepaired = new ArrayList<>();
BiConsumer<String, RangesForRepair> repairer = (table, _unused) -> tablesRepaired.add(table);
List<TransactionsTableInteraction> interactions = ImmutableList.of(new Transactions1TableInteraction(range(1L, 5L), POLICY), new Transactions2TableInteraction(range(6L, 10L), POLICY));
cassandraRepairHelper.repairTransactionsTables(ATLAS_SERVICE, interactions, repairer);
assertThat(tablesRepaired).containsExactlyInAnyOrder(TransactionConstants.TRANSACTION_TABLE.getTableName(), TransactionConstants.TRANSACTIONS2_TABLE.getTableName());
}
use of com.palantir.atlasdb.cassandra.backup.RangesForRepair in project atlasdb by palantir.
the class CassandraRepairEteTest method testRepairOnlyTxn2.
@Test
public void testRepairOnlyTxn2() {
List<String> tablesRepaired = new ArrayList<>();
BiConsumer<String, RangesForRepair> repairer = (table, _unused) -> tablesRepaired.add(table);
List<TransactionsTableInteraction> interactions = ImmutableList.of(new Transactions2TableInteraction(range(1L, 10_000_000L), POLICY));
cassandraRepairHelper.repairTransactionsTables(ATLAS_SERVICE, interactions, repairer);
assertThat(tablesRepaired).containsExactly(TransactionConstants.TRANSACTIONS2_TABLE.getTableName());
}
use of com.palantir.atlasdb.cassandra.backup.RangesForRepair in project atlasdb by palantir.
the class CassandraRepairEteTest method testRepairTxn3.
@Test
public void testRepairTxn3() {
List<String> tablesRepaired = new ArrayList<>();
BiConsumer<String, RangesForRepair> repairer = (table, _unused) -> tablesRepaired.add(table);
List<TransactionsTableInteraction> interactions = ImmutableList.of(new Transactions3TableInteraction(range(1L, 10_000_000L)));
cassandraRepairHelper.repairTransactionsTables(ATLAS_SERVICE, interactions, repairer);
// Transactions3 is backed by Transactions2 under the hood, so this is the table that will be repaired.
assertThat(tablesRepaired).containsExactly(TransactionConstants.TRANSACTIONS2_TABLE.getTableName());
}
Aggregations