zstan commented on code in PR #2768:
URL: https://github.com/apache/ignite-3/pull/2768#discussion_r1377469481


##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/mapping/FragmentMappingTest.java:
##########
@@ -0,0 +1,337 @@
+/*
+ * 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.mapping;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.catalog.CatalogManager;
+import org.apache.ignite.internal.cluster.management.topology.api.LogicalNode;
+import 
org.apache.ignite.internal.cluster.management.topology.api.LogicalTopologySnapshot;
+import 
org.apache.ignite.internal.sql.engine.exec.mapping.MappingTestRunner.TestSetup;
+import org.apache.ignite.internal.sql.engine.framework.TestBuilders;
+import 
org.apache.ignite.internal.sql.engine.framework.TestBuilders.ExecutionTargetProviderBuilder;
+import 
org.apache.ignite.internal.sql.engine.framework.TestBuilders.TableBuilder;
+import org.apache.ignite.internal.sql.engine.framework.TestTable;
+import org.apache.ignite.internal.sql.engine.planner.AbstractPlannerTest;
+import org.apache.ignite.internal.sql.engine.rel.IgniteRel;
+import org.apache.ignite.internal.sql.engine.schema.IgniteDataSource;
+import org.apache.ignite.internal.sql.engine.schema.IgniteSchema;
+import 
org.apache.ignite.internal.sql.engine.trait.DistributionFunction.AffinityDistribution;
+import 
org.apache.ignite.internal.sql.engine.trait.DistributionFunction.IdentityDistribution;
+import org.apache.ignite.internal.sql.engine.trait.IgniteDistribution;
+import org.apache.ignite.internal.sql.engine.trait.IgniteDistributions;
+import org.apache.ignite.internal.type.NativeTypes;
+import org.apache.ignite.internal.util.Pair;
+import org.apache.ignite.network.NetworkAddress;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests for fragment mapping.
+ *
+ * <p>Test setup:
+ * <pre>
+ *     // add nodes named n1, n2, and n3 to the cluster.
+ *     addNodes("N1", "N2", "N3");
+ *
+ *     // The first statement adds a table with data located at node n1.
+ *     // The first one adds a table with data located at node n2, n3.
+ *     // The catalog is going to contain to tables "t1_n1" and "t2_n2n3".
+ *     // Both tables have distribution affinity([0], tableId, zoneId)
+ *     addTable("T1", "N1");
+ *     addTable("T2", "N2", "N3");
+ *
+ *     // Adds table with identity(0) distribution. Can be used to mimic node 
system views.
+ *     addTableIdent("NT1", "N1");
+ *
+ *     // Adds table with single distribution. Can be used to mimic 
cluster-wide system views.
+ *     addTableSingle("CT2", "N1", "N2", "N3");
+ *
+ *     // Sets row count statistics to 100 for all tables named like T1_*
+ *     setRowCount("T1", 100);
+ *
+ *     var runner = new MappingTestRunner("tests_dir");
+ *     // run test cases
+ *     runner.run(this::initSchema, "file.test");
+ * </pre>
+ *
+ * <p>See {@link MappingTestRunner} for test file format description.
+ *
+ * @see MappingTestRunner
+ */
+public class FragmentMappingTest extends AbstractPlannerTest {
+
+    private static final Path LOCATION = 
Paths.get("src/test/resources/mapping");
+
+    private final TreeSet<String> nodeNames = new TreeSet<>();
+
+    private final TreeMap<String, Pair<IgniteDistribution, List<String>>> 
tables = new TreeMap<>();
+
+    private final Map<String, Integer> tableRows = new HashMap<>();
+
+    private final MappingTestRunner testRunner = new 
MappingTestRunner(LOCATION, this::parseQuery);
+
+    @Test
+    public void testValues() {
+        addNodes("N1", "N2");
+
+        testRunner.runTest(this::initSchema, "values.test");
+    }
+
+    @Test
+    public void testTable() {
+        addNodes("N1", "N2");
+
+        addTable("T1", "N1");

Review Comment:
   i try to play with this framework and change :
   addNodes("N2", "N3");
   addTable("T1", "N2");
   and in the table_affinity.test i change :
   N1
   SELECT * FROM t1_n2
   obtain test infinetely hanging



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