ibessonov commented on code in PR #5406:
URL: https://github.com/apache/ignite-3/pull/5406#discussion_r1995409964


##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/ItTruncateRaftLogAndRestartNodesTest.java:
##########
@@ -0,0 +1,494 @@
+/*
+ * 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.TestWrappers.unwrapIgniteImpl;
+import static org.apache.ignite.internal.TestWrappers.unwrapTableViewInternal;
+import static 
org.apache.ignite.internal.catalog.CatalogService.DEFAULT_STORAGE_PROFILE;
+import static 
org.apache.ignite.internal.testframework.flow.TestFlowUtils.subscribeToList;
+import static 
org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
+import static org.apache.ignite.internal.util.CompletableFutures.allOf;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.arrayWithSize;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.lessThan;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Flow.Publisher;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.Function;
+import java.util.stream.IntStream;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.binarytuple.BinaryTupleReader;
+import org.apache.ignite.internal.close.ManuallyCloseable;
+import org.apache.ignite.internal.logger.IgniteLogger;
+import org.apache.ignite.internal.logger.Loggers;
+import org.apache.ignite.internal.manager.ComponentContext;
+import org.apache.ignite.internal.raft.storage.LogStorageFactory;
+import org.apache.ignite.internal.raft.storage.impl.IgniteJraftServiceFactory;
+import org.apache.ignite.internal.raft.util.SharedLogStorageFactoryUtils;
+import org.apache.ignite.internal.replicator.TablePartitionId;
+import org.apache.ignite.internal.schema.BinaryRow;
+import org.apache.ignite.internal.schema.Column;
+import org.apache.ignite.internal.schema.SchemaDescriptor;
+import org.apache.ignite.internal.storage.MvPartitionStorage;
+import org.apache.ignite.internal.table.TableViewInternal;
+import org.apache.ignite.internal.table.distributed.storage.InternalTableImpl;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.tostring.IgniteToStringInclude;
+import org.apache.ignite.internal.tostring.S;
+import org.apache.ignite.internal.tx.InternalTransaction;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.network.ClusterNode;
+import org.apache.ignite.raft.jraft.conf.ConfigurationManager;
+import org.apache.ignite.raft.jraft.core.NodeImpl;
+import org.apache.ignite.raft.jraft.option.LogStorageOptions;
+import org.apache.ignite.raft.jraft.option.NodeOptions;
+import org.apache.ignite.raft.jraft.option.RaftOptions;
+import org.apache.ignite.raft.jraft.storage.LogStorage;
+import org.apache.ignite.tx.TransactionOptions;
+import org.hamcrest.Matchers;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Class for testing various scenarios with raft log truncation and node 
restarts that emulate the situation with fsync disabled for raft
+ * groups associated with tables.
+ */
+public class ItTruncateRaftLogAndRestartNodesTest extends 
ClusterPerTestIntegrationTest {
+    private static final IgniteLogger LOG = 
Loggers.forClass(ItTruncateRaftLogAndRestartNodesTest.class);
+
+    private static final String ZONE_NAME = "TEST_ZONE";
+
+    private static final String TABLE_NAME = "TEST_TABLE";
+
+    @Override
+    protected int initialNodes() {
+        return 0;
+    }
+
+    @Disabled("https://issues.apache.org/jira/browse/IGNITE-24802";)
+    @Test
+    void enterNodeWithIndexGreaterThanCurrentMajority() throws Exception {
+        cluster.startAndInit(3);
+
+        createZoneAndTablePerson(ZONE_NAME, TABLE_NAME, 3, 1);
+
+        cluster.transferLeadershipTo(2, cluster.solePartitionId());
+
+        var closableResources = new ArrayList<ManuallyCloseable>();
+
+        try {
+            TestLogStorageFactory testLogStorageFactoryNode0 = 
createTestLogStorageFactory(0, cluster.solePartitionId());
+            closableResources.add(testLogStorageFactoryNode0);
+
+            TestLogStorageFactory testLogStorageFactoryNode1 = 
createTestLogStorageFactory(1, cluster.solePartitionId());
+            closableResources.add(testLogStorageFactoryNode1);
+
+            long lastLogIndexBeforeInsertNode0 = raftNodeImpl(0, 
cluster.solePartitionId()).lastLogIndex();
+            long lastLogIndexBeforeInsertNode1 = raftNodeImpl(1, 
cluster.solePartitionId()).lastLogIndex();
+
+            Person[] people = generatePeople(10);
+            insertPeople(TABLE_NAME, people);
+
+            // Let's flush the state machine so that the raft log on a node 
cannot be truncated.
+            flushMvPartitionStorage(2, TABLE_NAME, 0);
+
+            stopNodes(0, 1, 2);
+
+            LogStorage logStorageNode0 = 
testLogStorageFactoryNode0.createLogStorage();
+            closableResources.add(logStorageNode0::shutdown);
+
+            LogStorage logStorageNode1 = 
testLogStorageFactoryNode1.createLogStorage();
+            closableResources.add(logStorageNode1::shutdown);
+
+            truncateRaftLogSuffixHalfOfChanges(logStorageNode0, 
lastLogIndexBeforeInsertNode0);
+            truncateRaftLogSuffixHalfOfChanges(logStorageNode1, 
lastLogIndexBeforeInsertNode1);
+
+            closeAllReversed(closableResources);

Review Comment:
   Please add `closableResources.clear()` after this line, to make the code 
clearer



-- 
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]

Reply via email to