Fixed failing Spring GemFire integration tests (whem mocking is disabled) during the Nightly build: CacheNamespaceTest.testCacheWithAutoReconnectEnabled as well as all test cases in the DiskStoreAndEvictionRegionParsingTest test suite class. The test failures were caused by the introduction of the GemFire 8 dependency and new constraint enforcements. Also made additional modifications and cleanup to the CacheClusterConfigurationIntegrationTests and related classes/components and files in an attempt to get the test passing reliably in the Bamboo CI env. Seems a race condition is occuring between the time the Locator starts along with when the shared, cluster-based configuration service is actually running and when the GemFire Server date node (test class) requests the shared, persistent, cluster configuration from the Locator.
This commit is contained in:
@@ -137,14 +137,14 @@ public class CacheClusterConfigurationIntegrationTest {
|
||||
locatorProcess = ProcessExecutor.launch(locatorWorkingDirectory, LocatorProcess.class,
|
||||
arguments.toArray(new String[arguments.size()]));
|
||||
|
||||
locatorProcess.registerShutdownHook();
|
||||
|
||||
locatorProcess.register(new ProcessInputStreamListener() {
|
||||
@Override public void onInput(final String input) {
|
||||
locatorProcessOutput.add(input);
|
||||
}
|
||||
});
|
||||
|
||||
locatorProcess.registerShutdownHook();
|
||||
|
||||
waitForLocatorStart(TimeUnit.SECONDS.toMillis(30));
|
||||
|
||||
System.out.println("Cluster Configuration Locator should be running!");
|
||||
|
||||
@@ -147,8 +147,11 @@ public class CacheNamespaceTest{
|
||||
|
||||
Cache gemfireCache = context.getBean("cache-with-auto-reconnect-enabled", Cache.class);
|
||||
|
||||
assertFalse(Boolean.parseBoolean(gemfireCache.getDistributedSystem().getProperties()
|
||||
.getProperty("disable-auto-reconnect")));
|
||||
boolean expected = Boolean.getBoolean("org.springframework.data.gemfire.test.GemfireTestRunner.nomock");
|
||||
boolean actual = Boolean.parseBoolean(gemfireCache.getDistributedSystem().getProperties()
|
||||
.getProperty("disable-auto-reconnect"));
|
||||
|
||||
assertEquals(String.format("Expected 'disable-auto-reconnect' to be %1$s!", expected), expected, actual);
|
||||
|
||||
CacheFactoryBean cacheFactoryBean = context.getBean("&cache-with-auto-reconnect-enabled", CacheFactoryBean.class);
|
||||
|
||||
@@ -161,8 +164,8 @@ public class CacheNamespaceTest{
|
||||
|
||||
CacheFactoryBean cacheFactoryBean = context.getBean("&heap-tuned-cache", CacheFactoryBean.class);
|
||||
|
||||
Float criticalHeapPercentage = (Float) TestUtils.readField("criticalHeapPercentage", cacheFactoryBean);
|
||||
Float evictionHeapPercentage = (Float) TestUtils.readField("evictionHeapPercentage", cacheFactoryBean);
|
||||
Float criticalHeapPercentage = TestUtils.readField("criticalHeapPercentage", cacheFactoryBean);
|
||||
Float evictionHeapPercentage = TestUtils.readField("evictionHeapPercentage", cacheFactoryBean);
|
||||
|
||||
assertEquals(70.0f, criticalHeapPercentage, 0.0001);
|
||||
assertEquals(60.0f, evictionHeapPercentage, 0.0001);
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.springframework.data.gemfire.TestUtils;
|
||||
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.CustomExpiry;
|
||||
@@ -58,10 +59,11 @@ import com.gemstone.gemfire.cache.util.ObjectSizer;
|
||||
/**
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations="diskstore-ns.xml",
|
||||
initializers=GemfireTestApplicationContextInitializer.class)
|
||||
@ContextConfiguration(locations="diskstore-ns.xml", initializers=GemfireTestApplicationContextInitializer.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class DiskStoreAndEvictionRegionParsingTest {
|
||||
|
||||
@Autowired
|
||||
@@ -70,26 +72,19 @@ public class DiskStoreAndEvictionRegionParsingTest {
|
||||
@Autowired
|
||||
DiskStore diskStore1;
|
||||
|
||||
private static File diskStoreDir;
|
||||
private static File diskStoreDirectory;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
String path = "./build/tmp";
|
||||
diskStoreDir = new File(path);
|
||||
if (!diskStoreDir.exists()) {
|
||||
diskStoreDir.mkdir();
|
||||
}
|
||||
diskStoreDirectory = new File("./build/tmp");
|
||||
assertTrue(diskStoreDirectory.isDirectory() || diskStoreDirectory.mkdir());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
for (File file : diskStoreDir.listFiles()) {
|
||||
file.delete();
|
||||
}
|
||||
diskStoreDir.delete();
|
||||
FileSystemUtils.deleteRecursively(diskStoreDirectory);
|
||||
|
||||
for (String name : new File(".").list(new FilenameFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.startsWith("BACKUPds");
|
||||
@@ -110,14 +105,14 @@ public class DiskStoreAndEvictionRegionParsingTest {
|
||||
assertEquals(true, diskStore1.getAutoCompact());
|
||||
assertEquals(DiskStoreFactory.DEFAULT_COMPACTION_THRESHOLD, diskStore1.getCompactionThreshold());
|
||||
assertEquals(9999, diskStore1.getTimeInterval());
|
||||
assertEquals(10, diskStore1.getMaxOplogSize());
|
||||
assertEquals(diskStoreDir, diskStore1.getDiskDirs()[0]);
|
||||
assertEquals(1, diskStore1.getMaxOplogSize());
|
||||
assertEquals(diskStoreDirectory, diskStore1.getDiskDirs()[0]);
|
||||
Cache cache = context.getBean("gemfireCache", Cache.class);
|
||||
assertSame(diskStore1, cache.findDiskStore("diskStore1"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testReplicaDataOptions() throws Exception {
|
||||
assertTrue(context.containsBean("replicated-data"));
|
||||
RegionFactoryBean fb = context.getBean("&replicated-data", RegionFactoryBean.class);
|
||||
@@ -134,8 +129,8 @@ public class DiskStoreAndEvictionRegionParsingTest {
|
||||
assertNull(evicAttr.getObjectSizer());
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testPartitionDataOptions() throws Exception {
|
||||
assertTrue(context.containsBean("partition-data"));
|
||||
RegionFactoryBean fb = context.getBean("&partition-data", RegionFactoryBean.class);
|
||||
@@ -153,8 +148,8 @@ public class DiskStoreAndEvictionRegionParsingTest {
|
||||
assertEquals(SimpleObjectSizer.class, sizer.getClass());
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testEntryTtl() throws Exception {
|
||||
assertTrue(context.containsBean("replicated-data"));
|
||||
RegionFactoryBean fb = context.getBean("&replicated-data", RegionFactoryBean.class);
|
||||
@@ -178,8 +173,8 @@ public class DiskStoreAndEvictionRegionParsingTest {
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testCustomExpiry() throws Exception {
|
||||
assertTrue(context.containsBean("replicated-data-custom-expiry"));
|
||||
RegionFactoryBean fb = context.getBean("&replicated-data-custom-expiry", RegionFactoryBean.class);
|
||||
@@ -198,8 +193,7 @@ public class DiskStoreAndEvictionRegionParsingTest {
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -209,7 +203,6 @@ public class DiskStoreAndEvictionRegionParsingTest {
|
||||
public ExpirationAttributes getExpiry(Entry<K, V> entry) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.data.gemfire.process.support.ProcessUtils;
|
||||
import org.springframework.data.gemfire.test.support.FileSystemUtils;
|
||||
import org.springframework.data.gemfire.test.support.ThreadUtils;
|
||||
|
||||
import com.gemstone.gemfire.distributed.LocatorLauncher;
|
||||
@@ -47,13 +48,14 @@ public class LocatorProcess {
|
||||
public static final String DEFAULT_LOG_LEVEL = "config";
|
||||
|
||||
public static void main(final String... args) throws IOException {
|
||||
//runLocator();
|
||||
runInternalLocator();
|
||||
|
||||
registerShutdownHook();
|
||||
|
||||
waitForLocatorStart(TimeUnit.SECONDS.toMillis(20));
|
||||
waitForLocatorStart(TimeUnit.SECONDS.toMillis(30));
|
||||
|
||||
ProcessUtils.writePid(new File(System.getProperty("user.dir"), getLocatorProcessControlFilename()),
|
||||
ProcessUtils.writePid(new File(FileSystemUtils.WORKING_DIRECTORY, getLocatorProcessControlFilename()),
|
||||
ProcessUtils.currentPid());
|
||||
|
||||
ProcessUtils.waitForStopSignal();
|
||||
@@ -63,19 +65,10 @@ public class LocatorProcess {
|
||||
return LocatorProcess.class.getSimpleName().toLowerCase().concat(".pid");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static LocatorLauncher runLocator() {
|
||||
LocatorLauncher locatorLauncher = buildLocatorLauncher();
|
||||
|
||||
// start the GemFire Locator process...
|
||||
locatorLauncher.start();
|
||||
|
||||
return locatorLauncher;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static InternalLocator runInternalLocator() throws IOException {
|
||||
String hostnameForClients = System.getProperty("spring.gemfire.hostname-for-clients", DEFAULT_HOSTNAME_FOR_CLIENTS);
|
||||
String hostnameForClients = System.getProperty("spring.gemfire.hostname-for-clients",
|
||||
DEFAULT_HOSTNAME_FOR_CLIENTS);
|
||||
|
||||
int locatorPort = Integer.getInteger("spring.gemfire.locator-port", DEFAULT_LOCATOR_PORT);
|
||||
|
||||
@@ -87,8 +80,10 @@ public class LocatorProcess {
|
||||
String.valueOf(Boolean.getBoolean("spring.gemfire.enable-cluster-configuration")));
|
||||
distributedSystemProperties.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME,
|
||||
System.getProperty("spring.gemfire.http-service-port", DEFAULT_HTTP_SERVICE_PORT));
|
||||
distributedSystemProperties.setProperty(DistributionConfig.JMX_MANAGER_NAME, String.valueOf(Boolean.TRUE));
|
||||
distributedSystemProperties.setProperty(DistributionConfig.JMX_MANAGER_START_NAME, String.valueOf(Boolean.FALSE));
|
||||
distributedSystemProperties.setProperty(DistributionConfig.JMX_MANAGER_NAME,
|
||||
System.getProperty("spring.gemfire.jmx-manager", Boolean.TRUE.toString()));
|
||||
distributedSystemProperties.setProperty(DistributionConfig.JMX_MANAGER_START_NAME,
|
||||
System.getProperty("spring.gemfire.jmx-manager-start", Boolean.FALSE.toString()));
|
||||
distributedSystemProperties.setProperty(DistributionConfig.LOAD_CLUSTER_CONFIG_FROM_DIR_NAME,
|
||||
String.valueOf(loadClusterConfigurationFromDirectory));
|
||||
distributedSystemProperties.setProperty(DistributionConfig.LOG_LEVEL_NAME,
|
||||
@@ -98,6 +93,16 @@ public class LocatorProcess {
|
||||
true, true, hostnameForClients, loadClusterConfigurationFromDirectory);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static LocatorLauncher runLocator() {
|
||||
LocatorLauncher locatorLauncher = buildLocatorLauncher();
|
||||
|
||||
// start the GemFire Locator process...
|
||||
locatorLauncher.start();
|
||||
|
||||
return locatorLauncher;
|
||||
}
|
||||
|
||||
private static LocatorLauncher buildLocatorLauncher() {
|
||||
return new LocatorLauncher.Builder()
|
||||
.setMemberName(DEFAULT_GEMFIRE_MEMBER_NAME)
|
||||
@@ -125,18 +130,16 @@ public class LocatorProcess {
|
||||
private static void registerShutdownHook() {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
||||
@Override public void run() {
|
||||
stopSharedConfigurationService();
|
||||
stopLocator(stopSharedConfigurationService(InternalLocator.getLocator()));
|
||||
}
|
||||
|
||||
LocatorLauncher instance = LocatorLauncher.getInstance();
|
||||
|
||||
if (instance != null) {
|
||||
instance.stop();
|
||||
private void stopLocator(final InternalLocator locator) {
|
||||
if (locator != null) {
|
||||
locator.stop();
|
||||
}
|
||||
}
|
||||
|
||||
private void stopSharedConfigurationService() {
|
||||
InternalLocator locator = InternalLocator.getLocator();
|
||||
|
||||
private InternalLocator stopSharedConfigurationService(final InternalLocator locator) {
|
||||
if (isClusterConfigurationEnabled(locator)) {
|
||||
SharedConfiguration sharedConfiguration = locator.getSharedConfiguration();
|
||||
|
||||
@@ -146,6 +149,8 @@ public class LocatorProcess {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return locator;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.gemfire.test.support.FileSystemUtils;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -39,21 +40,14 @@ import org.springframework.util.StringUtils;
|
||||
@SuppressWarnings("unused")
|
||||
public abstract class ProcessExecutor {
|
||||
|
||||
protected static final File JAVA_EXE = new File(new File(FileSystemUtils.JAVA_HOME, "bin"), "java");
|
||||
|
||||
protected static final String JAVA_CLASSPATH = System.getProperty("java.class.path");
|
||||
|
||||
protected static final String JAVA_HOME = System.getProperty("java.home");
|
||||
|
||||
protected static final String JAVA_EXE = JAVA_HOME.concat(File.separator).concat("bin")
|
||||
.concat(File.separator).concat("java");
|
||||
|
||||
protected static final String SPRING_GEMFIRE_SYSTEM_PROPERTY_PREFIX = "spring.gemfire.";
|
||||
|
||||
protected static final String USER_HOME = System.getProperty("user.home");
|
||||
|
||||
protected static final String USER_WORKING_DIRECTORY = System.getProperty("user.dir");
|
||||
|
||||
public static ProcessWrapper launch(final Class<?> type, final String... args) throws IOException {
|
||||
return launch(new File(USER_WORKING_DIRECTORY), type, args);
|
||||
return launch(FileSystemUtils.WORKING_DIRECTORY, type, args);
|
||||
}
|
||||
|
||||
public static ProcessWrapper launch(final File workingDirectory, final Class<?> type, final String... args)
|
||||
@@ -83,7 +77,7 @@ public abstract class ProcessExecutor {
|
||||
List<String> command = new ArrayList<String>();
|
||||
List<String> programArgs = Collections.emptyList();
|
||||
|
||||
command.add(JAVA_EXE);
|
||||
command.add(JAVA_EXE.getAbsolutePath());
|
||||
command.add("-server");
|
||||
command.add("-classpath");
|
||||
command.add(JAVA_CLASSPATH);
|
||||
|
||||
@@ -36,6 +36,12 @@ import com.gemstone.gemfire.management.internal.cli.util.spring.Assert;
|
||||
@SuppressWarnings("unused")
|
||||
public abstract class FileSystemUtils extends IOUtils {
|
||||
|
||||
public static final File JAVA_HOME = new File(System.getProperty("java.home"));
|
||||
|
||||
public static final File USER_HOME = new File(System.getProperty("user.home"));
|
||||
|
||||
public static final File WORKING_DIRECTORY = new File(System.getProperty("user.dir"));
|
||||
|
||||
public static File[] listFiles(final File directory, final FileFilter fileFilter) {
|
||||
Assert.isTrue(directory != null && directory.isDirectory(), String.format(
|
||||
"The File (%1$s) does not refer to a valid directory!", directory));
|
||||
|
||||
Reference in New Issue
Block a user