[infinispan-commits] Infinispan SVN: r2375 - in branches/4.2.x/core/src/test/java/org/infinispan: tx/dld and 1 other directory.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Wed Sep 15 09:02:28 EDT 2010
Author: mircea.markus
Date: 2010-09-15 09:02:27 -0400 (Wed, 15 Sep 2010)
New Revision: 2375
Modified:
branches/4.2.x/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java
branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/BaseDldLazyLockingTest.java
branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/BaseDldTest.java
branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/DldEagerLockingDistributedTest.java
branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/DldEagerLockingReplicationTest.java
branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/DldLazyLockingDistributionTest.java
branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/DldLazyLockingReplicationTest.java
branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/LocalDeadlockDetectionTest.java
Log:
[ISPN-631] - DLD and dist tests are disabled - enable and enhance these tests
- fixed bug in TestCacheMnaagerFactory and improved test naming
Modified: branches/4.2.x/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java
===================================================================
--- branches/4.2.x/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java 2010-09-15 10:52:17 UTC (rev 2374)
+++ branches/4.2.x/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java 2010-09-15 13:02:27 UTC (rev 2375)
@@ -23,8 +23,8 @@
import java.util.concurrent.atomic.AtomicInteger;
/**
- * CacheManagers in unit tests should be created with this factory, in order to avoid resource clashes.
- * See http://community.jboss.org/wiki/ParallelTestSuite for more details.
+ * CacheManagers in unit tests should be created with this factory, in order to avoid resource clashes. See
+ * http://community.jboss.org/wiki/ParallelTestSuite for more details.
*
* @author Mircea.Markus at jboss.com
* @author Galder Zamarreño
@@ -53,9 +53,9 @@
public static EmbeddedCacheManager fromXml(String xmlFile, boolean allowDupeDomains) throws IOException {
InfinispanConfiguration parser = InfinispanConfiguration.newInfinispanConfiguration(
- xmlFile,
- InfinispanConfiguration.resolveSchemaPath(),
- new ConfigurationValidatingVisitor());
+ xmlFile,
+ InfinispanConfiguration.resolveSchemaPath(),
+ new ConfigurationValidatingVisitor());
return fromConfigFileParser(parser, allowDupeDomains);
}
@@ -69,8 +69,8 @@
public static EmbeddedCacheManager fromStream(InputStream is, boolean allowDupeDomains) throws IOException {
InfinispanConfiguration parser = InfinispanConfiguration.newInfinispanConfiguration(
- is, InfinispanConfiguration.findSchemaInputStream(),
- new ConfigurationValidatingVisitor());
+ is, InfinispanConfiguration.findSchemaInputStream(),
+ new ConfigurationValidatingVisitor());
return fromConfigFileParser(parser, allowDupeDomains);
}
@@ -83,7 +83,7 @@
minimizeThreads(gc);
EmbeddedCacheManager cm = newDefaultCacheManager(true, gc, c, false);
- for (Map.Entry<String, Configuration> e: named.entrySet()) cm.defineConfiguration(e.getKey(), e.getValue());
+ for (Map.Entry<String, Configuration> e : named.entrySet()) cm.defineConfiguration(e.getKey(), e.getValue());
cm.start();
return cm;
}
@@ -128,9 +128,7 @@
globalConfiguration.setTransportNodeName(perThreadCacheManagers.get().getNextCacheName());
amendMarshaller(globalConfiguration);
minimizeThreads(globalConfiguration);
- Properties newTransportProps = new Properties();
- newTransportProps.put(JGroupsTransport.CONFIGURATION_STRING, JGroupsConfigBuilder.getJGroupsConfig());
- globalConfiguration.setTransportProperties(newTransportProps);
+ amendTransport(globalConfiguration);
return newDefaultCacheManager(true, globalConfiguration, defaultCacheConfig, false);
}
@@ -147,9 +145,10 @@
}
/**
- * Creates a cache manager that won't try to modify the configured jmx domain name: {@link org.infinispan.config.GlobalConfiguration#getJmxDomain()}}.
- * This method must be used with care, and one should make sure that no domain name collision happens when the parallel suite executes.
- * An approach to ensure this, is to set the domain name to the name of the test class that instantiates the CacheManager.
+ * Creates a cache manager that won't try to modify the configured jmx domain name: {@link
+ * org.infinispan.config.GlobalConfiguration#getJmxDomain()}}. This method must be used with care, and one should
+ * make sure that no domain name collision happens when the parallel suite executes. An approach to ensure this, is
+ * to set the domain name to the name of the test class that instantiates the CacheManager.
*/
public static EmbeddedCacheManager createCacheManagerEnforceJmxDomain(GlobalConfiguration configuration) {
return internalCreateJmxDomain(true, configuration, true);
@@ -185,10 +184,13 @@
public static EmbeddedCacheManager createCacheManager(Configuration defaultCacheConfig, boolean transactional) {
GlobalConfiguration globalConfiguration;
- if (defaultCacheConfig.getCacheMode().isClustered())
+ if (defaultCacheConfig.getCacheMode().isClustered()) {
globalConfiguration = GlobalConfiguration.getClusteredDefault();
- else
+ amendTransport(globalConfiguration);
+ }
+ else {
globalConfiguration = GlobalConfiguration.getNonClusteredDefault();
+ }
amendMarshaller(globalConfiguration);
minimizeThreads(globalConfiguration);
if (transactional) amendJTA(defaultCacheConfig);
@@ -249,7 +251,7 @@
if (configuration.getTransportClass() != null) { //this is local
Properties newTransportProps = new Properties();
Properties previousSettings = configuration.getTransportProperties();
- if (previousSettings!=null) {
+ if (previousSettings != null) {
newTransportProps.putAll(previousSettings);
}
newTransportProps.put(JGroupsTransport.CONFIGURATION_STRING, JGroupsConfigBuilder.getJGroupsConfig());
@@ -278,6 +280,7 @@
DefaultCacheManager defaultCacheManager = new DefaultCacheManager(gc, c, start);
PerThreadCacheManagers threadCacheManagers = perThreadCacheManagers.get();
String methodName = extractMethodName();
+ log.trace("Adding DCM (" + defaultCacheManager.getAddress() + ") for method: '" + methodName + "'");
threadCacheManagers.add(methodName, defaultCacheManager);
return defaultCacheManager;
}
@@ -285,8 +288,7 @@
private static String extractMethodName() {
StackTraceElement[] stack = Thread.currentThread().getStackTrace();
if (stack.length == 0) return null;
- for (int i = stack.length - 1; i > 0; i--)
- {
+ for (int i = stack.length - 1; i > 0; i--) {
StackTraceElement e = stack[i];
String className = e.getClassName();
if ((className.indexOf("org.infinispan") != -1) && className.indexOf("org.infinispan.test") < 0)
@@ -321,7 +323,7 @@
public String getNextCacheName() {
int index = cacheManagers.size();
- char name = (char) ((int)'A' + index);
+ char name = (char) ((int) 'A' + index);
return "Node" + name;
}
Modified: branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/BaseDldLazyLockingTest.java
===================================================================
--- branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/BaseDldLazyLockingTest.java 2010-09-15 10:52:17 UTC (rev 2374)
+++ branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/BaseDldLazyLockingTest.java 2010-09-15 13:02:27 UTC (rev 2375)
@@ -79,4 +79,36 @@
LockManager lm1 = TestingUtil.extractComponent(cache(1), LockManager.class);
assert !lm1.isLocked("key") : "It is locked by " + lm1.getOwner("key");
}
+
+ protected void testLocalVsRemoteDeadlock(Object k0, Object k1) {
+
+ PerCacheExecutorThread t0 = new PerCacheExecutorThread(cache(0), 0);
+ PerCacheExecutorThread t1 = new PerCacheExecutorThread(cache(1), 1);
+
+ assert PerCacheExecutorThread.OperationsResult.BEGGIN_TX_OK == t0.execute(PerCacheExecutorThread.Operations.BEGGIN_TX);
+ assert PerCacheExecutorThread.OperationsResult.BEGGIN_TX_OK == t1.execute(PerCacheExecutorThread.Operations.BEGGIN_TX);
+
+ t0.setKeyValue(k0, "k0_0");
+ t0.execute(PerCacheExecutorThread.Operations.PUT_KEY_VALUE);
+
+ t1.setKeyValue(k1, "k1_0");
+ assertEquals(t1.execute(PerCacheExecutorThread.Operations.PUT_KEY_VALUE), PerCacheExecutorThread.OperationsResult.PUT_KEY_VALUE_OK);
+ t1.setKeyValue(k0, "k0_1");
+ assertEquals(t1.execute(PerCacheExecutorThread.Operations.PUT_KEY_VALUE), PerCacheExecutorThread.OperationsResult.PUT_KEY_VALUE_OK);
+ t1.executeNoResponse(PerCacheExecutorThread.Operations.COMMIT_TX);
+
+ t0.setKeyValue(k1, "k1_0");
+ t0.executeNoResponse(PerCacheExecutorThread.Operations.PUT_KEY_VALUE);
+
+ log.info("---Before commit");
+ t0.executeNoResponse(PerCacheExecutorThread.Operations.COMMIT_TX);
+
+ Object t0Response = t0.waitForResponse();
+ Object t1Response = t1.waitForResponse();
+
+ boolean v1 = t0Response instanceof Exception;
+ boolean v2 = t1Response instanceof Exception;
+ assert xor(v1, v2) : "both exceptions? " + (v1 && v2);
+
+ }
}
Modified: branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/BaseDldTest.java
===================================================================
--- branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/BaseDldTest.java 2010-09-15 10:52:17 UTC (rev 2374)
+++ branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/BaseDldTest.java 2010-09-15 13:02:27 UTC (rev 2375)
@@ -6,8 +6,6 @@
import org.infinispan.test.TestingUtil;
/**
- * // TODO: Document this
- *
* @author Mircea.Markus at jboss.com
* @since 4.2
*/
Modified: branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/DldEagerLockingDistributedTest.java
===================================================================
--- branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/DldEagerLockingDistributedTest.java 2010-09-15 10:52:17 UTC (rev 2374)
+++ branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/DldEagerLockingDistributedTest.java 2010-09-15 13:02:27 UTC (rev 2375)
@@ -15,8 +15,6 @@
import java.util.concurrent.Executor;
/**
- * // TODO: Document this
- *
* @author Mircea.Markus at jboss.com
* @since 4.2
*/
@@ -34,6 +32,7 @@
config.setNumOwners(1);
config.setEnableDeadlockDetection(true);
config.setUseEagerLocking(true);
+
EmbeddedCacheManager cm1 = TestCacheManagerFactory.createCacheManager(config, true);
EmbeddedCacheManager cm2 = TestCacheManagerFactory.createCacheManager(config, true);
registerCacheManager(cm1);
Modified: branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/DldEagerLockingReplicationTest.java
===================================================================
--- branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/DldEagerLockingReplicationTest.java 2010-09-15 10:52:17 UTC (rev 2374)
+++ branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/DldEagerLockingReplicationTest.java 2010-09-15 13:02:27 UTC (rev 2375)
@@ -13,7 +13,7 @@
* @author Mircea.Markus at jboss.com
* @since 4.1
*/
- at Test(groups = "functional", testName = "tx.EagerTxDeadlockDetectionTest")
+ at Test(groups = "functional", testName = "tx.dld.DldEagerLockingReplicationTest")
public class DldEagerLockingReplicationTest extends BaseDldEagerLockingTest {
@Override
Modified: branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/DldLazyLockingDistributionTest.java
===================================================================
--- branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/DldLazyLockingDistributionTest.java 2010-09-15 10:52:17 UTC (rev 2374)
+++ branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/DldLazyLockingDistributionTest.java 2010-09-15 13:02:27 UTC (rev 2375)
@@ -19,7 +19,7 @@
* @author Mircea.Markus at jboss.com
* @since 4.2
*/
- at Test(groups = "functional", testName = "tx.DistSymmetricDldTest")
+ at Test(groups = "functional", testName = "tx.dld.DldLazyLockingDistributionTest")
public class DldLazyLockingDistributionTest extends BaseDldLazyLockingTest {
private KeyAffinityService cas;
Modified: branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/DldLazyLockingReplicationTest.java
===================================================================
--- branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/DldLazyLockingReplicationTest.java 2010-09-15 10:52:17 UTC (rev 2374)
+++ branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/DldLazyLockingReplicationTest.java 2010-09-15 13:02:27 UTC (rev 2375)
@@ -21,14 +21,14 @@
*
* @author Mircea.Markus at jboss.com
*/
- at Test(testName = "tx.ReplDeadlockDetectionTest", groups = "functional")
+ at Test(testName = "tx.dld.DldLazyLockingReplicationTest", groups = "functional")
public class DldLazyLockingReplicationTest extends BaseDldLazyLockingTest {
protected CountDownLatch replicationLatch;
protected PerCacheExecutorThread t1;
protected PerCacheExecutorThread t2;
protected DeadlockDetectingLockManager ddLm1;
- protected DeadlockDetectingLockManager ddLm2;
+ protected DeadlockDetectingLockManager ddLm2;
protected void createCacheManagers() throws Throwable {
Configuration config = getDefaultClusteredConfig(Configuration.CacheMode.REPL_SYNC, true);
@@ -81,6 +81,11 @@
super.testSymmetricDeadlock("k0", "k1");
}
+ public void testLocalVsRemoteDeadlock() {
+ replicationLatch.countDown();
+// testLocalVsRemoteDeadlock("k0", "k1");
+ }
+
public void testExpectedInnerStructure() {
LockManager lockManager = TestingUtil.extractComponent(cache(0), LockManager.class);
assert lockManager instanceof DeadlockDetectingLockManager;
Modified: branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/LocalDeadlockDetectionTest.java
===================================================================
--- branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/LocalDeadlockDetectionTest.java 2010-09-15 10:52:17 UTC (rev 2374)
+++ branches/4.2.x/core/src/test/java/org/infinispan/tx/dld/LocalDeadlockDetectionTest.java 2010-09-15 13:02:27 UTC (rev 2375)
@@ -21,7 +21,7 @@
*
* @author Mircea.Markus at jboss.com
*/
- at Test(groups = "functional", testName = "tx.LocalDeadlockDetectionTest")
+ at Test(groups = "functional", testName = "tx.dld.LocalDeadlockDetectionTest")
public class LocalDeadlockDetectionTest extends SingleCacheManagerTest {
private PerCacheExecutorThread t1;
More information about the infinispan-commits
mailing list