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

rpuch 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 ba27be0688e IGNITE-26099 Add Metastore snapshot file compatibility 
test (#6874)
ba27be0688e is described below

commit ba27be0688e0327de7d2fe95c544a4fd5a156a56
Author: Phillippko <[email protected]>
AuthorDate: Thu Nov 6 14:17:28 2025 +0400

    IGNITE-26099 Add Metastore snapshot file compatibility test (#6874)
---
 modules/compatibility-tests/jobs.gradle            |  2 +
 ...ItMetastorageRaftSnapshotCompatibilityTest.java | 95 ++++++++++++++++++++++
 .../apache/ignite/internal/compute/JobsCommon.java | 29 +++++++
 .../internal/compute/TruncateRaftLogCommand.java   | 54 ++++++++++++
 4 files changed, 180 insertions(+)

diff --git a/modules/compatibility-tests/jobs.gradle 
b/modules/compatibility-tests/jobs.gradle
index ad765ec42e8..15880b14b5b 100644
--- a/modules/compatibility-tests/jobs.gradle
+++ b/modules/compatibility-tests/jobs.gradle
@@ -45,6 +45,8 @@ dependencies {
     jobsImplementation project(':ignite-page-memory')
     jobsImplementation project(':ignite-storage-api')
     jobsImplementation project(':ignite-storage-page-memory')
+    jobsImplementation project(':ignite-raft')
+    jobsImplementation project(':ignite-raft-api')
 
     integrationTestImplementation sourceSets.jobs.output
 }
diff --git 
a/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/ItMetastorageRaftSnapshotCompatibilityTest.java
 
b/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/ItMetastorageRaftSnapshotCompatibilityTest.java
new file mode 100644
index 00000000000..cd6aa8942e6
--- /dev/null
+++ 
b/modules/compatibility-tests/src/integrationTest/java/org/apache/ignite/internal/ItMetastorageRaftSnapshotCompatibilityTest.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import static 
org.apache.ignite.internal.AssignmentsTestUtils.awaitAssignmentsStabilization;
+import static 
org.apache.ignite.internal.CompatibilityTestCommon.TABLE_NAME_TEST;
+import static 
org.apache.ignite.internal.CompatibilityTestCommon.createDefaultTables;
+import static org.apache.ignite.internal.TestWrappers.unwrapIgniteImpl;
+import static org.apache.ignite.internal.client.DeploymentUtils.runJob;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.Matchers.is;
+
+import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.internal.client.DeploymentUtils;
+import org.apache.ignite.internal.compute.SendAllMetastorageCommandTypesJob;
+import org.apache.ignite.internal.compute.TruncateRaftLogCommand;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.server.raft.MetastorageGroupId;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedClass;
+import org.junit.jupiter.params.provider.MethodSource;
+
+/** Compatibility tests for metastorage raft snapshot. */
+@ParameterizedClass
+@MethodSource("baseVersions")
+@MicronautTest(rebuildContext = true)
+public class ItMetastorageRaftSnapshotCompatibilityTest extends 
CompatibilityTestBase {
+    @Override
+    protected boolean restartWithCurrentEmbeddedVersion() {
+        return false;
+    }
+
+    @Override
+    protected int nodesCount() {
+        return 1;
+    }
+
+    @Override
+    protected void setupBaseVersion(Ignite baseIgnite) {
+        DeploymentUtils.deployJobs();
+
+        createDefaultTables(baseIgnite);
+
+        runSendAllMetastorageCommandTypesJob();
+        runTruncateLogCommand();
+    }
+
+    @Test
+    @Disabled("https://issues.apache.org/jira/browse/IGNITE-26923";)
+    void testMetastorageRaftSnapshotCompatibility() throws 
InterruptedException {
+        cluster.stop();
+        cluster.startEmbedded(2);
+
+        awaitAssignmentsStabilization(node(0), TABLE_NAME_TEST);
+
+        checkMetastorage();
+
+        MetaStorageManager newNodeMetastorage = 
unwrapIgniteImpl(cluster.node(1)).metaStorageManager();
+        MetaStorageManager oldNodeMetastorage = 
unwrapIgniteImpl(cluster.node(0)).metaStorageManager();
+
+        // Assert that new node got all log entries from old one.
+        await().until(oldNodeMetastorage::appliedRevision, 
is(newNodeMetastorage.appliedRevision()));
+        ;
+    }
+
+    private void checkMetastorage() {
+        // Will fail if metastorage is corrupted.
+        sql("SELECT * FROM " + TABLE_NAME_TEST);
+    }
+
+    private void runSendAllMetastorageCommandTypesJob() {
+        runJob(cluster, SendAllMetastorageCommandTypesJob.class, "");
+    }
+
+    private void runTruncateLogCommand() {
+        runJob(cluster, TruncateRaftLogCommand.class, 
MetastorageGroupId.INSTANCE.toString());
+    }
+}
diff --git 
a/modules/compatibility-tests/src/jobs/java/org/apache/ignite/internal/compute/JobsCommon.java
 
b/modules/compatibility-tests/src/jobs/java/org/apache/ignite/internal/compute/JobsCommon.java
new file mode 100644
index 00000000000..13c8306e132
--- /dev/null
+++ 
b/modules/compatibility-tests/src/jobs/java/org/apache/ignite/internal/compute/JobsCommon.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.compute;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.wrapper.Wrappers;
+
+/** Common utilities for jobs in compatibility tests. */
+class JobsCommon {
+    static IgniteImpl unwrapIgniteImpl(Ignite ignite) {
+        return Wrappers.unwrap(ignite, IgniteImpl.class);
+    }
+}
diff --git 
a/modules/compatibility-tests/src/jobs/java/org/apache/ignite/internal/compute/TruncateRaftLogCommand.java
 
b/modules/compatibility-tests/src/jobs/java/org/apache/ignite/internal/compute/TruncateRaftLogCommand.java
new file mode 100644
index 00000000000..6ac35c19890
--- /dev/null
+++ 
b/modules/compatibility-tests/src/jobs/java/org/apache/ignite/internal/compute/TruncateRaftLogCommand.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.compute;
+
+import static org.apache.ignite.internal.compute.JobsCommon.unwrapIgniteImpl;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.JobExecutionContext;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.network.MessagingService;
+import org.apache.ignite.raft.jraft.RaftMessagesFactory;
+import org.apache.ignite.raft.jraft.rpc.CliRequests.SnapshotRequest;
+
+/** Used to truncate the Raft log via a snapshot in the older cluster version. 
*/
+@SuppressWarnings("TestOnlyProblems")
+public class TruncateRaftLogCommand implements ComputeJob<String, Void> {
+    @Override
+    public CompletableFuture<Void> executeAsync(JobExecutionContext context, 
String groupId) {
+        try {
+            IgniteImpl igniteImpl = unwrapIgniteImpl(context.ignite());
+
+            SnapshotRequest request = new 
RaftMessagesFactory().snapshotRequest()
+                    .groupId(groupId)
+                    .peerId(igniteImpl.name())
+                    .build();
+
+            MessagingService messagingService = 
igniteImpl.raftManager().messagingService();
+
+            // Version 3.0.0 doesn't have "forced" snapshot, so we have to 
request it twice.
+            return messagingService.invoke(igniteImpl.name(), request, 10_000L)
+                    .thenCompose(ignored -> 
messagingService.invoke(igniteImpl.name(), request, 10_000L))
+                    .thenApply(ignored -> null);
+        } catch (Exception e) {
+            throw new CompletionException(e);
+        }
+    }
+}

Reply via email to