http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/537f631a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskContinuousMapperSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskContinuousMapperSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskContinuousMapperSelfTest.java deleted file mode 100644 index d475274..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskContinuousMapperSelfTest.java +++ /dev/null @@ -1,331 +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.gridgain.grid.kernal; - -import org.apache.ignite.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.resources.*; -import org.apache.ignite.testframework.junits.common.*; - -import java.io.*; -import java.util.*; - -/** - * {@link org.apache.ignite.compute.ComputeTaskContinuousMapper} test. - */ -@GridCommonTest(group = "Kernal Self") -public class GridTaskContinuousMapperSelfTest extends GridCommonAbstractTest { - /** - * @throws Exception If test failed. - */ - public void testContinuousMapperMethods() throws Exception { - try { - Ignite ignite = startGrid(0); - startGrid(1); - - ignite.compute().execute(TestAllMethodsTask.class, null); - } - finally { - stopGrid(0); - stopGrid(1); - } - } - - /** - * @throws Exception If test failed. - */ - public void testContinuousMapperLifeCycle() throws Exception { - try { - Ignite ignite = startGrid(0); - - ignite.compute().execute(TestLifeCycleTask.class, null); - } - finally { - stopGrid(0); - } - } - - /** - * @throws Exception If test failed. - */ - public void testContinuousMapperNegative() throws Exception { - try { - Ignite ignite = startGrid(0); - - ignite.compute().execute(TestNegativeTask.class, null); - } - finally { - stopGrid(0); - } - } - - /** */ - @SuppressWarnings({"PublicInnerClass"}) - public static class TestAllMethodsTask extends ComputeTaskAdapter<Object, Object> { - /** */ - @SuppressWarnings({"UnusedDeclaration"}) - @IgniteTaskContinuousMapperResource - private ComputeTaskContinuousMapper mapper; - - /** */ - private int cnt; - - /** {@inheritDoc} */ - @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, Object arg) throws IgniteCheckedException { - assert subgrid.size() == 2; - - mapper.send(new TestJob(cnt++), subgrid.get(0)); - - Map<ComputeJob, ClusterNode> mappedJobs = new HashMap<>(2); - - mappedJobs.put(new TestJob(cnt++), subgrid.get(0)); - mappedJobs.put(new TestJob(cnt++), subgrid.get(1)); - - mapper.send(mappedJobs); - - mapper.send(new TestJob(cnt++)); - - int size = subgrid.size(); - - Collection<ComputeJob> jobs = new ArrayList<>(size); - - for (ClusterNode n : subgrid) - jobs.add(new TestJob(cnt++)); - - mapper.send(jobs); - - return null; - } - - /** {@inheritDoc} */ - @Override public Object reduce(List<ComputeJobResult> results) throws IgniteCheckedException { - assert results.size() == cnt : "Unexpected result count: " + results.size(); - - return null; - } - } - - /** */ - @SuppressWarnings({"PublicInnerClass"}) - public static class TestLifeCycleTask extends ComputeTaskAdapter<Object, Object> { - /** */ - @IgniteLoggerResource - private IgniteLogger log; - - /** */ - private ComputeTaskContinuousMapper mapper; - - /** - * @param mapper Continuous mapper. - * @throws IgniteCheckedException Thrown if any exception occurs. - */ - @SuppressWarnings("unused") - @IgniteTaskContinuousMapperResource - private void setMapper(ComputeTaskContinuousMapper mapper) throws IgniteCheckedException { - this.mapper = mapper; - - mapper.send(new TestJob()); - } - - /** {@inheritDoc} */ - @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, Object arg) throws IgniteCheckedException { - mapper.send(new TestJob()); - - return null; - } - - /** {@inheritDoc} */ - @Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> received) throws IgniteCheckedException { - ComputeJobResultPolicy plc = super.result(res, received); - - if (received != null && received.size() == 2) - mapper.send(new TestJob()); - - return plc; - } - - /** {@inheritDoc} */ - @Override public Object reduce(List<ComputeJobResult> results) throws IgniteCheckedException { - assert results.size() == 3 : "Unexpected result count: " + results.size(); - - ClusterNode node = results.get(0).getNode(); - - try { - mapper.send(new TestJob(), node); - - assert false; - } - catch (IgniteCheckedException e) { - if (log.isInfoEnabled()) - log.info("Expected exception: " + e); - } - - try { - mapper.send(Collections.singletonMap(new TestJob(), node)); - - assert false; - } - catch (IgniteCheckedException e) { - if (log.isInfoEnabled()) - log.info("Expected exception: " + e); - } - - try { - mapper.send(new TestJob()); - - assert false; - } - catch (IgniteCheckedException e) { - if (log.isInfoEnabled()) - log.info("Expected exception: " + e); - } - - try { - mapper.send(Collections.singleton(new TestJob())); - - assert false; - } - catch (IgniteCheckedException e) { - if (log.isInfoEnabled()) - log.info("Expected exception: " + e); - } - - return null; - } - } - - /** */ - @SuppressWarnings({"PublicInnerClass"}) - public static class TestNegativeTask extends ComputeTaskAdapter<Object, Object> { - /** */ - @SuppressWarnings({"UnusedDeclaration"}) - @IgniteTaskContinuousMapperResource - private ComputeTaskContinuousMapper mapper; - - /** */ - @IgniteLoggerResource - private IgniteLogger log; - - /** {@inheritDoc} */ - @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, Object arg) throws IgniteCheckedException { - try { - mapper.send(new TestJob(), null); - - assert false; - - } - catch (NullPointerException e) { - if (log.isInfoEnabled()) - log.info("Expected exception: " + e); - } - - try { - mapper.send(null, subgrid.get(0)); - - assert false; - } - catch (NullPointerException e) { - if (log.isInfoEnabled()) - log.info("Expected exception: " + e); - } - - try { - mapper.send((Map<? extends ComputeJob, ClusterNode>)null); - - assert false; - } - catch (NullPointerException e) { - if (log.isInfoEnabled()) - log.info("Expected exception: " + e); - } - - try { - mapper.send(Collections.singletonMap(new TestJob(), (ClusterNode)null)); - - assert false; - } - catch (IgniteCheckedException e) { - if (log.isInfoEnabled()) - log.info("Expected exception: " + e); - } - - try { - mapper.send((ComputeJob)null); - - assert false; - } - catch (NullPointerException e) { - if (log.isInfoEnabled()) - log.info("Expected exception: " + e); - } - - try { - mapper.send((Collection<ComputeJob>)null); - - assert false; - } - catch (NullPointerException e) { - if (log.isInfoEnabled()) - log.info("Expected exception: " + e); - } - - try { - mapper.send(Collections.singleton((ComputeJob)null)); - - assert false; - } - catch (IgniteCheckedException e) { - if (log.isInfoEnabled()) - log.info("Expected exception: " + e); - } - - mapper.send(new TestJob()); - - return null; - } - - /** {@inheritDoc} */ - @Override public Object reduce(List<ComputeJobResult> results) throws IgniteCheckedException { - assert results.size() == 1; - - return null; - } - } - - /** */ - @SuppressWarnings({"PublicInnerClass"}) - public static class TestJob extends ComputeJobAdapter { - /** */ - public TestJob() { - super(-1); - } - - /** - * @param idx Index. - */ - public TestJob(int idx) { - super(idx); - } - - /** {@inheritDoc} */ - @Override public Serializable execute() throws IgniteCheckedException { - return argument(0); - } - } -}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/537f631a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskExecutionContextSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskExecutionContextSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskExecutionContextSelfTest.java deleted file mode 100644 index 7880686..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskExecutionContextSelfTest.java +++ /dev/null @@ -1,178 +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.gridgain.grid.kernal; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.marshaller.optimized.*; -import org.apache.ignite.resources.*; -import org.apache.ignite.internal.util.lang.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.testframework.*; -import org.apache.ignite.testframework.junits.common.*; - -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; - -/** - * Tests for {@code GridProjection.withXXX(..)} methods. - */ -public class GridTaskExecutionContextSelfTest extends GridCommonAbstractTest { - /** */ - private static final AtomicInteger CNT = new AtomicInteger(); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - cfg.setMarshaller(new IgniteOptimizedMarshaller(false)); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - startGridsMultiThreaded(2); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - stopAllGrids(); - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - CNT.set(0); - } - - /** - * @throws Exception If failed. - */ - public void testWithName() throws Exception { - Callable<String> f = new IgniteCallable<String>() { - @IgniteTaskSessionResource - private ComputeTaskSession ses; - - @Override public String call() { - return ses.getTaskName(); - } - }; - - Ignite g = grid(0); - - assert "name1".equals(g.compute().withName("name1").call(f)); - assert "name2".equals(g.compute().withName("name2").call(f)); - assert f.getClass().getName().equals(g.compute().call(f)); - - assert "name1".equals(g.compute().withName("name1").execute(new TestTask(false), null)); - assert "name2".equals(g.compute().withName("name2").execute(new TestTask(false), null)); - assert TestTask.class.getName().equals(g.compute().execute(new TestTask(false), null)); - } - - /** - * @throws Exception If failed. - */ - public void testWithNoFailoverClosure() throws Exception { - final Runnable r = new GridAbsClosureX() { - @Override public void applyx() throws IgniteCheckedException { - CNT.incrementAndGet(); - - throw new ComputeExecutionRejectedException("Expected error."); - } - }; - - final Ignite g = grid(0); - - GridTestUtils.assertThrows( - log, - new Callable<Object>() { - @Override public Object call() throws Exception { - g.compute().withNoFailover().run(r); - - return null; - } - }, - ComputeExecutionRejectedException.class, - "Expected error." - ); - - assertEquals(1, CNT.get()); - } - - /** - * @throws Exception If failed. - */ - public void testWithNoFailoverTask() throws Exception { - final Ignite g = grid(0); - - GridTestUtils.assertThrows( - log, - new Callable<Object>() { - @Override public Object call() throws Exception { - g.compute().withNoFailover().execute(new TestTask(true), null); - - return null; - } - }, - ComputeExecutionRejectedException.class, - "Expected error." - ); - - assertEquals(1, CNT.get()); - } - - /** - * Test task that returns its name. - */ - private static class TestTask extends ComputeTaskSplitAdapter<Void, String> { - /** */ - private final boolean fail; - - /** - * @param fail Whether to fail. - */ - private TestTask(boolean fail) { - this.fail = fail; - } - - /** {@inheritDoc} */ - @Override protected Collection<? extends ComputeJob> split(int gridSize, Void arg) throws IgniteCheckedException { - return F.asSet(new ComputeJobAdapter() { - @IgniteTaskSessionResource - private ComputeTaskSession ses; - - @Override public Object execute() throws IgniteCheckedException { - CNT.incrementAndGet(); - - if (fail) - throw new ComputeExecutionRejectedException("Expected error."); - - return ses.getTaskName(); - } - }); - } - - /** {@inheritDoc} */ - @Override public String reduce(List<ComputeJobResult> results) throws IgniteCheckedException { - return F.first(results).getData(); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/537f631a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskExecutionSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskExecutionSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskExecutionSelfTest.java deleted file mode 100644 index d9b74d6..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskExecutionSelfTest.java +++ /dev/null @@ -1,68 +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.gridgain.grid.kernal; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.testframework.junits.common.*; - -/** - * Task execution test. - */ -@GridCommonTest(group = "Kernal Self") -public class GridTaskExecutionSelfTest extends GridCommonAbstractTest { - /** Grid instance. */ - private Ignite ignite; - - /** */ - public GridTaskExecutionSelfTest() { - super(false); - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - ignite = startGrid(1); - - startGrid(2); - startGrid(3); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - stopGrid(1); - stopGrid(2); - stopGrid(3); - - ignite = null; - } - - /** - * @throws Exception If failed. - */ - public void testSynchronousExecute() throws Exception { - IgniteCompute comp = ignite.compute().enableAsync(); - - assertNull(comp.execute(GridTestTask.class, "testArg")); - - ComputeTaskFuture<?> fut = comp.future(); - - assert fut != null; - - info("Task result: " + fut.get()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/537f631a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskFailoverSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskFailoverSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskFailoverSelfTest.java deleted file mode 100644 index 4043589..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskFailoverSelfTest.java +++ /dev/null @@ -1,117 +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.gridgain.grid.kernal; - -import org.apache.ignite.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.resources.*; -import org.apache.ignite.testframework.junits.common.*; - -import java.io.*; -import java.util.*; - -/** - * Test for task failover. - */ -@GridCommonTest(group = "Kernal Self") -public class GridTaskFailoverSelfTest extends GridCommonAbstractTest { - /** Don't change it value. */ - public static final int SPLIT_COUNT = 2; - - /** */ - public GridTaskFailoverSelfTest() { - super(false); - } - - /** - * @throws Exception If test failed. - */ - @SuppressWarnings("unchecked") - public void testFailover() throws Exception { - Ignite ignite = startGrid(); - - try { - ignite.compute().localDeployTask(GridFailoverTestTask.class, GridFailoverTestTask.class.getClassLoader()); - - ComputeTaskFuture<?> fut = ignite.compute().execute(GridFailoverTestTask.class.getName(), null); - - assert fut != null; - - fut.get(); - - assert false : "Should never be reached due to exception thrown."; - } - catch (ClusterTopologyException e) { - info("Received correct exception: " + e); - } - finally { - stopGrid(); - } - } - - /** */ - @SuppressWarnings({"PublicInnerClass"}) - public static class GridFailoverTestTask extends ComputeTaskSplitAdapter<Serializable, Integer> { - /** */ - @IgniteLoggerResource - private IgniteLogger log; - - /** {@inheritDoc} */ - @Override public Collection<ComputeJobAdapter> split(int gridSize, Serializable arg) { - if (log.isInfoEnabled()) - log.info("Splitting job [job=" + this + ", gridSize=" + gridSize + ", arg=" + arg + ']'); - - Collection<ComputeJobAdapter> jobs = new ArrayList<>(SPLIT_COUNT); - - for (int i = 0; i < SPLIT_COUNT; i++) - jobs.add(new ComputeJobAdapter() { - @Override public Serializable execute() { - if (log.isInfoEnabled()) - log.info("Computing job [job=" + this + ']'); - - return null; - } - }); - - return jobs; - } - - /** {@inheritDoc} */ - @Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> received) throws - IgniteCheckedException { - if (res.getException() != null) - throw res.getException(); - - return ComputeJobResultPolicy.FAILOVER; - } - - /** {@inheritDoc} */ - @Override public Integer reduce(List<ComputeJobResult> results) { - if (log.isInfoEnabled()) - log.info("Reducing job [job=" + this + ", results=" + results + ']'); - - int res = 0; - - for (ComputeJobResult result : results) - res += (Integer)result.getData(); - - return res; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/537f631a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskFutureImplStopGridSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskFutureImplStopGridSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskFutureImplStopGridSelfTest.java deleted file mode 100644 index 9bd0eea..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskFutureImplStopGridSelfTest.java +++ /dev/null @@ -1,213 +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.gridgain.grid.kernal; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.resources.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.testframework.junits.common.*; - -import java.io.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; - -/** - * Test for task future when grid stops. - */ -@GridCommonTest(group = "Kernal Self") -@SuppressWarnings({"UnusedDeclaration"}) -public class GridTaskFutureImplStopGridSelfTest extends GridCommonAbstractTest { - /** */ - private static final int WAIT_TIME = 5000; - - /** */ - public static final int SPLIT_COUNT = 5; - - /** */ - private static CountDownLatch startSignal = new CountDownLatch(SPLIT_COUNT); - - /** */ - private static final Object mux = new Object(); - - /** */ - @SuppressWarnings({"StaticNonFinalField"}) - private static int cnt; - - /** */ - public GridTaskFutureImplStopGridSelfTest() { - super(false); - } - - /** - * @throws Exception If test failed. - */ - public void testGet() throws Exception { - Ignite ignite = startGrid(getTestGridName()); - - Thread futThread = null; - - try { - final ComputeTaskFuture<?> fut = executeAsync(ignite.compute(), GridStopTestTask.class.getName(), null); - - fut.listenAsync(new CI1<IgniteFuture>() { - @SuppressWarnings({"NakedNotify"}) - @Override public void apply(IgniteFuture gridFut) { - synchronized (mux) { - mux.notifyAll(); - } - } - }); - - final CountDownLatch latch = new CountDownLatch(1); - - final AtomicBoolean failed = new AtomicBoolean(false); - - futThread = new Thread(new Runnable() { - /** {@inheritDoc} */ - @Override public void run() { - try { - startSignal.await(); - - Object res = fut.get(); - - info("Task result: " + res); - } - catch (Throwable e) { - failed.set(true); - - // Make sure that message contains info about stopping grid. - assert e.getMessage().startsWith("Task failed due to stopping of the grid:"); - } - finally { - latch.countDown(); - } - } - - }, "test-task-future-thread"); - - futThread.start(); - - long delta = WAIT_TIME; - long end = System.currentTimeMillis() + delta; - - synchronized (mux) { - while (cnt < SPLIT_COUNT && delta > 0) { - mux.wait(delta); - - delta = end - System.currentTimeMillis(); - } - } - - // Stops grid. - stopGrid(getTestGridName()); - - boolean finished = latch.await(WAIT_TIME, TimeUnit.MILLISECONDS); - - info("Future thread [alive=" + futThread.isAlive() + ']'); - - info("Test task result [failed=" + failed.get() + ", taskFuture=" + fut + ']'); - - assert finished : "Future thread was not stopped."; - - assert fut.isDone(); - } - finally { - if (futThread != null && futThread.isAlive()) { - info("Task future thread interruption."); - - futThread.interrupt(); - } - - if (G.state(getTestGridName()) != IgniteState.STOPPED) - stopGrid(getTestGridName()); - } - } - - /** */ - @SuppressWarnings({"PublicInnerClass", "UnusedDeclaration"}) - public static class GridStopTestTask extends ComputeTaskSplitAdapter<Object, Object> { - /** */ - @IgniteLoggerResource - private IgniteLogger log; - - /** {@inheritDoc} */ - @Override public Collection<? extends ComputeJob> split(int gridSize, Object arg) throws IgniteCheckedException { - if (log.isInfoEnabled()) - log.info("Splitting job [job=" + this + ", gridSize=" + gridSize + ", arg=" + arg + ']'); - - Collection<ComputeJob> jobs = new ArrayList<>(SPLIT_COUNT); - - for (int i = 0; i < SPLIT_COUNT; i++) - jobs.add(new GridStopTestJob()); - - return jobs; - } - - /** {@inheritDoc} */ - @Override public Serializable reduce(List<ComputeJobResult> results) throws IgniteCheckedException { - if (log.isInfoEnabled()) - log.info("Aggregating job [job=" + this + ", results=" + results + ']'); - - int res = 0; - - for (ComputeJobResult result : results) { - res += (Integer)result.getData(); - } - - return res; - } - } - - /** */ - @SuppressWarnings({"PublicInnerClass"}) - public static class GridStopTestJob extends ComputeJobAdapter { - /** */ - @IgniteLoggerResource - private IgniteLogger log; - - /** {@inheritDoc} */ - @Override public Serializable execute() { - if (log.isInfoEnabled()) - log.info("Executing job [job=" + this + ']'); - - startSignal.countDown(); - - synchronized (mux) { - cnt++; - - mux.notifyAll(); - } - - try { - Thread.sleep(Integer.MAX_VALUE); - } - catch (InterruptedException ignore) { - if (log.isInfoEnabled()) - log.info("Job got interrupted: " + this); - } - - if (!Thread.currentThread().isInterrupted()) - log.error("Job not interrupted: " + this); - - return !Thread.currentThread().isInterrupted() ? 0 : 1; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/537f631a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskInstanceExecutionSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskInstanceExecutionSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskInstanceExecutionSelfTest.java deleted file mode 100644 index 5b64888..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskInstanceExecutionSelfTest.java +++ /dev/null @@ -1,121 +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.gridgain.grid.kernal; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.resources.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.testframework.junits.common.*; - -import java.util.*; - -/** - * Task instance execution test. - */ -@SuppressWarnings("PublicInnerClass") -@GridCommonTest(group = "Kernal Self") -public class GridTaskInstanceExecutionSelfTest extends GridCommonAbstractTest { - /** */ - private static Object testState; - - /** */ - public GridTaskInstanceExecutionSelfTest() { - super(true); - } - - /** - * @throws Exception If failed. - */ - public void testSynchronousExecute() throws Exception { - Ignite ignite = G.ignite(getTestGridName()); - - testState = 12345; - - GridStatefulTask task = new GridStatefulTask(testState); - - assert task.getState() != null; - assert task.getState() == testState; - - IgniteCompute comp = ignite.compute().enableAsync(); - - assertNull(comp.execute(task, "testArg")); - - ComputeTaskFuture<?> fut = comp.future(); - - assert fut != null; - - info("Task result: " + fut.get()); - } - - /** - * Stateful task. - */ - public static class GridStatefulTask extends GridTestTask { - /** */ - private Object state; - - /** */ - @IgniteLoggerResource - private IgniteLogger log; - - /** - * @param state State. - */ - public GridStatefulTask(Object state) { - this.state = state; - } - - /** - * @return The state. - */ - public Object getState() { - return state; - } - - /** {@inheritDoc} */ - @Override public Collection<? extends ComputeJob> split(int gridSize, Object arg) { - log.info("Task split state: " + state); - - assert state != null; - assert state == testState; - - return super.split(gridSize, arg); - } - - /** {@inheritDoc} */ - @Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> received) throws IgniteCheckedException { - log.info("Task result state: " + state); - - assert state != null; - assert state == testState; - - return super.result(res, received); - } - - /** {@inheritDoc} */ - @Override public Object reduce(List<ComputeJobResult> results) throws IgniteCheckedException { - log.info("Task reduce state: " + state); - - assert state != null; - assert state == testState; - - return super.reduce(results); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/537f631a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskInstantiationSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskInstantiationSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskInstantiationSelfTest.java deleted file mode 100644 index ac3aed5..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskInstantiationSelfTest.java +++ /dev/null @@ -1,117 +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.gridgain.grid.kernal; - -import org.apache.ignite.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.resources.*; -import org.apache.ignite.testframework.junits.common.*; -import org.jetbrains.annotations.*; - -import java.io.*; -import java.util.*; - -/** - * Tests instantiation of various task types (defined as private inner class, without default constructor, non-public - * default constructor). - */ -@GridCommonTest(group = "Kernal Self") -public class GridTaskInstantiationSelfTest extends GridCommonAbstractTest { - /** - * Constructor. - */ - public GridTaskInstantiationSelfTest() { - super(true); - } - - /** - * @throws Exception If an error occurs. - */ - public void testTasksInstantiation() throws Exception { - grid().compute().execute(PrivateClassTask.class, null); - - grid().compute().execute(NonPublicDefaultConstructorTask.class, null); - - try { - grid().compute().execute(NoDefaultConstructorTask.class, null); - - assert false : "Exception should have been thrown."; - } - catch (Exception e) { - info("Caught expected exception: " + e); - } - } - - /** - * Test task defined as private inner class. - */ - private static class PrivateClassTask extends ComputeTaskAdapter<String, Object> { - /** Ignite instance. */ - @IgniteInstanceResource - private Ignite ignite; - - /** {@inheritDoc} */ - @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, - @Nullable String arg) throws IgniteCheckedException { - for (ClusterNode node : subgrid) - if (node.id().equals(ignite.configuration().getNodeId())) - return Collections.singletonMap(new ComputeJobAdapter() { - @Override public Serializable execute() { - return null; - } - }, node); - - throw new IgniteCheckedException("Local node not found."); - } - - /** {@inheritDoc} */ - @Override public Object reduce(List<ComputeJobResult> results) { - return null; - } - } - - /** - * Test task defined with non-public default constructor. - */ - @SuppressWarnings({"PublicInnerClass"}) - public static final class NonPublicDefaultConstructorTask extends PrivateClassTask { - /** - * No-op constructor. - */ - private NonPublicDefaultConstructorTask() { - // No-op. - } - } - - /** - * Test task defined without default constructor. - */ - @SuppressWarnings({"PublicInnerClass"}) - public static final class NoDefaultConstructorTask extends PrivateClassTask { - /** - * No-op constructor. - * - * @param param Some parameter. - */ - @SuppressWarnings({"unused"}) - private NoDefaultConstructorTask(Object param) { - // No-op. - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/537f631a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskJobRejectSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskJobRejectSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskJobRejectSelfTest.java deleted file mode 100644 index 031578a..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskJobRejectSelfTest.java +++ /dev/null @@ -1,160 +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.gridgain.grid.kernal; - -import org.apache.ignite.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.events.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.spi.collision.fifoqueue.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.testframework.junits.common.*; -import org.jetbrains.annotations.*; - -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; - -import static java.util.concurrent.TimeUnit.*; -import static org.apache.ignite.events.IgniteEventType.*; - -/** - * Test that rejected job is not failed over. - */ -public class GridTaskJobRejectSelfTest extends GridCommonAbstractTest { - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - startGrid(1); - startGrid(2); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - stopGrid(1); - stopGrid(2); - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - FifoQueueCollisionSpi collision = new FifoQueueCollisionSpi(); - - collision.setParallelJobsNumber(1); - - cfg.setCollisionSpi(collision); - - return cfg; - } - - /** - * @throws Exception If failed. - */ - public void testReject() throws Exception { - grid(1).events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - X.println("Task event: " + evt); - - return true; - } - }, EVTS_TASK_EXECUTION); - - grid(1).events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - X.println("Job event: " + evt); - - return true; - } - }, EVTS_JOB_EXECUTION); - - final CountDownLatch startedLatch = new CountDownLatch(1); - - grid(1).events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - startedLatch.countDown(); - - return true; - } - }, EVT_JOB_STARTED); - - final AtomicInteger failedOver = new AtomicInteger(0); - - grid(1).events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - failedOver.incrementAndGet(); - - return true; - } - }, EVT_JOB_FAILED_OVER); - - final CountDownLatch finishedLatch = new CountDownLatch(1); - - grid(1).events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - finishedLatch.countDown(); - - return true; - } - }, EVT_TASK_FINISHED, EVT_TASK_FAILED); - - final ClusterNode node = grid(1).localNode(); - - IgniteCompute comp = grid(1).compute().enableAsync(); - - comp.execute(new ComputeTaskAdapter<Void, Void>() { - @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, - @Nullable Void arg) { - return F.asMap(new SleepJob(), node, new SleepJob(), node); - } - - /** {@inheritDoc} */ - @Nullable @Override public Void reduce(List<ComputeJobResult> results) throws IgniteCheckedException { - return null; - } - }, null); - - ComputeTaskFuture<?> fut = comp.future(); - - assert startedLatch.await(2, SECONDS); - - fut.cancel(); - - assert finishedLatch.await(2, SECONDS); - - assert failedOver.get() == 0; - } - - /** - * Sleeping job. - */ - private static final class SleepJob extends ComputeJobAdapter { - /** {@inheritDoc} */ - @Override public Object execute() { - try { - Thread.sleep(10000); - } - catch (InterruptedException ignored) { - Thread.currentThread().interrupt(); - } - - return null; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/537f631a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskListenerSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskListenerSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskListenerSelfTest.java deleted file mode 100644 index 58dda3f..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskListenerSelfTest.java +++ /dev/null @@ -1,106 +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.gridgain.grid.kernal; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.testframework.junits.common.*; - -import java.io.*; -import java.util.*; -import java.util.concurrent.atomic.*; - -/** - * This test checks that GridTaskListener is only called once per task. - */ -@SuppressWarnings("deprecation") -@GridCommonTest(group = "Kernal Self") -public class GridTaskListenerSelfTest extends GridCommonAbstractTest { - /** */ - public GridTaskListenerSelfTest() { - super(/*start grid*/true); - } - - /** - * Checks that GridTaskListener is only called once per task. - * - * @throws Exception If failed. - */ - @SuppressWarnings({"BusyWait", "unchecked"}) - public void testGridTaskListener() throws Exception { - final AtomicInteger cnt = new AtomicInteger(0); - - IgniteInClosure<IgniteFuture<?>> lsnr = new CI1<IgniteFuture<?>>() { - @Override public void apply(IgniteFuture<?> fut) { - assert fut != null; - - cnt.incrementAndGet(); - } - }; - - Ignite ignite = G.ignite(getTestGridName()); - - assert ignite != null; - - ignite.compute().localDeployTask(TestTask.class, TestTask.class.getClassLoader()); - - ComputeTaskFuture<?> fut = executeAsync(ignite.compute(), TestTask.class.getName(), null); - - fut.listenAsync(lsnr); - - fut.get(); - - while (cnt.get() == 0) { - try { - Thread.sleep(1000); - } - catch (InterruptedException e) { - error("Got interrupted while sleep.", e); - - break; - } - } - - assert cnt.get() == 1 : "Unexpected GridTaskListener apply count [count=" + cnt.get() + ", expected=1]"; - } - - /** Test task. */ - private static class TestTask extends ComputeTaskSplitAdapter<Serializable, Object> { - /** {@inheritDoc} */ - @Override protected Collection<? extends ComputeJob> split(int gridSize, Serializable arg) throws IgniteCheckedException { - Collection<ComputeJobAdapter> jobs = new ArrayList<>(); - - for (int i = 0; i < 5; i++) { - jobs.add(new ComputeJobAdapter() { - @Override public Serializable execute() { - return 1; - } - }); - } - - return jobs; - } - - /** {@inheritDoc} */ - @Override public Object reduce(List<ComputeJobResult> results) { - return null; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/537f631a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskMapAsyncSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskMapAsyncSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskMapAsyncSelfTest.java deleted file mode 100644 index f53d169..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskMapAsyncSelfTest.java +++ /dev/null @@ -1,141 +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.gridgain.grid.kernal; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.resources.*; -import org.apache.ignite.spi.discovery.tcp.*; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.testframework.junits.common.*; -import org.jetbrains.annotations.*; - -import java.io.*; -import java.util.*; - -/** - * - */ -@GridCommonTest(group = "Kernal Self") -public class GridTaskMapAsyncSelfTest extends GridCommonAbstractTest { - /** - * - */ - public GridTaskMapAsyncSelfTest() { - super(true); - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration c = super.getConfiguration(gridName); - - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true)); - - c.setDiscoverySpi(discoSpi); - - return c; - } - - /** - * @throws Exception If failed. - */ - public void testTaskMap() throws Exception { - Ignite ignite = G.ignite(getTestGridName()); - - info("Executing sync mapped task."); - - ignite.compute().execute(SyncMappedTask.class, null); - - info("Executing async mapped task."); - - ignite.compute().execute(AsyncMappedTask.class, null); - } - - /** - * - */ - @ComputeTaskMapAsync - private static class AsyncMappedTask extends BaseTask { - /** {@inheritDoc} */ - @Override protected Collection<? extends ComputeJob> split(int gridSize, Object arg) throws IgniteCheckedException { - Collection<? extends ComputeJob> res = super.split(gridSize, arg); - - assert mainThread != mapper; - - return res; - } - } - - /** - * - */ - private static class SyncMappedTask extends BaseTask { - /** {@inheritDoc} */ - @Override protected Collection<? extends ComputeJob> split(int gridSize, Object arg) throws IgniteCheckedException { - Collection<? extends ComputeJob> res = super.split(gridSize, arg); - - assert mainThread == mapper; - - return res; - } - } - - /** - * Test task. - */ - private abstract static class BaseTask extends ComputeTaskSplitAdapter<Object, Void> { - /** */ - protected static final Thread mainThread = Thread.currentThread(); - - /** */ - protected Thread mapper; - - /** */ - protected Thread runner; - - /** */ - @IgniteLoggerResource - protected IgniteLogger log; - - /** {@inheritDoc} */ - @Override protected Collection<? extends ComputeJob> split(int gridSize, Object arg) throws IgniteCheckedException { - mapper = Thread.currentThread(); - - return Collections.singleton(new ComputeJobAdapter() { - @Override public Serializable execute() { - runner = Thread.currentThread(); - - log.info("Runner: " + runner); - log.info("Main: " + mainThread); - log.info("Mapper: " + mapper); - - return null; - } - }); - } - - /** {@inheritDoc} */ - @Nullable @Override public Void reduce(List<ComputeJobResult> results) throws IgniteCheckedException { - return null; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/537f631a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskNameAnnotationSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskNameAnnotationSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskNameAnnotationSelfTest.java deleted file mode 100644 index 01902d8..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskNameAnnotationSelfTest.java +++ /dev/null @@ -1,124 +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.gridgain.grid.kernal; - -import org.apache.ignite.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.resources.*; -import org.apache.ignite.internal.util.lang.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.testframework.junits.common.*; -import org.jetbrains.annotations.*; - -import java.util.*; - -import static org.apache.ignite.compute.ComputeJobResultPolicy.*; - -/** - * Tests for {@link org.apache.ignite.compute.ComputeTaskName} annotation. - */ -public class GridTaskNameAnnotationSelfTest extends GridCommonAbstractTest { - /** Task name. */ - private static final String TASK_NAME = "test-task"; - - /** Peer deploy aware task name. */ - private static final String PEER_DEPLOY_AWARE_TASK_NAME = "peer-deploy-aware-test-task"; - - /** - * Starts grid. - */ - public GridTaskNameAnnotationSelfTest() { - super(true); - } - - /** - * @throws Exception If failed. - */ - public void testClass() throws Exception { - assert grid().compute().execute(TestTask.class, null).equals(TASK_NAME); - } - - /** - * @throws Exception If failed. - */ - public void testClassPeerDeployAware() throws Exception { - assert grid().compute().execute(PeerDeployAwareTestTask.class, null).equals(PEER_DEPLOY_AWARE_TASK_NAME); - } - - /** - * @throws Exception If failed. - */ - public void testInstance() throws Exception { - assert grid().compute().execute(new TestTask(), null).equals(TASK_NAME); - } - - /** - * @throws Exception If failed. - */ - public void testInstancePeerDeployAware() throws Exception { - assert grid().compute().execute(new PeerDeployAwareTestTask(), null). - equals(PEER_DEPLOY_AWARE_TASK_NAME); - } - - /** - * Test task. - */ - @ComputeTaskName(TASK_NAME) - private static class TestTask implements ComputeTask<Void, String> { - /** {@inheritDoc} */ - @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, - @Nullable Void arg) throws IgniteCheckedException { - return F.asMap(new ComputeJobAdapter() { - @IgniteTaskSessionResource - private ComputeTaskSession ses; - - @Override public Object execute() { - return ses.getTaskName(); - } - }, F.rand(subgrid)); - } - - /** {@inheritDoc} */ - @Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd) - throws IgniteCheckedException { - return WAIT; - } - - /** {@inheritDoc} */ - @Override public String reduce(List<ComputeJobResult> results) throws IgniteCheckedException { - return F.first(results).getData(); - } - } - - /** - * Test task that implements {@link org.apache.ignite.internal.util.lang.GridPeerDeployAware}. - */ - @ComputeTaskName(PEER_DEPLOY_AWARE_TASK_NAME) - private static class PeerDeployAwareTestTask extends TestTask implements GridPeerDeployAware { - /** {@inheritDoc} */ - @Override public Class<?> deployClass() { - return getClass(); - } - - /** {@inheritDoc} */ - @Override public ClassLoader classLoader() { - return getClass().getClassLoader(); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/537f631a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskResultCacheSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskResultCacheSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskResultCacheSelfTest.java deleted file mode 100644 index d051ad9..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskResultCacheSelfTest.java +++ /dev/null @@ -1,129 +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.gridgain.grid.kernal; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.testframework.junits.common.*; - -import java.io.*; -import java.util.*; - -/** - * - */ -@GridCommonTest(group = "Kernal Self") -public class GridTaskResultCacheSelfTest extends GridCommonAbstractTest { - /** - * - */ - public GridTaskResultCacheSelfTest() { - super(true); - } - - /** - * @throws Exception If failed. - */ - public void testNoCacheResults() throws Exception { - Ignite ignite = G.ignite(getTestGridName()); - - ignite.compute().execute(GridResultNoCacheTestTask.class, "Grid Result No Cache Test Argument"); - } - - /** - * @throws Exception If failed. - */ - public void testCacheResults() throws Exception { - Ignite ignite = G.ignite(getTestGridName()); - - ignite.compute().execute(GridResultCacheTestTask.class, "Grid Result Cache Test Argument"); - } - - /** - * - */ - @ComputeTaskNoResultCache - private static class GridResultNoCacheTestTask extends GridAbstractCacheTestTask { - /** {@inheritDoc} */ - @Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd) throws IgniteCheckedException { - assert res.getData() != null; - assert rcvd.isEmpty(); - - return super.result(res, rcvd); - } - - /** {@inheritDoc} */ - @Override public Object reduce(List<ComputeJobResult> results) throws IgniteCheckedException { - assert results.isEmpty(); - - return null; - } - } - - /** - * - */ - private static class GridResultCacheTestTask extends GridAbstractCacheTestTask { - /** {@inheritDoc} */ - @Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd) - throws IgniteCheckedException { - assert res.getData() != null; - assert rcvd.contains(res); - - for (ComputeJobResult jobRes : rcvd) - assert jobRes.getData() != null; - - return super.result(res, rcvd); - } - - /** {@inheritDoc} */ - @Override public Object reduce(List<ComputeJobResult> results) throws IgniteCheckedException { - for (ComputeJobResult res : results) { - if (res.getException() != null) - throw res.getException(); - - assert res.getData() != null; - } - - return null; - } - } - - /** - * Test task. - */ - private abstract static class GridAbstractCacheTestTask extends ComputeTaskSplitAdapter<String, Object> { - /** {@inheritDoc} */ - @Override protected Collection<? extends ComputeJob> split(int gridSize, String arg) throws IgniteCheckedException { - String[] words = arg.split(" "); - - Collection<ComputeJobAdapter> jobs = new ArrayList<>(words.length); - - for (String word : words) { - jobs.add(new ComputeJobAdapter(word) { - @Override public Serializable execute() { - return argument(0); - } - }); - } - - return jobs; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/537f631a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskTimeoutSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskTimeoutSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskTimeoutSelfTest.java deleted file mode 100644 index 9c800e2..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTaskTimeoutSelfTest.java +++ /dev/null @@ -1,223 +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.gridgain.grid.kernal; - -import org.apache.ignite.*; -import org.apache.ignite.compute.*; -import org.apache.ignite.events.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.resources.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.testframework.junits.common.*; - -import java.io.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; - -import static org.apache.ignite.events.IgniteEventType.*; - -/** - * - */ -@GridCommonTest(group = "Kernal Self") -public class GridTaskTimeoutSelfTest extends GridCommonAbstractTest { - /** Number of jobs each task spawns. */ - private static final int SPLIT_COUNT = 1; - - /** Timeout for task execution in milliseconds. */ - private static final long TIMEOUT = 1000; - - /** Number of worker threads. */ - private static final int N_THREADS = 16; - - /** Test execution period in milliseconds. */ - private static final int PERIOD = 10000; - - /** */ - public GridTaskTimeoutSelfTest() { - super(true); - } - - /** - * @param execId Execution ID. - */ - private void checkTimedOutEvents(final IgniteUuid execId) { - Ignite ignite = G.ignite(getTestGridName()); - - Collection<IgniteEvent> evts = ignite.events().localQuery(new PE() { - @Override public boolean apply(IgniteEvent evt) { - return ((IgniteTaskEvent) evt).taskSessionId().equals(execId); - } - }, EVT_TASK_TIMEDOUT); - - assert evts.size() == 1 : "Invalid number of timed out tasks: " + evts.size(); - } - - /** - * @throws Exception If failed. - */ - public void testSynchronousTimeout() throws Exception { - Ignite ignite = G.ignite(getTestGridName()); - - ignite.compute().localDeployTask(GridTaskTimeoutTestTask.class, GridTaskTimeoutTestTask.class.getClassLoader()); - - ComputeTaskFuture<?> fut = executeAsync(ignite.compute().withTimeout(TIMEOUT), - GridTaskTimeoutTestTask.class.getName(), null); - - try { - fut.get(); - - assert false : "GridComputeTaskTimeoutException was not thrown (synchronous apply)"; - } - catch (ComputeTaskTimeoutException e) { - info("Received expected timeout exception (synchronous apply): " + e); - } - - Thread.sleep(TIMEOUT + 500); - - checkTimedOutEvents(fut.getTaskSession().getId()); - } - - /** - * @throws Exception If failed. - */ - public void testAsynchronousTimeout() throws Exception { - Ignite ignite = G.ignite(getTestGridName()); - - ignite.compute().localDeployTask(GridTaskTimeoutTestTask.class, GridTaskTimeoutTestTask.class.getClassLoader()); - - ComputeTaskFuture<?> fut = executeAsync(ignite.compute().withTimeout(TIMEOUT), - GridTaskTimeoutTestTask.class.getName(), null); - - // Allow timed out events to be executed. - Thread.sleep(TIMEOUT + 500); - - checkTimedOutEvents(fut.getTaskSession().getId()); - } - - /** - * @throws Exception If failed. - */ - public void testSynchronousTimeoutMultithreaded() throws Exception { - final Ignite ignite = G.ignite(getTestGridName()); - - final AtomicBoolean finish = new AtomicBoolean(); - - final AtomicInteger cnt = new AtomicInteger(); - - final CountDownLatch finishLatch = new CountDownLatch(N_THREADS); - - new Thread(new Runnable() { - @Override public void run() { - try { - Thread.sleep(PERIOD); - - info("Stopping test."); - - finish.set(true); - } - catch (InterruptedException ignored) { - Thread.currentThread().interrupt(); - } - } - }).start(); - - multithreaded(new Runnable() { - @SuppressWarnings("InfiniteLoopStatement") - @Override public void run() { - while (!finish.get()) { - try { - ComputeTaskFuture<?> fut = executeAsync( - ignite.compute().withTimeout(TIMEOUT), GridTaskTimeoutTestTask.class.getName(), null); - - fut.get(); - - assert false : "Task has not been timed out. Future: " + fut; - } - catch (ComputeTaskTimeoutException ignored) { - // Expected. - } - catch (IgniteCheckedException e) { - throw new IllegalStateException(e); //shouldn't happen - } - finally { - int cnt0 = cnt.incrementAndGet(); - - if (cnt0 % 100 == 0) - info("Tasks finished: " + cnt0); - } - } - - info("Thread " + Thread.currentThread().getId() + " finishing."); - - finishLatch.countDown(); - } - }, N_THREADS); - - finishLatch.await(); - - //Grid will be stopped automatically on tearDown(). - } - - /** - * - */ - private static class GridTaskTimeoutTestTask extends ComputeTaskSplitAdapter<Serializable, Object> { - /** {@inheritDoc} */ - @Override protected Collection<? extends ComputeJob> split(int gridSize, Serializable arg) throws IgniteCheckedException { - Collection<GridTaskTimeoutTestJob> jobs = new ArrayList<>(SPLIT_COUNT); - - for (int i = 0; i < SPLIT_COUNT; i++) { - GridTaskTimeoutTestJob job = new GridTaskTimeoutTestJob(); - - job.setArguments(arg); - - jobs.add(job); - } - - return jobs; - } - - /** {@inheritDoc} */ - @Override public Object reduce(List<ComputeJobResult> results) throws IgniteCheckedException { - return null; - } - } - - /** - * - */ - private static class GridTaskTimeoutTestJob extends ComputeJobAdapter { - /** Injected logger. */ - @IgniteLoggerResource - private IgniteLogger log; - - /** {@inheritDoc} */ - @Override public Serializable execute() { - try { - Thread.sleep(Long.MAX_VALUE); - } - catch (InterruptedException ignored) { - // No-op. - } - - return null; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/537f631a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTopicExternalizableSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTopicExternalizableSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridTopicExternalizableSelfTest.java deleted file mode 100644 index b0b4007..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTopicExternalizableSelfTest.java +++ /dev/null @@ -1,166 +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.gridgain.grid.kernal; - -import org.apache.ignite.*; -import org.apache.ignite.internal.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.marshaller.*; - -import java.io.*; -import java.util.*; - -/** - * Grid topic externalization test. - */ -public class GridTopicExternalizableSelfTest extends GridExternalizableAbstractTest { - /** */ - private static final IgniteUuid A_GRID_UUID = IgniteUuid.randomUuid(); - - /** */ - private static final UUID AN_UUID = UUID.randomUUID(); - - /** */ - private static final long A_LONG = Long.MAX_VALUE; - - /** */ - private static final String A_STRING = "test_test_test_test_test_test_test_test_test_test_test_test_test_test"; - - /** */ - private static final int AN_INT = Integer.MAX_VALUE; - - /** - * @throws Exception If failed. - */ - public void testSerializationTopicCreatedByGridUuid() throws Exception { - for (IgniteMarshaller marsh : getMarshallers()) { - info("Test GridTopic externalization [marshaller=" + marsh + ']'); - - for (GridTopic topic : GridTopic.values()) { - Externalizable msgOut = (Externalizable)topic.topic(A_GRID_UUID); - - assertEquals(msgOut, GridTestIoUtils.externalize(msgOut, marsh)); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testSerializationTopicCreatedByGridUuidAndUUID() throws Exception { - for (IgniteMarshaller marsh : getMarshallers()) { - info("Test GridTopic externalization [marshaller=" + marsh + ']'); - - for (GridTopic topic : GridTopic.values()) { - Externalizable msgOut = (Externalizable)topic.topic(A_GRID_UUID, AN_UUID); - - assertEquals(msgOut, GridTestIoUtils.externalize(msgOut, marsh)); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testSerializationTopicCreatedByGridUuidAndLong() throws Exception { - for (IgniteMarshaller marsh : getMarshallers()) { - info("Test GridTopic externalization [marshaller=" + marsh + ']'); - - for (GridTopic topic : GridTopic.values()) { - Externalizable msgOut = (Externalizable)topic.topic(A_GRID_UUID, A_LONG); - - assertEquals(msgOut, GridTestIoUtils.externalize(msgOut, marsh)); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testSerializationTopicCreatedByStringAndUUIDAndLong() throws Exception { - for (IgniteMarshaller marsh : getMarshallers()) { - info("Test GridTopic externalization [marshaller=" + marsh + ']'); - - for (GridTopic topic : GridTopic.values()) { - Externalizable msgOut = (Externalizable)topic.topic(A_STRING, AN_UUID, A_LONG); - - assertEquals(msgOut, GridTestIoUtils.externalize(msgOut, marsh)); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testSerializationTopicCreatedByString() throws Exception { - for (IgniteMarshaller marsh : getMarshallers()) { - info("Test GridTopic externalization [marshaller=" + marsh + ']'); - - for (GridTopic topic : GridTopic.values()) { - Externalizable msgOut = (Externalizable)topic.topic(A_STRING); - - assertEquals(msgOut, GridTestIoUtils.externalize(msgOut, marsh)); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testSerializationTopicCreatedByStringAndIntAndLong() throws Exception { - for (IgniteMarshaller marsh : getMarshallers()) { - info("Test GridTopic externalization [marshaller=" + marsh + ']'); - - for (GridTopic topic : GridTopic.values()) { - Externalizable msgOut = (Externalizable)topic.topic(A_STRING, AN_INT, A_LONG); - - assertEquals(msgOut, GridTestIoUtils.externalize(msgOut, marsh)); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testSerializationTopicCreatedByStrinAndLong() throws Exception { - for (IgniteMarshaller marsh : getMarshallers()) { - info("Test GridTopic externalization [marshaller=" + marsh + ']'); - - for (GridTopic topic : GridTopic.values()) { - Externalizable msgOut = (Externalizable)topic.topic(A_STRING, A_LONG); - - assertEquals(msgOut, GridTestIoUtils.externalize(msgOut, marsh)); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testSerializationTopicCreatedByStringAndUUIDAndIntAndLong() throws Exception { - for (IgniteMarshaller marsh : getMarshallers()) { - info("Test GridTopic externalization [marshaller=" + marsh + ']'); - - for (GridTopic topic : GridTopic.values()) { - Externalizable msgOut = (Externalizable)topic.topic(A_STRING, AN_UUID, AN_INT, A_LONG); - - assertEquals(msgOut, GridTestIoUtils.externalize(msgOut, marsh)); - } - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/537f631a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTopologyBuildVersionSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTopologyBuildVersionSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridTopologyBuildVersionSelfTest.java deleted file mode 100644 index ac95aab..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridTopologyBuildVersionSelfTest.java +++ /dev/null @@ -1,102 +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.gridgain.grid.kernal; - -import org.apache.ignite.cluster.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.internal.*; -import org.apache.ignite.product.*; -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.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.testframework.junits.common.*; - -import java.util.*; -import java.util.concurrent.atomic.*; - -/** - * Tests build version setting into discovery maps. - */ -public class GridTopologyBuildVersionSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** Counter. */ - private static final AtomicInteger cnt = new AtomicInteger(); - - /** Test compatible versions. */ - private static final Collection<String> COMPATIBLE_VERS = - F.asList("1.0.0-ent", "2.0.0-ent", "3.0.0-ent", "4.0.0-ent"); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - final int idx = cnt.incrementAndGet(); - - // Override node attributes in discovery spi. - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi() { - @Override public void setNodeAttributes(Map<String, Object> attrs, IgniteProductVersion ver) { - super.setNodeAttributes(attrs, ver); - - attrs.put(GridNodeAttributes.ATTR_BUILD_VER, idx + ".0.0" + "-ent"); - - if (idx < 3) - attrs.remove(GridNodeAttributes.ATTR_BUILD_DATE); - else - attrs.put(GridNodeAttributes.ATTR_BUILD_DATE, "1385099743"); - - attrs.put(GridNodeAttributes.ATTR_COMPATIBLE_VERS, COMPATIBLE_VERS); - } - }; - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - - return cfg; - } - - /** - * @throws Exception If failed. - */ - public void testVersioning() throws Exception { - startGrids(4); - - try { - for (int i = 3; i >= 0; i--) { - GridKernal g = (GridKernal)grid(i); - - NavigableMap<IgniteProductVersion, Collection<ClusterNode>> verMap = g.context().discovery() - .topologyVersionMap(); - - assertEquals(4, verMap.size()); - - // Now check the map itself. - assertEquals(4, verMap.get(IgniteProductVersion.fromString("1.0.0")).size()); - assertEquals(3, verMap.get(IgniteProductVersion.fromString("2.0.0")).size()); - assertEquals(2, verMap.get(IgniteProductVersion.fromString("3.0.0-ent-1385099743")).size()); - assertEquals(1, verMap.get(IgniteProductVersion.fromString("4.0.0-ent-1385099743")).size()); - } - } - finally { - stopAllGrids(); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/537f631a/modules/core/src/test/java/org/gridgain/grid/kernal/GridVersionSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/GridVersionSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/GridVersionSelfTest.java deleted file mode 100644 index 117e0ff..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/GridVersionSelfTest.java +++ /dev/null @@ -1,69 +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.gridgain.grid.kernal; - -import org.apache.ignite.*; -import org.apache.ignite.product.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.testframework.junits.common.*; - -import static org.apache.ignite.IgniteSystemProperties.*; - -/** - * Tests version methods. - */ -public class GridVersionSelfTest extends GridCommonAbstractTest { - /** - * @throws Exception If failed. - */ - public void testVersions() throws Exception { - String propVal = System.getProperty(GG_UPDATE_NOTIFIER); - - System.setProperty(GG_UPDATE_NOTIFIER, "true"); - - try { - Ignite ignite = startGrid(); - - IgniteProductVersion currVer = ignite.product().version(); - - String newVer = null; - - for (int i = 0; i < 30; i++) { - newVer = ignite.product().latestVersion(); - - if (newVer != null) - break; - - U.sleep(100); - } - - info("Versions [cur=" + currVer + ", latest=" + newVer + ']'); - - assertNotNull(newVer); - assertNotSame(currVer.toString(), newVer); - } - finally { - stopGrid(); - - if (propVal != null) - System.setProperty(GG_UPDATE_NOTIFIER, propVal); - else - System.clearProperty(GG_UPDATE_NOTIFIER); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/537f631a/modules/core/src/test/java/org/gridgain/grid/kernal/package.html ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/package.html b/modules/core/src/test/java/org/gridgain/grid/kernal/package.html deleted file mode 100644 index 135eb1a..0000000 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/package.html +++ /dev/null @@ -1,24 +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. - --> - -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -<html> -<body> - <!-- Package description. --> - Contains internal tests or test related classes and interfaces. -</body> -</html>