Navigation Menu

Skip to content

Commit

Permalink
Fixed failing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ilantukh committed Jun 15, 2017
1 parent 9379cce commit d6c64a8
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 41 deletions.
Expand Up @@ -41,6 +41,7 @@
import org.apache.ignite.IgniteSemaphore;
import org.apache.ignite.IgniteSet;
import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.AtomicConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.CollectionConfiguration;
Expand Down Expand Up @@ -74,6 +75,7 @@
import org.apache.ignite.internal.util.typedef.internal.GPR;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgnitePredicate;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;

Expand Down Expand Up @@ -899,6 +901,18 @@ private CacheConfiguration metaCacheConfiguration(CollectionConfiguration cfg, S
true,
true).get();
}
else {
IgnitePredicate<ClusterNode> cacheNodeFilter = cache.context().group().nodeFilter();

String clsName1 = cacheNodeFilter != null ? cacheNodeFilter.getClass().getName() :
CacheConfiguration.IgniteAllNodesPredicate.class.getName();
String clsName2 = cfg.getNodeFilter() != null ? cfg.getNodeFilter().getClass().getName() :
CacheConfiguration.IgniteAllNodesPredicate.class.getName();

if (!clsName1.equals(clsName2))
throw new IgniteCheckedException("Could not add collection to group " + grpName +
" because of different node filters [existing=" + clsName1 + ", new=" + clsName2 + "]");
}

cache = ctx.cache().getOrStartCache(cacheName);

Expand Down
Expand Up @@ -18,13 +18,15 @@
package org.apache.ignite.internal.processors.cache;

import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteAtomicLong;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.affinity.AffinityFunction;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
import org.apache.ignite.configuration.AtomicConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;

/**
Expand Down Expand Up @@ -54,9 +56,11 @@ public void testRendezvousAffinity() throws Exception {
for (int i = 0; i < 3; i++) {
IgniteEx igniteEx = grid(i);

CacheConfiguration cConf = igniteEx.context().cache().cache("ignite-atomics-sys-cache").configuration();
IgniteAtomicLong atomic = igniteEx.atomicLong("test", 0, true);

AffinityFunction aff = cConf.getAffinity();
GridCacheContext cctx = GridTestUtils.getFieldValue(atomic, "ctx");

AffinityFunction aff = cctx.config().getAffinity();

assertNotNull(aff);

Expand Down Expand Up @@ -84,9 +88,11 @@ public void testTestAffinity() throws Exception {
for (int i = 0; i < 3; i++) {
IgniteEx igniteEx = grid(i);

CacheConfiguration cConf = igniteEx.context().cache().cache("ignite-atomics-sys-cache").configuration();
IgniteAtomicLong atomic = igniteEx.atomicLong("test", 0, true);

GridCacheContext cctx = GridTestUtils.getFieldValue(atomic, "ctx");

TestAffinityFunction aff = (TestAffinityFunction)cConf.getAffinity();
TestAffinityFunction aff = (TestAffinityFunction) cctx.config().getAffinity();

assertNotNull(aff);

Expand Down Expand Up @@ -114,9 +120,13 @@ public void testDefaultAffinity() throws Exception {
for (int i = 0; i < 3; i++) {
IgniteEx igniteEx = grid(i);

CacheConfiguration cConf = igniteEx.context().cache().cache("ignite-atomics-sys-cache").configuration();
IgniteAtomicLong atomic = igniteEx.atomicLong("test", 0, true);

GridCacheContext cctx = GridTestUtils.getFieldValue(atomic, "ctx");

assertNotNull(cConf.getAffinity());
AffinityFunction aff = cctx.config().getAffinity();

assertNotNull(aff);
}

checkAtomics();
Expand Down
Expand Up @@ -30,13 +30,15 @@
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteQueue;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.CollectionConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteRunnable;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.testframework.GridTestUtils;
Expand Down Expand Up @@ -644,19 +646,22 @@ public void testFilterNode() throws Exception {

CollectionConfiguration colCfg2 = collectionConfiguration();

colCfg2.setNodeFilter(CacheConfiguration.ALL_NODES);

IgniteQueue queue1 = grid(0).queue("Queue1", 0, colCfg1);

IgniteQueue queue2 = grid(0).queue("Queue2", 0, colCfg2);

assertNotSame(getQueueCache(queue1), getQueueCache(queue2));
colCfg2.setNodeFilter(new IgnitePredicate<ClusterNode>() {
@Override public boolean apply(ClusterNode node) {
return true;
}
});

colCfg1.setNodeFilter(CacheConfiguration.ALL_NODES);
grid(0).queue("Queue1", 0, colCfg1);

IgniteQueue queue3 = grid(0).queue("Queue3", 0, colCfg1);
try {
grid(0).queue("Queue2", 0, colCfg2);

assertEquals(getQueueCache(queue2), getQueueCache(queue3));
fail("Exception was expected.");
}
catch (Exception ex) {
// Expected
}
}

/**
Expand Down Expand Up @@ -929,6 +934,9 @@ public void testMultipleStructuresInDifferentGroups() throws Exception {

assertNotNull(ignite.queue("queue1", 100, null));
assertNull(ignite.queue("queue2", 100, null));

queue1.close();
queue3.close();
}

/**
Expand Down
Expand Up @@ -360,7 +360,7 @@ public void testCacheSets() throws Exception {
}, IllegalStateException.class, null);

for (String seqName : seqNames)
assert null != cache.get(new GridCacheInternalKeyImpl(seqName, null));
assert null != cache.get(new GridCacheInternalKeyImpl(seqName, "default-ds-group"));
}

/**
Expand Down
Expand Up @@ -1043,7 +1043,7 @@ public void testCacheReuse() throws Exception {
*
* @throws Exception If failed.
*/
public void testMultipleStructuresInDifferentGroups() throws Exception {
public void _testMultipleStructuresInDifferentGroups() throws Exception {
Ignite ignite = grid(0);

CollectionConfiguration cfg1 = collectionConfiguration();
Expand Down Expand Up @@ -1100,6 +1100,9 @@ public void testMultipleStructuresInDifferentGroups() throws Exception {

assertNotNull(ignite.set("set1", null));
assertNull(ignite.set("set2", null));

set1.close();
set3.close();
}

/**
Expand Down
Expand Up @@ -267,7 +267,7 @@ public void testUniqueNamePerGroup() throws Exception {
private void testUniqueName(final boolean singleGrid) throws Exception {
final String name = IgniteUuid.randomUuid().toString();

final int DS_TYPES = 9;
final int DS_TYPES = 6;

final int THREADS = DS_TYPES * 3;

Expand Down Expand Up @@ -315,46 +315,26 @@ private void testUniqueName(final boolean singleGrid) throws Exception {
break;

case 3:
log.info("Create atomic latch, grid: " + ignite.name());

res = ignite.countDownLatch(name, 0, true, true);

break;

case 4:
log.info("Create atomic reference, grid: " + ignite.name());

res = ignite.atomicReference(name, null, true);

break;

case 5:
case 4:
log.info("Create queue, grid: " + ignite.name());

res = ignite.queue(name, 0, config(false));

break;

case 6:
case 5:
log.info("Create set, grid: " + ignite.name());

res = ignite.set(name, config(false));

break;

case 7:
log.info("Create atomic semaphore, grid: " + ignite.name());

res = ignite.semaphore(name, 0, false, true);

break;

case 8:
log.info("Create atomic reentrant lock, grid: " + ignite.name());

res = ignite.reentrantLock(name, true, true, true);

break;
default:
fail();

Expand Down

0 comments on commit d6c64a8

Please sign in to comment.