Repository: ignite Updated Branches: refs/heads/master 54891f8c9 -> 80d244d80
#Removing random eviction policy tests as it is deprecated. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/80d244d8 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/80d244d8 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/80d244d8 Branch: refs/heads/master Commit: 80d244d8013187a03fbcb2a1a627629de79d6d65 Parents: 54891f8 Author: Alexey Goncharuk <alexey.goncha...@gmail.com> Authored: Wed Jan 27 14:06:50 2016 +0300 Committer: Alexey Goncharuk <alexey.goncha...@gmail.com> Committed: Wed Jan 27 14:06:50 2016 +0300 ---------------------------------------------------------------------- .../RandomEvictionPolicyCacheSizeSelfTest.java | 79 ---- .../random/RandomEvictionPolicySelfTest.java | 363 ------------------- .../IgniteCacheEvictionSelfTestSuite.java | 4 - 3 files changed, 446 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/80d244d8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/random/RandomEvictionPolicyCacheSizeSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/random/RandomEvictionPolicyCacheSizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/random/RandomEvictionPolicyCacheSizeSelfTest.java deleted file mode 100644 index a560f59..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/random/RandomEvictionPolicyCacheSizeSelfTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache.eviction.random; - -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.eviction.random.RandomEvictionPolicy; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -/** - * Random eviction policy cache size test. - */ -public class RandomEvictionPolicyCacheSizeSelfTest extends GridCommonAbstractTest { - /** Grid count. */ - private static final int GRID_CNT = 3; - - /** Keys count. */ - private static final int KEYS_CNT = 50; - - /** Policy max size. */ - private static final int PLC_MAX_SIZE = 10; - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - startGrids(GRID_CNT); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - stopAllGrids(); - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - CacheConfiguration ccfg = defaultCacheConfiguration(); - ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); - ccfg.setNearConfiguration(null); - ccfg.setEvictionPolicy(new RandomEvictionPolicy(PLC_MAX_SIZE)); - - cfg.setCacheConfiguration(ccfg); - - return cfg; - } - - /** - * @throws Exception If failed. - */ - public void testSize() throws Exception { - IgniteCache<Integer, Integer> cache = grid(0).cache(null); - - for (int i = 0; i < KEYS_CNT; i++) - cache.put(i, i); - - // Ensure that all entries accessed without data races and cache size will correct - for (int i = 0; i < KEYS_CNT; i++) - cache.get(i); - - assertEquals(PLC_MAX_SIZE * GRID_CNT, cache.size()); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/80d244d8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/random/RandomEvictionPolicySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/random/RandomEvictionPolicySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/random/RandomEvictionPolicySelfTest.java deleted file mode 100644 index a253a25..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/random/RandomEvictionPolicySelfTest.java +++ /dev/null @@ -1,363 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache.eviction.random; - -import java.util.Random; -import java.util.concurrent.Callable; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.eviction.random.RandomEvictionPolicy; -import org.apache.ignite.internal.processors.cache.eviction.EvictionAbstractTest; -import org.jetbrains.annotations.Nullable; - -/** - * Random eviction policy test. - */ -public class RandomEvictionPolicySelfTest extends - EvictionAbstractTest<RandomEvictionPolicy<String, String>> { - /** - * @throws Exception If failed. - */ - public void testMemory() throws Exception { - try { - Ignite g = startGrid(0); - - int max = 10; - - policy(0).setMaxSize(max); - - int keys = 31; - - for (int i = 0; i < keys; i++) { - String s = Integer.toString(i); - - g.cache(null).put(s, s); - } - - assert g.cache(null).size() <= max; - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If failed. - */ - public void testRandom() throws Exception { - try { - Ignite g = startGrid(0); - - int max = 10; - - policy(0).setMaxSize(max); - - Random rand = new Random(); - - int keys = 31; - - String[] t = new String[keys]; - - for (int i = 0; i < t.length; i++) - t[i] = Integer.toString(i); - - int runs = 10000; - - for (int i = 0; i < runs; i++) { - boolean rmv = rand.nextBoolean(); - - int j = rand.nextInt(t.length); - - if (rmv) - g.cache(null).remove(t[j]); - else - g.cache(null).put(t[j], t[j]); - - if (i % 1000 == 0) - info("Stats [cntr=" + i + ", total=" + runs + ']'); - } - - int size = g.cache(null).size(); - - info("Cache size: " + size); - - assert size <= (max * 1.2) : size; // Add 20% room for random evictions. - - info(policy(0)); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If failed. - */ - public void testAllowEmptyEntries() throws Exception { - try { - startGrid(); - - IgniteCache<String, String> c = jcache(); - - MockEntry e1 = new MockEntry("1", c); - MockEntry e2 = new MockEntry("2", c); - MockEntry e3 = new MockEntry("3", c); - MockEntry e4 = new MockEntry("4", c); - MockEntry e5 = new MockEntry("5", c); - - RandomEvictionPolicy<String, String> p = policy(); - - p.setMaxSize(10); - - p.onEntryAccessed(false, e1); - - assertFalse(e1.isEvicted()); - - p.onEntryAccessed(false, e2); - - assertFalse(e1.isEvicted()); - assertFalse(e2.isEvicted()); - - p.onEntryAccessed(false, e3); - - assertFalse(e1.isEvicted()); - assertFalse(e3.isEvicted()); - - p.onEntryAccessed(false, e4); - - assertFalse(e1.isEvicted()); - assertFalse(e3.isEvicted()); - assertFalse(e4.isEvicted()); - - p.onEntryAccessed(false, e5); - - assertFalse(e1.isEvicted()); - assertFalse(e3.isEvicted()); - assertFalse(e5.isEvicted()); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If failed. - */ - public void testRandomMultiThreaded() throws Exception { - try { - final Ignite g = startGrid(0); - - int max = 10; - - policy(0).setMaxSize(max); - - final Random rand = new Random(); - - int keys = 31; - - final String[] t = new String[keys]; - - for (int i = 0; i < t.length; i++) - t[i] = Integer.toString(i); - - multithreaded(new Callable() { - @Nullable @Override public Object call() { - int runs = 3000; - - for (int i = 0; i < runs; i++) { - boolean rmv = rand.nextBoolean(); - - int j = rand.nextInt(t.length); - - if (rmv) - g.cache(null).remove(t[j]); - else - g.cache(null).put(t[j], t[j]); - - if (i != 0 && i % 1000 == 0) - info("Stats [cntr=" + i + ", total=" + runs + ']'); - } - - return null; - } - }, 10); - - int size = g.cache(null).size(); - - assertTrue("Unexpected cache size [size=" + size + ", max=" + max + ']', size <= max); - - info(policy(0)); - } - finally { - stopAllGrids(); - } - } - - /** {@inheritDoc} */ - @Override public void testMaxMemSizeAllowEmptyEntries() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testMaxMemSizeMemory() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testMaxMemSizePartitionedNearDisabled() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testMaxMemSizePolicy() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testMaxMemSizePolicyWithBatch() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testMaxMemSizePut() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testMaxMemSizeRandom() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testMaxSizeAllowEmptyEntries() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testMaxSizeAllowEmptyEntriesWithBatch() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testMaxSizeMemory() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testMaxSizeMemoryWithBatch() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override protected void doTestPolicy() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testMaxSizePut() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testMaxSizePutWithBatch() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testMaxSizeRandom() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testMaxSizeRandomWithBatch() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testMaxSizePolicyWithBatch() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testMaxSizePartitionedNearDisabledWithBatch() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override protected void doTestPolicyWithBatch() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testMaxSizePartitionedNearDisabled() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testPartitionedNearEnabled() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testPartitionedNearDisabledMultiThreaded() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testPartitionedNearDisabledBackupSyncMultiThreaded() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testPartitionedNearEnabledMultiThreaded() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void testPartitionedNearEnabledBackupSyncMultiThreaded() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ - @Override protected RandomEvictionPolicy<String, String> createPolicy(int plcMax) { - RandomEvictionPolicy<String, String> plc = new RandomEvictionPolicy<>(); - - plc.setMaxSize(plcMax); - - return plc; - } - - /** {@inheritDoc} */ - @Override protected RandomEvictionPolicy<String, String> createNearPolicy(int nearMax) { - RandomEvictionPolicy<String, String> plc = new RandomEvictionPolicy<>(); - - plc.setMaxSize(plcMax); - - return plc; - } - - /** {@inheritDoc} */ - @Override protected void checkNearPolicies(int nearMax) { - // No-op. - } - - /** {@inheritDoc} */ - @Override protected void checkPolicies() { - // No-op. - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/80d244d8/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheEvictionSelfTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheEvictionSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheEvictionSelfTestSuite.java index 165410f..3d8bbba 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheEvictionSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheEvictionSelfTestSuite.java @@ -36,8 +36,6 @@ import org.apache.ignite.internal.processors.cache.eviction.fifo.FifoEvictionPol import org.apache.ignite.internal.processors.cache.eviction.lru.LruEvictionPolicySelfTest; import org.apache.ignite.internal.processors.cache.eviction.lru.LruNearEvictionPolicySelfTest; import org.apache.ignite.internal.processors.cache.eviction.lru.LruNearOnlyNearEvictionPolicySelfTest; -import org.apache.ignite.internal.processors.cache.eviction.random.RandomEvictionPolicyCacheSizeSelfTest; -import org.apache.ignite.internal.processors.cache.eviction.random.RandomEvictionPolicySelfTest; import org.apache.ignite.internal.processors.cache.eviction.sorted.SortedEvictionPolicySelfTest; /** @@ -56,8 +54,6 @@ public class IgniteCacheEvictionSelfTestSuite extends TestSuite { suite.addTest(new TestSuite(LruEvictionPolicySelfTest.class)); suite.addTest(new TestSuite(LruNearEvictionPolicySelfTest.class)); suite.addTest(new TestSuite(LruNearOnlyNearEvictionPolicySelfTest.class)); - suite.addTest(new TestSuite(RandomEvictionPolicySelfTest.class)); - suite.addTest(new TestSuite(RandomEvictionPolicyCacheSizeSelfTest.class)); suite.addTest(new TestSuite(GridCacheNearEvictionSelfTest.class)); suite.addTest(new TestSuite(GridCacheAtomicNearEvictionSelfTest.class)); suite.addTest(new TestSuite(GridCacheEvictionFilterSelfTest.class));