You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2017/03/13 10:28:11 UTC

[37/50] [abbrv] ignite git commit: ignite-4803 Added test.

ignite-4803 Added test.


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

Branch: refs/heads/ignite-4565-ddl
Commit: 37a5f92a40ed878ab61a0f92733cbe031784848a
Parents: 32506d6
Author: Igor Seliverstov <gv...@gmail.com>
Authored: Fri Mar 10 10:45:25 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Mar 10 10:45:25 2017 +0300

----------------------------------------------------------------------
 ...sExchangeOnDiscoveryHistoryOverflowTest.java | 190 +++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite5.java       |   3 +
 2 files changed, 193 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/37a5f92a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionsExchangeOnDiscoveryHistoryOverflowTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionsExchangeOnDiscoveryHistoryOverflowTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionsExchangeOnDiscoveryHistoryOverflowTest.java
new file mode 100644
index 0000000..962e6b5
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionsExchangeOnDiscoveryHistoryOverflowTest.java
@@ -0,0 +1,190 @@
+/*
+ * 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.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.events.Event;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.P1;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.jetbrains.annotations.NotNull;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_DISCOVERY_HISTORY_SIZE;
+import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.PRIMARY;
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
+import static org.apache.ignite.events.EventType.EVT_NODE_JOINED;
+import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
+import static org.apache.ignite.internal.events.DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT;
+
+/**
+ * Test discovery history overflow.
+ */
+public class PartitionsExchangeOnDiscoveryHistoryOverflowTest extends IgniteCacheAbstractTest {
+    /** */
+    private static final int CACHES_COUNT = 50;
+
+    /** */
+    private static final int DISCOVERY_HISTORY_SIZE = 10;
+
+    /** */
+    private static String histSize;
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        histSize = System.getProperty(IGNITE_DISCOVERY_HISTORY_SIZE);
+
+        System.setProperty(IGNITE_DISCOVERY_HISTORY_SIZE, String.valueOf(DISCOVERY_HISTORY_SIZE));
+
+        super.beforeTestsStarted();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        if (histSize != null)
+            System.setProperty(IGNITE_DISCOVERY_HISTORY_SIZE, histSize);
+        else
+            System.getProperties().remove(IGNITE_DISCOVERY_HISTORY_SIZE);
+
+        super.afterTestsStopped();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return 4;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheMode cacheMode() {
+        return PARTITIONED;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheAtomicityMode atomicityMode() {
+        return ATOMIC;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheAtomicWriteOrderMode atomicWriteOrderMode() {
+        return PRIMARY;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected NearCacheConfiguration nearConfiguration() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        Map<IgnitePredicate<? extends Event>, int[]> map = new HashMap<>();
+
+        // To make partitions exchanges longer.
+        map.put(new P1<Event>() {
+            @Override public boolean apply(Event evt) {
+                try {
+                    Thread.sleep(10);
+                }
+                catch (InterruptedException e) {
+                    // No op.
+                }
+
+                return false;
+            }
+        }, new int[]{EVT_NODE_JOINED, EVT_NODE_FAILED, EVT_NODE_LEFT, EVT_DISCOVERY_CUSTOM_EVT});
+
+        cfg.setLocalEventListeners(map);
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testDynamicCacheCreation() throws Exception {
+        for (int iter = 0; iter < 5; iter++) {
+            log.info("Iteration: " + iter);
+
+            IgniteInternalFuture[] futs = new IgniteInternalFuture[CACHES_COUNT];
+
+            for (int i = 0; i < CACHES_COUNT; i ++) {
+                final int cacheIdx = i;
+
+                final int gridIdx = cacheIdx % gridCount();
+
+                futs[i] = GridTestUtils.runAsync(new Callable<IgniteCache>() {
+                    @Override public IgniteCache call() throws Exception {
+                        return grid(gridIdx).createCache(cacheConfiguration(gridIdx, cacheIdx));
+                    }
+                });
+            }
+
+            for (IgniteInternalFuture fut : futs) {
+                assertNotNull(fut);
+
+                fut.get();
+            }
+
+            for (int i = 0; i < CACHES_COUNT; i ++) {
+                final int cacheIdx = i;
+
+                final int gridIdx = cacheIdx % gridCount();
+
+                futs[i] = GridTestUtils.runAsync(new Callable<Void>() {
+                    @Override public Void call() throws Exception {
+                        grid(gridIdx).destroyCache(cacheConfiguration(gridIdx, cacheIdx).getName());
+
+                        return null;
+                    }
+                });
+            }
+
+            for (IgniteInternalFuture fut : futs) {
+                assertNotNull(fut);
+
+                fut.get();
+            }
+        }
+    }
+
+    /**
+     * @param gridIdx Grid index.
+     * @param cacheIdx Cache index.
+     * @return Newly created cache configuration.
+     * @throws Exception In case of error.
+     */
+    @NotNull private CacheConfiguration cacheConfiguration(int gridIdx, int cacheIdx) throws Exception {
+        CacheConfiguration cfg = cacheConfiguration(getTestGridName(gridIdx));
+
+        cfg.setName("dynamic-cache-" + cacheIdx);
+
+        return cfg;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/37a5f92a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
index 144aac6..03204e2 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
@@ -27,6 +27,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheSwapSpaceSpiConsiste
 import org.apache.ignite.internal.processors.cache.IgniteCachePutStackOverflowSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheReadThroughEvictionsVariationsSuite;
 import org.apache.ignite.internal.processors.cache.IgniteCacheStoreCollectionTest;
+import org.apache.ignite.internal.processors.cache.PartitionsExchangeOnDiscoveryHistoryOverflowTest;
 import org.apache.ignite.internal.processors.cache.distributed.CacheLateAffinityAssignmentFairAffinityTest;
 import org.apache.ignite.internal.processors.cache.distributed.CacheLateAffinityAssignmentNodeJoinValidationTest;
 import org.apache.ignite.internal.processors.cache.distributed.CacheLateAffinityAssignmentTest;
@@ -65,6 +66,8 @@ public class IgniteCacheTestSuite5 extends TestSuite {
 
         suite.addTestSuite(CacheRebalancingSelfTest.class);
 
+        suite.addTestSuite(PartitionsExchangeOnDiscoveryHistoryOverflowTest.class);
+
         return suite;
     }
 }