ibessonov commented on code in PR #1471:
URL: https://github.com/apache/ignite-3/pull/1471#discussion_r1056294380


##########
modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvTableStorageTest.java:
##########
@@ -314,154 +315,392 @@ public void testMisconfiguredIndices() {
     }
 
     @Test
-    public void testStartRebalanceMvPartition() throws Exception {
-        MvPartitionStorage partitionStorage = 
tableStorage.getOrCreateMvPartition(PARTITION_ID);
+    public void testDestroyPartition() throws Exception {
+        assertThrows(IllegalArgumentException.class, () -> 
tableStorage.destroyPartition(getOutConfigRangePartitionId()));
 
-        partitionStorage.runConsistently(() -> {
-            partitionStorage.addWriteCommitted(
-                    new RowId(PARTITION_ID),
-                    binaryRow(new TestKey(0, "0"), new TestValue(1, "1")),
-                    clock.now()
-            );
+        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);
 
-            partitionStorage.lastApplied(100, 10);
+        mvPartitionStorage.runConsistently(() -> {
+            mvPartitionStorage.addWriteCommitted(rowId, binaryRow, 
clock.now());
+
+            hashIndexStorage.put(indexRow);
 
-            partitionStorage.committedGroupConfiguration(new 
RaftGroupConfiguration(List.of("peer"), List.of("learner"), null, null));
+            sortedIndexStorage.put(indexRow);
 
             return null;
         });
 
-        partitionStorage.flush().get(1, TimeUnit.SECONDS);
+        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.startRebalanceMvPartition(PARTITION_ID).get(1, 
TimeUnit.SECONDS);
+        tableStorage.destroyPartition(PARTITION_ID).get(1, SECONDS);
 
-        MvPartitionStorage newPartitionStorage0 = 
tableStorage.getMvPartition(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()));
 
-        assertNotNull(newPartitionStorage0);
-        assertNotSame(partitionStorage, newPartitionStorage0);
+        checkStorageDestroyed(mvPartitionStorage);
+        checkStorageDestroyed(hashIndexStorage);
+        checkStorageDestroyed(sortedIndexStorage);
 
-        assertEquals(0L, newPartitionStorage0.lastAppliedIndex());
-        assertEquals(0L, newPartitionStorage0.lastAppliedTerm());
-        assertNull(newPartitionStorage0.committedGroupConfiguration());
-        assertEquals(0L, newPartitionStorage0.persistedIndex());
-        assertEquals(0, newPartitionStorage0.rowsCount());
+        assertThrows(StorageClosedException.class, () -> 
getAll(scanVersionsCursor));
+        assertThrows(StorageClosedException.class, () -> 
getAll(scanTimestampCursor));
 
-        tableStorage.startRebalanceMvPartition(PARTITION_ID).get(1, 
TimeUnit.SECONDS);
+        assertThrows(StorageClosedException.class, () -> 
getAll(getFromHashIndexCursor));
 
-        MvPartitionStorage newPartitionStorage1 = 
tableStorage.getMvPartition(PARTITION_ID);
+        assertThrows(StorageClosedException.class, () -> 
getAll(getFromSortedIndexCursor));
+        assertThrows(StorageClosedException.class, () -> 
getAll(scanFromSortedIndexCursor));
 
-        assertSame(newPartitionStorage0, newPartitionStorage1);
+        // Let's check that nothing will happen if we try to destroy a 
non-existing partition.
+        assertDoesNotThrow(() -> 
tableStorage.destroyPartition(PARTITION_ID).get(1, SECONDS));
     }
 
     @Test
-    public void testAbortRebalanceMvPartition() throws Exception {
-        assertDoesNotThrow(() -> 
tableStorage.abortRebalanceMvPartition(PARTITION_ID).get(1, TimeUnit.SECONDS));
+    public void testReCreatePartition() throws Exception {

Review Comment:
   I would add an explicit assumption here that the storage is not volatile, 
otherwise it makes no sense.
   (by that I mean `assumeTrue` or `assumeThat` methods)



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