This is an automated email from the ASF dual-hosted git repository.
ibessonov 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 5e8e0b1867c IGNITE-26711 Add enhancements to compatibility framework
(#6774)
5e8e0b1867c is described below
commit 5e8e0b1867c62d54abbe41ad7eb727fedc9e13f8
Author: Aditya Mukhopadhyay <[email protected]>
AuthorDate: Tue Oct 21 11:26:01 2025 +0530
IGNITE-26711 Add enhancements to compatibility framework (#6774)
---
...tionRaftLogOnAnotherNodesCompatibilityTest.java | 2 +-
.../internal/ItDataNodesCompatibilityTest.java | 4 +-
...ItPartitionRaftLogOneNodeCompatibilityTest.java | 2 +-
.../internal/MetastorageRaftCompatibilityTest.java | 4 +-
...ldClientWithCurrentServerCompatibilityTest.java | 4 +-
.../ignite/internal/CompatibilityTestBase.java | 2 +-
.../org/apache/ignite/internal/IgniteCluster.java | 152 ++++++++++++++-------
7 files changed, 116 insertions(+), 54 deletions(-)
diff --git
a/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/ItApplyPartitionRaftLogOnAnotherNodesCompatibilityTest.java
b/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/ItApplyPartitionRaftLogOnAnotherNodesCompatibilityTest.java
index 4fdd41c6feb..40e0e483969 100644
---
a/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/ItApplyPartitionRaftLogOnAnotherNodesCompatibilityTest.java
+++
b/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/ItApplyPartitionRaftLogOnAnotherNodesCompatibilityTest.java
@@ -73,7 +73,7 @@ public class
ItApplyPartitionRaftLogOnAnotherNodesCompatibilityTest extends Comp
void testIncreaseReplicas() throws Exception {
cluster.stop();
- cluster.startEmbedded(nodesCount(), false);
+ cluster.startEmbedded(nodesCount());
sql(String.format("ALTER ZONE %s SET REPLICAS=3,
DATA_NODES_FILTER='$..*'", ZONE_NAME));
diff --git
a/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/ItDataNodesCompatibilityTest.java
b/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/ItDataNodesCompatibilityTest.java
index 6eb5258e9ff..63259b854c1 100644
---
a/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/ItDataNodesCompatibilityTest.java
+++
b/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/ItDataNodesCompatibilityTest.java
@@ -92,7 +92,7 @@ public class ItDataNodesCompatibilityTest extends
CompatibilityTestBase {
cluster.stop();
int initialNodesCount = nodesCount();
- cluster.startEmbedded(initialNodesCount, false);
+ cluster.startEmbedded(initialNodesCount);
IgniteImpl node = unwrapIgniteImpl(cluster.node(0));
int zoneId =
node.catalogManager().activeCatalog(node.clock().currentLong()).zone(ZONE_NAME).id();
@@ -133,7 +133,7 @@ public class ItDataNodesCompatibilityTest extends
CompatibilityTestBase {
// Check that we read the new data nodes after one more restart.
cluster.stop();
- cluster.startEmbedded(initialNodesCount, false);
+ cluster.startEmbedded(initialNodesCount);
IgniteImpl restartedNode = unwrapIgniteImpl(cluster.node(0));
diff --git
a/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/ItPartitionRaftLogOneNodeCompatibilityTest.java
b/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/ItPartitionRaftLogOneNodeCompatibilityTest.java
index a08095729fb..a7d6a32a0e4 100644
---
a/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/ItPartitionRaftLogOneNodeCompatibilityTest.java
+++
b/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/ItPartitionRaftLogOneNodeCompatibilityTest.java
@@ -67,7 +67,7 @@ public class ItPartitionRaftLogOneNodeCompatibilityTest
extends CompatibilityTes
cleanTableStoragesDir();
- cluster.startEmbedded(nodesCount(), false);
+ cluster.startEmbedded(nodesCount());
assertThat(sql(String.format("SELECT * FROM %s", TABLE_NAME)),
hasSize(10));
}
diff --git
a/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/MetastorageRaftCompatibilityTest.java
b/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/MetastorageRaftCompatibilityTest.java
index d88e2718dbe..49a9929b498 100644
---
a/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/MetastorageRaftCompatibilityTest.java
+++
b/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/MetastorageRaftCompatibilityTest.java
@@ -86,14 +86,14 @@ public class MetastorageRaftCompatibilityTest extends
CompatibilityTestBase {
@Test
void testReapplication() {
- cluster.startEmbedded(1, false);
+ cluster.startEmbedded(1);
checkMetastorage();
}
@Test
void testStreamToFollower() throws InterruptedException {
- cluster.startEmbedded(2, false);
+ cluster.startEmbedded(2);
checkMetastorage();
diff --git
a/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/client/OldClientWithCurrentServerCompatibilityTest.java
b/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/client/OldClientWithCurrentServerCompatibilityTest.java
index 72c1da66454..501b403bf6e 100644
---
a/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/client/OldClientWithCurrentServerCompatibilityTest.java
+++
b/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/client/OldClientWithCurrentServerCompatibilityTest.java
@@ -28,6 +28,7 @@ import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.ignite.client.IgniteClient;
+import org.apache.ignite.internal.Cluster.ServerRegistration;
import org.apache.ignite.internal.CompatibilityTestBase;
import org.apache.ignite.internal.IgniteCluster;
import org.apache.ignite.internal.OldClientLoader;
@@ -69,7 +70,8 @@ public class OldClientWithCurrentServerCompatibilityTest
extends BaseIgniteAbstr
clientVersion = clientVer;
cluster = CompatibilityTestBase.createCluster(testInfo, workDir,
CompatibilityTestBase.NODE_BOOTSTRAP_CFG_TEMPLATE);
- cluster.startEmbedded(1, true);
+ List<ServerRegistration> serverRegistrations =
cluster.startEmbeddedNotInitialized(1);
+ cluster.initEmbedded(serverRegistrations, x -> {});
initTestData(cluster.node(0));
diff --git
a/modules/compatibility-tests/src/testFixtures/java/org/apache/ignite/internal/CompatibilityTestBase.java
b/modules/compatibility-tests/src/testFixtures/java/org/apache/ignite/internal/CompatibilityTestBase.java
index 875c31205ef..b1f6cf880d5 100644
---
a/modules/compatibility-tests/src/testFixtures/java/org/apache/ignite/internal/CompatibilityTestBase.java
+++
b/modules/compatibility-tests/src/testFixtures/java/org/apache/ignite/internal/CompatibilityTestBase.java
@@ -125,7 +125,7 @@ public abstract class CompatibilityTestBase extends
BaseIgniteAbstractTest {
if (restartWithCurrentEmbeddedVersion()) {
cluster.stop();
- cluster.startEmbedded(nodesCount, false);
+ cluster.startEmbedded(nodesCount);
await().until(this::noActiveRebalance, willBe(true));
}
}
diff --git
a/modules/compatibility-tests/src/testFixtures/java/org/apache/ignite/internal/IgniteCluster.java
b/modules/compatibility-tests/src/testFixtures/java/org/apache/ignite/internal/IgniteCluster.java
index 6413cba72aa..21a4d2bf453 100644
---
a/modules/compatibility-tests/src/testFixtures/java/org/apache/ignite/internal/IgniteCluster.java
+++
b/modules/compatibility-tests/src/testFixtures/java/org/apache/ignite/internal/IgniteCluster.java
@@ -88,7 +88,7 @@ public class IgniteCluster {
private final HttpClient client = HttpClient.newBuilder().build();
// External process nodes
- private List<RunnerNode> runnerNodes;
+ private final List<RunnerNode> runnerNodes = new CopyOnWriteArrayList<>();
private volatile boolean started = false;
private volatile boolean stopped = false;
@@ -112,7 +112,7 @@ public class IgniteCluster {
throw new IllegalStateException("The cluster is already started");
}
- runnerNodes = startRunnerNodes(igniteVersion, nodesCount,
extraIgniteModuleIds);
+ startRunnerNodes(igniteVersion, nodesCount, extraIgniteModuleIds);
}
/**
@@ -120,16 +120,52 @@ public class IgniteCluster {
*
* @param nodesCount Number of nodes in the cluster.
*/
- public void startEmbedded(int nodesCount, boolean initCluster) {
- startEmbedded(null, nodesCount, initCluster);
+ public void startEmbedded(int nodesCount) {
+ startEmbedded(null, nodesCount);
}
/**
* Starts cluster in embedded mode with nodes of current version.
*
+ * @param testInfo Test info.
* @param nodesCount Number of nodes in the cluster.
*/
- public void startEmbedded(@Nullable TestInfo testInfo, int nodesCount,
boolean initCluster) {
+ public void startEmbedded(
+ @Nullable TestInfo testInfo,
+ int nodesCount
+ ) {
+ List<ServerRegistration> nodeRegistrations =
startEmbeddedNotInitialized(testInfo, nodesCount);
+
+ for (ServerRegistration registration : nodeRegistrations) {
+ assertThat(registration.registrationFuture(),
willCompleteSuccessfully());
+ }
+
+ started = true;
+ }
+
+ /**
+ * Starts cluster in embedded mode with nodes of current version.
+ *
+ * @param nodesCount Number of nodes in the cluster.
+ *
+ * @return a list of server registrations, one for each node.
+ */
+ public List<ServerRegistration> startEmbeddedNotInitialized(int
nodesCount) {
+ return startEmbeddedNotInitialized(null, nodesCount);
+ }
+
+ /**
+ * Starts cluster in embedded mode with nodes of current version.
+ *
+ * @param testInfo Test info.
+ * @param nodesCount Number of nodes in the cluster.
+ *
+ * @return a list of server registrations, one for each node.
+ */
+ public List<ServerRegistration> startEmbeddedNotInitialized(
+ @Nullable TestInfo testInfo,
+ int nodesCount
+ ) {
if (started) {
throw new IllegalStateException("The cluster is already started");
}
@@ -142,15 +178,9 @@ public class IgniteCluster {
nodeRegistrations.add(startEmbeddedNode(testInfo, nodeIndex,
nodesCount));
}
- if (initCluster) {
- init(x -> {});
- }
-
- for (ServerRegistration registration : nodeRegistrations) {
- assertThat(registration.registrationFuture(),
willCompleteSuccessfully());
- }
-
started = true;
+
+ return nodeRegistrations;
}
/**
@@ -173,27 +203,39 @@ public class IgniteCluster {
LOG.info("Shut the embedded cluster down");
- if (runnerNodes != null) {
- List<String> nodeNames = runnerNodes.stream()
- .map(RunnerNode::nodeName)
- .collect(toList());
+ List<String> nodeNames = runnerNodes.stream()
+ .map(RunnerNode::nodeName)
+ .collect(toList());
- LOG.info("Shutting the runner nodes down: [nodes={}]", nodeNames);
+ LOG.info("Shutting the runner nodes down: [nodes={}]", nodeNames);
- runnerNodes.parallelStream().forEach(RunnerNode::stop);
- runnerNodes.clear();
+ runnerNodes.parallelStream().forEach(RunnerNode::stop);
+ runnerNodes.clear();
- LOG.info("Shutting down nodes is complete: [nodes={}]", nodeNames);
- }
+ LOG.info("Shutting down nodes is complete: [nodes={}]", nodeNames);
started = false;
stopped = true;
}
+ /**
+ * Init a cluster running in embedded mode. Only required if this has not
been done before in a prior run.
+ *
+ * @param nodeRegistrations list of server registrations.
+ * @param initParametersConfigurator the consumer to use for configuration.
+ */
+ public void initEmbedded(List<ServerRegistration> nodeRegistrations,
Consumer<InitParametersBuilder> initParametersConfigurator) {
+ init(initParametersConfigurator);
+
+ for (ServerRegistration registration : nodeRegistrations) {
+ assertThat(registration.registrationFuture(),
willCompleteSuccessfully());
+ }
+ }
+
/**
* Initializes the cluster using REST API on the first node with default
settings.
*/
- void init(Consumer<InitParametersBuilder> initParametersConfigurator) {
+ public void init(Consumer<InitParametersBuilder>
initParametersConfigurator) {
init(new int[] { 0 }, initParametersConfigurator);
}
@@ -294,7 +336,15 @@ public class IgniteCluster {
return nodes;
}
- private ServerRegistration startEmbeddedNode(
+ /**
+ * Starts an embedded node with the given index.
+ *
+ * @param testInfo Test info.
+ * @param nodeIndex Index of the node to start.
+ * @param nodesCount the total number of nodes in the cluster.
+ * @return Server registration and future that completes when the node is
fully started and joined the cluster.
+ */
+ public ServerRegistration startEmbeddedNode(
@Nullable TestInfo testInfo,
int nodeIndex,
int nodesCount
@@ -334,34 +384,19 @@ public class IgniteCluster {
return new ServerRegistration(node, registrationFuture);
}
- private List<RunnerNode> startRunnerNodes(String igniteVersion, int
nodesCount, List<String> extraIgniteModuleIds) {
- try (ProjectConnection connection = GradleConnector.newConnector()
- .forProjectDirectory(getProjectRoot())
- .connect()
- ) {
- BuildEnvironment environment =
connection.model(BuildEnvironment.class).get();
-
- File javaHome = environment.getJava().getJavaHome();
-
- Set<String> dependencyIds = new HashSet<>();
- dependencyIds.add(IGNITE_RUNNER_DEPENDENCY_ID);
- dependencyIds.addAll(extraIgniteModuleIds);
-
- String dependenciesListNotation = dependencyIds.stream()
- .map(dependency -> dependency + ":" + igniteVersion)
- .collect(joining(","));
+ private void startRunnerNodes(String igniteVersion, int nodesCount,
List<String> extraIgniteModuleIds) {
+ try (ProjectConnection connection = getProjectConnection()) {
+ File javaHome = getJavaHome(connection);
+ File argFile = getArgsFile(connection, igniteVersion,
extraIgniteModuleIds);
- File argFile = constructArgFile(connection,
dependenciesListNotation, false);
-
- List<RunnerNode> result = new ArrayList<>();
for (int nodeIndex = 0; nodeIndex < nodesCount; nodeIndex++) {
String nodeName =
clusterConfiguration.nodeNamingStrategy().nodeName(clusterConfiguration,
nodeIndex);
String nodeConfig = formatConfig(clusterConfiguration,
nodeName, nodeIndex, nodesCount);
+ RunnerNode newNode = RunnerNode.startNode(javaHome, argFile,
igniteVersion, clusterConfiguration, nodeConfig, nodesCount,
+ nodeName);
- result.add(RunnerNode.startNode(javaHome, argFile,
igniteVersion, clusterConfiguration, nodeConfig, nodesCount, nodeName));
+ runnerNodes.add(newNode);
}
-
- return result;
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -435,4 +470,29 @@ public class IgniteCluster {
nodeIndex
);
}
+
+ private static ProjectConnection getProjectConnection() {
+ return GradleConnector.newConnector()
+ .forProjectDirectory(getProjectRoot())
+ .connect();
+ }
+
+ private static File getJavaHome(ProjectConnection connection) {
+ BuildEnvironment environment =
connection.model(BuildEnvironment.class).get();
+
+ return environment.getJava().getJavaHome();
+ }
+
+ private static File getArgsFile(ProjectConnection connection, String
igniteVersion, List<String> extraIgniteModuleIds)
+ throws IOException {
+ Set<String> dependencyIds = new HashSet<>();
+ dependencyIds.add(IGNITE_RUNNER_DEPENDENCY_ID);
+ dependencyIds.addAll(extraIgniteModuleIds);
+
+ String dependenciesListNotation = dependencyIds.stream()
+ .map(dependency -> dependency + ":" + igniteVersion)
+ .collect(joining(","));
+
+ return constructArgFile(connection, dependenciesListNotation, false);
+ }
}