From ce362243453319ccecd9572e01141456d67ed750 Mon Sep 17 00:00:00 2001 From: Dan Berindei Date: Thu, 18 Jul 2013 10:33:54 +0300 Subject: [PATCH 1/2] ISPN-3325 ConsistentHashV1IntegrationTest.testCorrectBalancingOfKeysAfterNodeKill random failures --- .../ConsistentHashV1IntegrationTest.java | 49 ++++++------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ConsistentHashV1IntegrationTest.java b/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ConsistentHashV1IntegrationTest.java index 33ff151b4e13..e98ea4e574b6 100644 --- a/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ConsistentHashV1IntegrationTest.java +++ b/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ConsistentHashV1IntegrationTest.java @@ -14,26 +14,26 @@ import org.infinispan.server.hotrod.HotRodServer; import org.infinispan.test.MultipleCacheManagersTest; import org.infinispan.test.TestingUtil; -import org.infinispan.commons.util.Util; import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterTest; import org.testng.annotations.Test; -import java.util.ArrayList; -import java.util.List; import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; -import static org.infinispan.client.hotrod.test.HotRodClientTestingUtil.*; +import static org.infinispan.client.hotrod.test.HotRodClientTestingUtil.killServers; import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; /** * @author Mircea Markus */ @Test (groups = "functional", testName = "client.hotrod.ConsistentHashV1IntegrationTest") public class ConsistentHashV1IntegrationTest extends MultipleCacheManagersTest { + public static final int NUM_KEYS = 200; private HotRodServer hotRodServer1; private HotRodServer hotRodServer2; @@ -117,23 +117,18 @@ public void testCorrectBalancingOfKeys() { private void runTest(int cacheIndex) { ConsistentHash serverCH = advancedCache(cacheIndex).getDistributionManager().getConsistentHash(); - // compatibility with 1.0/1.1 clients is not perfect, so we must allow for some misses - int misses = 0; - for (int i = 0; i < 200; i++) { + for (int i = 0; i < NUM_KEYS; i++) { byte[] keyBytes = (byte[]) kas.getKeyForAddress(address(cacheIndex)); String key = DistributionRetryTest.ByteKeyGenerator.getStringObject(keyBytes); - List
serverBackups = serverCH.locateOwners(keyBytes); - assert serverBackups.contains(address(cacheIndex)); - remoteCache.put(key, "v"); - - Address hitServer = getHitServer(); - if (!serverBackups.contains(hitServer)) { - misses++; - } + Address serverPrimary = serverCH.locatePrimaryOwner(keyBytes); + assertEquals(address(cacheIndex), serverPrimary); - assert misses < 5 : String.format("i=%s, backups: %s, hit server: %s, key=%s", i, serverBackups, hitServer, Util.printArray(key.getBytes(), false)); + remoteCache.put(key, "v"); } + // compatibility with 1.0/1.1 clients is not perfect, so we must allow for some misses + assertTrue(hitCountInterceptor(cacheIndex).getHits() > NUM_KEYS * 0.99); + hitCountInterceptor(cacheIndex).reset(); } public void testCorrectBalancingOfKeysAfterNodeKill() { @@ -189,27 +184,15 @@ private org.infinispan.client.hotrod.impl.consistenthash.ConsistentHash extractC return transport.getConsistentHash(); } - private Address getHitServer() { - List
result = new ArrayList
(); + private void resetHitInterceptors() { for (int i = 0; i < 4; i++) { - InterceptorChain ic = advancedCache(i).getComponentRegistry().getComponent(InterceptorChain.class); - HitsAwareCacheManagersTest.HitCountInterceptor interceptor = - (HitsAwareCacheManagersTest.HitCountInterceptor) ic.getInterceptorsWithClass(HitsAwareCacheManagersTest.HitCountInterceptor.class).get(0); - if (interceptor.getHits() == 1) { - result.add(address(i)); - } + HitsAwareCacheManagersTest.HitCountInterceptor interceptor = hitCountInterceptor(i); interceptor.reset(); } - if (result.size() > 1) throw new IllegalStateException("More than one hit! : " + result); - return result.get(0); } - private void resetHitInterceptors() { - for (int i = 0; i < 4; i++) { - InterceptorChain ic = advancedCache(i).getComponentRegistry().getComponent(InterceptorChain.class); - HitsAwareCacheManagersTest.HitCountInterceptor interceptor = - (HitsAwareCacheManagersTest.HitCountInterceptor) ic.getInterceptorsWithClass(HitsAwareCacheManagersTest.HitCountInterceptor.class).get(0); - interceptor.reset(); - } + private HitsAwareCacheManagersTest.HitCountInterceptor hitCountInterceptor(int i) { + InterceptorChain ic = advancedCache(i).getComponentRegistry().getComponent(InterceptorChain.class); + return (HitsAwareCacheManagersTest.HitCountInterceptor) ic.getInterceptorsWithClass(HitsAwareCacheManagersTest.HitCountInterceptor.class).get(0); } } From 92f887d4d4bc45b49c6c6f47ecb509bbd82a808f Mon Sep 17 00:00:00 2001 From: Dan Berindei Date: Thu, 18 Jul 2013 10:35:51 +0300 Subject: [PATCH 2/2] Remove references to version.scala in parent pom.xml Fixes problems with IntelliJ compilation of server modules. --- parent/pom.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/parent/pom.xml b/parent/pom.xml index 4e5cee88392c..6605fcc3f551 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -1864,7 +1864,6 @@ - ${version.scala} -Xmx256m @@ -1913,7 +1912,6 @@ - ${version.scala} -Xmx256m -XX:+UseCompressedOops