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

vpyatkov 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 72bf4c09a6 IGNITE-22848 ItDmlTest#scanExecutedWithinGivenTransaction 
make this test correctness (#4149)
72bf4c09a6 is described below

commit 72bf4c09a6138e0e9e73d44d5dde1a60334db1a7
Author: Vladislav Pyatkov <[email protected]>
AuthorDate: Sat Jul 27 09:49:58 2024 +0300

    IGNITE-22848 ItDmlTest#scanExecutedWithinGivenTransaction make this test 
correctness (#4149)
---
 .../ignite/internal/sql/engine/ItDmlTest.java      | 26 +++++++++++++++++-----
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git 
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDmlTest.java
 
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDmlTest.java
index 895ea74f1e..8adae45f56 100644
--- 
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDmlTest.java
+++ 
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDmlTest.java
@@ -21,7 +21,11 @@ import static 
org.apache.ignite.internal.lang.IgniteStringFormatter.format;
 import static 
org.apache.ignite.internal.sql.engine.util.QueryChecker.containsSubPlan;
 import static 
org.apache.ignite.internal.sql.engine.util.QueryChecker.containsTableScan;
 import static 
org.apache.ignite.internal.sql.engine.util.SqlTestUtils.assertThrowsSqlException;
+import static 
org.apache.ignite.internal.testframework.IgniteTestUtils.runAsync;
+import static 
org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.params.provider.Arguments.arguments;
@@ -33,6 +37,7 @@ import java.time.LocalTime;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.CompletableFuture;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import org.apache.calcite.sql.type.SqlTypeName;
@@ -44,6 +49,7 @@ import 
org.apache.ignite.internal.testframework.WithSystemProperty;
 import org.apache.ignite.lang.ErrorGroups.Sql;
 import org.apache.ignite.lang.IgniteException;
 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;
@@ -452,10 +458,10 @@ public class ItDmlTest extends BaseSqlIntegrationTest {
      * Test verifies that scan is executed within provided transaction.
      */
     @Test
-    @Disabled("https://issues.apache.org/jira/browse/IGNITE-15081";)
     public void scanExecutedWithinGivenTransaction() {
         sql("CREATE TABLE test (id int primary key, val int)");
 
+        Transaction olderTx = CLUSTER.aliveNode().transactions().begin();
         Transaction tx = CLUSTER.aliveNode().transactions().begin();
 
         sql(tx, "INSERT INTO test VALUES (0, 0)");
@@ -463,16 +469,24 @@ public class ItDmlTest extends BaseSqlIntegrationTest {
         // just inserted row should be visible within the same transaction
         assertEquals(1, sql(tx, "select * from test").size());
 
-        Transaction anotherTx = CLUSTER.aliveNode().transactions().begin();
-
         // just inserted row should not be visible until related transaction 
is committed
-        assertEquals(0, sql(anotherTx, "select * from test").size());
+        assertEquals(0,
+                sql(CLUSTER.aliveNode().transactions().begin(new 
TransactionOptions().readOnly(true)), "select * from test").size());
+
+        CompletableFuture<Integer> selectFut = runAsync(() -> sql(olderTx, 
"select * from test").size());
+
+        assertFalse(selectFut.isDone());
 
         tx.commit();
 
-        assertEquals(1, sql(anotherTx, "select * from test").size());
+        assertThat(selectFut, willCompleteSuccessfully());
+
+        assertEquals(1, selectFut.join());
+
+        assertEquals(1,
+                sql(CLUSTER.aliveNode().transactions().begin(new 
TransactionOptions().readOnly(true)), "select * from test").size());
 
-        anotherTx.commit();
+        olderTx.commit();
     }
 
     @Test

Reply via email to