Skip to content

Commit 8f92f72

Browse files
committed
Add test logic to cleanup all Apache Geode system resources after test execution.
1 parent b49f609 commit 8f92f72

File tree

1 file changed

+64
-12
lines changed

1 file changed

+64
-12
lines changed

spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/integration/IntegrationTestsSupport.java

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@
5656
import org.apache.geode.internal.net.SSLConfigurationFactory;
5757
import org.apache.geode.internal.net.SocketCreatorFactory;
5858

59-
import org.apache.shiro.util.StringUtils;
60-
6159
import org.springframework.beans.factory.annotation.Autowired;
6260
import org.springframework.context.ApplicationContext;
6361
import org.springframework.context.ApplicationEvent;
@@ -71,6 +69,7 @@
7169
import org.springframework.data.gemfire.GemfireUtils;
7270
import org.springframework.data.gemfire.support.GemfireBeanFactoryLocator;
7371
import org.springframework.data.gemfire.tests.mock.GemFireMockObjectsSupport;
72+
import org.springframework.data.gemfire.tests.util.ComposableFileFilter;
7473
import org.springframework.data.gemfire.tests.util.FileSystemUtils;
7574
import org.springframework.data.gemfire.tests.util.FileUtils;
7675
import org.springframework.data.gemfire.util.ArrayUtils;
@@ -80,6 +79,8 @@
8079
import org.springframework.util.Assert;
8180
import org.springframework.util.ReflectionUtils;
8281

82+
import org.apache.shiro.util.StringUtils;
83+
8384
/**
8485
* Abstract base class supporting integration tests with either Apache Geode or VMware Tanzu GemFire
8586
* in a Spring context.
@@ -243,7 +244,7 @@ public static void clearAllJavaGemFireGeodeAndSpringDotPrefixedSystemProperties(
243244
/**
244245
* Clears (removes) all non-standard Spring {@link PropertySource PropertySources} from the Spring
245246
* {@link Environment} after test (class/suite) execution.
246-
*
247+
* <p>
247248
* Only {@link System#getProperties() System Properties} and {@literal Environment Variables} are standard.
248249
*
249250
* @see org.springframework.core.env.Environment
@@ -284,7 +285,7 @@ public static void closeAllBeanFactoryLocators() {
284285
* @see org.apache.geode.cache.GemFireCache
285286
*/
286287
@AfterClass
287-
public static void closeAnyGemFireCache() {
288+
public static void closeAnyApacheGeodeCache() {
288289
closeGemFireCacheWaitOnCacheClosedEvent();
289290
}
290291

@@ -294,7 +295,7 @@ public static void closeAnyGemFireCache() {
294295
* @see org.apache.geode.distributed.Locator
295296
*/
296297
@AfterClass
297-
public static void closeAnyGemFireLocator() {
298+
public static void closeAnyApacheGeodeLocator() {
298299
stopGemFireLocatorWaitOnStopEvent();
299300
}
300301

@@ -335,20 +336,71 @@ public static void closeAnySslConfiguration() {
335336
}
336337

337338
/**
338-
* Deletes any Apache Geode process ID ({@literal PID}) {@link File Files} after test (class/suite) execution.
339-
*
340-
* @see java.io.File
339+
* Deletes all and any Apache Geode {@link File files} remaining in the {@literal Filesystem}
340+
* after all Apache Geode processes have been terminated.
341341
*/
342342
@AfterClass
343-
public static void deleteAllGemFireProcessIdFiles() {
343+
public static void deleteAllApacheGeodeFilesystemFiles() {
344344

345-
FileFilter fileFilter = file -> file != null
346-
&& file.getName().startsWith("vf.gf")
347-
&& file.getName().endsWith(".pid");
345+
FileFilter fileFilter = allApacheGeodeProcessIdFilesFilter()
346+
.orThen(allApacheGeodeLocatorFilesFilter())
347+
.orThen(allApacheGeodeConfigDiskDirectoriesFilter())
348+
.orThen(allApacheGeodeBackupFilesFilter())
349+
.orThen(allApacheGeodeLogFilesFilter());
348350

349351
FileSystemUtils.deleteRecursive(FileSystemUtils.WORKING_DIRECTORY, fileFilter);
350352
}
351353

354+
/**
355+
* Return a {@link FileFilter} identifying all Apache Geode {@literal BACKUP*} {@link File Files}
356+
* in the {@literal Filesystem} after test execution.
357+
*
358+
* @see org.springframework.data.gemfire.tests.util.ComposableFileFilter
359+
*/
360+
protected static @NonNull ComposableFileFilter allApacheGeodeBackupFilesFilter() {
361+
return file -> file != null && file.getAbsolutePath().contains("BACKUP");
362+
}
363+
364+
/**
365+
* Return a {@link FileFilter} identifying all Apache Geode {@literal ConfigDiskDir} {@link File Directories}
366+
* in the {@literal Filesystem} after test execution.
367+
*
368+
* @see org.springframework.data.gemfire.tests.util.ComposableFileFilter
369+
*/
370+
protected static @NonNull ComposableFileFilter allApacheGeodeConfigDiskDirectoriesFilter() {
371+
return file -> file != null && file.getAbsolutePath().contains("ConfigDiskDir");
372+
}
373+
374+
/**
375+
* Return a {@link FileFilter} identifying all Apache Geode Locator {@link File Files}
376+
* in the {@literal Filesystem} after test execution.
377+
*
378+
* @see org.springframework.data.gemfire.tests.util.ComposableFileFilter
379+
*/
380+
protected static @NonNull ComposableFileFilter allApacheGeodeLocatorFilesFilter() {
381+
return file -> file != null && file.getName().startsWith("locator");
382+
}
383+
384+
/**
385+
* Return a {@link FileFilter} identifying all Apache Geode {@literal Log} {@link File Files}
386+
* in the {@literal Filesystem} after test execution.
387+
*
388+
* @see org.springframework.data.gemfire.tests.util.ComposableFileFilter
389+
*/
390+
protected static @NonNull ComposableFileFilter allApacheGeodeLogFilesFilter() {
391+
return file -> file != null && file.getName().endsWith(".log");
392+
}
393+
394+
/**
395+
* Return a {@link FileFilter} identifying all Apache Geode process ID ({@literal PID}) {@link File Files}
396+
* in the {@literal Filesystem} after test execution.
397+
*
398+
* @see org.springframework.data.gemfire.tests.util.ComposableFileFilter
399+
*/
400+
protected static @NonNull ComposableFileFilter allApacheGeodeProcessIdFilesFilter() {
401+
return file -> file != null && file.getName().startsWith("vf.gf") && file.getName().endsWith(".pid");
402+
}
403+
352404
/**
353405
* Destroys the use of all Apache Geode / VMware Tanzu GemFire mock objects and resources held by the mock objects
354406
* after test (class/suite) execution.

0 commit comments

Comments
 (0)