You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ap...@apache.org on 2025/04/11 10:33:59 UTC

(ignite-3) branch main updated: IGNITE-25098 Refactor fake node startup for colocation tests (#5608)

This is an automated email from the ASF dual-hosted git repository.

apolovtsev 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 514bdc6ae42 IGNITE-25098 Refactor fake node startup for colocation tests (#5608)
514bdc6ae42 is described below

commit 514bdc6ae42c60fc98f3c471d84c703e2fa950df
Author: Alexander Polovtcev <al...@gmail.com>
AuthorDate: Fri Apr 11 13:33:54 2025 +0300

    IGNITE-25098 Refactor fake node startup for colocation tests (#5608)
---
 .../replicator/AbstractZoneReplicationTest.java    | 17 ++----
 .../replicator/ItAbstractColocationTest.java       | 19 ++-----
 .../partition/replicator/ItBuildIndexTest.java     |  2 -
 .../partition/replicator/ItColocationSqlTest.java  |  4 --
 .../replicator/ItColocationTxRecoveryTest.java     |  2 -
 .../replicator/ItZoneDataReplicationTest.java      |  8 ---
 .../partition/replicator/ItZoneTxFinishTest.java   |  6 ---
 .../partition/replicator/fixtures/Node.java        | 62 +++++++++-------------
 8 files changed, 34 insertions(+), 86 deletions(-)

diff --git a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/AbstractZoneReplicationTest.java b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/AbstractZoneReplicationTest.java
index 31248be97fe..fe2279a0045 100644
--- a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/AbstractZoneReplicationTest.java
+++ b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/AbstractZoneReplicationTest.java
@@ -140,18 +140,15 @@ abstract class AbstractZoneReplicationTest extends IgniteAbstractTest {
                 .mapToObj(i -> newNode(addresses.get(i), nodeFinder))
                 .forEach(cluster::add);
 
-        cluster.parallelStream().forEach(Node::start);
+        CompletableFuture<?>[] startFutures = cluster.parallelStream()
+                .map(Node::start)
+                .toArray(CompletableFuture[]::new);
 
         Node node0 = cluster.get(0);
 
         node0.cmgManager.initCluster(List.of(node0.name), List.of(node0.name), "cluster");
 
-        cluster.forEach(Node::waitWatches);
-
-        assertThat(
-                allOf(cluster.stream().map(n -> n.cmgManager.onJoinReady()).toArray(CompletableFuture[]::new)),
-                willCompleteSuccessfully()
-        );
+        assertThat(allOf(startFutures), willCompleteSuccessfully());
 
         assertTrue(waitForCondition(
                 () -> {
@@ -170,11 +167,7 @@ abstract class AbstractZoneReplicationTest extends IgniteAbstractTest {
 
         cluster.add(node);
 
-        node.start();
-
-        node.waitWatches();
-
-        assertThat(node.cmgManager.onJoinReady(), willCompleteSuccessfully());
+        assertThat(node.start(), willCompleteSuccessfully());
 
         return node;
     }
diff --git a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItAbstractColocationTest.java b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItAbstractColocationTest.java
index 66b5ab3fa13..f9a07905c33 100644
--- a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItAbstractColocationTest.java
+++ b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItAbstractColocationTest.java
@@ -175,19 +175,16 @@ abstract class ItAbstractColocationTest extends IgniteAbstractTest {
                         hasCustomAttributes ? customAttributes.get(i) : defaultNodeAttributesConfiguration))
                 .forEach(cluster::add);
 
-        cluster.parallelStream().forEach(Node::start);
+        CompletableFuture<?>[] startFutures = cluster.parallelStream()
+                .map(Node::start)
+                .toArray(CompletableFuture[]::new);
 
         Node node0 = cluster.get(0);
         List<String> allNodeNames = cluster.stream().map(n -> n.name).collect(toList());
 
         node0.cmgManager.initCluster(allNodeNames, allNodeNames, "cluster");
 
-        cluster.forEach(Node::waitWatches);
-
-        assertThat(
-                allOf(cluster.stream().map(n -> n.cmgManager.onJoinReady()).toArray(CompletableFuture[]::new)),
-                willCompleteSuccessfully()
-        );
+        assertThat(allOf(startFutures), willCompleteSuccessfully());
 
         assertTrue(waitForCondition(
                 () -> {
@@ -206,11 +203,7 @@ abstract class ItAbstractColocationTest extends IgniteAbstractTest {
 
         cluster.add(node);
 
-        node.start();
-
-        node.waitWatches();
-
-        assertThat(node.cmgManager.onJoinReady(), willCompleteSuccessfully());
+        assertThat(node.start(), willCompleteSuccessfully());
 
         return node;
     }
@@ -286,8 +279,6 @@ abstract class ItAbstractColocationTest extends IgniteAbstractTest {
     }
 
     static int createTable(Node node, String zoneName, String tableName, String storageProfile) {
-        node.waitForMetadataCompletenessAtNow();
-
         TableTestUtils.createTable(
                 node.catalogManager,
                 DEFAULT_SCHEMA_NAME,
diff --git a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItBuildIndexTest.java b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItBuildIndexTest.java
index c4bbd29ca6e..ad39700ed99 100644
--- a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItBuildIndexTest.java
+++ b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItBuildIndexTest.java
@@ -92,8 +92,6 @@ public class ItBuildIndexTest extends ItAbstractColocationTest {
     }
 
     private static void createCustomTable(Node node, String zoneName, String tableName) {
-        node.waitForMetadataCompletenessAtNow();
-
         TableTestUtils.createTable(
                 node.catalogManager,
                 DEFAULT_SCHEMA_NAME,
diff --git a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItColocationSqlTest.java b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItColocationSqlTest.java
index a071c0e72ca..9e344f3f739 100644
--- a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItColocationSqlTest.java
+++ b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItColocationSqlTest.java
@@ -52,8 +52,6 @@ class ItColocationSqlTest extends ItAbstractColocationTest {
         createTable(node, TEST_ZONE_NAME, TEST_TABLE_NAME1);
         createTable(node, TEST_ZONE_NAME, TEST_TABLE_NAME2);
 
-        cluster.forEach(Node::waitForMetadataCompletenessAtNow);
-
         KeyValueView<Long, Integer> kvView1 = node.tableManager.table(TEST_TABLE_NAME1).keyValueView(Long.class, Integer.class);
         KeyValueView<Long, Integer> kvView2 = node.tableManager.table(TEST_TABLE_NAME2).keyValueView(Long.class, Integer.class);
 
@@ -125,8 +123,6 @@ class ItColocationSqlTest extends ItAbstractColocationTest {
         createTable(node, TEST_ZONE_NAME, TEST_TABLE_NAME1);
         createTable(node, TEST_ZONE_NAME, TEST_TABLE_NAME2);
 
-        cluster.forEach(Node::waitForMetadataCompletenessAtNow);
-
         KeyValueView<Long, Integer> kvView1 = node.tableManager.table(TEST_TABLE_NAME1).keyValueView(Long.class, Integer.class);
         KeyValueView<Long, Integer> kvView2 = node.tableManager.table(TEST_TABLE_NAME2).keyValueView(Long.class, Integer.class);
 
diff --git a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItColocationTxRecoveryTest.java b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItColocationTxRecoveryTest.java
index 9e662e1a52f..45b79adf586 100644
--- a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItColocationTxRecoveryTest.java
+++ b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItColocationTxRecoveryTest.java
@@ -58,8 +58,6 @@ class ItColocationTxRecoveryTest extends ItAbstractColocationTest {
 
         createTable(node0, TEST_ZONE_NAME, TEST_TABLE_NAME1);
 
-        cluster.forEach(Node::waitForMetadataCompletenessAtNow);
-
         putInitialValue(node0);
 
         ReplicaMeta primaryReplica = node0.getPrimaryReplica(zoneId);
diff --git a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItZoneDataReplicationTest.java b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItZoneDataReplicationTest.java
index 804b24d0da0..f4fe48906bc 100644
--- a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItZoneDataReplicationTest.java
+++ b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItZoneDataReplicationTest.java
@@ -58,8 +58,6 @@ public class ItZoneDataReplicationTest extends AbstractZoneReplicationTest {
         createTable(TEST_ZONE_NAME, TEST_TABLE_NAME1);
         createTable(TEST_ZONE_NAME, TEST_TABLE_NAME2);
 
-        cluster.forEach(Node::waitForMetadataCompletenessAtNow);
-
         Node node = cluster.get(0);
 
         KeyValueView<Integer, Integer> kvView1 = node.tableManager.table(TEST_TABLE_NAME1).keyValueView(Integer.class, Integer.class);
@@ -143,8 +141,6 @@ public class ItZoneDataReplicationTest extends AbstractZoneReplicationTest {
 
         var zonePartitionId = new ZonePartitionId(zoneId, 0);
 
-        cluster.forEach(Node::waitForMetadataCompletenessAtNow);
-
         Node node = cluster.get(0);
 
         Map<Integer, Integer> data1 = IntStream.range(0, 10).boxed().collect(toMap(Function.identity(), Function.identity()));
@@ -185,8 +181,6 @@ public class ItZoneDataReplicationTest extends AbstractZoneReplicationTest {
 
         createTable(TEST_ZONE_NAME, TEST_TABLE_NAME1);
 
-        cluster.forEach(Node::waitForMetadataCompletenessAtNow);
-
         Node node = cluster.get(0);
 
         KeyValueView<Integer, Integer> kvView = node.tableManager.table(TEST_TABLE_NAME1).keyValueView(Integer.class, Integer.class);
@@ -200,8 +194,6 @@ public class ItZoneDataReplicationTest extends AbstractZoneReplicationTest {
 
         node = addNodeToCluster();
 
-        node.waitForMetadataCompletenessAtNow();
-
         kvView = node.tableManager.table(TEST_TABLE_NAME1).keyValueView(Integer.class, Integer.class);
 
         assertThat(kvView.get(null, 42), is(42));
diff --git a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItZoneTxFinishTest.java b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItZoneTxFinishTest.java
index 5eea417c630..5bc2f7a185c 100644
--- a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItZoneTxFinishTest.java
+++ b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItZoneTxFinishTest.java
@@ -71,8 +71,6 @@ class ItZoneTxFinishTest extends AbstractZoneReplicationTest {
 
         var zonePartitionId = new ZonePartitionId(zoneId, 0);
 
-        cluster.forEach(Node::waitForMetadataCompletenessAtNow);
-
         Node node = cluster.get(0);
 
         KeyValueView<Integer, Integer> kvView1 = node.tableManager.table(TEST_TABLE_NAME1).keyValueView(Integer.class, Integer.class);
@@ -167,8 +165,6 @@ class ItZoneTxFinishTest extends AbstractZoneReplicationTest {
 
         var zonePartitionId = new ZonePartitionId(zoneId, 0);
 
-        cluster.forEach(Node::waitForMetadataCompletenessAtNow);
-
         Node node = cluster.get(0);
 
         KeyValueView<Integer, Integer> kvView1 = node.tableManager.table(TEST_TABLE_NAME1).keyValueView(Integer.class, Integer.class);
@@ -245,8 +241,6 @@ class ItZoneTxFinishTest extends AbstractZoneReplicationTest {
 
         var zonePartitionId = new ZonePartitionId(zoneId, 0);
 
-        cluster.forEach(Node::waitForMetadataCompletenessAtNow);
-
         Node node = cluster.get(0);
 
         KeyValueView<Integer, Integer> kvView1 = node.tableManager.table(TEST_TABLE_NAME1).keyValueView(Integer.class, Integer.class);
diff --git a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/fixtures/Node.java b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/fixtures/Node.java
index aa7da1842db..e79bb817618 100644
--- a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/fixtures/Node.java
+++ b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/fixtures/Node.java
@@ -28,7 +28,6 @@ import static org.apache.ignite.internal.distributionzones.rebalance.ZoneRebalan
 import static org.apache.ignite.internal.testframework.IgniteTestUtils.testNodeName;
 import static org.apache.ignite.internal.testframework.IgniteTestUtils.waitForCondition;
 import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willSucceedIn;
 import static org.apache.ignite.internal.util.IgniteUtils.stopAsync;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
@@ -50,7 +49,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ForkJoinPool;
 import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
 import java.util.function.LongSupplier;
 import org.apache.ignite.internal.app.ThreadPoolsManager;
 import org.apache.ignite.internal.catalog.CatalogManager;
@@ -217,7 +215,7 @@ public class Node {
 
     public final ReplicaManager replicaManager;
 
-    public final MetaStorageManager metaStorageManager;
+    public final MetaStorageManagerImpl metaStorageManager;
 
     private final VaultManager vaultManager;
 
@@ -266,9 +264,6 @@ public class Node {
     /** Cleanup manager for tx resources. */
     private final ResourceVacuumManager resourceVacuumManager;
 
-    /** The future have to be complete after the node start and all Meta storage watches are deployd. */
-    private CompletableFuture<Void> deployWatchesFut;
-
     /** Hybrid clock. */
     public final HybridClock hybridClock = new HybridClockImpl();
 
@@ -839,18 +834,13 @@ public class Node {
         return new PublicApiThreadingIgniteSql(igniteSql, ForkJoinPool.commonPool());
     }
 
-    public void waitForMetadataCompletenessAtNow() {
-        assertThat(schemaSyncService.waitForMetadataCompleteness(hybridClock.now()), willCompleteSuccessfully());
-    }
-
     /**
      * Starts the created components.
      */
-    public void start() {
+    public CompletableFuture<Void> start() {
         ComponentContext componentContext = new ComponentContext();
 
-        deployWatchesFut = startComponentsAsync(
-                componentContext,
+        IgniteComponent[] componentsToStartBeforeJoin = {
                 threadPoolsManager,
                 vaultManager,
                 nodeCfgMgr,
@@ -862,10 +852,9 @@ public class Node {
                 raftManager,
                 cmgManager,
                 lowWatermark
-        ).thenComposeAsync(
-                v -> cmgManager.joinFuture()
-        ).thenApplyAsync(v -> startComponentsAsync(
-                componentContext,
+        };
+
+        IgniteComponent[] componentsToStartAfterJoin = {
                 metaStorageManager,
                 clusterCfgMgr,
                 placementDriverManager,
@@ -888,21 +877,25 @@ public class Node {
                 resourceVacuumManager,
                 systemViewManager,
                 sqlQueryProcessor
-        )).thenComposeAsync(componentFuts -> {
-            CompletableFuture<Void> configurationNotificationFut = metaStorageManager.recoveryFinishedFuture()
-                    .thenCompose(rev -> allOf(
-                            nodeCfgMgr.configurationRegistry().notifyCurrentConfigurationListeners(),
-                            clusterCfgMgr.configurationRegistry().notifyCurrentConfigurationListeners(),
-                            ((MetaStorageManagerImpl) metaStorageManager).notifyRevisionUpdateListenerOnStart(),
-                            componentFuts
-                    ));
-
-            assertThat(configurationNotificationFut, willSucceedIn(1, TimeUnit.MINUTES));
-
-            lowWatermark.scheduleUpdates();
+        };
 
-            return metaStorageManager.deployWatches();
-        });
+        return startComponentsAsync(componentContext, componentsToStartBeforeJoin)
+                .thenCompose(v -> cmgManager.joinFuture())
+                .thenComposeAsync(v -> {
+                    CompletableFuture<Void> componentsStartAfterJoin = startComponentsAsync(componentContext, componentsToStartAfterJoin);
+
+                    return metaStorageManager.recoveryFinishedFuture()
+                            .thenCompose(rev -> allOf(
+                                    nodeCfgMgr.configurationRegistry().notifyCurrentConfigurationListeners(),
+                                    clusterCfgMgr.configurationRegistry().notifyCurrentConfigurationListeners(),
+                                    metaStorageManager.notifyRevisionUpdateListenerOnStart(),
+                                    componentsStartAfterJoin
+                            ));
+                }).thenCompose(v -> {
+                    lowWatermark.scheduleUpdates();
+
+                    return metaStorageManager.deployWatches();
+                }).thenCompose(v -> cmgManager.onJoinReady());
     }
 
     private CompletableFuture<Void> startComponentsAsync(ComponentContext componentContext, IgniteComponent... components) {
@@ -917,13 +910,6 @@ public class Node {
         return allOf(componentStartFutures);
     }
 
-    /**
-     * Waits for watches deployed.
-     */
-    public void waitWatches() {
-        assertThat("Watches were not deployed", deployWatchesFut, willCompleteSuccessfully());
-    }
-
     /**
      * Stops the created components.
      */