Conditionally (and recursively) remove the test directory of the forked GemFire/Geode server process.

This commit is contained in:
John Blum
2022-10-13 15:58:06 -07:00
parent 1617173c44
commit 218aec18ea
2 changed files with 19 additions and 5 deletions

View File

@@ -36,7 +36,6 @@ import org.apache.geode.cache.server.CacheServer;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.data.gemfire.tests.process.ProcessWrapper;
import org.springframework.data.gemfire.tests.util.FileSystemUtils;
import org.springframework.data.gemfire.tests.util.SocketUtils;
import org.springframework.data.gemfire.util.ArrayUtils;
import org.springframework.lang.NonNull;
@@ -172,7 +171,7 @@ public abstract class ClientServerIntegrationTestsSupport extends IntegrationTes
it.stop(duration);
if (it.isNotRunning() && isDeleteDirectoryOnExit()) {
FileSystemUtils.deleteRecursive(it.getWorkingDirectory());
removeRecursiveDirectory(it.getWorkingDirectory());
}
return it.isRunning();

View File

@@ -55,8 +55,15 @@ import org.springframework.lang.Nullable;
* and bootstrap Apache Geode or VMware GemFire Server {@link Cache} and {@link ClientCache} applications.
*
* @author John Blum
* @see java.io.File
* @see java.net.InetAddress
* @see org.apache.geode.cache.Cache
* @see org.apache.geode.cache.client.ClientCache
* @see org.springframework.context.ApplicationContext
* @see org.springframework.context.annotation.Bean
* @see org.springframework.context.annotation.Configuration
* @see org.springframework.context.event.ContextRefreshedEvent
* @see org.springframework.context.event.EventListener
* @see org.springframework.data.gemfire.config.annotation.CacheServerApplication
* @see org.springframework.data.gemfire.config.annotation.ClientCacheApplication
* @see org.springframework.data.gemfire.config.annotation.EnablePdx
@@ -70,6 +77,8 @@ import org.springframework.lang.Nullable;
@SuppressWarnings("unused")
public abstract class ForkingClientServerIntegrationTestsSupport extends ClientServerIntegrationTestsSupport {
protected static final String REMOVE_TEST_DIRECTORY_PROPERTY = "spring.data.gemfire.test.directory.remove";
private static ProcessWrapper gemfireServer;
public static @NonNull ProcessWrapper startGemFireServer(@NonNull Class<?> gemfireServerMainClass,
@@ -222,7 +231,15 @@ public abstract class ForkingClientServerIntegrationTestsSupport extends ClientS
@AfterClass
public static void stopGemFireServer() {
getGemFireServerProcess().ifPresent(ForkingClientServerIntegrationTestsSupport::stop);
if (Boolean.parseBoolean(System.getProperty(REMOVE_TEST_DIRECTORY_PROPERTY, Boolean.TRUE.toString()))) {
getGemFireServerProcess()
.map(ProcessWrapper::getWorkingDirectory)
.ifPresent(IntegrationTestsSupport::removeRecursiveDirectory);
}
setGemFireServerProcess(null);
}
@@ -242,9 +259,7 @@ public abstract class ForkingClientServerIntegrationTestsSupport extends ClientS
@EnablePdx
@ClientCacheApplication
public static class BaseGemFireClientConfiguration extends ClientServerIntegrationTestsConfiguration {
}
public static class BaseGemFireClientConfiguration extends ClientServerIntegrationTestsConfiguration { }
@EnablePdx
@CacheServerApplication(name = "ForkingClientServerIntegrationTestsSupport")