xtern commented on code in PR #5111:
URL: https://github.com/apache/ignite-3/pull/5111#discussion_r1928409208


##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/framework/TestBuilders.java:
##########
@@ -357,6 +358,26 @@ public interface ClusterBuilder {
          */
         ClusterBuilder nodes(String firstNodeName, String... otherNodeNames);
 
+        /**
+         * A decorator to wrap {@link CatalogManager} instance which will be 
used int test cluster.

Review Comment:
   ```suggestion
            * A decorator to wrap {@link CatalogManager} instance which will be 
used in the test cluster.
   ```



##########
modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItSqlMultiStatementTxTest.java:
##########
@@ -304,6 +305,9 @@ void dmlFailsOnReadOnlyTransaction() {
         assertThrowsSqlException(RUNTIME_ERR, "DML cannot be started by using 
read only transactions.",
                 () -> await(insCur.nextResult()));
 
+        assertThrowsSqlException(EXECUTION_CANCELLED_ERR, "The query was 
cancelled while executing.",
+                () -> await(insCur.requestNextAsync(1)));

Review Comment:
   ```suggestion
           expectQueryCancelled(() -> await(insCur.requestNextAsync(1)));
   ```



##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/QueryTimeoutTest.java:
##########
@@ -0,0 +1,276 @@
+/*
+ * 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.sql.engine.exec;
+
+import static java.util.UUID.randomUUID;
+import static 
org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrows;
+import static 
org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrowWithCauseOrSuppressed;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.lang.reflect.Proxy;
+import java.util.BitSet;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Flow.Publisher;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.ignite.internal.catalog.CatalogManager;
+import org.apache.ignite.internal.sql.engine.AsyncSqlCursor;
+import org.apache.ignite.internal.sql.engine.QueryCancelledException;
+import org.apache.ignite.internal.sql.engine.QueryProperty;
+import org.apache.ignite.internal.sql.engine.api.kill.CancellableOperationType;
+import org.apache.ignite.internal.sql.engine.api.kill.OperationKillHandler;
+import org.apache.ignite.internal.sql.engine.exec.RowHandler.RowFactory;
+import org.apache.ignite.internal.sql.engine.exec.exp.RangeCondition;
+import org.apache.ignite.internal.sql.engine.exec.mapping.ColocationGroup;
+import org.apache.ignite.internal.sql.engine.framework.TestBuilders;
+import org.apache.ignite.internal.sql.engine.framework.TestCluster;
+import org.apache.ignite.internal.sql.engine.framework.TestNode;
+import org.apache.ignite.internal.sql.engine.property.SqlProperties;
+import org.apache.ignite.internal.sql.engine.property.SqlPropertiesHelper;
+import org.apache.ignite.internal.sql.engine.schema.TableDescriptor;
+import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest;
+import org.apache.ignite.internal.tx.InternalTransaction;
+import org.apache.ignite.internal.util.SubscriptionUtils;
+import org.apache.ignite.sql.SqlException;
+import org.jetbrains.annotations.Nullable;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+/** Tests cases for cancellation due to timeout. */
+@SuppressWarnings("ThrowableNotThrown")
+public class QueryTimeoutTest extends BaseIgniteAbstractTest {
+    private static final String NODE_NAME = "gateway";
+
+    private final AtomicBoolean ignoreCatalogUpdates = new 
AtomicBoolean(false);
+
+    private static final SqlProperties PROPS_WITH_TIMEOUT = 
SqlPropertiesHelper.newBuilder()
+            // Relatively high timeout is set to make tests are stable on TC. 
The reason is that
+            // query have to make it to the final point which is varied from 
test to test in
+            // order to 1) make sure timeout is handled properly at particular 
stages of query
+            // execution, and 2) to fail with proper exception class.
+            .set(QueryProperty.QUERY_TIMEOUT, 2_000L)
+            .build();
+
+    private TestCluster cluster;
+    private TestNode gatewayNode;
+
+    @BeforeEach
+    void startCluster() {
+        ignoreCatalogUpdates.set(false);
+
+        cluster = TestBuilders.cluster()
+                .nodes(NODE_NAME)
+                .catalogManagerDecorator(this::catalogManagerDecorator)
+                .operationKillHandlers(
+                        new OperationKillHandler() {
+                            @Override
+                            public CompletableFuture<Boolean> 
cancelAsync(String operationId) {
+                                return new CompletableFuture<>();
+                            }
+
+                            @Override
+                            public boolean local() {
+                                return true;
+                            }
+
+                            @Override
+                            public CancellableOperationType type() {
+                                return CancellableOperationType.QUERY;
+                            }
+                        }
+                )
+                .build();
+
+        cluster.start();
+
+
+        gatewayNode = cluster.node(NODE_NAME);
+
+        gatewayNode.initSchema("CREATE TABLE my_table (id INT PRIMARY KEY, val 
VARCHAR(128))");
+        cluster.setDataProvider("MY_TABLE", neverReplyingScannableTable());
+        cluster.setUpdatableTable("MY_TABLE", neverReplyingUpdatableTable());
+        cluster.setAssignmentsProvider(
+                "MY_TABLE",
+                (partitionsCount, includeBackups) -> IntStream.range(0, 
partitionsCount)
+                        .mapToObj(p -> List.of(NODE_NAME))
+                        .collect(Collectors.toList())
+        );
+    }
+
+    @AfterEach
+    void stopCluster() throws Exception {
+        cluster.stop();
+    }
+
+    @Test
+    void testTimeoutDdl() {
+        ignoreCatalogUpdates.set(true);
+
+        assertThrows(
+                QueryCancelledException.class,
+                () -> gatewayNode.executeQuery(PROPS_WITH_TIMEOUT, "CREATE 
TABLE x (id INTEGER PRIMARY KEY, val INTEGER)"),
+                "Query timeout"

Review Comment:
   ```suggestion
                  QueryCancelledException.TIMEOUT_MSG
   ```



-- 
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: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to