HHH-6955 Use Infinispan's test JGroups stack that uses TEST_PING

By doing this, discovery of nodes is not timed and instead is done
in-memory which is much more reliable from a testing perspective.
Due to timing issues, some tests would randomly fail because the
cluster did not form in time, so changing to this JGroups stack for
testing solves random test failures due to invalidation messages
not being sent around.
This commit is contained in:
Galder Zamarreño 2012-01-10 19:09:01 +01:00
parent cc9fbf42a9
commit 81c505c70c
3 changed files with 60 additions and 50 deletions

View File

@ -35,6 +35,8 @@ test {
systemProperties['jgroups.ping.num_initial_members'] = 1
systemProperties['jgroups.udp.enable_bundling'] = false
systemProperties['jgroups.bind_addr'] = 'localhost'
// Use Infinispan's test JGroups stack that uses TEST_PING
systemProperties['hibernate.cache.infinispan.jgroups_cfg'] = 'stacks/tcp.xml'
// systemProperties['log4j.configuration'] = 'file:/log4j/log4j-infinispan.xml'
enabled = true
}

View File

@ -11,7 +11,8 @@
<!-- Note that the JGroups transport uses sensible defaults if no configuration property is defined. -->
<properties>
<!--<property name="configurationFile" value="jgroups-tcp.xml"/>-->
<property name="configurationFile" value="tcp.xml"/>
<property name="configurationFile"
value="${hibernate.cache.infinispan.jgroups_cfg:tcp.xml}"/>
</properties>
<!-- See the JGroupsTransport javadocs for more flags -->
</transport>

View File

@ -48,6 +48,8 @@ public abstract class AbstractNonFunctionalTestCase extends org.hibernate.testin
private static final String PREFER_IPV4STACK = "java.net.preferIPv4Stack";
private String preferIPv4Stack;
private static final String JGROUPS_CFG_FILE = "hibernate.cache.infinispan.jgroups_cfg";
private String jgroupsCfgFile;
private CacheTestSupport testSupport = new CacheTestSupport();
@ -55,6 +57,8 @@ public abstract class AbstractNonFunctionalTestCase extends org.hibernate.testin
public void prepareCacheSupport() throws Exception {
preferIPv4Stack = System.getProperty(PREFER_IPV4STACK);
System.setProperty(PREFER_IPV4STACK, "true");
jgroupsCfgFile = System.getProperty(JGROUPS_CFG_FILE);
System.setProperty(JGROUPS_CFG_FILE, "stacks/tcp.xml");
testSupport.setUp();
}
@ -65,10 +69,14 @@ public abstract class AbstractNonFunctionalTestCase extends org.hibernate.testin
if (preferIPv4Stack == null) {
System.clearProperty(PREFER_IPV4STACK);
}
else {
} else {
System.setProperty(PREFER_IPV4STACK, preferIPv4Stack);
}
if (jgroupsCfgFile == null)
System.clearProperty(JGROUPS_CFG_FILE);
else
System.setProperty(JGROUPS_CFG_FILE, jgroupsCfgFile);
}
protected void registerCache(Cache cache) {
@ -94,8 +102,7 @@ public abstract class AbstractNonFunctionalTestCase extends org.hibernate.testin
protected void sleep(long ms) {
try {
Thread.sleep(ms);
}
catch (InterruptedException e) {
} catch (InterruptedException e) {
log.warn("Interrupted during sleep", e);
}
}