ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [39/50] [abbrv] ignite git commit: Added test.
Date Mon, 11 Apr 2016 14:26:06 GMT
Added test.


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

Branch: refs/heads/ignite-1786
Commit: 083acbda83a0167b95c096aea406a5adb7a8451b
Parents: cead1e0
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Apr 8 13:52:53 2016 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Apr 8 13:52:53 2016 +0300

----------------------------------------------------------------------
 .../MarshallerCacheJobRunNodeRestartTest.java   | 237 +++++++++++++++++++
 1 file changed, 237 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/083acbda/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java
new file mode 100644
index 0000000..482edee
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java
@@ -0,0 +1,237 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.io.File;
+import java.util.concurrent.Callable;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.lang.IgniteInClosure;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class MarshallerCacheJobRunNodeRestartTest extends GridCommonAbstractTest {
+    /** */
+    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private boolean client;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+        cfg.setClientMode(client);
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testJobRun() throws Exception {
+        for (int i = 0; i < 5; i++) {
+            U.resolveWorkDirectory("marshaller", true);
+
+            log.info("Iteration: " + i);
+
+            final int NODES = 3;
+
+            startGridsMultiThreaded(NODES);
+
+            client = true;
+
+            startGrid(NODES);
+
+            client = false;
+
+            final IgniteInternalFuture fut = GridTestUtils.runAsync(new Callable<Void>()
{
+                @Override public Void call() throws Exception {
+                    for (int i = 0; i < 3; i++) {
+                        startGrid(NODES + 1);
+
+                        U.sleep(1000);
+
+                        stopGrid(NODES + 1);
+                    }
+
+                    return null;
+                }
+            });
+
+            GridTestUtils.runMultiThreaded(new IgniteInClosure<Integer>() {
+                @Override public void apply(Integer integer) {
+                    Ignite ignite = ignite(integer % 4);
+
+                    while (!fut.isDone()) {
+                        for (int i = 0; i < 10; i++)
+                            ignite.compute().broadcast(job(i));
+                    }
+                }
+            }, (NODES + 1) * 5, "test");
+
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @param idx Job class index.
+     * @return Job.
+     */
+    static IgniteCallable job(int idx) {
+        switch (idx) {
+            case 0:
+                return new Job1();
+            case 1:
+                return new Job2();
+            case 2:
+                return new Job3();
+            case 3:
+                return new Job4();
+            case 4:
+                return new Job5();
+            case 5:
+                return new Job6();
+            case 6:
+                return new Job7();
+            case 7:
+                return new Job8();
+            case 8:
+                return new Job9();
+            case 9:
+                return new Job10();
+            default:
+                fail();
+        }
+
+        fail();
+
+        return null;
+    }
+
+    /**
+     *
+     */
+    static class Job1 implements IgniteCallable {
+        /** {@inheritDoc} */
+        @Override public Object call() throws Exception {
+            return new Job2();
+        }
+    }
+
+    /**
+     *
+     */
+    static class Job2 implements IgniteCallable {
+        /** {@inheritDoc} */
+        @Override public Object call() throws Exception {
+            return new Job3();
+        }
+    }
+
+    /**
+     *
+     */
+    static class Job3 implements IgniteCallable {
+        /** {@inheritDoc} */
+        @Override public Object call() throws Exception {
+            return new Job4();
+        }
+    }
+
+    /**
+     *
+     */
+    static class Job4 implements IgniteCallable {
+        /** {@inheritDoc} */
+        @Override public Object call() throws Exception {
+            return new Job5();
+        }
+    }
+
+    /**
+     *
+     */
+    static class Job5 implements IgniteCallable {
+        /** {@inheritDoc} */
+        @Override public Object call() throws Exception {
+            return new Job6();
+        }
+    }
+
+    /**
+     *
+     */
+    static class Job6 implements IgniteCallable {
+        /** {@inheritDoc} */
+        @Override public Object call() throws Exception {
+            return new Job7();
+        }
+    }
+
+    /**
+     *
+     */
+    static class Job7 implements IgniteCallable {
+        /** {@inheritDoc} */
+        @Override public Object call() throws Exception {
+            return new Job8();
+        }
+    }
+
+    /**
+     *
+     */
+    static class Job8 implements IgniteCallable {
+        /** {@inheritDoc} */
+        @Override public Object call() throws Exception {
+            return new Job9();
+        }
+    }
+
+    /**
+     *
+     */
+    static class Job9 implements IgniteCallable {
+        /** {@inheritDoc} */
+        @Override public Object call() throws Exception {
+            return new Job10();
+        }
+    }
+
+    /**
+     *
+     */
+    static class Job10 implements IgniteCallable {
+        /** {@inheritDoc} */
+        @Override public Object call() throws Exception {
+            return new Job1();
+        }
+    }
+}


Mime
View raw message