rpuch commented on code in PR #1854:
URL: https://github.com/apache/ignite-3/pull/1854#discussion_r1151512542
##########
modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerTest.java:
##########
@@ -409,8 +418,8 @@ public void testInternalApiTableManagerOnStop() {
}
/**
- * Checks that the all RAFT nodes will be stopped when Table manager is
stopping and
- * an exception that was thrown by one of the component will not prevent
stopping other components.
+ * Checks that the all RAFT nodes will be stopped when Table manager is
stopping and an exception that was thrown by one of the
+ * component will not prevent stopping other components.
Review Comment:
```suggestion
* Checks that all RAFT nodes will be stopped when Table manager is
stopping and an exception that was thrown by one of the
* components will not prevent stopping other components.
```
##########
modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerTest.java:
##########
@@ -469,8 +478,8 @@ public void tableManagerStopTest3() throws Exception {
}
/**
- * Checks that the all RAFT nodes will be stopped when Table manager is
stopping and
- * an exception that was thrown by one of the component will not prevent
stopping other components.
+ * Checks that the all RAFT nodes will be stopped when Table manager is
stopping and an exception that was thrown by one of the
+ * component will not prevent stopping other components.
Review Comment:
```suggestion
* Checks that all RAFT nodes will be stopped when Table manager is
stopping and an exception that was thrown by one of the
* components will not prevent stopping other components.
```
##########
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 because the underlying object's method is called when using the
`when(spy.doIt()).thenBlaBla()`, which does not happen with
`doBlaBla().when(spy).doIt())`
##########
modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerTest.java:
##########
@@ -734,21 +820,21 @@ private TableManager
createTableManager(CompletableFuture<TableManager> tblManag
) {
@Override
protected MvTableStorage createTableStorage(TableConfiguration
tableCfg, TablesConfiguration tablesCfg) {
- return Mockito.spy(super.createTableStorage(tableCfg,
tablesCfg));
+ mvTableStorage = spy(super.createTableStorage(tableCfg,
tablesCfg));
+
+ return mvTableStorage;
}
@Override
protected TxStateTableStorage
createTxStateTableStorage(TableConfiguration tableCfg) {
- return Mockito.spy(super.createTxStateTableStorage(tableCfg));
+ txStateTableStorage =
spy(super.createTxStateTableStorage(tableCfg));
+
+ return txStateTableStorage;
}
};
sm.start();
- if (!waitingSqlSchema) {
Review Comment:
Why don't we need this wait anymore?
##########
modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerTest.java:
##########
@@ -429,8 +438,8 @@ public void tableManagerStopTest1() throws Exception {
}
/**
- * Checks that the all RAFT nodes will be stopped when Table manager is
stopping and
- * an exception that was thrown by one of the component will not prevent
stopping other components.
+ * Checks that the all RAFT nodes will be stopped when Table manager is
stopping and an exception that was thrown by one of the
+ * component will not prevent stopping other components.
Review Comment:
```suggestion
* Checks that all RAFT nodes will be stopped when Table manager is
stopping and an exception that was thrown by one of the
* components will not prevent stopping other components.
```
##########
modules/table/src/test/java/org/apache/ignite/internal/table/distributed/TableManagerTest.java:
##########
@@ -449,8 +458,8 @@ public void tableManagerStopTest2() throws Exception {
}
/**
- * Checks that the all RAFT nodes will be stopped when Table manager is
stopping and
- * an exception that was thrown by one of the component will not prevent
stopping other components.
+ * Checks that the all RAFT nodes will be stopped when Table manager is
stopping and an exception that was thrown by one of the
+ * component will not prevent stopping other components.
Review Comment:
```suggestion
* Checks that all RAFT nodes will be stopped when Table manager is
stopping and an exception that was thrown by one of the
* components will not prevent stopping other components.
```
##########
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} -
Review Comment:
```suggestion
* @param isTxStorageUnderRebalance When {@code true} - TX state storage
is emulated as being under rebalance, when {@code false} -
```
--
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]