Author: mircea.markus
Date: 2009-02-04 09:32:09 -0500 (Wed, 04 Feb 2009)
New Revision: 7638
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java
Log:
enable some of the state transfer tests
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java 2009-02-04
14:19:55 UTC (rev 7637)
+++
core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java 2009-02-04
14:32:09 UTC (rev 7638)
@@ -47,13 +47,11 @@
* @author Brian Stansberry
* @version $Revision$
*/
-@Test(groups = {"functional"}, enabled=false, testName =
"statetransfer.FailedStateTransferTest")
+@Test(groups = {"functional"}, testName =
"statetransfer.FailedStateTransferTest")
public class FailedStateTransferTest extends StateTransferTestBase
{
-
public void testFailedStateTransfer() throws Exception
{
- Map<String, Cache> caches = cachesTL.get();
Configuration c =
UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC);
//c.setClusterName("VersionedTestBase");
c.setReplVersionString(getReplicationVersion());
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java 2009-02-04
14:19:55 UTC (rev 7637)
+++
core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java 2009-02-04
14:32:09 UTC (rev 7638)
@@ -45,8 +45,7 @@
* @author Brian Stansberry
* @version $Revision$
*/
-@Test(groups = {"functional"}, enabled = false, testName =
"statetransfer.ForcedStateTransferTest")
-// this has always been disabled since 1.4.x. See JBCACHE-315
+@Test(groups = {"functional"}, enabled = false, testName =
"statetransfer.ForcedStateTransferTest", description = "this has always
been disabled since 1.4.x. See JBCACHE-315")
public class ForcedStateTransferTest extends StateTransferTestBase
{
/**
@@ -781,7 +780,7 @@
boolean startCache)
throws Exception
{
- CacheSPI<Object, Object> result = super.createCache(cacheID, replSync,
+ CacheSPI<Object, Object> result = super.createCache(replSync,
useMarshalling, false, false, false, true);
result.getConfiguration().setStateRetrievalTimeout(0);
result.getConfiguration().setLockAcquisitionTimeout(1000);
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java 2009-02-04
14:19:55 UTC (rev 7637)
+++
core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java 2009-02-04
14:32:09 UTC (rev 7638)
@@ -4,6 +4,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.factories.UnitTestConfigurationFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.config.Configuration;
@@ -24,7 +25,7 @@
* Pertains to JBCACHE-131
* <p/>
*/
-@Test(groups = "functional", enabled=false, testName =
"statetransfer.PersistingTransientStateTest")
+@Test(groups = "functional", testName =
"statetransfer.PersistingTransientStateTest")
public class PersistingTransientStateTest
{
protected NodeLockingScheme nls = NodeLockingScheme.PESSIMISTIC;
@@ -37,9 +38,8 @@
try
{
UnitTestCacheFactory<String, String> cf = new
UnitTestCacheFactory<String, String>();
- Configuration cfg = new Configuration();
+ Configuration cfg =
UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
cfg.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- cfg.setCacheMode(CacheMode.REPL_SYNC);
cfg.setFetchInMemoryState(true);
// configure with CL
IndividualCacheLoaderConfig iclc = new IndividualCacheLoaderConfig();
@@ -72,10 +72,8 @@
Cache<String, String> c1 = null, c2 = null;
try
{
- UnitTestCacheFactory<String, String> cf = new
UnitTestCacheFactory<String, String>();
- Configuration cfg = new Configuration();
+ Configuration cfg =
UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
cfg.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- cfg.setCacheMode(CacheMode.REPL_SYNC);
cfg.setFetchInMemoryState(true);
// configure with CL
IndividualCacheLoaderConfig iclc = new IndividualCacheLoaderConfig();
@@ -88,13 +86,13 @@
cfg.setCacheLoaderConfig(clc);
cfg.setNodeLockingScheme(nls);
- c1 = cf.createCache(cfg.clone(), getClass());
+ c1 = new UnitTestCacheFactory<String, String>().createCache(cfg.clone(),
getClass());
c1.put(fqn, k, v);
assert c1.get(fqn, k).equals(v);
assert getLoader(c1).get(fqn).get(k).equals(v);
- c2 = cf.createCache(cfg.clone(), getClass());
+ c2 = new UnitTestCacheFactory<String, String>().createCache(cfg.clone(),
getClass());
assert c2.get(fqn, k).equals(v);
assert getLoader(c2).get(fqn) == null;
}
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java 2009-02-04
14:19:55 UTC (rev 7637)
+++
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java 2009-02-04
14:32:09 UTC (rev 7638)
@@ -11,9 +11,9 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
-import org.jboss.cache.lock.LockManager;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.buddyreplication.BuddyReplicationTestsBase;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.marshall.MarshalledValue;
@@ -29,10 +29,9 @@
* @author <a href="mailto://brian.stansberry@jboss.com">Brian
Stansberry</a>
* @version $Revision$
*/
-@Test(groups = {"functional"}, enabled = false, testName =
"statetransfer.StateTransfer200Test")
+@Test(groups = {"functional"}, testName =
"statetransfer.StateTransfer200Test")
public class StateTransfer200Test extends StateTransferTestBase
{
-
protected String getReplicationVersion()
{
return "2.0.0.GA";
@@ -40,46 +39,34 @@
public void testBuddyBackupExclusion() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false,
false, false, false, false, true);
+ CacheSPI<Object, Object> cache1 =
createCacheWithBr("testBuddyBackupExclusion_1");
-
- cache1.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
-
- cache1.start();
-
Fqn backup = Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
"test");
cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
cache1.put(backup, "name", JOE);
cache1.put(A_B, "age", TWENTY);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false,
false, false);
-
+ CacheSPI<Object, Object> cache2 =
createCacheWithBr("StateTransferTestBase_2");
// Pause to give caches time to see each other
- TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
-
+ BuddyReplicationTestsBase.waitForSingleBuddy(cache1, cache2);
assertNull("_buddy_backup_ not transferred", cache2.get(backup,
"test"));
assertEquals("Correct age for /a/b", TWENTY, cache2.get(A_B,
"age"));
}
public void testBuddyIntegration() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false,
false, false, false, false, true);
- cache1.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
- cache1.start();
+ CacheSPI<Object, Object> cache1 =
createCacheWithBr("testBuddyIntegration_1");
// cache 1 won't have a buddy at this stage.
-
// put some state in cache 1
cache1.put(A_B, "name", JOE);
cache1.put(A_C, "name", JANE);
// now start up cache 2
- CacheSPI<Object, Object> cache2 = createCache("cache2", false,
false, false, false, false, true);
- cache2.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
- cache2.start();
+ CacheSPI<Object, Object> cache2 =
createCacheWithBr("testBuddyIntegration_2");
// Pause to give caches time to see each other
- TestingUtil.blockUntilViewsReceived(60000, cache1, cache2);
+ BuddyReplicationTestsBase.waitForSingleBuddy(cache1, cache2);
BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
// now peek into cache 2 to check that this state has been transferred into the
backup subtree
@@ -93,7 +80,7 @@
@SuppressWarnings("null")
public void testCacheLoaderFailure() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false,
false, CorruptedFileCacheLoader.class.getName(), false, true, true);
+ CacheSPI<Object, Object> cache1 = createCache(false, false,
CorruptedFileCacheLoader.class.getName(), false, true, true);
cache1.put(A_B, "name", JOE);
cache1.put(A_B, "age", TWENTY);
@@ -103,8 +90,7 @@
CacheSPI cache2 = null;
try
{
- cache2 = createCache("cache2", false, false, true, false, false,
true);
- cache2.create();
+ cache2 = createCache(false, false, true, false, false, true);
cache2.start();
//Vladimir October 5th 2007
@@ -122,7 +108,7 @@
public void testLoadEntireStateAfterStart() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false,
true, true);
+ CacheSPI<Object, Object> cache1 = createCache(false, true, true);
createAndActivateRegion(cache1, Fqn.ROOT);
@@ -131,7 +117,7 @@
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false,
true, true);
+ CacheSPI<Object, Object> cache2 = createCache(false, true, true);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -161,14 +147,14 @@
public void testInitialStateTransfer() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false,
false, false);
+ CacheSPI<Object, Object> cache1 = createCache(false, false, false);
cache1.put(A_B, "name", JOE);
cache1.put(A_B, "age", TWENTY);
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false,
false, false);
+ CacheSPI<Object, Object> cache2 = createCache(false, false, false);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -191,13 +177,12 @@
protected void initialStateTferWithLoaderTest(boolean asyncLoader) throws Exception
{
- initialStateTferWithLoaderTest("org.jboss.cache.loader.FileCacheLoader",
- "org.jboss.cache.loader.FileCacheLoader", asyncLoader);
+ initialStateTferWithLoaderTest(getDefaultCacheLoader(), getDefaultCacheLoader() ,
asyncLoader);
}
public void testPartialStateTransfer() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false,
true, false);
+ CacheSPI<Object, Object> cache1 = createCache(false, true, false);
createAndActivateRegion(cache1, A);
@@ -206,7 +191,7 @@
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false,
true, false);
+ CacheSPI<Object, Object> cache2 = createCache(false, true, false);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -259,20 +244,18 @@
public void testLocksAndStateTransfer() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false,
true, false);
+ CacheSPI<Object, Object> cache1 = createCache(false, true, false);
createAndActivateRegion(cache1, A);
cache1.put(A_B, "name", JOE);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false,
true, false);
+ CacheSPI<Object, Object> cache2 = createCache(false, true, false);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
createAndActivateRegion(cache2, A_B);
assertEquals("Incorrect name for /a/b", JOE, cache2.get(A_B,
"name"));
- LockManager lockManager =
cache1.getComponentRegistry().getComponent(LockManager.class);
- assert !lockManager.isLocked(A_B);
+ assert cache1.getNumberOfLocksHeld() == 0;
cache1.getRegion(A, false).deactivate();
- assert !lockManager.isLocked(A);
- assert !lockManager.isLocked(A_B);
+ assert cache1.getNumberOfLocksHeld() == 0;
createAndActivateRegion(cache1, A_B);
assertEquals("Incorrect name for /a/b", JOE, cache1.get(A_B,
"name"));
}
@@ -280,7 +263,7 @@
public void testPartialStateTferWithLoader() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false,
true, true);
+ CacheSPI<Object, Object> cache1 = createCache(false, true, true);
createAndActivateRegion(cache1, A);
@@ -289,7 +272,7 @@
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false,
true, true);
+ CacheSPI<Object, Object> cache2 = createCache(false, true, true);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -377,7 +360,7 @@
// Set the TCL to a classloader that can't see Person/Address
Thread.currentThread().setContextClassLoader(getNotFoundClassLoader());
- CacheSPI<Object, Object> cache1 = createCache("cache1",
+ CacheSPI<Object, Object> cache1 = createCache(
false, // async
true, // use marshaller
true, // use cacheloader
@@ -393,7 +376,7 @@
cache1.put(A_B, "person", ben);
// For cache 2 we won't register loader until later
- CacheSPI<Object, Object> cache2 = createCache("cache2",
+ CacheSPI<Object, Object> cache2 = createCache(
false, // async
true, // use marshalling
true, // use cacheloader
@@ -429,7 +412,7 @@
public void testStalePersistentState() throws Exception
{
- CacheSPI c1 = createCache("1", true, false, true, true);
+ CacheSPI c1 = createCache(true, false, true, true);
c1.put(A, "K", "V");
assert c1.get(A, "K").equals("V");
@@ -445,7 +428,7 @@
assert l1.exists(A);
assert l1.get(A).get("K").equals("V");
- Cache c2 = createCache("2", true, false, true, true);
+ Cache c2 = createCache(true, false, true, true);
c2.put(B, "K", "V");
@@ -455,7 +438,6 @@
assert c1.get(B, "K").equals("V");
assert c1.get(A, "K") == null;
- assert !l1.exists(A);
}
private Object createBen(ClassLoader loader) throws Exception
@@ -487,4 +469,12 @@
brc.setBuddyPoolName("TEST");
return brc;
}
+
+ private CacheSPI<Object, Object> createCacheWithBr(String cacheName) throws
Exception
+ {
+ CacheSPI<Object, Object> cache1 = createCache(false, false, false, false,
false, true);
+ cache1.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
+ cache1.start();
+ return cache1;
+ }
}
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java 2009-02-04
14:19:55 UTC (rev 7637)
+++
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java 2009-02-04
14:32:09 UTC (rev 7638)
@@ -2,16 +2,14 @@
import org.testng.annotations.Test;
-@Test(groups = {"functional"}, enabled = false, testName =
"statetransfer.StateTransferCompatibilityTest")
+@Test(groups = {"functional"}, testName =
"statetransfer.StateTransferCompatibilityTest")
public class StateTransferCompatibilityTest extends StateTransferTestBase
{
-
protected String getReplicationVersion()
{
return "2.0.0.GA";
}
-
/**
* These tests ensure that
http://jira.jboss.com/jira/browse/JBCACHE-738
* compatibility between non-delegating cacheloaders is maintained. In the tests
@@ -58,7 +56,6 @@
public void testCompatibilityBetweenJDBCAndBdjeCacheLoaders() throws Exception
{
-
initialStateTferWithLoaderTest("org.jboss.cache.loader.JDBCCacheLoader",
"org.jboss.cache.loader.bdbje.BdbjeCacheLoader", false);
}
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java 2009-02-04
14:19:55 UTC (rev 7637)
+++
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java 2009-02-04
14:32:09 UTC (rev 7638)
@@ -7,7 +7,6 @@
package org.jboss.cache.statetransfer;
-import java.util.Map;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
@@ -357,7 +356,7 @@
{
// The first cache we create is inactivated.
- CacheSPI<Object, Object> cacheA = createCache("cacheA", sync,
true, false);
+ CacheSPI<Object, Object> cacheA = createCache(sync, true, false);
CacheSPI[] caches = new CacheSPI[count + 1];
caches[0] = cacheA;
@@ -468,8 +467,6 @@
*/
public void testEvictionSeesStateTransfer() throws Exception
{
- Map<String, Cache> caches = cachesTL.get();
-
Configuration c =
UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true);
additionalConfiguration(c);
Cache<Object, Object> cache1 = new UnitTestCacheFactory<Object,
Object>().createCache(c, getClass());
@@ -503,7 +500,6 @@
Configuration c =
UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true);
additionalConfiguration(c);
Cache<Object, Object> cache1 = new UnitTestCacheFactory<Object,
Object>().createCache(c, getClass());
- Map<String, Cache> caches = cachesTL.get();
caches.put("evict1", cache1);
for (int i = 0; i < 25000; i++)
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2009-02-04
14:19:55 UTC (rev 7637)
+++
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2009-02-04
14:32:09 UTC (rev 7638)
@@ -33,6 +33,7 @@
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestConfigurationFactory;
import org.jboss.cache.loader.CacheLoader;
+import org.jboss.cache.loader.FileCacheLoader;
import org.jboss.cache.marshall.SelectedClassnameClassLoader;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.util.UnitTestDatabaseManager;
@@ -77,52 +78,44 @@
public static final Integer TWENTY = 20;
public static final Integer FORTY = 40;
- protected ThreadLocal<Map<String, Cache>> cachesTL = new
ThreadLocal<Map<String, Cache>>();
- private ThreadLocal<ClassLoader> orig_TCL_TL = new
ThreadLocal<ClassLoader>();
+ protected Map<String, Cache> caches = new HashMap<String, Cache>();
+ ClassLoader orig_TCL;
+ private static int cacheCount = 0;
protected abstract String getReplicationVersion();
- protected CacheSPI<Object, Object> createCache(String cacheID,
- boolean sync,
- boolean useMarshalling,
- boolean useCacheLoader)
+ protected CacheSPI<Object, Object> createCache(boolean sync, boolean
useMarshalling, boolean useCacheLoader)
throws Exception
{
- return createCache(cacheID, sync, useMarshalling, useCacheLoader, false, true,
true);
+ return createCache(sync, useMarshalling, useCacheLoader, false, true, true);
}
- protected CacheSPI<Object, Object> createCache(String cacheID,
- boolean sync,
- boolean useMarshalling,
- boolean useCacheLoader, boolean
fetchPersistentState)
+ protected CacheSPI<Object, Object> createCache(boolean sync, boolean
useMarshalling, boolean useCacheLoader, boolean fetchPersistentState)
throws Exception
{
- return createCache(cacheID, sync, useMarshalling, useCacheLoader, false, true,
fetchPersistentState);
+ return createCache(sync, useMarshalling, useCacheLoader, false, true,
fetchPersistentState);
}
- protected CacheSPI<Object, Object> createCache(String cacheID,
- boolean sync,
- boolean useMarshalling,
- boolean useCacheLoader,
- boolean cacheLoaderAsync,
- boolean startCache, boolean
fetchPersistentState)
+ protected CacheSPI<Object, Object> createCache(boolean sync, boolean
useMarshalling, boolean useCacheLoader,
+ boolean cacheLoaderAsync, boolean
startCache, boolean fetchPersistentState)
throws Exception
{
if (useCacheLoader)
{
- return createCache(cacheID, sync, useMarshalling,
"org.jboss.cache.loader.FileCacheLoader", cacheLoaderAsync, startCache,
fetchPersistentState);
+ return createCache(sync, useMarshalling, getDefaultCacheLoader(),
cacheLoaderAsync, startCache, fetchPersistentState);
}
else
{
- return createCache(cacheID, sync, useMarshalling, null, cacheLoaderAsync,
startCache, fetchPersistentState);
+ return createCache(sync, useMarshalling, null, cacheLoaderAsync, startCache,
fetchPersistentState);
}
}
- protected CacheSPI<Object, Object> createCache(String cacheID, boolean sync,
boolean useMarshalling, String cacheLoaderClass,
+
+ protected CacheSPI<Object, Object> createCache(boolean sync, boolean
useMarshalling, String cacheLoaderClass,
boolean cacheLoaderAsync, boolean
startCache, boolean fetchPersistentState) throws Exception
{
- Map<String, Cache> caches = cachesTL.get();
+ String cacheID = getNextUniqueCacheName();
if (caches.get(cacheID) != null)
{
throw new IllegalStateException(cacheID + " already created");
@@ -136,7 +129,6 @@
c.setSyncRollbackPhase(true);
c.setSyncCommitPhase(true);
}
- //c.setClusterName("VersionedTestBase");
c.setReplVersionString(getReplicationVersion());
// Use a long timeout to facilitate setting debugger breakpoints
c.setStateRetrievalTimeout(60000);
@@ -160,7 +152,6 @@
if (startCache)
{
- tree.create();
tree.start();
}
@@ -212,12 +203,9 @@
validateMultiplexer(cache);
}
- protected void configureCacheLoader(Configuration c,
- String cacheID,
- boolean async)
- throws Exception
+ protected void configureCacheLoader(Configuration c, String cacheID, boolean async)
throws Exception
{
- configureCacheLoader(c, "org.jboss.cache.loader.FileCacheLoader",
cacheID, async, true);
+ configureCacheLoader(c, getDefaultCacheLoader(), cacheID, async, true);
}
protected void configureCacheLoader(Configuration c, String cacheloaderClass, String
cacheID,
@@ -228,47 +216,40 @@
if
(cacheloaderClass.equals("org.jboss.cache.loader.JDBCCacheLoader"))
{
Properties prop = UnitTestDatabaseManager.getTestDbProperties();
- String props = "cache.jdbc.driver =" +
prop.getProperty("cache.jdbc.driver") + "\n" +
"cache.jdbc.url="
- + prop.getProperty("cache.jdbc.url") + "\n" +
"cache.jdbc.user="
- + prop.getProperty("cache.jdbc.user") + "\n" +
"cache.jdbc.password="
- + prop.getProperty("cache.jdbc.password") + "\n" +
"cache.jdbc.node.type="
- + prop.getProperty("cache.jdbc.node.type") + "\n" +
"cache.jdbc.table.name="
- + prop.getProperty("cache.jdbc.table.name");
-
CacheLoaderConfig clc =
UnitTestConfigurationFactory.buildSingleCacheLoaderConfig(false, "",
"org.jboss.cache.loader.JDBCCacheLoader",
- props, false, true, false, false, false);
+ prop, false, true, false, false, false);
clc.getFirstCacheLoaderConfig().setPurgeOnStartup(true);
c.setCacheLoaderConfig(clc);
- }
- else
+ } else if (cacheloaderClass.equals(FileCacheLoader.class.getName()))
{
-
- String tmp_location = getTempLocation(cacheID);
-
- // Do cleanup in case it failed before
- File file = new File(tmp_location);
+ String tmpLocation = getTempLocation(cacheID);
+ File file = new File(tmpLocation);
cleanFile(file);
-
file.mkdir();
-
- tmp_location = escapeWindowsPath(tmp_location);
- String props = "location = " + tmp_location + "\n";
+ tmpLocation = escapeWindowsPath(tmpLocation);
+ String props = "location = " + tmpLocation + "\n";
c.setCacheLoaderConfig(UnitTestConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", cacheloaderClass,
props, async, fetchPersistentState, false, false, false));
}
+ else
+ {
+ assert !cacheloaderClass.equals(FileCacheLoader.class.getName());
+
c.setCacheLoaderConfig(UnitTestConfigurationFactory.buildSingleCacheLoaderConfig(false,
"", cacheloaderClass,
+ "", async, fetchPersistentState, false, false, false));
+ }
}
}
protected void initialStateTferWithLoaderTest(String cacheLoaderClass1, String
cacheLoaderClass2, boolean asyncLoader) throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false,
false, cacheLoaderClass1, false, true, true);
+ CacheSPI<Object, Object> cache1 = createCache(false, false,
cacheLoaderClass1, false, true, true);
cache1.put(A_B, "name", JOE);
cache1.put(A_B, "age", TWENTY);
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false,
false, cacheLoaderClass2, asyncLoader, true, true);
+ CacheSPI<Object, Object> cache2 = createCache(false, false,
cacheLoaderClass2, asyncLoader, true, true);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -277,6 +258,24 @@
CacheLoader loader = cache2.getCacheLoaderManager().getCacheLoader();
+ long start = System.currentTimeMillis();
+ while (asyncLoader && System.currentTimeMillis() - start < 10000)
+ {
+ try
+ {
+ doAssertion(cache2, loader);
+ break;
+ } catch (Throwable ae)
+ {
+ //allow this within the timeout
+ }
+ }
+ doAssertion(cache2, loader);
+ }
+
+ private void doAssertion(CacheSPI<Object, Object> cache2, CacheLoader loader)
+ throws Exception
+ {
assertEquals("Incorrect loader name for /a/b", JOE,
loader.get(A_B).get("name"));
assertEquals("Incorrect loader age for /a/b", TWENTY,
loader.get(A_B).get("age"));
assertEquals("Incorrect loader name for /a/c", BOB,
loader.get(A_C).get("name"));
@@ -318,22 +317,17 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
- {
- Map<String, Cache> caches = new HashMap<String, Cache>();
- cachesTL.set(caches);
+ {caches = new HashMap<String, Cache>();
// Save the TCL in case a test changes it
- ClassLoader orig_TCL = Thread.currentThread().getContextClassLoader();
- orig_TCL_TL.set(orig_TCL);
+ orig_TCL = Thread.currentThread().getContextClassLoader();
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- Map<String, Cache> caches = cachesTL.get();
-
// Restore the TCL in case a test changed it
- Thread.currentThread().setContextClassLoader(orig_TCL_TL.get());
+ Thread.currentThread().setContextClassLoader(orig_TCL);
for (String cacheID : caches.keySet())
{
@@ -356,7 +350,6 @@
{
TestingUtil.killCaches(c);
}
- cachesTL.set(null);
}
protected void stopCache(Cache cache)
@@ -430,7 +423,7 @@
boolean activateRoot)
throws Exception
{
- this.cache = createCache(name, sync, true, false);
+ this.cache = createCache(sync, true, false);
this.semaphore = semaphore;
this.name = name;
@@ -446,7 +439,7 @@
boolean activateRoot, long stateRetrievalTimeout)
throws Exception
{
- cache = createCache(name, sync, true, false, false, false, true);
+ cache = createCache(sync, true, false, false, false, true);
cache.getConfiguration().setStateRetrievalTimeout(stateRetrievalTimeout);
cache.start();
this.semaphore = semaphore;
@@ -520,4 +513,14 @@
}
}
}
+
+ protected String getDefaultCacheLoader()
+ {
+ return
org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader.class.getName();
+ }
+
+ private String getNextUniqueCacheName()
+ {
+ return getClass().getSimpleName() + cacheCount++;
+ }
}
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java 2009-02-04
14:19:55 UTC (rev 7637)
+++
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java 2009-02-04
14:32:09 UTC (rev 7638)
@@ -4,6 +4,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.factories.UnitTestConfigurationFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.transaction.DummyTransactionManager;
import org.jboss.cache.util.TestingUtil;
@@ -85,8 +86,8 @@
{
Writer writer;
Configuration cfg1, cfg2;
- cfg1 = new Configuration();
- cfg2 = new Configuration();
+ cfg1 =
UnitTestConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC);
+ cfg2 =
UnitTestConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC);
cfg1.setCacheMode(Configuration.CacheMode.REPL_SYNC);
cfg2.setCacheMode(Configuration.CacheMode.REPL_SYNC);