JBoss Cache SVN: r7576 - core/trunk/src/test/java/org/jboss/cache/eviction.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2009-01-22 16:38:45 -0500 (Thu, 22 Jan 2009)
New Revision: 7576
Modified:
core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java
Log:
fix tests on jdk5
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java 2009-01-22 21:34:38 UTC (rev 7575)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java 2009-01-22 21:38:45 UTC (rev 7576)
@@ -84,7 +84,7 @@
assertNotNull(cache.getNode(fqn3));
assertNotNull(cache.getNode(fqn4));
- Thread.sleep(1500);
+ Thread.sleep(2000);
ec.startEviction();
log.info("should remove 1 and 3 now");
15 years, 11 months
JBoss Cache SVN: r7575 - core/trunk/src/test/java/org/jboss/cache/buddyreplication.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2009-01-22 16:34:38 -0500 (Thu, 22 Jan 2009)
New Revision: 7575
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesNoPoolNoDataGravitationTest.java
Log:
fix tests on jdk5
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesNoPoolNoDataGravitationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesNoPoolNoDataGravitationTest.java 2009-01-22 21:19:34 UTC (rev 7574)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesNoPoolNoDataGravitationTest.java 2009-01-22 21:34:38 UTC (rev 7575)
@@ -16,7 +16,7 @@
/**
* @author Mircea.Markus(a)jboss.com
*/
-@Test(groups = "functional", testName = "buddyreplication.Buddy3NodesNoPoolNoDataGravitationTest")
+@Test(groups = "functional", invocationCount = 10, testName = "buddyreplication.Buddy3NodesNoPoolNoDataGravitationTest")
public class Buddy3NodesNoPoolNoDataGravitationTest extends AbstractNodeBasedBuddyTest
{
@@ -40,31 +40,6 @@
waitForBuddy(caches.get(2), caches.get(0), true);
}
- public void testRemovalFromClusterSingleBuddy() throws Exception
- {
- try
- {
- waitForBuddy(caches.get(0), caches.get(1), true);
- waitForBuddy(caches.get(1), caches.get(2), true);
- waitForBuddy(caches.get(2), caches.get(0), true);
-
- // now remove a cache from the cluster
- caches.get(2).stop();
-
- TestingUtil.sleepThread(getSleepTimeout());
-
- // now test new buddy groups
- waitForBuddy(caches.get(0), caches.get(1), true);
- waitForBuddy(caches.get(1), caches.get(0), true);
- assertNoLocks(caches);
- }
- finally
- {
- caches.get(2).start();
- replListener.set(2, ReplicationListener.getReplicationListener(caches.get(2)));
- }
- }
-
public void testSimplePut() throws Exception
{
String fqn = "/test";
@@ -169,4 +144,29 @@
assertFalse(caches.get(0).exists(backupFqn));
}
+ @Test(dependsOnMethods = {"testSingleBuddy", "testSimplePut", "testPutAndRemove", "testDataReplicationSuppression"})
+ public void testRemovalFromClusterSingleBuddy() throws Exception
+ {
+ try
+ {
+ waitForBuddy(caches.get(0), caches.get(1), true);
+ waitForBuddy(caches.get(1), caches.get(2), true);
+ waitForBuddy(caches.get(2), caches.get(0), true);
+
+ // now remove a cache from the cluster
+ caches.get(2).stop();
+
+ TestingUtil.sleepThread(getSleepTimeout());
+
+ // now test new buddy groups
+ waitForBuddy(caches.get(0), caches.get(1), true);
+ waitForBuddy(caches.get(1), caches.get(0), true);
+ assertNoLocks(caches);
+ }
+ finally
+ {
+ caches.get(2).start();
+ replListener.set(2, ReplicationListener.getReplicationListener(caches.get(2)));
+ }
+ }
}
15 years, 11 months
JBoss Cache SVN: r7574 - core/trunk/src/test/java/org/jboss/cache/buddyreplication.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2009-01-22 16:19:34 -0500 (Thu, 22 Jan 2009)
New Revision: 7574
Removed:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/RemoveRootBuddyTest.java
Log:
removed test as it was doing no assertion
Deleted: core/trunk/src/test/java/org/jboss/cache/buddyreplication/RemoveRootBuddyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/RemoveRootBuddyTest.java 2009-01-22 21:17:32 UTC (rev 7573)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/RemoveRootBuddyTest.java 2009-01-22 21:19:34 UTC (rev 7574)
@@ -1,43 +0,0 @@
-package org.jboss.cache.buddyreplication;
-
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.util.internals.replicationlisteners.ReplicationListener;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Test added to replicate a found issue. When fixing it consider moving test to some other class.
- *
- * @author Mircea.Markus(a)jboss.com
- * @since 2.1
- */
-@Test(groups = {"functional"}, testName = "buddyreplication.RemoveRootBuddyTest")
-public class RemoveRootBuddyTest extends BuddyReplicationTestsBase
-{
- public void testRemoveRootNode() throws Exception
- {
- CacheSPI cache1 = createCache(false, 1, "myBuddyPoolReplicationGroup", false, true, true);
- CacheSPI cache2 = createCache(false, 1, "myBuddyPoolReplicationGroup", false, true, true);
- waitForSingleBuddy(cache1, cache2);
- ReplicationListener replicationListener2 = ReplicationListener.getReplicationListener(cache2);
- List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>(2);
- cachesTL.set(caches);
- caches.add(cache1);
- caches.add(cache2);
- int opCount = 10;
- for (int i = 0; i < opCount; i++)
- {
- String key = String.valueOf(opCount);
- String value = String.valueOf(opCount);
- Fqn f = Fqn.fromElements("test", key);
- replicationListener2.expect(PutKeyValueCommand.class);
- cache1.put(f, key, value);
- replicationListener2.waitForReplicationToOccur();
- }
- cache1.removeNode(Fqn.ROOT);
- }
-}
15 years, 11 months
JBoss Cache SVN: r7573 - core/trunk/src/test/java/org/jboss/cache/loader.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2009-01-22 16:17:32 -0500 (Thu, 22 Jan 2009)
New Revision: 7573
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheLoaderTest.java
Log:
more strict concurrency control
Modified: core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheLoaderTest.java 2009-01-22 21:02:49 UTC (rev 7572)
+++ core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheLoaderTest.java 2009-01-22 21:17:32 UTC (rev 7573)
@@ -29,7 +29,7 @@
* @author Bela Ban
* @version $Id$
*/
-@Test(groups = "functional", enabled = true, testName = "loader.TcpCacheLoaderTest", sequential = true)
+@Test(groups = "functional", testName = "loader.TcpCacheLoaderTest")
public class TcpCacheLoaderTest extends CacheLoaderTestsBase
{
protected static final String TCP_CACHE_SERVER_HOST = "127.0.0.1";
@@ -282,7 +282,7 @@
int startAfter;
@NodeCreated
- public void restart(Event e)
+ public void restart(Event e) throws InterruptedException
{
if (e.isPre())
{
@@ -293,19 +293,16 @@
else if (delayedRestart)
{
stopCacheServer();
- new Thread()
- {
- public void run()
- {
- if (startAfter > 0)
- {
- TestingUtil.sleepThread(startAfter);
- startCacheServer();
- }
- }
- }.start();
}
}
+ else
+ {
+ if (delayedRestart && startAfter>0)
+ {
+ Thread.sleep(startAfter);
+ startCacheServer();
+ }
+ }
}
}
}
15 years, 11 months
JBoss Cache SVN: r7572 - core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2009-01-22 16:02:49 -0500 (Thu, 22 Jan 2009)
New Revision: 7572
Modified:
core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRollbackTxTest.java
Log:
more strict concurrency control
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRollbackTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRollbackTxTest.java 2009-01-22 19:48:46 UTC (rev 7571)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRollbackTxTest.java 2009-01-22 21:02:49 UTC (rev 7572)
@@ -3,15 +3,19 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.transaction.AsyncRollbackTransactionManager;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
+import javax.transaction.Status;
/**
* Test behaviour of async rollback timeouted transaction
@@ -19,11 +23,11 @@
* @author <a href="mailto:jhalat@infovide.pl">Jacek Halat</a>
* @since 1.4.0
*/
-@Test(groups = {"functional"}, sequential = true, testName = "transaction.pessimistic.AsyncRollbackTxTest")
+@Test(groups = {"functional"}, testName = "transaction.pessimistic.AsyncRollbackTxTest")
public class AsyncRollbackTxTest
{
private CacheSPI<String, String> cache;
- private TransactionManager tm;
+ private AsyncRollbackTransactionManager tm;
private Fqn fqn = Fqn.fromString("/test");
// This sleep time (millis) should be longer than the transaction timeout time.
private long sleepTime = 2500;
@@ -39,7 +43,7 @@
c.setSerializationExecutorPoolSize(0);
UnitTestCacheFactory<String, String> instance = new UnitTestCacheFactory<String, String>();
cache = (CacheSPI<String, String>) instance.createCache(c, getClass());
- tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
+ tm = (AsyncRollbackTransactionManager) cache.getConfiguration().getRuntimeConfig().getTransactionManager();
tm.setTransactionTimeout(txTimeout);
}
@@ -215,8 +219,14 @@
cache.get(fqn, "k");// obtain read lock on node
}
- // sleep to ensure tx times out.
- sleep(2500);
+ for (int i =0; i < 100; i++) //max 50 secs
+ {
+ if (tm.getTransaction().getStatus() == Status.STATUS_ROLLEDBACK)
+ {
+ break;
+ }
+ Thread.sleep(500);
+ }
if (commit)
{
15 years, 11 months
JBoss Cache SVN: r7571 - in core/trunk/src/test/java/org/jboss/cache: transaction/pessimistic and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2009-01-22 14:48:46 -0500 (Thu, 22 Jan 2009)
New Revision: 7571
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/ConcurrentTransactionalTest.java
Log:
more strict replication control
Modified: core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java 2009-01-22 16:36:26 UTC (rev 7570)
+++ core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java 2009-01-22 19:48:46 UTC (rev 7571)
@@ -28,15 +28,15 @@
protected void configureCache() throws Exception
{
- configureCache("");
+ configureCache("", true);
}
- protected void configureCache(String props) throws Exception
+ protected void configureCache(String props, boolean async) throws Exception
{
cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false, getClass());
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
cache.getConfiguration().setCacheLoaderConfig(UnitTestConfigurationFactory
- .buildSingleCacheLoaderConfig(false, "", "org.jboss.cache.loader.FileCacheLoader", props, true, false, true, false, false));
+ .buildSingleCacheLoaderConfig(false, "", "org.jboss.cache.loader.FileCacheLoader", props, async, false, true, false, false));
cache.create();
cache.start();
}
@@ -84,7 +84,7 @@
configureCache(
"cache.async.put=false\n" +
"cache.async.pollWait=10000\n" +
- "");
+ "", true);
CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
Fqn fqn = Fqn.fromString("/a/b/c/d");
HashMap<Object, Object> map = new HashMap<Object, Object>();
@@ -103,7 +103,7 @@
configureCache(
"cache.async.queueSize=1\n" +
"cache.async.pollWait=10\n" +
- "");
+ "", true);
CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
Fqn fqn = Fqn.fromString("/bound");
loader.remove(fqn);
@@ -122,7 +122,7 @@
configureCache(
"cache.async.returnOld=false\n" +
"cache.async.pollWait=10\n" +
- "");
+ "", true);
CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
cache.put(Fqn.ROOT, "key1", "value1");
Thread.sleep(100);
@@ -133,12 +133,11 @@
public void testStoreState() throws Exception
{
- configureCache();
+ configureCache("", false);
Fqn X = Fqn.fromString("/x");
CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
loader.remove(X);
cache.put(X, "key1", "value1");
- Thread.sleep(1000);
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
loader.loadEntireState(os);
@@ -160,7 +159,7 @@
configureCache(
"cache.async.queueSize=1\n" +
"cache.async.pollWait=10\n" +
- "cache.async.threadPoolSize=5");
+ "cache.async.threadPoolSize=5", true);
CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
Fqn fqn = Fqn.fromString("/bound");
loader.remove(fqn);
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/ConcurrentTransactionalTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/ConcurrentTransactionalTest.java 2009-01-22 16:36:26 UTC (rev 7570)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/ConcurrentTransactionalTest.java 2009-01-22 19:48:46 UTC (rev 7571)
@@ -41,7 +41,7 @@
private volatile CacheSPI<Integer, String> cache;
private Log logger_ = LogFactory.getLog(ConcurrentTransactionalTest.class);
private volatile Throwable thread_ex = null;
- private static final int NUM = 10000;
+ private static final int NUM = 1000;
Log log = LogFactory.getLog(ConcurrentTransactionalTest.class);
private void createCache(IsolationLevel level)
@@ -166,7 +166,7 @@
tx = TransactionSetup.getUserTransaction();
for (int i = 0; i < NUM; i++)
{
- log("adding data i=" + i);
+ log(cache + " adding data i=" + i);
tx.begin();
cache.put("/a/b/c", i, val);
tx.commit();
@@ -175,7 +175,7 @@
}
catch (Throwable t)
{
- t.printStackTrace();
+ log.error("cache = " + cache + ", tx = " + tx+ t);
thread_ex = t;
}
}
15 years, 11 months