This is an automated email from the ASF dual-hosted git repository.
sanpwc pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new a4ceab5d43 IGNITE-21892 Await replica services creation in
ItPlacementDriverReplicaSideTest (#3574)
a4ceab5d43 is described below
commit a4ceab5d433540c2f7c70c337840d8f817376eda
Author: Alexander Lapin <[email protected]>
AuthorDate: Wed Apr 10 10:25:48 2024 +0300
IGNITE-21892 Await replica services creation in
ItPlacementDriverReplicaSideTest (#3574)
---
.../ItPlacementDriverReplicaSideTest.java | 25 +++++++++++++++-------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git
a/modules/replicator/src/integrationTest/java/org/apache/ignite/internal/replicator/ItPlacementDriverReplicaSideTest.java
b/modules/replicator/src/integrationTest/java/org/apache/ignite/internal/replicator/ItPlacementDriverReplicaSideTest.java
index bc86533795..a52d4d8e9f 100644
---
a/modules/replicator/src/integrationTest/java/org/apache/ignite/internal/replicator/ItPlacementDriverReplicaSideTest.java
+++
b/modules/replicator/src/integrationTest/java/org/apache/ignite/internal/replicator/ItPlacementDriverReplicaSideTest.java
@@ -27,7 +27,6 @@ import static
org.apache.ignite.internal.util.CollectionUtils.first;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -42,6 +41,7 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
@@ -455,6 +455,8 @@ public class ItPlacementDriverReplicaSideTest extends
IgniteAbstractTest {
) throws Exception {
var res = new CompletableFuture<TopologyAwareRaftGroupService>();
+ List<CompletableFuture<?>> serviceFutures = new
ArrayList<>(nodes.size() * 2);
+
for (String nodeName : nodes) {
var replicaManager = replicaManagers.get(nodeName);
var raftManager = raftManagers.get(nodeName);
@@ -474,14 +476,11 @@ public class ItPlacementDriverReplicaSideTest extends
IgniteAbstractTest {
RaftGroupOptions.defaults(),
raftClientFactory.get(nodeName)
);
+ serviceFutures.add(raftClientFut);
- raftClientFut.thenAccept(raftClient -> {
+ CompletableFuture<Replica> replicaFuture =
raftClientFut.thenCompose(raftClient -> {
try {
- if (!res.isDone()) {
- res.complete(raftClient);
- }
-
- replicaManager.startReplica(
+ return replicaManager.startReplica(
groupId,
(request, senderId) -> {
log.info("Handle request [type={}]",
request.getClass().getSimpleName());
@@ -498,11 +497,21 @@ public class ItPlacementDriverReplicaSideTest extends
IgniteAbstractTest {
raftClient,
new
PendingComparableValuesTracker<>(Long.MAX_VALUE));
} catch (NodeStoppingException e) {
- fail("Can not start replica [groupId=" + groupId + ']');
+ throw new RuntimeException(e);
}
});
+ serviceFutures.add(replicaFuture);
}
+ CompletableFuture.allOf(serviceFutures.toArray(new
CompletableFuture[0]))
+ .thenRun(() -> {
+ try {
+ res.complete((TopologyAwareRaftGroupService)
serviceFutures.get(0).get());
+ } catch (InterruptedException | ExecutionException e) {
+ throw new RuntimeException(e);
+ }
+ });
+
return res;
}
}