You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2014/12/30 10:07:17 UTC

[3/9] incubator-ignite git commit: # ignite moved test using queries to indexing module

# ignite moved test using queries to indexing module


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/04a442ef
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/04a442ef
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/04a442ef

Branch: refs/heads/ignite-1
Commit: 04a442efaa3953098f61c832d52147cb0c9e374d
Parents: 7abc5f9
Author: sboikov <sb...@gridgain.com>
Authored: Tue Dec 30 09:37:39 2014 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Dec 30 09:37:39 2014 +0300

----------------------------------------------------------------------
 .../tcp/GridOrderedMessageCancelSelfTest.java   | 211 -------------------
 .../bamboo/GridComputeGridTestSuite.java        |   1 -
 .../tcp/GridOrderedMessageCancelSelfTest.java   | 211 +++++++++++++++++++
 .../testsuites/GridCacheQuerySelfTestSuite.java |   3 +
 4 files changed, 214 insertions(+), 212 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/04a442ef/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java
deleted file mode 100644
index 2a8edcf..0000000
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/* @java.file.header */
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.apache.ignite.spi.communication.tcp;
-
-import org.apache.ignite.*;
-import org.apache.ignite.compute.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.marshaller.*;
-import org.apache.ignite.resources.*;
-import org.apache.ignite.spi.discovery.tcp.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.query.*;
-import org.gridgain.grid.kernal.*;
-import org.gridgain.grid.kernal.managers.communication.*;
-import org.gridgain.grid.kernal.processors.cache.query.*;
-import org.gridgain.grid.util.direct.*;
-import org.gridgain.grid.util.typedef.internal.*;
-import org.gridgain.testframework.junits.common.*;
-import org.jetbrains.annotations.*;
-
-import java.util.*;
-import java.util.concurrent.*;
-
-import static java.util.concurrent.TimeUnit.*;
-import static org.gridgain.grid.cache.GridCacheMode.*;
-import static org.gridgain.grid.cache.GridCachePreloadMode.*;
-
-/**
- *
- */
-public class GridOrderedMessageCancelSelfTest extends GridCommonAbstractTest {
-    /** IP finder. */
-    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
-    /** Cancel latch. */
-    private static CountDownLatch cancelLatch;
-
-    /** Process response latch. */
-    private static CountDownLatch resLatch;
-
-    /** Finish latch. */
-    private static CountDownLatch finishLatch;
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        GridCacheConfiguration cache = defaultCacheConfiguration();
-
-        cache.setCacheMode(PARTITIONED);
-        cache.setPreloadMode(NONE);
-
-        cfg.setCacheConfiguration(cache);
-
-        cfg.setCommunicationSpi(new CommunicationSpi());
-
-        TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
-        disco.setIpFinder(IP_FINDER);
-
-        cfg.setDiscoverySpi(disco);
-
-        return cfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        cancelLatch = new CountDownLatch(1);
-        resLatch = new CountDownLatch(1);
-        finishLatch = new CountDownLatch(1);
-
-        startGridsMultiThreaded(2);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        stopAllGrids();
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testQuery() throws Exception {
-        GridCacheQueryFuture<Map.Entry<Object, Object>> fut =
-            grid(0).cache(null).queries().createSqlQuery(String.class, "_key is not null").execute();
-
-        testMessageSet(fut);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testTask() throws Exception {
-        ComputeTaskFuture<?> fut = executeAsync(compute(grid(0).forRemotes()), Task.class, null);
-
-        testMessageSet(fut);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testTaskException() throws Exception {
-        ComputeTaskFuture<?> fut = executeAsync(compute(grid(0).forRemotes()), FailTask.class, null);
-
-        testMessageSet(fut);
-    }
-
-    /**
-     * @param fut Future to cancel.
-     * @throws Exception If failed.
-     */
-    private void testMessageSet(IgniteFuture<?> fut) throws Exception {
-        cancelLatch.await();
-
-        assertTrue(fut.cancel());
-
-        resLatch.countDown();
-
-        assertTrue(U.await(finishLatch, 5000, MILLISECONDS));
-
-        Map map = U.field(((GridKernal)grid(0)).context().io(), "msgSetMap");
-
-        info("Map: " + map);
-
-        assertTrue(map.isEmpty());
-    }
-
-    /**
-     * Communication SPI.
-     */
-    private static class CommunicationSpi extends TcpCommunicationSpi {
-        /** */
-        @IgniteMarshallerResource
-        private IgniteMarshaller marsh;
-
-        /** {@inheritDoc} */
-        @Override protected void notifyListener(UUID sndId, GridTcpCommunicationMessageAdapter msg,
-            IgniteRunnable msgC) {
-            try {
-                GridIoMessage ioMsg = (GridIoMessage)msg;
-
-                boolean wait = ioMsg.message() instanceof GridCacheQueryResponse ||
-                        ioMsg.message() instanceof GridJobExecuteResponse;
-
-                if (wait) {
-                    cancelLatch.countDown();
-
-                    assertTrue(U.await(resLatch, 5000, MILLISECONDS));
-                }
-
-                super.notifyListener(sndId, msg, msgC);
-
-                if (wait)
-                    finishLatch.countDown();
-            }
-            catch (Exception e) {
-                fail("Unexpected error: " + e);
-            }
-        }
-    }
-
-    /**
-     * Test task.
-     */
-    @ComputeTaskSessionFullSupport
-    private static class Task extends ComputeTaskSplitAdapter<Void, Void> {
-        /** {@inheritDoc} */
-        @Override protected Collection<? extends ComputeJob> split(int gridSize, Void arg) throws IgniteCheckedException {
-            return Collections.singleton(new ComputeJobAdapter() {
-                @Nullable @Override public Object execute() {
-                    return null;
-                }
-            });
-        }
-
-        /** {@inheritDoc} */
-        @Nullable @Override public Void reduce(List<ComputeJobResult> results) throws IgniteCheckedException {
-            return null;
-        }
-    }
-
-    /**
-     * Test task.
-     */
-    @ComputeTaskSessionFullSupport
-    private static class FailTask extends ComputeTaskSplitAdapter<Void, Void> {
-        /** {@inheritDoc} */
-        @Override protected Collection<? extends ComputeJob> split(int gridSize, Void arg) throws IgniteCheckedException {
-            return Collections.singleton(new ComputeJobAdapter() {
-                @Nullable @Override public Object execute() throws IgniteCheckedException {
-                    throw new IgniteCheckedException("Task failed.");
-                }
-            });
-        }
-
-        /** {@inheritDoc} */
-        @Nullable @Override public Void reduce(List<ComputeJobResult> results) throws IgniteCheckedException {
-            return null;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/04a442ef/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridComputeGridTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridComputeGridTestSuite.java b/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridComputeGridTestSuite.java
index b488a5a..a574cfc 100644
--- a/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridComputeGridTestSuite.java
+++ b/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridComputeGridTestSuite.java
@@ -78,7 +78,6 @@ public class GridComputeGridTestSuite {
         suite.addTestSuite(GridTaskNameAnnotationSelfTest.class);
         suite.addTestSuite(GridJobCheckpointCleanupSelfTest.class);
         suite.addTestSuite(GridEventStorageSelfTest.class);
-        suite.addTestSuite(GridOrderedMessageCancelSelfTest.class);
         suite.addTestSuite(GridFailoverTaskWithPredicateSelfTest.class);
         suite.addTestSuite(GridProjectionLocalJobMultipleArgumentsSelfTest.class);
         suite.addTestSuite(GridAffinitySelfTest.class);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/04a442ef/modules/indexing/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java
new file mode 100644
index 0000000..2a8edcf
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java
@@ -0,0 +1,211 @@
+/* @java.file.header */
+
+/*  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+package org.apache.ignite.spi.communication.tcp;
+
+import org.apache.ignite.*;
+import org.apache.ignite.compute.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.marshaller.*;
+import org.apache.ignite.resources.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.gridgain.grid.cache.*;
+import org.gridgain.grid.cache.query.*;
+import org.gridgain.grid.kernal.*;
+import org.gridgain.grid.kernal.managers.communication.*;
+import org.gridgain.grid.kernal.processors.cache.query.*;
+import org.gridgain.grid.util.direct.*;
+import org.gridgain.grid.util.typedef.internal.*;
+import org.gridgain.testframework.junits.common.*;
+import org.jetbrains.annotations.*;
+
+import java.util.*;
+import java.util.concurrent.*;
+
+import static java.util.concurrent.TimeUnit.*;
+import static org.gridgain.grid.cache.GridCacheMode.*;
+import static org.gridgain.grid.cache.GridCachePreloadMode.*;
+
+/**
+ *
+ */
+public class GridOrderedMessageCancelSelfTest extends GridCommonAbstractTest {
+    /** IP finder. */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** Cancel latch. */
+    private static CountDownLatch cancelLatch;
+
+    /** Process response latch. */
+    private static CountDownLatch resLatch;
+
+    /** Finish latch. */
+    private static CountDownLatch finishLatch;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        GridCacheConfiguration cache = defaultCacheConfiguration();
+
+        cache.setCacheMode(PARTITIONED);
+        cache.setPreloadMode(NONE);
+
+        cfg.setCacheConfiguration(cache);
+
+        cfg.setCommunicationSpi(new CommunicationSpi());
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setIpFinder(IP_FINDER);
+
+        cfg.setDiscoverySpi(disco);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        cancelLatch = new CountDownLatch(1);
+        resLatch = new CountDownLatch(1);
+        finishLatch = new CountDownLatch(1);
+
+        startGridsMultiThreaded(2);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testQuery() throws Exception {
+        GridCacheQueryFuture<Map.Entry<Object, Object>> fut =
+            grid(0).cache(null).queries().createSqlQuery(String.class, "_key is not null").execute();
+
+        testMessageSet(fut);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTask() throws Exception {
+        ComputeTaskFuture<?> fut = executeAsync(compute(grid(0).forRemotes()), Task.class, null);
+
+        testMessageSet(fut);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTaskException() throws Exception {
+        ComputeTaskFuture<?> fut = executeAsync(compute(grid(0).forRemotes()), FailTask.class, null);
+
+        testMessageSet(fut);
+    }
+
+    /**
+     * @param fut Future to cancel.
+     * @throws Exception If failed.
+     */
+    private void testMessageSet(IgniteFuture<?> fut) throws Exception {
+        cancelLatch.await();
+
+        assertTrue(fut.cancel());
+
+        resLatch.countDown();
+
+        assertTrue(U.await(finishLatch, 5000, MILLISECONDS));
+
+        Map map = U.field(((GridKernal)grid(0)).context().io(), "msgSetMap");
+
+        info("Map: " + map);
+
+        assertTrue(map.isEmpty());
+    }
+
+    /**
+     * Communication SPI.
+     */
+    private static class CommunicationSpi extends TcpCommunicationSpi {
+        /** */
+        @IgniteMarshallerResource
+        private IgniteMarshaller marsh;
+
+        /** {@inheritDoc} */
+        @Override protected void notifyListener(UUID sndId, GridTcpCommunicationMessageAdapter msg,
+            IgniteRunnable msgC) {
+            try {
+                GridIoMessage ioMsg = (GridIoMessage)msg;
+
+                boolean wait = ioMsg.message() instanceof GridCacheQueryResponse ||
+                        ioMsg.message() instanceof GridJobExecuteResponse;
+
+                if (wait) {
+                    cancelLatch.countDown();
+
+                    assertTrue(U.await(resLatch, 5000, MILLISECONDS));
+                }
+
+                super.notifyListener(sndId, msg, msgC);
+
+                if (wait)
+                    finishLatch.countDown();
+            }
+            catch (Exception e) {
+                fail("Unexpected error: " + e);
+            }
+        }
+    }
+
+    /**
+     * Test task.
+     */
+    @ComputeTaskSessionFullSupport
+    private static class Task extends ComputeTaskSplitAdapter<Void, Void> {
+        /** {@inheritDoc} */
+        @Override protected Collection<? extends ComputeJob> split(int gridSize, Void arg) throws IgniteCheckedException {
+            return Collections.singleton(new ComputeJobAdapter() {
+                @Nullable @Override public Object execute() {
+                    return null;
+                }
+            });
+        }
+
+        /** {@inheritDoc} */
+        @Nullable @Override public Void reduce(List<ComputeJobResult> results) throws IgniteCheckedException {
+            return null;
+        }
+    }
+
+    /**
+     * Test task.
+     */
+    @ComputeTaskSessionFullSupport
+    private static class FailTask extends ComputeTaskSplitAdapter<Void, Void> {
+        /** {@inheritDoc} */
+        @Override protected Collection<? extends ComputeJob> split(int gridSize, Void arg) throws IgniteCheckedException {
+            return Collections.singleton(new ComputeJobAdapter() {
+                @Nullable @Override public Object execute() throws IgniteCheckedException {
+                    throw new IgniteCheckedException("Task failed.");
+                }
+            });
+        }
+
+        /** {@inheritDoc} */
+        @Nullable @Override public Void reduce(List<ComputeJobResult> results) throws IgniteCheckedException {
+            return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/04a442ef/modules/indexing/src/test/java/org/gridgain/testsuites/GridCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/gridgain/testsuites/GridCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/gridgain/testsuites/GridCacheQuerySelfTestSuite.java
index 7a2ec15..6f0cf04 100644
--- a/modules/indexing/src/test/java/org/gridgain/testsuites/GridCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/gridgain/testsuites/GridCacheQuerySelfTestSuite.java
@@ -10,6 +10,7 @@
 package org.gridgain.testsuites;
 
 import junit.framework.*;
+import org.apache.ignite.spi.communication.tcp.*;
 import org.gridgain.grid.kernal.processors.cache.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.near.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.replicated.*;
@@ -86,6 +87,8 @@ public class GridCacheQuerySelfTestSuite extends TestSuite {
 
         suite.addTestSuite(GridCacheSwapScanQuerySelfTest.class);
 
+        suite.addTestSuite(GridOrderedMessageCancelSelfTest.class);
+
         return suite;
     }
 }