tkalkirill commented on code in PR #1325:
URL: https://github.com/apache/ignite-3/pull/1325#discussion_r1030534215


##########
modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvTableStorageTest.java:
##########
@@ -382,6 +389,85 @@ public void testFinishRebalanceMvPartition() throws 
Exception {
         assertDoesNotThrow(() -> 
tableStorage.finishRebalanceMvPartition(PARTITION_ID).get(1, TimeUnit.SECONDS));
     }
 
+    @Test
+    public void testDestroyPartition() throws Exception {
+        assertThrows(
+                IllegalArgumentException.class,
+                () -> 
tableStorage.destroyPartition(tableStorage.configuration().partitions().value())
+        );
+
+        MvPartitionStorage mvPartitionStorage = 
tableStorage.getOrCreateMvPartition(PARTITION_ID);
+        HashIndexStorage hashIndexStorage = 
tableStorage.getOrCreateHashIndex(PARTITION_ID, hashIdx.id());
+        SortedIndexStorage sortedIndexStorage = 
tableStorage.getOrCreateSortedIndex(PARTITION_ID, sortedIdx.id());
+
+        RowId rowId = new RowId(PARTITION_ID);
+
+        BinaryRow binaryRow = binaryRow(new TestKey(0, "0"), new TestValue(1, 
"1"));
+
+        IndexRow indexRow = indexRow(binaryRow, rowId);
+
+        mvPartitionStorage.runConsistently(() -> {
+            mvPartitionStorage.addWriteCommitted(rowId, binaryRow, 
clock.now());
+
+            hashIndexStorage.put(indexRow);
+
+            sortedIndexStorage.put(indexRow);
+
+            return null;
+        });
+
+        Cursor<ReadResult> scanVersionsCursor = 
mvPartitionStorage.scanVersions(rowId);
+        PartitionTimestampCursor scanTimestampCursor = 
mvPartitionStorage.scan(clock.now());
+
+        Cursor<RowId> getFromHashIndexCursor = 
hashIndexStorage.get(indexRow.indexColumns());
+
+        Cursor<RowId> getFromSortedIndexCursor = 
sortedIndexStorage.get(indexRow.indexColumns());
+        Cursor<IndexRow> scanFromSortedIndexCursor = 
sortedIndexStorage.scan(null, null, 0);
+
+        tableStorage.destroyPartition(PARTITION_ID);
+
+        // Let's check that we won't get destroyed storages.
+        assertNull(tableStorage.getMvPartition(PARTITION_ID));
+        assertThrows(StorageException.class, () -> 
tableStorage.getOrCreateHashIndex(PARTITION_ID, hashIdx.id()));
+        assertThrows(StorageException.class, () -> 
tableStorage.getOrCreateSortedIndex(PARTITION_ID, sortedIdx.id()));
+
+        checkStorageDestroyed(mvPartitionStorage);
+        checkStorageDestroyed(hashIndexStorage);
+        checkStorageDestroyed(sortedIndexStorage);
+
+        assertThrows(StorageClosedException.class, () -> 
getAll(scanVersionsCursor));
+        assertThrows(StorageClosedException.class, () -> 
getAll(scanTimestampCursor));
+
+        assertThrows(StorageClosedException.class, () -> 
getAll(getFromHashIndexCursor));
+
+        assertThrows(StorageClosedException.class, () -> 
getAll(getFromSortedIndexCursor));
+        assertThrows(StorageClosedException.class, () -> 
getAll(scanFromSortedIndexCursor));
+
+        // Let's check that nothing will happen if we try to destroy a 
non-existing partition.
+        tableStorage.destroyPartition(PARTITION_ID);

Review Comment:
   Fix it



-- 
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]

Reply via email to