This is an automated email from the ASF dual-hosted git repository. vozerov pushed a commit to branch ignite-11310-nodml in repository https://gitbox.apache.org/repos/asf/ignite.git
commit c32d0c2cd627436fbe6e791b71ab1604dc108a98 Author: devozerov <voze...@gridgain.com> AuthorDate: Thu Feb 14 15:17:38 2019 +0300 Test fixes. --- .../query/IgniteSqlSegmentedIndexSelfTest.java | 107 +++++++++------------ 1 file changed, 44 insertions(+), 63 deletions(-) diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSegmentedIndexSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSegmentedIndexSelfTest.java index be8a5f0..8f57367 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSegmentedIndexSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSegmentedIndexSelfTest.java @@ -27,13 +27,12 @@ import javax.cache.Cache; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheKeyConfiguration; import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.affinity.AffinityKeyMapped; import org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy; import org.apache.ignite.cache.query.SqlFieldsQuery; 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.processors.cache.index.AbstractIndexingCommonTest; import org.junit.Test; @@ -57,20 +56,7 @@ public class IgniteSqlSegmentedIndexSelfTest extends AbstractIndexingCommonTest private static final int ORPHAN_ROWS = 10; /** */ - private static int QRY_PARALLELISM_LVL = 97; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - CacheKeyConfiguration keyCfg = new CacheKeyConfiguration("MyCache", "affKey"); - - cfg.setCacheKeyConfiguration(keyCfg); - - cfg.setPeerClassLoadingEnabled(false); - - return cfg; - } + private static final int QRY_PARALLELISM_LVL = 97; /** @return number of nodes to be prestarted. */ protected int nodesCount() { @@ -78,11 +64,13 @@ public class IgniteSqlSegmentedIndexSelfTest extends AbstractIndexingCommonTest } /** {@inheritDoc} */ + @SuppressWarnings("deprecation") @Override protected void beforeTestsStarted() throws Exception { startGrids(nodesCount()); } /** {@inheritDoc} */ + @SuppressWarnings("deprecation") @Override protected void afterTest() throws Exception { super.afterTest(); @@ -105,11 +93,11 @@ public class IgniteSqlSegmentedIndexSelfTest extends AbstractIndexingCommonTest } /** - * @throws Exception If failed. + * Test segmented index. */ @Test - public void testSegmentedIndex() throws Exception { - ignite(0).createCache(cacheConfig(PERSON_CAHE_NAME, true, Integer.class, Person.class)); + public void testSegmentedIndex() { + ignite(0).createCache(cacheConfig(PERSON_CAHE_NAME, true, PersonKey.class, Person.class)); ignite(0).createCache(cacheConfig(ORG_CACHE_NAME, true, Integer.class, Organization.class)); fillCache(); @@ -123,10 +111,9 @@ public class IgniteSqlSegmentedIndexSelfTest extends AbstractIndexingCommonTest /** * Check correct index snapshots with segmented indices. - * @throws Exception If failed. */ @Test - public void testSegmentedIndexReproducableResults() throws Exception { + public void testSegmentedIndexReproducableResults() { ignite(0).createCache(cacheConfig(ORG_CACHE_NAME, true, Integer.class, Organization.class)); IgniteCache<Object, Object> cache = ignite(0).cache(ORG_CACHE_NAME); @@ -149,10 +136,9 @@ public class IgniteSqlSegmentedIndexSelfTest extends AbstractIndexingCommonTest /** * Checks correct <code>select count(*)</code> result with segmented indices. - * @throws Exception If failed. */ @Test - public void testSegmentedIndexSizeReproducableResults() throws Exception { + public void testSegmentedIndexSizeReproducableResults() { ignite(0).createCache(cacheConfig(ORG_CACHE_NAME, true, Integer.class, Organization.class)); IgniteCache<Object, Object> cache = ignite(0).cache(ORG_CACHE_NAME); @@ -174,12 +160,11 @@ public class IgniteSqlSegmentedIndexSelfTest extends AbstractIndexingCommonTest } /** - * Run tests on single-node grid - * - * @throws Exception If failed. + * Run tests on single-node grid. */ + @SuppressWarnings("deprecation") @Test - public void testSegmentedIndexWithEvictionPolicy() throws Exception { + public void testSegmentedIndexWithEvictionPolicy() { final IgniteCache<Object, Object> cache = ignite(0).createCache( cacheConfig(ORG_CACHE_NAME, true, Integer.class, Organization.class) .setEvictionPolicy(new FifoEvictionPolicy(10)) @@ -199,11 +184,10 @@ public class IgniteSqlSegmentedIndexSelfTest extends AbstractIndexingCommonTest /** * Verifies that <code>select count(*)</code> return valid result on a single-node grid. - * - * @throws Exception If failed. */ + @SuppressWarnings("deprecation") @Test - public void testSizeOnSegmentedIndexWithEvictionPolicy() throws Exception { + public void testSizeOnSegmentedIndexWithEvictionPolicy() { final IgniteCache<Object, Object> cache = ignite(0).createCache( cacheConfig(ORG_CACHE_NAME, true, Integer.class, Organization.class) .setEvictionPolicy(new FifoEvictionPolicy(10)) @@ -228,7 +212,7 @@ public class IgniteSqlSegmentedIndexSelfTest extends AbstractIndexingCommonTest */ @Test public void testSegmentedPartitionedWithReplicated() throws Exception { - ignite(0).createCache(cacheConfig(PERSON_CAHE_NAME, true, Integer.class, Person.class)); + ignite(0).createCache(cacheConfig(PERSON_CAHE_NAME, true, PersonKey.class, Person.class)); ignite(0).createCache(cacheConfig(ORG_CACHE_NAME, false, Integer.class, Organization.class)); fillCache(); @@ -242,17 +226,15 @@ public class IgniteSqlSegmentedIndexSelfTest extends AbstractIndexingCommonTest /** * Check distributed joins. - * - * @throws Exception If failed. */ - public void checkDistributedQueryWithSegmentedIndex() throws Exception { + public void checkDistributedQueryWithSegmentedIndex() { for (int i = 0; i < nodesCount(); i++) { - IgniteCache<Integer, Person> c1 = ignite(i).cache(PERSON_CAHE_NAME); + IgniteCache<PersonKey, Person> c1 = ignite(i).cache(PERSON_CAHE_NAME); long expPersons = 0; - for (Cache.Entry<Integer, Person> e : c1) { - final Integer orgId = e.getValue().orgId; + for (Cache.Entry<PersonKey, Person> e : c1) { + final Integer orgId = e.getKey().orgId; // We have as orphan ORG rows as orphan PERSON rows. if (ORPHAN_ROWS <= orgId && orgId < 500) @@ -269,14 +251,12 @@ public class IgniteSqlSegmentedIndexSelfTest extends AbstractIndexingCommonTest /** * Test local query. - * - * @throws Exception If failed. */ - public void checkLocalQueryWithSegmentedIndex() throws Exception { + public void checkLocalQueryWithSegmentedIndex() { for (int i = 0; i < nodesCount(); i++) { final Ignite node = ignite(i); - IgniteCache<Integer, Person> c1 = node.cache(PERSON_CAHE_NAME); + IgniteCache<PersonKey, Person> c1 = node.cache(PERSON_CAHE_NAME); IgniteCache<Integer, Organization> c2 = node.cache(ORG_CACHE_NAME); Set<Integer> locOrgIds = new HashSet<>(); @@ -286,8 +266,8 @@ public class IgniteSqlSegmentedIndexSelfTest extends AbstractIndexingCommonTest long expPersons = 0; - for (Cache.Entry<Integer, Person> e : c1.localEntries()) { - final Integer orgId = e.getValue().orgId; + for (Cache.Entry<PersonKey, Person> e : c1.localEntries()) { + final Integer orgId = e.getKey().orgId; if (locOrgIds.contains(orgId)) expPersons++; @@ -303,14 +283,12 @@ public class IgniteSqlSegmentedIndexSelfTest extends AbstractIndexingCommonTest /** * Verifies that local <code>select count(*)</code> query returns a correct result. - * - * @throws Exception If failed. */ - public void checkLocalSizeQueryWithSegmentedIndex() throws Exception { + public void checkLocalSizeQueryWithSegmentedIndex() { for (int i = 0; i < nodesCount(); i++) { final Ignite node = ignite(i); - IgniteCache<Integer, Person> c1 = node.cache(PERSON_CAHE_NAME); + IgniteCache<PersonKey, Person> c1 = node.cache(PERSON_CAHE_NAME); IgniteCache<Integer, Organization> c2 = node.cache(ORG_CACHE_NAME); Set<Integer> locOrgIds = new HashSet<>(); @@ -320,8 +298,8 @@ public class IgniteSqlSegmentedIndexSelfTest extends AbstractIndexingCommonTest int expPersons = 0; - for (Cache.Entry<Integer, Person> e : c1.localEntries()) { - final Integer orgId = e.getValue().orgId; + for (Cache.Entry<PersonKey, Person> e : c1.localEntries()) { + final Integer orgId = e.getKey().orgId; if (locOrgIds.contains(orgId)) expPersons++; @@ -349,7 +327,22 @@ public class IgniteSqlSegmentedIndexSelfTest extends AbstractIndexingCommonTest // We have as orphan ORG rows as orphan PERSON rows. int orgID = ORPHAN_ROWS + random.nextInt(ORG_CACHE_SIZE + ORPHAN_ROWS); - c1.put(i, new Person(orgID, "pers-" + i)); + c1.put(new PersonKey(i, orgID), new Person("pers-" + i)); + } + } + + private static class PersonKey { + @QuerySqlField + int id; + + /** */ + @AffinityKeyMapped + @QuerySqlField + Integer orgId; + + public PersonKey(int id, Integer orgId) { + this.id = id; + this.orgId = orgId; } } @@ -358,26 +351,14 @@ public class IgniteSqlSegmentedIndexSelfTest extends AbstractIndexingCommonTest */ private static class Person implements Serializable { /** */ - @QuerySqlField(index = true) - Integer orgId; - - /** */ @QuerySqlField String name; - /** - * - */ - public Person() { - // No-op. - } /** - * @param orgId Organization ID. * @param name Name. */ - public Person(int orgId, String name) { - this.orgId = orgId; + public Person(String name) { this.name = name; } }