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 8a0490df7a6 IGNITE-26490 Add tests for WI resolution during index 
build (#6632)
8a0490df7a6 is described below

commit 8a0490df7a60dcb1d7c5f9032324aba25235e223
Author: Roman Puchkovskiy <[email protected]>
AuthorDate: Mon Sep 22 18:15:26 2025 +0400

    IGNITE-26490 Add tests for WI resolution during index build (#6632)
---
 .../internal/index/ItBuildIndexOneNodeTest.java    | 56 ++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git 
a/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexOneNodeTest.java
 
b/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexOneNodeTest.java
index 5f041a60772..324eaa86622 100644
--- 
a/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexOneNodeTest.java
+++ 
b/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexOneNodeTest.java
@@ -56,14 +56,19 @@ import 
org.apache.ignite.internal.sql.engine.util.QueryChecker;
 import org.apache.ignite.internal.storage.MvPartitionStorage;
 import org.apache.ignite.internal.storage.RowId;
 import org.apache.ignite.internal.storage.engine.MvTableStorage;
+import org.apache.ignite.internal.storage.index.IndexRow;
 import org.apache.ignite.internal.storage.index.IndexStorage;
+import org.apache.ignite.internal.storage.index.SortedIndexStorage;
 import org.apache.ignite.internal.table.TableViewInternal;
+import org.apache.ignite.internal.tx.message.WriteIntentSwitchReplicaRequest;
+import org.apache.ignite.internal.util.Cursor;
 import org.apache.ignite.sql.SqlException;
 import org.apache.ignite.table.Table;
 import org.apache.ignite.tx.Transaction;
 import org.apache.ignite.tx.TransactionOptions;
 import org.jetbrains.annotations.Nullable;
 import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 
 /** Integration test for testing the building of an index in a single node 
cluster. */
@@ -340,6 +345,57 @@ public class ItBuildIndexOneNodeTest extends 
BaseSqlIntegrationTest {
                 .check();
     }
 
+    @Test
+    void writeIntentFromCommittedTxShouldBeIndexed() throws Exception {
+        createZoneAndTable(ZONE_NAME, TABLE_NAME, 1, 1);
+
+        disableWriteIntentSwitchExecution();
+
+        Transaction tx = node().transactions().begin();
+        insertDataInTransaction(tx, TABLE_NAME, List.of("ID", "NAME", 
"SALARY"), new Object[]{0, "0", 10.0});
+        tx.commit();
+
+        createIndexForSalaryFieldAndWaitBecomeAvailable();
+
+        CatalogIndexDescriptor indexDescriptor = indexDescriptor(INDEX_NAME);
+        SortedIndexStorage indexStorage = (SortedIndexStorage) 
indexStorage(indexDescriptor, 0);
+
+        boolean hasSomethingInIndex;
+        try (Cursor<IndexRow> indexRows = indexStorage.readOnlyScan(null, 
null, 0)) {
+            hasSomethingInIndex = indexRows.hasNext();
+        }
+
+        assertTrue(hasSomethingInIndex, "Row should have been put to the 
index");
+    }
+
+    @Test
+    @Disabled("https://issues.apache.org/jira/browse/IGNITE-21546";)
+    void writeIntentFromAbortedTxShouldNotBeIndexed() throws Exception {
+        createZoneAndTable(ZONE_NAME, TABLE_NAME, 1, 1);
+
+        disableWriteIntentSwitchExecution();
+
+        Transaction tx = node().transactions().begin();
+        insertDataInTransaction(tx, TABLE_NAME, List.of("ID", "NAME", 
"SALARY"), new Object[]{0, "0", 10.0});
+        tx.rollback();
+
+        createIndexForSalaryFieldAndWaitBecomeAvailable();
+
+        CatalogIndexDescriptor indexDescriptor = indexDescriptor(INDEX_NAME);
+        SortedIndexStorage indexStorage = (SortedIndexStorage) 
indexStorage(indexDescriptor, 0);
+
+        boolean hasSomethingInIndex;
+        try (Cursor<IndexRow> indexRows = indexStorage.readOnlyScan(null, 
null, 0)) {
+            hasSomethingInIndex = indexRows.hasNext();
+        }
+
+        assertFalse(hasSomethingInIndex, "Nothing should have been put to the 
index");
+    }
+
+    private static void disableWriteIntentSwitchExecution() {
+        node().dropMessages((recipientId, message) -> message instanceof 
WriteIntentSwitchReplicaRequest);
+    }
+
     private static IgniteImpl node() {
         return unwrapIgniteImpl(CLUSTER.node(0));
     }

Reply via email to