From 1f91adabaa07607d5d0d7f53227f3c685917250f Mon Sep 17 00:00:00 2001 From: Jens Deppe Date: Thu, 30 Apr 2020 07:24:07 -0700 Subject: [PATCH] GEODE-8050: Ensure tests cleanup consistently to allow running them all within one JVM instance Authored-by: Jens Deppe --- .../apache/geode/redis/HashesIntegrationTest.java | 5 +++++ .../redis/RedisLockServiceIntegrationTest.java | 5 +++++ .../geode/redis/general/PexpireIntegrationTest.java | 13 +++++++++++++ 3 files changed, 23 insertions(+) diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/HashesIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/HashesIntegrationTest.java index dfe7fd70143f..32c045333f74 100755 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/HashesIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/HashesIntegrationTest.java @@ -52,8 +52,10 @@ import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Test; +import org.junit.contrib.java.lang.system.RestoreSystemProperties; import org.junit.experimental.categories.Category; import redis.clients.jedis.Jedis; import redis.clients.jedis.ScanResult; @@ -76,6 +78,9 @@ public class HashesIntegrationTest { private static int port = 6379; private static int ITERATION_COUNT = 4000; + @ClassRule + public static RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties(); + @BeforeClass public static void setUp() throws IOException { rand = new Random(); diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/RedisLockServiceIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/RedisLockServiceIntegrationTest.java index 24194d6f9231..b23ac78494fb 100644 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/RedisLockServiceIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/RedisLockServiceIntegrationTest.java @@ -23,7 +23,9 @@ import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Test; +import org.junit.contrib.java.lang.system.RestoreSystemProperties; import redis.clients.jedis.Jedis; import org.apache.geode.cache.CacheFactory; @@ -39,6 +41,9 @@ public class RedisLockServiceIntegrationTest { private static Jedis jedis; private static int port = 6379; + @ClassRule + public static RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties(); + @BeforeClass public static void setUp() { CacheFactory cf = new CacheFactory(); diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/PexpireIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/PexpireIntegrationTest.java index e16a086d889e..689df5a11420 100644 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/PexpireIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/PexpireIntegrationTest.java @@ -15,6 +15,9 @@ package org.apache.geode.redis.general; +import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; +import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL; +import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; import static org.assertj.core.api.Assertions.assertThat; import org.junit.AfterClass; @@ -22,6 +25,8 @@ import org.junit.Test; import redis.clients.jedis.Jedis; +import org.apache.geode.cache.CacheFactory; +import org.apache.geode.cache.GemFireCache; import org.apache.geode.internal.AvailablePortHelper; import org.apache.geode.redis.GeodeRedisServer; @@ -30,11 +35,18 @@ public class PexpireIntegrationTest { public static Jedis jedis; public static int REDIS_CLIENT_TIMEOUT = 10000000; private static GeodeRedisServer server; + private static GemFireCache cache; @BeforeClass public static void setUp() { int port = AvailablePortHelper.getRandomAvailableTCPPort(); + CacheFactory cf = new CacheFactory(); + cf.set(LOG_LEVEL, "error"); + cf.set(MCAST_PORT, "0"); + cf.set(LOCATORS, ""); + cache = cf.create(); + server = new GeodeRedisServer("localhost", port); server.start(); jedis = new Jedis("localhost", port, REDIS_CLIENT_TIMEOUT); @@ -43,6 +55,7 @@ public static void setUp() { @AfterClass public static void classLevelTearDown() { jedis.close(); + cache.close(); server.shutdown(); }