Repository: incubator-ignite Updated Branches: refs/heads/ignite-sprint-3 9c8160bf7 -> 54f48783b
IGNITE-721 Added test. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b8543dc5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b8543dc5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b8543dc5 Branch: refs/heads/ignite-sprint-3 Commit: b8543dc5e8437dcaa241b45ac675c57bc515735b Parents: 60640de Author: nikolay_tikhonov <ntikho...@gridgain.com> Authored: Fri Apr 10 15:35:22 2015 +0300 Committer: nikolay_tikhonov <ntikho...@gridgain.com> Committed: Fri Apr 10 15:35:22 2015 +0300 ---------------------------------------------------------------------- .../IgniteFairAffinityDynamicCacheSelfTest.java | 96 ++++++++++++++++++++ .../ignite/testsuites/IgniteCacheTestSuite.java | 2 + 2 files changed, 98 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b8543dc5/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/IgniteFairAffinityDynamicCacheSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/IgniteFairAffinityDynamicCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/IgniteFairAffinityDynamicCacheSelfTest.java new file mode 100644 index 0000000..e51be58 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/IgniteFairAffinityDynamicCacheSelfTest.java @@ -0,0 +1,96 @@ +/* + * 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.cache.affinity.fair; + +import org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.*; +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.testframework.*; +import org.apache.ignite.testframework.junits.common.*; + +import java.util.concurrent.*; + +/** + * + */ +public class IgniteFairAffinityDynamicCacheSelfTest extends GridCommonAbstractTest { + /** */ + private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); + + /** */ + public IgniteFairAffinityDynamicCacheSelfTest(){ + super(false); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + TcpDiscoverySpi disco = new TcpDiscoverySpi(); + + disco.setIpFinder(IP_FINDER); + + cfg.getTransactionConfiguration().setTxSerializableEnabled(true); + + cfg.setDiscoverySpi(disco); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + startGridsMultiThreaded(3); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + } + + /** + * @throws Exception If failed. + */ + public void testStartStopCache() throws Exception { + CacheConfiguration<Integer, Integer> cacheCfg = new CacheConfiguration<>(); + + cacheCfg.setCacheMode(CacheMode.PARTITIONED); + cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); + cacheCfg.setBackups(1); + cacheCfg.setName("test"); + cacheCfg.setAffinity(new FairAffinityFunction()); + + final IgniteCache<Integer, Integer> cache = ignite(0).createCache(cacheCfg); + + for (int i = 0; i < 10_000; i++) + cache.put(i, i); + + IgniteInternalFuture<Object> destFut = GridTestUtils.runAsync(new Callable<Object>() { + @Override public Object call() throws Exception { + ignite(0).destroyCache(cache.getName()); + + return null; + } + }); + + destFut.get(2000L); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b8543dc5/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java index 230817e..b023e0d 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java @@ -83,6 +83,8 @@ public class IgniteCacheTestSuite extends TestSuite { // Affinity tests. suite.addTestSuite(GridFairAffinityFunctionNodesSelfTest.class); + suite.addTestSuite(GridFairAffinityFunctionSelfTest.class); + suite.addTestSuite(IgniteFairAffinityDynamicCacheSelfTest.class); suite.addTestSuite(GridCacheAffinityBackupsSelfTest.class); suite.addTestSuite(IgniteCacheAffinitySelfTest.class);