http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/examples/HadoopPopularWords.java ---------------------------------------------------------------------- diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/examples/HadoopPopularWords.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/examples/HadoopPopularWords.java new file mode 100644 index 0000000..a2d0710 --- /dev/null +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/examples/HadoopPopularWords.java @@ -0,0 +1,298 @@ +/* + * 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.hadoop.impl.examples; + +import com.google.common.collect.MinMaxPriorityQueue; +import java.io.IOException; +import java.util.Comparator; +import java.util.Map.Entry; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.io.IntWritable; +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.io.Text; +import org.apache.hadoop.mapreduce.Job; +import org.apache.hadoop.mapreduce.Mapper; +import org.apache.hadoop.mapreduce.Reducer; +import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; +import org.apache.hadoop.mapreduce.lib.input.TextInputFormat; +import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.internal.util.typedef.internal.U; + +import static com.google.common.collect.Maps.immutableEntry; +import static com.google.common.collect.MinMaxPriorityQueue.orderedBy; +import static java.util.Collections.reverseOrder; + +/** + * Hadoop-based 10 popular words example: all files in a given directory are tokenized and for each word longer than + * 3 characters the number of occurrences ins calculated. Finally, 10 words with the highest occurrence count are + * output. + * + * NOTE: in order to run this example on Windows please ensure that cygwin is installed and available in the system + * path. + */ +public class HadoopPopularWords { + /** Ignite home. */ + private static final String IGNITE_HOME = U.getIgniteHome(); + + /** The path to the input directory. ALl files in that directory will be processed. */ + private static final Path BOOKS_LOCAL_DIR = + new Path("file:" + IGNITE_HOME, "modules/tests/java/org/apache/ignite/grid/hadoop/books"); + + /** The path to the output directory. THe result file will be written to this location. */ + private static final Path RESULT_LOCAL_DIR = + new Path("file:" + IGNITE_HOME, "modules/tests/java/org/apache/ignite/grid/hadoop/output"); + + /** Popular books source dir in DFS. */ + private static final Path BOOKS_DFS_DIR = new Path("tmp/word-count-example/in"); + + /** Popular books source dir in DFS. */ + private static final Path RESULT_DFS_DIR = new Path("tmp/word-count-example/out"); + + /** Path to the distributed file system configuration. */ + private static final String DFS_CFG = "examples/config/filesystem/core-site.xml"; + + /** Top N words to select **/ + private static final int POPULAR_WORDS_CNT = 10; + + /** + * For each token in the input string the mapper emits a {word, 1} pair. + */ + private static class TokenizingMapper extends Mapper<LongWritable, Text, Text, IntWritable> { + /** Constant value. */ + private static final IntWritable ONE = new IntWritable(1); + + /** The word converted into the Text. */ + private Text word = new Text(); + + /** + * Emits a entry where the key is the word and the value is always 1. + * + * @param key the current position in the input file (not used here) + * @param val the text string + * @param ctx mapper context + * @throws IOException + * @throws InterruptedException + */ + @Override protected void map(LongWritable key, Text val, Context ctx) + throws IOException, InterruptedException { + // Get the mapped object. + final String line = val.toString(); + + // Splits the given string to words. + final String[] words = line.split("[^a-zA-Z0-9]"); + + for (final String w : words) { + // Only emit counts for longer words. + if (w.length() <= 3) + continue; + + word.set(w); + + // Write the word into the context with the initial count equals 1. + ctx.write(word, ONE); + } + } + } + + /** + * The reducer uses a priority queue to rank the words based on its number of occurrences. + */ + private static class TopNWordsReducer extends Reducer<Text, IntWritable, Text, IntWritable> { + private MinMaxPriorityQueue<Entry<Integer, String>> q; + + TopNWordsReducer() { + q = orderedBy(reverseOrder(new Comparator<Entry<Integer, String>>() { + @Override public int compare(Entry<Integer, String> o1, Entry<Integer, String> o2) { + return o1.getKey().compareTo(o2.getKey()); + } + })).expectedSize(POPULAR_WORDS_CNT).maximumSize(POPULAR_WORDS_CNT).create(); + } + + /** + * This method doesn't emit anything, but just keeps track of the top N words. + * + * @param key The word. + * @param vals The words counts. + * @param ctx Reducer context. + * @throws IOException If failed. + * @throws InterruptedException If failed. + */ + @Override public void reduce(Text key, Iterable<IntWritable> vals, Context ctx) throws IOException, + InterruptedException { + int sum = 0; + + for (IntWritable val : vals) + sum += val.get(); + + q.add(immutableEntry(sum, key.toString())); + } + + /** + * This method is called after all the word entries have been processed. It writes the accumulated + * statistics to the job output file. + * + * @param ctx The job context. + * @throws IOException If failed. + * @throws InterruptedException If failed. + */ + @Override protected void cleanup(Context ctx) throws IOException, InterruptedException { + IntWritable i = new IntWritable(); + + Text txt = new Text(); + + // iterate in desc order + while (!q.isEmpty()) { + Entry<Integer, String> e = q.removeFirst(); + + i.set(e.getKey()); + + txt.set(e.getValue()); + + ctx.write(txt, i); + } + } + } + + /** + * Configures the Hadoop MapReduce job. + * + * @return Instance of the Hadoop MapRed job. + * @throws IOException If failed. + */ + @SuppressWarnings("deprecation") + private Job createConfigBasedHadoopJob() throws IOException { + Job jobCfg = new Job(); + + Configuration cfg = jobCfg.getConfiguration(); + + // Use explicit configuration of distributed file system, if provided. + cfg.addResource(U.resolveIgniteUrl(DFS_CFG)); + + jobCfg.setJobName("HadoopPopularWordExample"); + jobCfg.setJarByClass(HadoopPopularWords.class); + jobCfg.setInputFormatClass(TextInputFormat.class); + jobCfg.setOutputKeyClass(Text.class); + jobCfg.setOutputValueClass(IntWritable.class); + jobCfg.setMapperClass(TokenizingMapper.class); + jobCfg.setReducerClass(TopNWordsReducer.class); + + FileInputFormat.setInputPaths(jobCfg, BOOKS_DFS_DIR); + FileOutputFormat.setOutputPath(jobCfg, RESULT_DFS_DIR); + + // Local job tracker allows the only task per wave, but text input format + // replaces it with the calculated value based on input split size option. + if ("local".equals(cfg.get("mapred.job.tracker", "local"))) { + // Split job into tasks using 32MB split size. + FileInputFormat.setMinInputSplitSize(jobCfg, 32L * 1024 * 1024); + FileInputFormat.setMaxInputSplitSize(jobCfg, Long.MAX_VALUE); + } + + return jobCfg; + } + + /** + * Runs the Hadoop job. + * + * @return {@code True} if succeeded, {@code false} otherwise. + * @throws Exception If failed. + */ + private boolean runWordCountConfigBasedHadoopJob() throws Exception { + Job job = createConfigBasedHadoopJob(); + + // Distributed file system this job will work with. + FileSystem fs = FileSystem.get(job.getConfiguration()); + + X.println(">>> Using distributed file system: " + fs.getHomeDirectory()); + + // Prepare input and output job directories. + prepareDirectories(fs); + + long time = System.currentTimeMillis(); + + // Run job. + boolean res = job.waitForCompletion(true); + + X.println(">>> Job execution time: " + (System.currentTimeMillis() - time) / 1000 + " sec."); + + // Move job results into local file system, so you can view calculated results. + publishResults(fs); + + return res; + } + + /** + * Prepare job's data: cleanup result directories that might have left over + * after previous runs, copy input files from the local file system into DFS. + * + * @param fs Distributed file system to use in job. + * @throws IOException If failed. + */ + private void prepareDirectories(FileSystem fs) throws IOException { + X.println(">>> Cleaning up DFS result directory: " + RESULT_DFS_DIR); + + fs.delete(RESULT_DFS_DIR, true); + + X.println(">>> Cleaning up DFS input directory: " + BOOKS_DFS_DIR); + + fs.delete(BOOKS_DFS_DIR, true); + + X.println(">>> Copy local files into DFS input directory: " + BOOKS_DFS_DIR); + + fs.copyFromLocalFile(BOOKS_LOCAL_DIR, BOOKS_DFS_DIR); + } + + /** + * Publish job execution results into local file system, so you can view them. + * + * @param fs Distributed file sytem used in job. + * @throws IOException If failed. + */ + private void publishResults(FileSystem fs) throws IOException { + X.println(">>> Cleaning up DFS input directory: " + BOOKS_DFS_DIR); + + fs.delete(BOOKS_DFS_DIR, true); + + X.println(">>> Cleaning up LOCAL result directory: " + RESULT_LOCAL_DIR); + + fs.delete(RESULT_LOCAL_DIR, true); + + X.println(">>> Moving job results into LOCAL result directory: " + RESULT_LOCAL_DIR); + + fs.copyToLocalFile(true, RESULT_DFS_DIR, RESULT_LOCAL_DIR); + } + + /** + * Executes a modified version of the Hadoop word count example. Here, in addition to counting the number of + * occurrences of the word in the source files, the N most popular words are selected. + * + * @param args None. + */ + public static void main(String[] args) { + try { + new HadoopPopularWords().runWordCountConfigBasedHadoopJob(); + } + catch (Exception e) { + X.println(">>> Failed to run word count example: " + e.getMessage()); + } + + System.exit(0); + } +}
http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java index 576d8db..2be2fa9 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java @@ -39,6 +39,7 @@ import org.apache.ignite.internal.processors.hadoop.impl.igfs.IgniteHadoopFileSy import org.apache.ignite.internal.processors.hadoop.impl.igfs.IgniteHadoopFileSystemLoopbackExternalToClientDualSyncSelfTest; import org.apache.ignite.internal.processors.hadoop.impl.igfs.IgniteHadoopFileSystemLoopbackExternalToClientPrimarySelfTest; import org.apache.ignite.internal.processors.hadoop.impl.igfs.IgniteHadoopFileSystemLoopbackExternalToClientProxySelfTest; +import org.apache.ignite.internal.processors.hadoop.impl.taskexecutor.HadoopExecutorServiceTest; import org.apache.ignite.internal.processors.hadoop.impl.util.BasicUserNameMapperSelfTest; import org.apache.ignite.internal.processors.hadoop.impl.util.ChainedUserNameMapperSelfTest; import org.apache.ignite.internal.processors.hadoop.impl.util.KerberosUserNameMapperSelfTest; @@ -175,6 +176,8 @@ public class IgniteHadoopTestSuite extends TestSuite { suite.addTest(new TestSuite(ldr.loadClass(HadoopFileSystemsTest.class.getName()))); + //suite.addTest(new TestSuite(ldr.loadClass(HadoopExecutorServiceTest.class.getName()))); + suite.addTest(new TestSuite(ldr.loadClass(HadoopValidationSelfTest.class.getName()))); suite.addTest(new TestSuite(ldr.loadClass(HadoopJobTrackerSelfTest.class.getName()))); @@ -370,4 +373,4 @@ public class IgniteHadoopTestSuite extends TestSuite { throw new IllegalStateException("Failed to install " + appName + "."); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteIgfsLinuxAndMacOSTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteIgfsLinuxAndMacOSTestSuite.java b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteIgfsLinuxAndMacOSTestSuite.java index 5708a18..bebb656 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteIgfsLinuxAndMacOSTestSuite.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteIgfsLinuxAndMacOSTestSuite.java @@ -21,6 +21,7 @@ import junit.framework.TestSuite; import org.apache.ignite.internal.processors.hadoop.HadoopTestClassLoader; import org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfs20FileSystemShmemPrimarySelfTest; import org.apache.ignite.internal.processors.hadoop.impl.igfs.IgfsEventsTestSuite; +import org.apache.ignite.internal.processors.hadoop.impl.igfs.IgfsNearOnlyMultiNodeSelfTest; import org.apache.ignite.internal.processors.hadoop.impl.igfs.IgniteHadoopFileSystemIpcCacheSelfTest; import org.apache.ignite.internal.processors.hadoop.impl.igfs.IgniteHadoopFileSystemShmemExternalDualAsyncSelfTest; import org.apache.ignite.internal.processors.hadoop.impl.igfs.IgniteHadoopFileSystemShmemExternalDualSyncSelfTest; @@ -65,8 +66,10 @@ public class IgniteIgfsLinuxAndMacOSTestSuite extends TestSuite { suite.addTest(new TestSuite(ldr.loadClass(HadoopIgfs20FileSystemShmemPrimarySelfTest.class.getName()))); + //suite.addTest(new TestSuite(ldr.loadClass(IgfsNearOnlyMultiNodeSelfTest.class.getName()))); + suite.addTest(IgfsEventsTestSuite.suite()); return suite; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java index 22d870d..2d9b25e 100644 --- a/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java +++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java @@ -19,6 +19,7 @@ package org.apache.ignite.testsuites; import junit.framework.TestSuite; import org.apache.ignite.cache.hibernate.HibernateL2CacheConfigurationSelfTest; +import org.apache.ignite.cache.hibernate.HibernateL2CacheMultiJvmTest; import org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest; import org.apache.ignite.cache.hibernate.HibernateL2CacheStrategySelfTest; import org.apache.ignite.cache.hibernate.HibernateL2CacheTransactionalSelfTest; @@ -45,6 +46,7 @@ public class IgniteHibernateTestSuite extends TestSuite { suite.addTestSuite(HibernateL2CacheTransactionalUseSyncSelfTest.class); suite.addTestSuite(HibernateL2CacheConfigurationSelfTest.class); suite.addTestSuite(HibernateL2CacheStrategySelfTest.class); + //suite.addTestSuite(HibernateL2CacheMultiJvmTest.class); suite.addTestSuite(CacheHibernateBlobStoreSelfTest.class); http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java ---------------------------------------------------------------------- diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java index 1e06329..89e4c2a 100644 --- a/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java +++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java @@ -19,6 +19,7 @@ package org.apache.ignite.testsuites; import junit.framework.TestSuite; import org.apache.ignite.cache.hibernate.HibernateL2CacheConfigurationSelfTest; +import org.apache.ignite.cache.hibernate.HibernateL2CacheMultiJvmTest; import org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest; import org.apache.ignite.cache.hibernate.HibernateL2CacheStrategySelfTest; import org.apache.ignite.cache.hibernate.HibernateL2CacheTransactionalSelfTest; @@ -45,6 +46,7 @@ public class IgniteHibernate5TestSuite extends TestSuite { suite.addTestSuite(HibernateL2CacheTransactionalUseSyncSelfTest.class); suite.addTestSuite(HibernateL2CacheConfigurationSelfTest.class); suite.addTestSuite(HibernateL2CacheStrategySelfTest.class); + //suite.addTestSuite(HibernateL2CacheMultiJvmTest.class); suite.addTestSuite(CacheHibernateBlobStoreSelfTest.class); http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexAbstractTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexAbstractTest.java new file mode 100644 index 0000000..2c21e23 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexAbstractTest.java @@ -0,0 +1,361 @@ +/* + * 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.cache.index; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import org.apache.ignite.Ignition; +import org.apache.ignite.binary.BinaryObject; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor; +import org.apache.ignite.internal.processors.query.IgniteSQLException; +import org.apache.ignite.lang.IgniteCallable; +import org.apache.ignite.lang.IgniteInClosure; +import org.apache.ignite.testframework.GridTestUtils; + +/** + * Base class for testing work of combinations of DML and DDL operations. + */ +public abstract class H2DynamicIndexingComplexAbstractTest extends DynamicIndexAbstractSelfTest { + /** Cache mode to test with. */ + private final CacheMode cacheMode; + + /** Cache atomicity mode to test with. */ + private final CacheAtomicityMode atomicityMode; + + /** Node index to initiate operations from. */ + private final int nodeIdx; + + /** Backups to configure */ + private final int backups; + + /** Names of companies to use. */ + private final static List<String> COMPANIES = Arrays.asList("ASF", "GNU", "BSD"); + + /** Cities to use. */ + private final static List<String> CITIES = Arrays.asList("St. Petersburg", "Boston", "Berkeley", "London"); + + /** Index of server node. */ + protected final static int SRV_IDX = 0; + + /** Index of client node. */ + protected final static int CLIENT_IDX = 1; + + /** + * Constructor. + * @param cacheMode Cache mode. + * @param atomicityMode Cache atomicity mode. + * @param backups Number of backups. + * @param nodeIdx Node index. + */ + H2DynamicIndexingComplexAbstractTest(CacheMode cacheMode, CacheAtomicityMode atomicityMode, int backups, int nodeIdx) { + this.cacheMode = cacheMode; + this.atomicityMode = atomicityMode; + this.backups = backups; + this.nodeIdx = nodeIdx; + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + super.beforeTestsStarted(); + + Ignition.start(serverConfiguration(0)); + + Ignition.start(clientConfiguration(1)); + + Ignition.start(serverConfiguration(2)); + + Ignition.start(serverConfiguration(3)); + } + + /** Do test. */ + @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + public void testOperations() { + executeSql("CREATE TABLE person (id int, name varchar, age int, company varchar, city varchar, " + + "primary key (id, name, city)) WITH \"template=" + cacheMode.name() + ",atomicity=" + atomicityMode.name() + + ",backups=" + backups + ",affinity_key=city\""); + + executeSql("CREATE INDEX idx on person (city asc, name asc)"); + + executeSql("CREATE TABLE city (name varchar, population int, primary key (name)) WITH " + + "\"template=" + cacheMode.name() + ",atomicity=" + atomicityMode.name() + + ",backups=" + backups + ",affinity_key=name\""); + + executeSql("INSERT INTO city (name, population) values(?, ?), (?, ?), (?, ?)", + "St. Petersburg", 6000000, + "Boston", 2000000, + "London", 8000000 + ); + + final long PERSON_COUNT = 100; + + for (int i = 0; i < PERSON_COUNT; i++) + executeSql("INSERT INTO person (id, name, age, company, city) values (?, ?, ?, ?, ?)", + i, + "Person " + i, + 20 + (i % 10), + COMPANIES.get(i % COMPANIES.size()), + CITIES.get(i % CITIES.size())); + + assertAllPersons(new IgniteInClosure<List<?>>() { + @Override public void apply(List<?> person) { + assertInitPerson(person); + } + }); + + long r = (Long)executeSqlSingle("SELECT COUNT(*) from Person"); + + assertEquals(PERSON_COUNT, r); + + r = (Long)executeSqlSingle("SELECT COUNT(*) from Person p inner join City c on p.city = c.name"); + + // Berkeley is not present in City table, although 25 people have it specified as their city. + assertEquals(75L, r); + + executeSqlSingle("UPDATE Person SET company = 'GNU', age = CASE WHEN MOD(id, 2) <> 0 THEN age + 5 ELSE " + + "age + 1 END WHERE company = 'ASF'"); + + assertAllPersons(new IgniteInClosure<List<?>>() { + @Override public void apply(List<?> person) { + int id = (Integer)person.get(0); + + if (id % COMPANIES.size() == 0) { + int initAge = 20 + id % 10; + + int expAge = (initAge % 2 != 0 ? initAge + 5 : initAge + 1); + + assertPerson(id, "Person " + id, expAge, "GNU", CITIES.get(id % CITIES.size()), person); + } + else + assertInitPerson(person); + } + }); + + executeSql("DROP INDEX idx"); + + // Index drop should not affect data. + assertAllPersons(new IgniteInClosure<List<?>>() { + @Override public void apply(List<?> person) { + int id = (Integer)person.get(0); + + if (id % COMPANIES.size() == 0) { + int initAge = 20 + id % 10; + + int expAge = initAge % 2 != 0 ? initAge + 5 : initAge + 1; + + assertPerson(id, "Person " + id, expAge, "GNU", CITIES.get(id % CITIES.size()), person); + } + else + assertInitPerson(person); + } + }); + + // Let's drop all BSD folks living in Berkeley and Boston - this compares ASCII codes of 1st symbols. + executeSql("DELETE FROM person WHERE ASCII(company) = ASCII(city)"); + + assertAllPersons(new IgniteInClosure<List<?>>() { + @Override public void apply(List<?> person) { + String city = city(person); + + String company = company(person); + + assertFalse(city.charAt(0) == company.charAt(0)); + } + }); + + assertNotNull(node().cache("SQL_PUBLIC_PERSON")); + + executeSql("DROP TABLE person"); + + assertNull(node().cache("SQL_PUBLIC_PERSON")); + + GridTestUtils.assertThrows(null, new IgniteCallable<Object>() { + @Override public Object call() throws Exception { + return executeSql("SELECT * from Person"); + } + }, IgniteSQLException.class, "Table \"PERSON\" not found"); + } + + /** + * Select all data from the table and check that all records correspond to rules set by given closure. + * @param clo Closure to apply to each record. + */ + private void assertAllPersons(IgniteInClosure<List<?>> clo) { + List<List<?>> res = executeSql("SELECT * from Person"); + + for (List<?> p : res) + clo.apply(p); + } + + /** + * Get person's id from data row. + * @param person data row. + * @return person's id. + */ + private static int id(List<?> person) { + return (Integer)person.get(0); + } + + /** + * Get person's name from data row. + * @param person data row. + * @return person's name. + */ + private static String name(List<?> person) { + return (String)person.get(1); + } + + /** + * Get person's age from data row. + * @param person data row. + * @return person's age. + */ + private static int age(List<?> person) { + return (Integer)person.get(2); + } + + /** + * Get person's company from data row. + * @param person data row. + * @return person's company. + */ + private static String company(List<?> person) { + return (String)person.get(3); + } + + /** + * Get person's city from data row. + * @param person data row. + * @return person's city. + */ + private static String city(List<?> person) { + return (String)person.get(4); + } + + /** + * Check that all columns in data row are exactly how they were initially inserted. + * @param person data row. + */ + private void assertInitPerson(List<?> person) { + assertEquals(5, person.size()); + + int id = id(person); + + String name = "Person " + id; + + int age = 20 + id % 10; + + String company = COMPANIES.get(id % COMPANIES.size()); + + String city = CITIES.get(id % CITIES.size()); + + assertPerson(id, name, age, company, city, person); + } + + /** + * Check contents of SQL data row and corresponding cache entry. + * @param id Expected id. + * @param name Expected name. + * @param age Expected age. + * @param company Expected company. + * @param city Expected city. + * @param person Data row. + */ + private void assertPerson(int id, String name, int age, String company, String city, List<?> person) { + assertEquals(name, name(person)); + + assertEquals(age, age(person)); + + assertEquals(company, company(person)); + + assertEquals(city, city(person)); + + String cacheName = "SQL_PUBLIC_PERSON"; + + Collection<GridQueryTypeDescriptor> descs = node().context().query().types(cacheName); + + assertEquals(1, descs.size()); + + GridQueryTypeDescriptor desc = descs.iterator().next(); + + String keyType = desc.keyTypeName(); + + String valType = desc.valueTypeName(); + + BinaryObject k = node().binary().builder(keyType) + .setField("id", id) + .setField("name", name) + .setField("city", city).build(); + + Object v = node().cache(cacheName).withKeepBinary().get(k); + + assertNotNull(v); + + BinaryObject expVal = node().binary().builder(valType) + .setField("age", age) + .setField("company", company).build(); + + assertEquals(expVal, v); + } + + /** + * Run SQL statement on specified node. + * @param stmt Statement to run. + * @return Run result. + */ + private List<List<?>> executeSql(IgniteEx node, String stmt, Object... args) { + return node.context().query().querySqlFields(new SqlFieldsQuery(stmt).setArgs(args), true).getAll(); + } + + /** + * Run SQL statement on default node. + * @param stmt Statement to run. + * @return Run result. + */ + private List<List<?>> executeSql(String stmt, Object... args) { + return executeSql(node(), stmt, args); + } + + /** + * Run SQL statement that is expected to return strictly one value (like COUNT(*)). + * @param stmt Statement to run. + * @return Run result. + */ + private Object executeSqlSingle(String stmt, Object... args) { + List<List<?>> res = executeSql(stmt, args); + + assertEquals(1, res.size()); + + List<?> row = res.get(0); + + assertEquals(1, row.size()); + + return row.get(0); + } + + /** + * @return Node to initiate operations from. + */ + protected IgniteEx node() { + return grid(nodeIdx); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientAtomicPartitionedNoBackupsTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientAtomicPartitionedNoBackupsTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientAtomicPartitionedNoBackupsTest.java index 25be1ed..5c0d50f 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientAtomicPartitionedNoBackupsTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientAtomicPartitionedNoBackupsTest.java @@ -24,7 +24,7 @@ import org.apache.ignite.cache.CacheMode; * Test to check work of DML+DDL operations of atomic partitioned cache without backups * with queries initiated from client node. */ -public class H2DynamicIndexingComplexClientAtomicPartitionedNoBackupsTest extends H2DynamicIndexingComplexTest { +public class H2DynamicIndexingComplexClientAtomicPartitionedNoBackupsTest extends H2DynamicIndexingComplexAbstractTest { /** * Constructor. */ http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientAtomicPartitionedTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientAtomicPartitionedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientAtomicPartitionedTest.java index a05390f..d241c39 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientAtomicPartitionedTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientAtomicPartitionedTest.java @@ -23,7 +23,7 @@ import org.apache.ignite.cache.CacheMode; /** * Test to check work of DML+DDL operations of atomic partitioned cache with queries initiated from client node. */ -public class H2DynamicIndexingComplexClientAtomicPartitionedTest extends H2DynamicIndexingComplexTest { +public class H2DynamicIndexingComplexClientAtomicPartitionedTest extends H2DynamicIndexingComplexAbstractTest { /** * Constructor. */ http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientAtomicReplicatedTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientAtomicReplicatedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientAtomicReplicatedTest.java index 6962eff..2ef045c 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientAtomicReplicatedTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientAtomicReplicatedTest.java @@ -23,7 +23,7 @@ import org.apache.ignite.cache.CacheMode; /** * Test to check work of DML+DDL operations of atomic replicated cache with queries initiated from client node. */ -public class H2DynamicIndexingComplexClientAtomicReplicatedTest extends H2DynamicIndexingComplexTest { +public class H2DynamicIndexingComplexClientAtomicReplicatedTest extends H2DynamicIndexingComplexAbstractTest { /** * Constructor. */ http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientTransactionalPartitionedNoBackupsTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientTransactionalPartitionedNoBackupsTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientTransactionalPartitionedNoBackupsTest.java index bccb38e..891c94e 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientTransactionalPartitionedNoBackupsTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientTransactionalPartitionedNoBackupsTest.java @@ -24,7 +24,7 @@ import org.apache.ignite.cache.CacheMode; * Test to check work of DML+DDL operations of transactional partitioned cache without backups * with queries initiated from client node. */ -public class H2DynamicIndexingComplexClientTransactionalPartitionedNoBackupsTest extends H2DynamicIndexingComplexTest { +public class H2DynamicIndexingComplexClientTransactionalPartitionedNoBackupsTest extends H2DynamicIndexingComplexAbstractTest { /** * Constructor. */ http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientTransactionalPartitionedTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientTransactionalPartitionedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientTransactionalPartitionedTest.java index 8ec73cf..0ee5720 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientTransactionalPartitionedTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientTransactionalPartitionedTest.java @@ -23,7 +23,7 @@ import org.apache.ignite.cache.CacheMode; /** * Test to check work of DML+DDL operations of transactional partitioned cache with queries initiated from client node. */ -public class H2DynamicIndexingComplexClientTransactionalPartitionedTest extends H2DynamicIndexingComplexTest { +public class H2DynamicIndexingComplexClientTransactionalPartitionedTest extends H2DynamicIndexingComplexAbstractTest { /** * Constructor. */ http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientTransactionalReplicatedTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientTransactionalReplicatedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientTransactionalReplicatedTest.java index 6000277..4565f8c 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientTransactionalReplicatedTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexClientTransactionalReplicatedTest.java @@ -23,7 +23,7 @@ import org.apache.ignite.cache.CacheMode; /** * Test to check work of DML+DDL operations of transactional replicated cache with queries initiated from client node. */ -public class H2DynamicIndexingComplexClientTransactionalReplicatedTest extends H2DynamicIndexingComplexTest { +public class H2DynamicIndexingComplexClientTransactionalReplicatedTest extends H2DynamicIndexingComplexAbstractTest { /** * Constructor. */ http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerAtomicPartitionedNoBackupsTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerAtomicPartitionedNoBackupsTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerAtomicPartitionedNoBackupsTest.java index 6e806f9..1933114 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerAtomicPartitionedNoBackupsTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerAtomicPartitionedNoBackupsTest.java @@ -24,7 +24,7 @@ import org.apache.ignite.cache.CacheMode; * Test to check work of DML+DDL operations of atomic partitioned cache without backups * with queries initiated from server node. */ -public class H2DynamicIndexingComplexServerAtomicPartitionedNoBackupsTest extends H2DynamicIndexingComplexTest { +public class H2DynamicIndexingComplexServerAtomicPartitionedNoBackupsTest extends H2DynamicIndexingComplexAbstractTest { /** * Constructor. */ http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerAtomicPartitionedTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerAtomicPartitionedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerAtomicPartitionedTest.java index 18f4456..20ed864 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerAtomicPartitionedTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerAtomicPartitionedTest.java @@ -23,7 +23,7 @@ import org.apache.ignite.cache.CacheMode; /** * Test to check work of DML+DDL operations of atomic partitioned cache with queries initiated from server node. */ -public class H2DynamicIndexingComplexServerAtomicPartitionedTest extends H2DynamicIndexingComplexTest { +public class H2DynamicIndexingComplexServerAtomicPartitionedTest extends H2DynamicIndexingComplexAbstractTest { /** * Constructor. */ http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerAtomicReplicatedTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerAtomicReplicatedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerAtomicReplicatedTest.java index 2bfe678..da02917 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerAtomicReplicatedTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerAtomicReplicatedTest.java @@ -23,7 +23,7 @@ import org.apache.ignite.cache.CacheMode; /** * Test to check work of DML+DDL operations of atomic replicated cache with queries initiated from server node. */ -public class H2DynamicIndexingComplexServerAtomicReplicatedTest extends H2DynamicIndexingComplexTest { +public class H2DynamicIndexingComplexServerAtomicReplicatedTest extends H2DynamicIndexingComplexAbstractTest { /** * Constructor. */ http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerTransactionalPartitionedNoBackupsTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerTransactionalPartitionedNoBackupsTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerTransactionalPartitionedNoBackupsTest.java index 37b4489..c79b051 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerTransactionalPartitionedNoBackupsTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerTransactionalPartitionedNoBackupsTest.java @@ -24,7 +24,7 @@ import org.apache.ignite.cache.CacheMode; * Test to check work of DML+DDL operations of transactional partitioned cache without backups * with queries initiated from server node. */ -public class H2DynamicIndexingComplexServerTransactionalPartitionedNoBackupsTest extends H2DynamicIndexingComplexTest { +public class H2DynamicIndexingComplexServerTransactionalPartitionedNoBackupsTest extends H2DynamicIndexingComplexAbstractTest { /** * Constructor. */ http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerTransactionalPartitionedTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerTransactionalPartitionedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerTransactionalPartitionedTest.java index 85a58c1..d132c5b 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerTransactionalPartitionedTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerTransactionalPartitionedTest.java @@ -23,7 +23,7 @@ import org.apache.ignite.cache.CacheMode; /** * Test to check work of DML+DDL operations of transactional partitioned cache with queries initiated from server node. */ -public class H2DynamicIndexingComplexServerTransactionalPartitionedTest extends H2DynamicIndexingComplexTest { +public class H2DynamicIndexingComplexServerTransactionalPartitionedTest extends H2DynamicIndexingComplexAbstractTest { /** * Constructor. */ http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerTransactionalReplicatedTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerTransactionalReplicatedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerTransactionalReplicatedTest.java index 54329b1..ac2ef60 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerTransactionalReplicatedTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexServerTransactionalReplicatedTest.java @@ -23,7 +23,7 @@ import org.apache.ignite.cache.CacheMode; /** * Test to check work of DML+DDL operations of transactional replicated cache with queries initiated from client node. */ -public class H2DynamicIndexingComplexServerTransactionalReplicatedTest extends H2DynamicIndexingComplexTest { +public class H2DynamicIndexingComplexServerTransactionalReplicatedTest extends H2DynamicIndexingComplexAbstractTest { /** * Constructor. */ http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexTest.java deleted file mode 100644 index 2095294..0000000 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexTest.java +++ /dev/null @@ -1,361 +0,0 @@ -/* - * 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.cache.index; - -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import org.apache.ignite.Ignition; -import org.apache.ignite.binary.BinaryObject; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.query.SqlFieldsQuery; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor; -import org.apache.ignite.internal.processors.query.IgniteSQLException; -import org.apache.ignite.lang.IgniteCallable; -import org.apache.ignite.lang.IgniteInClosure; -import org.apache.ignite.testframework.GridTestUtils; - -/** - * Base class for testing work of combinations of DML and DDL operations. - */ -public abstract class H2DynamicIndexingComplexTest extends DynamicIndexAbstractSelfTest { - /** Cache mode to test with. */ - private final CacheMode cacheMode; - - /** Cache atomicity mode to test with. */ - private final CacheAtomicityMode atomicityMode; - - /** Node index to initiate operations from. */ - private final int nodeIdx; - - /** Backups to configure */ - private final int backups; - - /** Names of companies to use. */ - private final static List<String> COMPANIES = Arrays.asList("ASF", "GNU", "BSD"); - - /** Cities to use. */ - private final static List<String> CITIES = Arrays.asList("St. Petersburg", "Boston", "Berkeley", "London"); - - /** Index of server node. */ - protected final static int SRV_IDX = 0; - - /** Index of client node. */ - protected final static int CLIENT_IDX = 1; - - /** - * Constructor. - * @param cacheMode Cache mode. - * @param atomicityMode Cache atomicity mode. - * @param backups Number of backups. - * @param nodeIdx Node index. - */ - H2DynamicIndexingComplexTest(CacheMode cacheMode, CacheAtomicityMode atomicityMode, int backups, int nodeIdx) { - this.cacheMode = cacheMode; - this.atomicityMode = atomicityMode; - this.backups = backups; - this.nodeIdx = nodeIdx; - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - super.beforeTestsStarted(); - - Ignition.start(serverConfiguration(0)); - - Ignition.start(clientConfiguration(1)); - - Ignition.start(serverConfiguration(2)); - - Ignition.start(serverConfiguration(3)); - } - - /** Do test. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") - public void testOperations() { - executeSql("CREATE TABLE person (id int, name varchar, age int, company varchar, city varchar, " + - "primary key (id, name, city)) WITH \"template=" + cacheMode.name() + ",atomicity=" + atomicityMode.name() + - ",backups=" + backups + ",affinity_key=city\""); - - executeSql("CREATE INDEX idx on person (city asc, name asc)"); - - executeSql("CREATE TABLE city (name varchar, population int, primary key (name)) WITH " + - "\"template=" + cacheMode.name() + ",atomicity=" + atomicityMode.name() + - ",backups=" + backups + ",affinity_key=name\""); - - executeSql("INSERT INTO city (name, population) values(?, ?), (?, ?), (?, ?)", - "St. Petersburg", 6000000, - "Boston", 2000000, - "London", 8000000 - ); - - final long PERSON_COUNT = 100; - - for (int i = 0; i < PERSON_COUNT; i++) - executeSql("INSERT INTO person (id, name, age, company, city) values (?, ?, ?, ?, ?)", - i, - "Person " + i, - 20 + (i % 10), - COMPANIES.get(i % COMPANIES.size()), - CITIES.get(i % CITIES.size())); - - assertAllPersons(new IgniteInClosure<List<?>>() { - @Override public void apply(List<?> person) { - assertInitPerson(person); - } - }); - - long r = (Long)executeSqlSingle("SELECT COUNT(*) from Person"); - - assertEquals(PERSON_COUNT, r); - - r = (Long)executeSqlSingle("SELECT COUNT(*) from Person p inner join City c on p.city = c.name"); - - // Berkeley is not present in City table, although 25 people have it specified as their city. - assertEquals(75L, r); - - executeSqlSingle("UPDATE Person SET company = 'GNU', age = CASE WHEN MOD(id, 2) <> 0 THEN age + 5 ELSE " + - "age + 1 END WHERE company = 'ASF'"); - - assertAllPersons(new IgniteInClosure<List<?>>() { - @Override public void apply(List<?> person) { - int id = (Integer)person.get(0); - - if (id % COMPANIES.size() == 0) { - int initAge = 20 + id % 10; - - int expAge = (initAge % 2 != 0 ? initAge + 5 : initAge + 1); - - assertPerson(id, "Person " + id, expAge, "GNU", CITIES.get(id % CITIES.size()), person); - } - else - assertInitPerson(person); - } - }); - - executeSql("DROP INDEX idx"); - - // Index drop should not affect data. - assertAllPersons(new IgniteInClosure<List<?>>() { - @Override public void apply(List<?> person) { - int id = (Integer)person.get(0); - - if (id % COMPANIES.size() == 0) { - int initAge = 20 + id % 10; - - int expAge = initAge % 2 != 0 ? initAge + 5 : initAge + 1; - - assertPerson(id, "Person " + id, expAge, "GNU", CITIES.get(id % CITIES.size()), person); - } - else - assertInitPerson(person); - } - }); - - // Let's drop all BSD folks living in Berkeley and Boston - this compares ASCII codes of 1st symbols. - executeSql("DELETE FROM person WHERE ASCII(company) = ASCII(city)"); - - assertAllPersons(new IgniteInClosure<List<?>>() { - @Override public void apply(List<?> person) { - String city = city(person); - - String company = company(person); - - assertFalse(city.charAt(0) == company.charAt(0)); - } - }); - - assertNotNull(node().cache("SQL_PUBLIC_PERSON")); - - executeSql("DROP TABLE person"); - - assertNull(node().cache("SQL_PUBLIC_PERSON")); - - GridTestUtils.assertThrows(null, new IgniteCallable<Object>() { - @Override public Object call() throws Exception { - return executeSql("SELECT * from Person"); - } - }, IgniteSQLException.class, "Table \"PERSON\" not found"); - } - - /** - * Select all data from the table and check that all records correspond to rules set by given closure. - * @param clo Closure to apply to each record. - */ - private void assertAllPersons(IgniteInClosure<List<?>> clo) { - List<List<?>> res = executeSql("SELECT * from Person"); - - for (List<?> p : res) - clo.apply(p); - } - - /** - * Get person's id from data row. - * @param person data row. - * @return person's id. - */ - private static int id(List<?> person) { - return (Integer)person.get(0); - } - - /** - * Get person's name from data row. - * @param person data row. - * @return person's name. - */ - private static String name(List<?> person) { - return (String)person.get(1); - } - - /** - * Get person's age from data row. - * @param person data row. - * @return person's age. - */ - private static int age(List<?> person) { - return (Integer)person.get(2); - } - - /** - * Get person's company from data row. - * @param person data row. - * @return person's company. - */ - private static String company(List<?> person) { - return (String)person.get(3); - } - - /** - * Get person's city from data row. - * @param person data row. - * @return person's city. - */ - private static String city(List<?> person) { - return (String)person.get(4); - } - - /** - * Check that all columns in data row are exactly how they were initially inserted. - * @param person data row. - */ - private void assertInitPerson(List<?> person) { - assertEquals(5, person.size()); - - int id = id(person); - - String name = "Person " + id; - - int age = 20 + id % 10; - - String company = COMPANIES.get(id % COMPANIES.size()); - - String city = CITIES.get(id % CITIES.size()); - - assertPerson(id, name, age, company, city, person); - } - - /** - * Check contents of SQL data row and corresponding cache entry. - * @param id Expected id. - * @param name Expected name. - * @param age Expected age. - * @param company Expected company. - * @param city Expected city. - * @param person Data row. - */ - private void assertPerson(int id, String name, int age, String company, String city, List<?> person) { - assertEquals(name, name(person)); - - assertEquals(age, age(person)); - - assertEquals(company, company(person)); - - assertEquals(city, city(person)); - - String cacheName = "SQL_PUBLIC_PERSON"; - - Collection<GridQueryTypeDescriptor> descs = node().context().query().types(cacheName); - - assertEquals(1, descs.size()); - - GridQueryTypeDescriptor desc = descs.iterator().next(); - - String keyType = desc.keyTypeName(); - - String valType = desc.valueTypeName(); - - BinaryObject k = node().binary().builder(keyType) - .setField("id", id) - .setField("name", name) - .setField("city", city).build(); - - Object v = node().cache(cacheName).withKeepBinary().get(k); - - assertNotNull(v); - - BinaryObject expVal = node().binary().builder(valType) - .setField("age", age) - .setField("company", company).build(); - - assertEquals(expVal, v); - } - - /** - * Run SQL statement on specified node. - * @param stmt Statement to run. - * @return Run result. - */ - private List<List<?>> executeSql(IgniteEx node, String stmt, Object... args) { - return node.context().query().querySqlFields(new SqlFieldsQuery(stmt).setArgs(args), true).getAll(); - } - - /** - * Run SQL statement on default node. - * @param stmt Statement to run. - * @return Run result. - */ - private List<List<?>> executeSql(String stmt, Object... args) { - return executeSql(node(), stmt, args); - } - - /** - * Run SQL statement that is expected to return strictly one value (like COUNT(*)). - * @param stmt Statement to run. - * @return Run result. - */ - private Object executeSqlSingle(String stmt, Object... args) { - List<List<?>> res = executeSql(stmt, args); - - assertEquals(1, res.size()); - - List<?> row = res.get(0); - - assertEquals(1, row.size()); - - return row.get(0); - } - - /** - * @return Node to initiate operations from. - */ - protected IgniteEx node() { - return grid(nodeIdx); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java index 39194d7..d70e5c3 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java @@ -21,11 +21,14 @@ import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.CacheIteratorScanQueryTest; import org.apache.ignite.internal.processors.cache.CacheLocalQueryDetailMetricsSelfTest; import org.apache.ignite.internal.processors.cache.CacheLocalQueryMetricsSelfTest; +import org.apache.ignite.internal.processors.cache.CacheOffheapBatchIndexingBaseTest; +import org.apache.ignite.internal.processors.cache.CacheOffheapBatchIndexingMultiTypeTest; import org.apache.ignite.internal.processors.cache.CacheOffheapBatchIndexingSingleTypeTest; import org.apache.ignite.internal.processors.cache.CachePartitionedQueryDetailMetricsDistributedSelfTest; import org.apache.ignite.internal.processors.cache.CachePartitionedQueryDetailMetricsLocalSelfTest; import org.apache.ignite.internal.processors.cache.CachePartitionedQueryMetricsDistributedSelfTest; import org.apache.ignite.internal.processors.cache.CachePartitionedQueryMetricsLocalSelfTest; +import org.apache.ignite.internal.processors.cache.CacheQueryBuildValueTest; import org.apache.ignite.internal.processors.cache.CacheQueryEvictDataLostTest; import org.apache.ignite.internal.processors.cache.CacheQueryNewClientSelfTest; import org.apache.ignite.internal.processors.cache.CacheReplicatedQueryDetailMetricsDistributedSelfTest; @@ -46,6 +49,7 @@ import org.apache.ignite.internal.processors.cache.IgniteBinaryObjectLocalQueryA import org.apache.ignite.internal.processors.cache.IgniteBinaryObjectQueryArgumentsTest; import org.apache.ignite.internal.processors.cache.IgniteBinaryWrappedObjectFieldsQuerySelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheCollocatedQuerySelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheConfigVariationsQueryTest; import org.apache.ignite.internal.processors.cache.IgniteCacheDeleteSqlQuerySelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheDistributedJoinCollocatedAndNotTest; import org.apache.ignite.internal.processors.cache.IgniteCacheDistributedJoinCustomAffinityMapper; @@ -57,6 +61,7 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheDuplicateEntityCon import org.apache.ignite.internal.processors.cache.IgniteCacheFieldsQueryNoDataSelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheFullTextQueryNodeJoiningSelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheInsertSqlQuerySelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheJoinPartitionedAndReplicatedCollocationTest; import org.apache.ignite.internal.processors.cache.IgniteCacheJoinPartitionedAndReplicatedTest; import org.apache.ignite.internal.processors.cache.IgniteCacheJoinQueryWithAffinityKeyTest; import org.apache.ignite.internal.processors.cache.IgniteCacheLargeResultSelfTest; @@ -71,10 +76,13 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheQueryH2IndexingLea import org.apache.ignite.internal.processors.cache.IgniteCacheQueryIndexSelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheQueryLoadSelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheSqlQueryErrorSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheUnionDuplicatesTest; import org.apache.ignite.internal.processors.cache.IgniteCacheUpdateSqlQuerySelfTest; import org.apache.ignite.internal.processors.cache.IgniteCheckClusterStateBeforeExecuteQueryTest; +import org.apache.ignite.internal.processors.cache.IgniteClientReconnectCacheQueriesFailoverTest; import org.apache.ignite.internal.processors.cache.IgniteCrossCachesJoinsQueryTest; import org.apache.ignite.internal.processors.cache.IgniteDynamicSqlRestoreTest; +import org.apache.ignite.internal.processors.cache.IgniteErrorOnRebalanceTest; import org.apache.ignite.internal.processors.cache.IncorrectQueryEntityTest; import org.apache.ignite.internal.processors.cache.QueryEntityCaseMismatchTest; import org.apache.ignite.internal.processors.cache.SqlFieldsQuerySelfTest; @@ -109,6 +117,11 @@ import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerCoord import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerNodeFIlterBasicSelfTest; import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerNodeFilterCoordinatorBasicSelfTest; import org.apache.ignite.internal.processors.cache.index.H2ConnectionLeaksSelfTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexClientAtomicPartitionedNoBackupsTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexClientTransactionalPartitionedNoBackupsTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexServerAtomicPartitionedNoBackupsTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexServerTransactionalPartitionedNoBackupsTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexAbstractTest; import org.apache.ignite.internal.processors.cache.index.IgniteDecimalSelfTest; import org.apache.ignite.internal.processors.cache.index.H2DynamicColumnsClientBasicSelfTest; import org.apache.ignite.internal.processors.cache.index.H2DynamicColumnsServerBasicSelfTest; @@ -139,9 +152,11 @@ import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalQueryCa import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalQuerySelfTest; import org.apache.ignite.internal.processors.cache.query.CacheScanQueryFailoverTest; import org.apache.ignite.internal.processors.cache.query.GridCacheQueryTransformerSelfTest; +import org.apache.ignite.internal.processors.cache.query.GridCircularQueueTest; import org.apache.ignite.internal.processors.cache.query.IgniteCacheQueryCacheDestroySelfTest; import org.apache.ignite.internal.processors.cache.query.IndexingSpiQuerySelfTest; import org.apache.ignite.internal.processors.cache.query.IndexingSpiQueryTxSelfTest; +import org.apache.ignite.internal.processors.cache.query.IndexingSpiQueryWithH2IndexingSelfTest; import org.apache.ignite.internal.processors.client.ClientConnectorConfigurationValidationSelfTest; import org.apache.ignite.internal.processors.database.baseline.IgniteStableBaselineBinObjFieldsQuerySelfTest; import org.apache.ignite.internal.processors.query.IgniteCachelessQueriesSelfTest; @@ -262,6 +277,15 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite { suite.addTestSuite(IgniteCachePartitionedQueryP2PDisabledSelfTest.class); suite.addTestSuite(IgniteCachePartitionedQueryEvtsDisabledSelfTest.class); + //suite.addTestSuite(IgniteCacheUnionDuplicatesTest.class); + //suite.addTestSuite(IgniteCacheConfigVariationsQueryTest.class); + //suite.addTestSuite(IgniteCacheJoinPartitionedAndReplicatedCollocationTest.class); + //suite.addTestSuite(IgniteClientReconnectCacheQueriesFailoverTest.class); + //suite.addTestSuite(IgniteErrorOnRebalanceTest.class); + //suite.addTestSuite(CacheQueryBuildValueTest.class); + //suite.addTestSuite(CacheOffheapBatchIndexingMultiTypeTest.class); + //suite.addTestSuite(CacheOffheapBatchIndexingBaseTest.class); + suite.addTestSuite(IgniteCacheQueryIndexSelfTest.class); suite.addTestSuite(IgniteCacheCollocatedQuerySelfTest.class); suite.addTestSuite(IgniteCacheLargeResultSelfTest.class); @@ -306,6 +330,9 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite { suite.addTestSuite(IgniteCacheMultipleIndexedTypesTest.class); suite.addTestSuite(IgniteSqlQueryMinMaxTest.class); + //suite.addTestSuite(GridCircularQueueTest.class); + //suite.addTestSuite(IndexingSpiQueryWithH2IndexingSelfTest.class); + // DDL. suite.addTestSuite(H2DynamicIndexTransactionalReplicatedSelfTest.class); suite.addTestSuite(H2DynamicIndexTransactionalPartitionedSelfTest.class); @@ -319,13 +346,18 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite { suite.addTestSuite(H2DynamicColumnsServerCoordinatorBasicSelfTest.class); // DML+DDL. + //suite.addTestSuite(H2DynamicIndexingComplexAbstractTest.class); suite.addTestSuite(H2DynamicIndexingComplexClientAtomicPartitionedTest.class); + //suite.addTestSuite(H2DynamicIndexingComplexClientAtomicPartitionedNoBackupsTest.class); suite.addTestSuite(H2DynamicIndexingComplexClientAtomicReplicatedTest.class); suite.addTestSuite(H2DynamicIndexingComplexClientTransactionalPartitionedTest.class); + //suite.addTestSuite(H2DynamicIndexingComplexClientTransactionalPartitionedNoBackupsTest.class); suite.addTestSuite(H2DynamicIndexingComplexClientTransactionalReplicatedTest.class); suite.addTestSuite(H2DynamicIndexingComplexServerAtomicPartitionedTest.class); + //suite.addTestSuite(H2DynamicIndexingComplexServerAtomicPartitionedNoBackupsTest.class); suite.addTestSuite(H2DynamicIndexingComplexServerAtomicReplicatedTest.class); suite.addTestSuite(H2DynamicIndexingComplexServerTransactionalPartitionedTest.class); + //suite.addTestSuite(H2DynamicIndexingComplexServerTransactionalPartitionedNoBackupsTest.class); suite.addTestSuite(H2DynamicIndexingComplexServerTransactionalReplicatedTest.class); // Fields queries. http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java index 486626a..e810d30 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java @@ -22,10 +22,15 @@ import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinu import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousBatchForceServerModeAckTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryAsyncFilterListenerTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryConcurrentPartitionUpdateTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryCounterPartitionedAtomicTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryCounterPartitionedTxTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryCounterReplicatedAtomicTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryCounterReplicatedTxTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryEventBufferTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryExecuteInPrimaryTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFactoryAsyncFilterRandomOperationTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFactoryFilterRandomOperationTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverAtomicNearEnabledSelfSelfTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryLostPartitionTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryOperationFromCallbackTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryOperationP2PTest; @@ -69,6 +74,7 @@ import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheC import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientTxReconnectTest; import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryImmutableEntryTest; import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryNoUnsubscribeTest; +import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryReconnectTest; /** * Test suite for cache queries. @@ -137,6 +143,14 @@ public class IgniteCacheQuerySelfTestSuite3 extends TestSuite { suite.addTestSuite(CacheContinuousWithTransformerFailoverTest.class); suite.addTestSuite(CacheContinuousWithTransformerRandomOperationsTest.class); + //suite.addTestSuite(CacheContinuousQueryCounterPartitionedAtomicTest.class); + //suite.addTestSuite(CacheContinuousQueryCounterPartitionedTxTest.class); + //suite.addTestSuite(CacheContinuousQueryCounterReplicatedAtomicTest.class); + //suite.addTestSuite(CacheContinuousQueryCounterReplicatedTxTest.class); + //suite.addTestSuite(CacheContinuousQueryFailoverAtomicNearEnabledSelfSelfTest.class); + + //suite.addTestSuite(IgniteCacheContinuousQueryReconnectTest.class); + return suite; } } http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryEntityWithJsr310Java8DateTimeApiFieldsTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryEntityWithJsr310Java8DateTimeApiFieldsTest.java b/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryEntityWithJsr310Java8DateTimeApiFieldsTest.java index 903b8dc..9cb0f21 100644 --- a/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryEntityWithJsr310Java8DateTimeApiFieldsTest.java +++ b/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryEntityWithJsr310Java8DateTimeApiFieldsTest.java @@ -35,7 +35,7 @@ import org.apache.ignite.configuration.CacheConfiguration; /** * Tests queries against entities with JSR-310 Java 8 Date and Time API fields. */ -public class CacheQueryEntityWithJsr310Java8DateTimeApiFieldsTest extends CacheQueryJsr310Java8DateTimeApiBaseTest { +public class CacheQueryEntityWithJsr310Java8DateTimeApiFieldsTest extends CacheQueryJsr310Java8DateTimeApiAbstractTest { /** * Entity containing JSR-310 fields. */ http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryJsr310Java8DateTimeApiAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryJsr310Java8DateTimeApiAbstractTest.java b/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryJsr310Java8DateTimeApiAbstractTest.java new file mode 100644 index 0000000..d0ca8f1 --- /dev/null +++ b/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryJsr310Java8DateTimeApiAbstractTest.java @@ -0,0 +1,88 @@ +/* + * 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.h2; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +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.junits.common.GridCommonAbstractTest; + +/** + * Base class for JSR-310 Java 8 Date and Time API queries tests. + */ +public abstract class CacheQueryJsr310Java8DateTimeApiAbstractTest extends GridCommonAbstractTest { + /** IP finder. */ + private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); + + /** {@link LocalTime} instance. */ + protected static final LocalTime LOCAL_TIME = LocalTime.now().minusHours(10); + + /** + * The number of days subtracted from the current time when constructing + * {@link LocalDate} and {@link LocalDateTime} + * instances. + */ + protected static final long DAYS_BEFORE_NOW = 10; + + /** {@link LocalDate} instance. */ + protected static final LocalDate LOCAL_DATE = LocalDate.now().minusDays(DAYS_BEFORE_NOW); + + /** {@link LocalDateTime} instance. */ + protected static final LocalDateTime LOCAL_DATE_TIME = LocalDateTime.of(LOCAL_DATE, LocalTime.MIDNIGHT); + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + TcpDiscoverySpi discoverySpi = (TcpDiscoverySpi)cfg.getDiscoverySpi(); + + discoverySpi.setIpFinder(IP_FINDER); + + return cfg; + } + + /** + * Creates a cache configuration with the specified cache name + * and indexed type key/value pairs. + * + * @param cacheName Cache name + * @param indexedTypes key/value pairs according to {@link CacheConfiguration#setIndexedTypes(Class[])}. + * @param <K> Key type. + * @param <V> Value type. + * @return Cache configuration. + */ + protected static <K, V> CacheConfiguration<K, V> createCacheConfig(String cacheName, Class<?>... indexedTypes) { + return new CacheConfiguration<K, V>(cacheName) + .setCacheMode(CacheMode.REPLICATED) + .setAtomicityMode(CacheAtomicityMode.ATOMIC) + .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) + .setIndexedTypes(indexedTypes); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryJsr310Java8DateTimeApiBaseTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryJsr310Java8DateTimeApiBaseTest.java b/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryJsr310Java8DateTimeApiBaseTest.java deleted file mode 100644 index 6f643b4..0000000 --- a/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryJsr310Java8DateTimeApiBaseTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.h2; - -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.CacheWriteSynchronizationMode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -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.junits.common.GridCommonAbstractTest; - -/** - * Base class for JSR-310 Java 8 Date and Time API queries tests. - */ -public abstract class CacheQueryJsr310Java8DateTimeApiBaseTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** {@link LocalTime} instance. */ - protected static final LocalTime LOCAL_TIME = LocalTime.now().minusHours(10); - - /** - * The number of days subtracted from the current time when constructing - * {@link LocalDate} and {@link LocalDateTime} - * instances. - */ - protected static final long DAYS_BEFORE_NOW = 10; - - /** {@link LocalDate} instance. */ - protected static final LocalDate LOCAL_DATE = LocalDate.now().minusDays(DAYS_BEFORE_NOW); - - /** {@link LocalDateTime} instance. */ - protected static final LocalDateTime LOCAL_DATE_TIME = LocalDateTime.of(LOCAL_DATE, LocalTime.MIDNIGHT); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoverySpi = (TcpDiscoverySpi)cfg.getDiscoverySpi(); - - discoverySpi.setIpFinder(IP_FINDER); - - return cfg; - } - - /** - * Creates a cache configuration with the specified cache name - * and indexed type key/value pairs. - * - * @param cacheName Cache name - * @param indexedTypes key/value pairs according to {@link CacheConfiguration#setIndexedTypes(Class[])}. - * @param <K> Key type. - * @param <V> Value type. - * @return Cache configuration. - */ - protected static <K, V> CacheConfiguration<K, V> createCacheConfig(String cacheName, Class<?>... indexedTypes) { - return new CacheConfiguration<K, V>(cacheName) - .setCacheMode(CacheMode.REPLICATED) - .setAtomicityMode(CacheAtomicityMode.ATOMIC) - .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) - .setIndexedTypes(indexedTypes); - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - stopAllGrids(); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/de9227d7/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java index 810f6af..17897de 100644 --- a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java +++ b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java @@ -18,6 +18,7 @@ package org.apache.ignite.testsuites; import junit.framework.TestSuite; +import org.apache.ignite.cache.spring.GridSpringCacheManagerMultiJvmSelfTest; import org.apache.ignite.cache.spring.GridSpringCacheManagerSelfTest; import org.apache.ignite.cache.spring.GridSpringCacheManagerSpringBeanSelfTest; import org.apache.ignite.cache.spring.SpringCacheManagerContextInjectionTest; @@ -37,6 +38,7 @@ import org.apache.ignite.p2p.GridP2PUserVersionChangeSelfTest; import org.apache.ignite.spring.IgniteExcludeInConfigurationTest; import org.apache.ignite.spring.IgniteStartFromStreamConfigurationTest; import org.apache.ignite.spring.injection.GridServiceInjectionSpringResourceTest; +import org.apache.ignite.startup.cmdline.GridCommandLineLoaderTest; import org.apache.ignite.testframework.IgniteTestSuite; import org.apache.ignite.transactions.spring.GridSpringTransactionManagerSelfTest; import org.apache.ignite.transactions.spring.GridSpringTransactionManagerSpringBeanSelfTest; @@ -91,6 +93,10 @@ public class IgniteSpringTestSuite extends TestSuite { suite.addTestSuite(SpringCacheTest.class); + //suite.addTestSuite(GridSpringCacheManagerMultiJvmSelfTest.class); + + //suite.addTestSuite(GridCommandLineLoaderTest.class); + return suite; } }
