sashapolo commented on code in PR #1854:
URL: https://github.com/apache/ignite-3/pull/1854#discussion_r1151530448
##########
modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerTest.java:
##########
@@ -581,6 +590,85 @@ public void testDoubledCreateTable() throws Exception {
assertSame(table, tblManagerFut.join().table(scmTbl.name()));
}
+ @Test
+ void testStoragesGetClearedInMiddleOfFailedTxStorageRebalance() throws
Exception {
+ testStoragesGetClearedInMiddleOfFailedRebalance(true);
+ }
+
+ @Test
+ void testStoragesGetClearedInMiddleOfFailedPartitionStorageRebalance()
throws Exception {
+ testStoragesGetClearedInMiddleOfFailedRebalance(false);
+ }
+
+ /**
+ * Emulates a situation, when either a TX state storage or partition
storage were stopped in a middle of a rebalance. We then expect
+ * that these storages get cleared upon startup.
+ *
+ * @param isTxStorageUnderRebalance when {@code true} - TX state storage
is emulated as being under rebalance, when {@code false} -
+ * partition storage is emulated instead.
+ */
+ private void testStoragesGetClearedInMiddleOfFailedRebalance(boolean
isTxStorageUnderRebalance) throws NodeStoppingException {
+ when(rm.startRaftGroupService(any(), any(), any())).thenAnswer(mock ->
completedFuture(mock(TopologyAwareRaftGroupService.class)));
+
+ mockMetastore();
+
+ TableManager tableManager = createTableManager(tblManagerFut);
+
+ tblManagerFut.complete(tableManager);
+
+ var txStateStorage = mock(TxStateStorage.class);
+ var mvPartitionStorage = mock(MvPartitionStorage.class);
+
+ if (isTxStorageUnderRebalance) {
+ // Emulate a situation when TX state storage was stopped in a
middle of rebalance.
+
when(txStateStorage.persistedIndex()).thenReturn(TxStateStorage.REBALANCE_IN_PROGRESS);
+ } else {
+ // Emulate a situation when partition storage was stopped in a
middle of rebalance.
+
when(mvPartitionStorage.persistedIndex()).thenReturn(MvPartitionStorage.REBALANCE_IN_PROGRESS);
+ }
+
+ when(txStateStorage.clear()).thenReturn(completedFuture(null));
+
+ // We need to mock storages inside a configuration listener because of
how mocks are created in the Table Manager,
+ // see "createTableManager".
+ tblsCfg.tables().any().listen(ctx -> {
+ // For some reason, "when(something).thenReturn" does not work on
spies, but this notation works.
Review Comment:
Probably yes, thanks for the explanation
--
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]