From 52d9168e5879470161b4a72735bfcd849dfa13c6 Mon Sep 17 00:00:00 2001 From: Alexander Paschenko Date: Thu, 28 Sep 2017 20:56:23 +0300 Subject: [PATCH 1/4] IGNITE-6416 Dynamic columns tests refactoring. --- .../odbc/jdbc/JdbcRequestHandler.java | 3 +- ...amicColumnsAbstractConcurrentSelfTest.java | 16 +- .../index/DynamicColumnsAbstractTest.java | 166 +++--------------- ...H2DynamicColumnsAbstractBasicSelfTest.java | 35 ++-- 4 files changed, 48 insertions(+), 172 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java index ea25b11a980b3..4515683a06f94 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java @@ -23,6 +23,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -515,7 +516,7 @@ private JdbcResponse getTablesMeta(JdbcMetaTablesRequest req) { */ private JdbcResponse getColumnsMeta(JdbcMetaColumnsRequest req) { try { - Collection meta = new HashSet<>(); + Collection meta = new LinkedHashSet<>(); for (String cacheName : ctx.cache().publicCacheNames()) { for (GridQueryTypeDescriptor table : ctx.query().types(cacheName)) { diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractConcurrentSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractConcurrentSelfTest.java index 969c9850632fb..2362e540fb5ba 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractConcurrentSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractConcurrentSelfTest.java @@ -174,7 +174,7 @@ public void testCoordinatorChange() throws Exception { colFut1.get(); - checkNodesState(TBL_NAME, c("age", Integer.class.getName())); + checkTableState(QueryUtils.DFLT_SCHEMA, TBL_NAME, c("age", Integer.class.getName())); // Test migration from normal server to non-affinity server. idxLatch = blockIndexing(srv2Id); @@ -190,7 +190,7 @@ public void testCoordinatorChange() throws Exception { colFut2.get(); - checkNodesState(TBL_NAME, c("city", String.class.getName())); + checkTableState(QueryUtils.DFLT_SCHEMA, TBL_NAME, c("city", String.class.getName())); } /** @@ -238,7 +238,7 @@ public void testOperationChaining() throws Exception { U.await(finishLatch); - checkNodesState(TBL_NAME, c1, c2); + checkTableState(QueryUtils.DFLT_SCHEMA, TBL_NAME, c1, c2); } /** @@ -275,7 +275,7 @@ public void testNodeJoinOnPendingOperation() throws Exception { U.await(finishLatch); - checkNodesState(TBL_NAME, c); + checkTableState(QueryUtils.DFLT_SCHEMA, TBL_NAME, c); } /** @@ -334,7 +334,7 @@ public void testConcurrentPutRemove() throws Exception { finishLatch.await(); // Make sure new column is there. - checkNodesState(TBL_NAME, c("v", Integer.class.getName())); + checkTableState(QueryUtils.DFLT_SCHEMA, TBL_NAME, c("v", Integer.class.getName())); run(srv1, "update person set \"v\" = case when mod(id, 2) <> 0 then substring(name, 7, length(name) - 6) " + "else null end"); @@ -450,7 +450,7 @@ public void testConcurrentRebalance() throws Exception { // Validate index state. idxFut.get(); - checkNodesState(TBL_NAME, c); + checkTableState(QueryUtils.DFLT_SCHEMA, TBL_NAME, c); } /** @@ -656,7 +656,7 @@ private void checkClientReconnect(final boolean restartCache, boolean dynamicCac } }); - checkNodeState((IgniteEx)cli, schemaName, TBL_NAME, cols); + checkTableState(schemaName, TBL_NAME, cols); } /** @@ -845,7 +845,7 @@ public void testConcurrentOperationsAndNodeStartStopMultithreaded() throws Excep idxQry += ')'; - checkNodesState(TBL_NAME, expCols); + checkTableState(QueryUtils.DFLT_SCHEMA, TBL_NAME, expCols); put(cli, 0, 500); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java index b25359adbed7c..298010f70a735 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java @@ -17,17 +17,18 @@ package org.apache.ignite.internal.processors.cache.index; -import java.util.Arrays; -import java.util.Collection; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import java.util.concurrent.Callable; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; -import org.apache.ignite.Ignition; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.configuration.CacheConfiguration; @@ -35,23 +36,14 @@ import org.apache.ignite.configuration.MemoryConfiguration; import org.apache.ignite.configuration.MemoryPolicyConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor; -import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor; import org.apache.ignite.internal.processors.query.IgniteSQLException; import org.apache.ignite.internal.processors.query.QueryField; -import org.apache.ignite.internal.processors.query.QuerySchema; import org.apache.ignite.internal.processors.query.QueryUtils; -import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; -import org.apache.ignite.internal.processors.query.h2.opt.GridH2KeyValueRowOnheap; -import org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor; -import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table; -import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.h2.table.Column; import org.h2.value.DataType; /** @@ -68,155 +60,47 @@ public abstract class DynamicColumnsAbstractTest extends GridCommonAbstractTest private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); /** - * Check that given columns have been added to all related structures on target node exactly where needed - * (namely, schema in cache descriptor, type descriptor on started cache, and H2 state on started cache). - * @param node Target node. + * Check that given columns are seen by client. * @param schemaName Schema name to look for the table in. * @param tblName Table name to check. * @param cols Columns whose presence must be checked. */ - static void checkNodeState(IgniteEx node, String schemaName, String tblName, QueryField... cols) { - String cacheName = F.eq(schemaName, QueryUtils.DFLT_SCHEMA) ? - QueryUtils.createTableCacheName(schemaName, tblName) : schemaName; + static void checkTableState(String schemaName, String tblName, QueryField... cols) throws SQLException { + try (Connection c = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1")) { + List flds = new ArrayList<>(); - // Schema state check - should pass regardless of cache state. - { - DynamicCacheDescriptor desc = node.context().cache().cacheDescriptor(cacheName); + try (ResultSet rs = c.getMetaData().getColumns(null, schemaName, tblName, "%")) { + while (rs.next()) { + String name = rs.getString("COLUMN_NAME"); - assertNotNull("Cache descriptor not found", desc); + short type = rs.getShort("DATA_TYPE"); - assertTrue(desc.sql() == F.eq(schemaName, QueryUtils.DFLT_SCHEMA)); + String typeClsName = DataType.getTypeClassName(DataType.convertSQLTypeToValueType(type)); - QuerySchema schema = desc.schema(); + short nullable = rs.getShort("NULLABLE"); - assertNotNull(schema); - - QueryEntity entity = null; - - for (QueryEntity e : schema.entities()) { - if (F.eq(tblName, e.getTableName())) { - entity = e; - - break; + flds.add(new QueryField(name, typeClsName, nullable == 1)); } } - assertNotNull("Query entity not found", entity); - - Iterator> it = entity.getFields().entrySet().iterator(); + Iterator it = flds.iterator(); - for (int i = entity.getFields().size() - cols.length; i > 0 && it.hasNext(); i--) + for (int i = flds.size() - cols.length; i > 0 && it.hasNext(); i--) it.next(); - for (QueryField col : cols) { - assertTrue("New column not found in query entity: " + col.name(), it.hasNext()); + for (QueryField exp : cols) { + assertTrue("New column not found in metadata: " + exp.name(), it.hasNext()); - Map.Entry e = it.next(); + QueryField act = it.next(); - assertEquals(col.name(), e.getKey()); + assertEquals(exp.name(), act.name()); - assertEquals(col.typeName(), e.getValue()); + assertEquals(exp.typeName(), act.typeName()); - if (!col.isNullable()) { - assertNotNull(entity.getNotNullFields()); - - assertTrue(entity.getNotNullFields().contains(col.name())); - } - else if (entity.getNotNullFields() != null) - assertFalse(entity.getNotNullFields().contains(col.name())); + // TODO uncomment after IGNITE-6529 is implemented. + //assertEquals(exp.isNullable(), act.isNullable()); } } - - // Start cache on this node if we haven't yet. - node.cache(cacheName); - - // Type descriptor state check. - { - Collection descs = node.context().query().types(cacheName); - - GridQueryTypeDescriptor desc = null; - - for (GridQueryTypeDescriptor d : descs) { - if (F.eq(tblName, d.tableName())) { - desc = d; - - break; - } - } - - assertNotNull("Type descriptor not found", desc); - - Iterator>> it = desc.fields().entrySet().iterator(); - - for (int i = desc.fields().size() - cols.length; i > 0 && it.hasNext(); i--) - it.next(); - - for (QueryField col : cols) { - assertTrue("New column not found in type descriptor: " + col.name(), it.hasNext()); - - Map.Entry> e = it.next(); - - assertEquals(col.name(), e.getKey()); - - assertEquals(col.typeName(), e.getValue().getName()); - - assertTrue(col.isNullable() || desc.property(col.name()).notNull()); - } - } - - // H2 table state check. - { - GridH2Table tbl = ((IgniteH2Indexing)node.context().query().getIndexing()).dataTable(schemaName, - tblName); - - assertNotNull("Table not found", tbl); - - Iterator colIt = Arrays.asList(tbl.getColumns()).iterator(); - - GridH2RowDescriptor rowDesc = tbl.rowDescriptor(); - - int i = 0; - - for (; i < tbl.getColumns().length - cols.length && colIt.hasNext(); i++) - colIt.next(); - - for (QueryField col : cols) { - assertTrue("New column not found in H2 table: " + col.name(), colIt.hasNext()); - - assertTrue(colIt.hasNext()); - - Column c = colIt.next(); - - assertEquals(col.name(), c.getName()); - - assertEquals(col.typeName(), DataType.getTypeClassName(c.getType())); - - assertFalse(rowDesc.isKeyValueOrVersionColumn(i)); - - assertEquals(col.isNullable(), c.isNullable()); - - try { - assertEquals(DataType.getTypeFromClass(Class.forName(col.typeName())), - rowDesc.fieldType(i - GridH2KeyValueRowOnheap.DEFAULT_COLUMNS_COUNT)); - } - catch (ClassNotFoundException e) { - throw new AssertionError(e); - } - - i++; - } - } - } - - /** - * Check that given columns have been added to all related structures on all started nodes (namely, schema - * in cache descriptor, type descriptor on started cache, and H2 state on started cache). - * @param tblName Table name to check. - * @param cols Columns whose presence must be checked. - */ - static void checkNodesState(String tblName, QueryField... cols) { - for (Ignite node : Ignition.allGrids()) - checkNodeState((IgniteEx)node, QueryUtils.DFLT_SCHEMA, tblName, cols); } /** diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicColumnsAbstractBasicSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicColumnsAbstractBasicSelfTest.java index 5e649596622ae..4c36e331b0597 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicColumnsAbstractBasicSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicColumnsAbstractBasicSelfTest.java @@ -17,17 +17,16 @@ package org.apache.ignite.internal.processors.cache.index; +import java.sql.SQLException; import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.Ignition; import org.apache.ignite.binary.BinaryObject; import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.query.QueryField; import org.apache.ignite.internal.processors.query.QueryUtils; import org.apache.ignite.testframework.config.GridTestProperties; @@ -97,29 +96,25 @@ private IgniteConfiguration[] configurations() throws Exception { /** * Test column addition to the end of the columns list. */ - public void testAddColumnSimple() { + public void testAddColumnSimple() throws SQLException { run("ALTER TABLE Person ADD COLUMN age int"); doSleep(500); QueryField c = c("AGE", Integer.class.getName()); - for (Ignite node : Ignition.allGrids()) - checkNodeState((IgniteEx)node, QueryUtils.DFLT_SCHEMA, "PERSON", c); + checkTableState(QueryUtils.DFLT_SCHEMA, "PERSON", c); } /** * Test column addition to the end of the columns list. */ - public void testAddFewColumnsSimple() { + public void testAddFewColumnsSimple() throws SQLException { run("ALTER TABLE Person ADD COLUMN (age int, \"city\" varchar)"); doSleep(500); - for (Ignite node : Ignition.allGrids()) - checkNodeState((IgniteEx)node, QueryUtils.DFLT_SCHEMA, "PERSON", - c("AGE", Integer.class.getName()), - c("city", String.class.getName())); + checkTableState(QueryUtils.DFLT_SCHEMA, "PERSON", c("AGE", Integer.class.getName()), c("city", String.class.getName())); } /** @@ -217,22 +212,21 @@ public void testComplexOperations() { /** * Test that we can add columns dynamically to tables associated with non dynamic caches as well. */ - public void testAddColumnToNonDynamicCache() { + public void testAddColumnToNonDynamicCache() throws SQLException { run("ALTER TABLE \"idx\".PERSON ADD COLUMN CITY varchar"); doSleep(500); QueryField c = c("CITY", String.class.getName()); - for (Ignite node : Ignition.allGrids()) - checkNodeState((IgniteEx)node, "idx", "PERSON", c); + checkTableState("idx", "PERSON", c); } /** * Test that we can add columns dynamically to tables associated with non dynamic caches storing user types as well. */ @SuppressWarnings("unchecked") - public void testAddColumnToNonDynamicCacheWithRealValueType() { + public void testAddColumnToNonDynamicCacheWithRealValueType() throws SQLException { CacheConfiguration ccfg = defaultCacheConfiguration().setName("City") .setIndexedTypes(Integer.class, City.class); @@ -244,8 +238,7 @@ public void testAddColumnToNonDynamicCacheWithRealValueType() { QueryField c = c("POPULATION", Integer.class.getName()); - for (Ignite node : Ignition.allGrids()) - checkNodeState((IgniteEx)node, "City", "CITY", c); + checkTableState("City", "CITY", c); run(cache, "INSERT INTO \"City\".City (_key, id, name, state, population) values " + "(1, 1, 'Washington', 'DC', 2500000)"); @@ -276,29 +269,27 @@ public void testAddColumnToNonDynamicCacheWithRealValueType() { /** * Test addition of column with not null constraint. */ - public void testAddNotNullColumn() { + public void testAddNotNullColumn() throws SQLException { run("ALTER TABLE Person ADD COLUMN age int NOT NULL"); doSleep(500); QueryField c = new QueryField("AGE", Integer.class.getName(), false); - for (Ignite node : Ignition.allGrids()) - checkNodeState((IgniteEx)node, QueryUtils.DFLT_SCHEMA, "PERSON", c); + checkTableState(QueryUtils.DFLT_SCHEMA, "PERSON", c); } /** * Test addition of column explicitly defined as nullable. */ - public void testAddNullColumn() { + public void testAddNullColumn() throws SQLException { run("ALTER TABLE Person ADD COLUMN age int NULL"); doSleep(500); QueryField c = new QueryField("AGE", Integer.class.getName(), true); - for (Ignite node : Ignition.allGrids()) - checkNodeState((IgniteEx)node, QueryUtils.DFLT_SCHEMA, "PERSON", c); + checkTableState(QueryUtils.DFLT_SCHEMA, "PERSON", c); } /** From e7d3eec3b7ff5dcefc396ffab62455271db70618 Mon Sep 17 00:00:00 2001 From: Alexander Paschenko Date: Thu, 28 Sep 2017 21:00:21 +0300 Subject: [PATCH 2/4] Minor. --- .../index/DynamicColumnsAbstractTest.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java index 298010f70a735..749fb65ac57b3 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java @@ -66,9 +66,9 @@ public abstract class DynamicColumnsAbstractTest extends GridCommonAbstractTest * @param cols Columns whose presence must be checked. */ static void checkTableState(String schemaName, String tblName, QueryField... cols) throws SQLException { - try (Connection c = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1")) { - List flds = new ArrayList<>(); + List flds = new ArrayList<>(); + try (Connection c = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1")) { try (ResultSet rs = c.getMetaData().getColumns(null, schemaName, tblName, "%")) { while (rs.next()) { String name = rs.getString("COLUMN_NAME"); @@ -82,24 +82,24 @@ static void checkTableState(String schemaName, String tblName, QueryField... col flds.add(new QueryField(name, typeClsName, nullable == 1)); } } + } - Iterator it = flds.iterator(); + Iterator it = flds.iterator(); - for (int i = flds.size() - cols.length; i > 0 && it.hasNext(); i--) - it.next(); + for (int i = flds.size() - cols.length; i > 0 && it.hasNext(); i--) + it.next(); - for (QueryField exp : cols) { - assertTrue("New column not found in metadata: " + exp.name(), it.hasNext()); + for (QueryField exp : cols) { + assertTrue("New column not found in metadata: " + exp.name(), it.hasNext()); - QueryField act = it.next(); + QueryField act = it.next(); - assertEquals(exp.name(), act.name()); + assertEquals(exp.name(), act.name()); - assertEquals(exp.typeName(), act.typeName()); + assertEquals(exp.typeName(), act.typeName()); - // TODO uncomment after IGNITE-6529 is implemented. - //assertEquals(exp.isNullable(), act.isNullable()); - } + // TODO uncomment after IGNITE-6529 is implemented. + //assertEquals(exp.isNullable(), act.isNullable()); } } From 19e299b3ee318d1bb18e27a203dbfc4a0d0e9dad Mon Sep 17 00:00:00 2001 From: Alexander Paschenko Date: Mon, 13 Nov 2017 19:00:41 +0300 Subject: [PATCH 3/4] Test fix --- .../cache/index/DynamicColumnsAbstractConcurrentSelfTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractConcurrentSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractConcurrentSelfTest.java index 5a3b904c4238b..981295e715d0d 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractConcurrentSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractConcurrentSelfTest.java @@ -429,7 +429,7 @@ public void testConcurrentRebalance() throws Exception { CountDownLatch idxLatch1 = blockIndexing(srv1); CountDownLatch idxLatch2 = blockIndexing(srv2); - QueryField c = c("salary", Float.class.getName()); + QueryField c = c("salary", Double.class.getName()); final IgniteInternalFuture idxFut = addCols(srv1, QueryUtils.DFLT_SCHEMA, c); From 933e8c64fbc4f4f6ad2eca0376c1f3f9fc2cace4 Mon Sep 17 00:00:00 2001 From: Alexander Paschenko Date: Tue, 14 Nov 2017 13:48:15 +0300 Subject: [PATCH 4/4] Test fix. --- ...DynamicColumnsAbstractConcurrentSelfTest.java | 11 ++++++++--- .../cache/index/DynamicColumnsAbstractTest.java | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractConcurrentSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractConcurrentSelfTest.java index 981295e715d0d..0263f5c009c8f 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractConcurrentSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractConcurrentSelfTest.java @@ -149,7 +149,7 @@ public void testCoordinatorChange() throws Exception { // Start servers. Ignite srv1 = ignitionStart(serverConfiguration(1), null); Ignite srv2 = ignitionStart(serverConfiguration(2), null); - ignitionStart(serverConfiguration(3, true), finishLatch); + Ignite srv3 = ignitionStart(serverConfiguration(3, true), finishLatch); UUID srv1Id = srv1.cluster().localNode().id(); UUID srv2Id = srv2.cluster().localNode().id(); @@ -175,7 +175,8 @@ public void testCoordinatorChange() throws Exception { colFut1.get(); - checkTableState(QueryUtils.DFLT_SCHEMA, TBL_NAME, c("age", Integer.class.getName())); + // Port number is for srv2. + checkTableState(QueryUtils.DFLT_SCHEMA, TBL_NAME, 10801, c("age", Integer.class.getName())); // Test migration from normal server to non-affinity server. idxLatch = blockIndexing(srv2Id); @@ -191,7 +192,11 @@ public void testCoordinatorChange() throws Exception { colFut2.get(); - checkTableState(QueryUtils.DFLT_SCHEMA, TBL_NAME, c("city", String.class.getName())); + // Let's actually create cache on non affinity server. + srv3.cache(QueryUtils.createTableCacheName(QueryUtils.DFLT_SCHEMA, "PERSON")); + + // Port number is for srv3. + checkTableState(QueryUtils.DFLT_SCHEMA, TBL_NAME, 10802, c("city", String.class.getName())); } /** diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java index 9c88ab1e6b0ff..34be76eaf1bd9 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java @@ -32,9 +32,10 @@ import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.ClientConnectorConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.DataRegionConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.query.IgniteSQLException; import org.apache.ignite.internal.processors.query.QueryField; @@ -66,9 +67,20 @@ public abstract class DynamicColumnsAbstractTest extends GridCommonAbstractTest * @param cols Columns whose presence must be checked. */ static void checkTableState(String schemaName, String tblName, QueryField... cols) throws SQLException { + checkTableState(schemaName, tblName, ClientConnectorConfiguration.DFLT_PORT, cols); + } + + /** + * Check that given columns are seen by client. + * @param schemaName Schema name to look for the table in. + * @param tblName Table name to check. + * @param port Port number. + * @param cols Columns whose presence must be checked. + */ + static void checkTableState(String schemaName, String tblName, int port, QueryField... cols) throws SQLException { List flds = new ArrayList<>(); - try (Connection c = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1")) { + try (Connection c = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1:" + port)) { try (ResultSet rs = c.getMetaData().getColumns(null, schemaName, tblName, "%")) { while (rs.next()) { String name = rs.getString("COLUMN_NAME");