alex-plekhanov commented on a change in pull request #9671:
URL: https://github.com/apache/ignite/pull/9671#discussion_r803530067



##########
File path: 
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexRebuildIntegrationTest.java
##########
@@ -0,0 +1,316 @@
+/*
+ * 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.processors.query.calcite.integration;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.cluster.ClusterState;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.cache.query.index.IndexProcessor;
+import org.apache.ignite.internal.managers.indexing.IndexesRebuildTask;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.query.calcite.QueryChecker;
+import 
org.apache.ignite.internal.processors.query.schema.IndexRebuildCancelToken;
+import 
org.apache.ignite.internal.processors.query.schema.SchemaIndexCacheVisitorClosure;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.hamcrest.CoreMatchers;
+import org.junit.Test;
+
+/**
+ * Test index rebuild.
+ */
+public class IndexRebuildIntegrationTest extends AbstractBasicIntegrationTest {
+    /** Index rebuild init latch. */
+    private static CountDownLatch initLatch;
+
+    /** Index rebuild start latch. */
+    private static CountDownLatch startLatch;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        IndexProcessor.idxRebuildCls = BlockingIndexesRebuildTask.class;
+
+        return 
super.getConfiguration(igniteInstanceName).setDataStorageConfiguration(
+            new DataStorageConfiguration().setDefaultDataRegionConfiguration(
+                new DataRegionConfiguration().setPersistenceEnabled(true)));
+    }
+
+    /** {@inheritDoc} */
+    @Override protected int nodeCount() {
+        return 2;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        initLatch = null;
+        startLatch = null;
+
+        super.beforeTest();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() {
+        // Override super method to skip caches destroy.
+        cleanQueryPlanCache();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        cleanPersistenceDir();
+
+        super.beforeTestsStarted();
+
+        client.cluster().state(ClusterState.ACTIVE);
+
+        executeSql("CREATE TABLE tbl (id INT PRIMARY KEY, val VARCHAR, val2 
VARCHAR) WITH CACHE_NAME=\"test\"");
+        executeSql("CREATE INDEX idx_id_val ON tbl (id DESC, val)");
+        executeSql("CREATE INDEX idx_id_val2 ON tbl (id, val2 DESC)");
+        executeSql("CREATE INDEX idx_val ON tbl (val DESC)");
+
+        for (int i = 0; i < 100; i++)
+            executeSql("INSERT INTO tbl VALUES (?, ?, ?)", i, "val" + i, "val" 
+ i);
+
+        executeSql("CREATE TABLE tbl2 (id INT PRIMARY KEY, val VARCHAR)");
+
+        for (int i = 0; i < 100; i++)
+            executeSql("INSERT INTO tbl2 VALUES (?, ?)", i, "val" + i);
+    }
+
+    /** */
+    @Test
+    public void testRebuildOnInitiatorNode() throws Exception {
+        String sql = "SELECT * FROM tbl WHERE id = 0 AND val='val0'";
+
+        QueryChecker validChecker = assertQuery(grid(0), sql)
+            .matches(QueryChecker.containsIndexScan("PUBLIC", "TBL", 
"IDX_ID_VAL"))

Review comment:
       Then we need to reuse the same queries for integration and planning 
tests. And we should ensure that queries in planning tests can't be changed 
without corresponding changes to integration tests. Perhaps, introduce some 
constants with queries. But I think it's not much convenient, so it's better to 
just recheck the required rel op in integration tests.
   
   Without concurrent workload, the plan should be the same for explain and the 
query. It's much more likely that plan in planner test for the same query will 
be different than plan for integration test (and there are a lot of such cases 
currently).




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