tkalkirill commented on code in PR #1578:
URL: https://github.com/apache/ignite-3/pull/1578#discussion_r1088189307
##########
modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvTableStorageTest.java:
##########
@@ -632,10 +627,76 @@ public void testRestartStoragesAfterFailDuringRebalance()
{
hashIndexStorage = tableStorage.getOrCreateHashIndex(PARTITION_ID,
hashIdx.id());
sortedIndexStorage = tableStorage.getOrCreateSortedIndex(PARTITION_ID,
sortedIdx.id());
- // Let's check the repositories: they should be empty.
- checkForMissingRows(mvPartitionStorage, hashIndexStorage,
sortedIndexStorage, rows);
+ if (tableStorage.isVolatile()) {
+ // Let's check the repositories: they should be empty.
+ checkForMissingRows(mvPartitionStorage, hashIndexStorage,
sortedIndexStorage, rows);
+
+ checkLastApplied(mvPartitionStorage, 0, 0, 0);
+ } else {
+ checkForPresenceRows(mvPartitionStorage, hashIndexStorage,
sortedIndexStorage, rows);
+
+ checkLastApplied(mvPartitionStorage, REBALANCE_IN_PROGRESS,
REBALANCE_IN_PROGRESS, REBALANCE_IN_PROGRESS);
+ }
+ }
+
+ @Test
+ void testClear() {
+ assertThrows(IllegalArgumentException.class, () ->
tableStorage.clearPartition(getPartitionIdOutOfRange()));
+
+ // Let's check that there will be an error for a non-existent
partition.
+ assertThrows(StorageException.class, () ->
tableStorage.clearPartition(PARTITION_ID));
+
+ MvPartitionStorage mvPartitionStorage =
tableStorage.getOrCreateMvPartition(PARTITION_ID);
+ HashIndexStorage hashIndexStorage =
tableStorage.getOrCreateHashIndex(PARTITION_ID, hashIdx.id());
+ SortedIndexStorage sortedIndexStorage =
tableStorage.getOrCreateSortedIndex(PARTITION_ID, sortedIdx.id());
+
+ // Let's check the cleanup for an empty partition.
+ assertThat(tableStorage.clearPartition(PARTITION_ID),
willCompleteSuccessfully());
+
+ checkLastApplied(mvPartitionStorage, 0, 0, 0);
+ assertNull(mvPartitionStorage.committedGroupConfiguration());
+
+ // Let's fill the storages and clean them.
+ List<IgniteTuple3<RowId, TableRow, HybridTimestamp>> rows = List.of(
+ new IgniteTuple3<>(new RowId(PARTITION_ID), tableRow(new
TestKey(0, "0"), new TestValue(0, "0")), clock.now()),
+ new IgniteTuple3<>(new RowId(PARTITION_ID), tableRow(new
TestKey(1, "1"), new TestValue(1, "1")), clock.now())
+ );
+
+ RaftGroupConfiguration raftGroupConfig =
createRandomRaftGroupConfiguration();
+
+ fillStorages(mvPartitionStorage, hashIndexStorage, sortedIndexStorage,
rows);
+
+ mvPartitionStorage.runConsistently(() -> {
+ mvPartitionStorage.lastApplied(100, 500);
+
+ mvPartitionStorage.committedGroupConfiguration(raftGroupConfig);
+
+ return null;
+ });
+
+ // Let's clear the storages and check them out.
+ assertThat(tableStorage.clearPartition(PARTITION_ID),
willCompleteSuccessfully());
checkLastApplied(mvPartitionStorage, 0, 0, 0);
+ assertNull(mvPartitionStorage.committedGroupConfiguration());
+
+ checkForMissingRows(mvPartitionStorage, hashIndexStorage,
sortedIndexStorage, rows);
+ }
+
Review Comment:
At the moment it is more difficult to drill a hole for tests in order to
generally stop cleaning the storages.
I propose to add a check that all methods after cleaning will work.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]