This is an automated email from the ASF dual-hosted git repository. jensdeppe pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push: new cf063bf GEODE-8123: Allow Redis to start on a random port (#5108) cf063bf is described below commit cf063bffb9bf226844492a5d81e915720eacb888 Author: Jens Deppe <jde...@pivotal.io> AuthorDate: Thu May 14 11:38:59 2020 -0700 GEODE-8123: Allow Redis to start on a random port (#5108) - Specify "redis-port" with a value of -1 in order to start on a random port --- .../geode/distributed/ConfigurationProperties.java | 6 +- .../distributed/internal/DistributionConfig.java | 2 +- geode-redis/build.gradle | 2 + .../apache/geode/redis/GeodeRedisServerRule.java | 80 ++++++++++++++++++++++ .../redis/GeodeRedisServerStartupDUnitTest.java | 73 ++++++++++++++++++++ .../redis/ConcurrentStartIntegrationTest.java | 4 +- .../org/apache/geode/redis/GeoIntegrationTest.java | 28 ++------ .../apache/geode/redis/HashesIntegrationTest.java | 56 +++++---------- .../apache/geode/redis/ListsIntegrationTest.java | 46 ++++--------- .../apache/geode/redis/PubSubIntegrationTest.java | 31 ++------- .../redis/RedisLockServiceIntegrationTest.java | 27 ++------ .../geode/redis/RedisServerIntegrationTest.java | 10 ++- .../apache/geode/redis/RenameIntegrationTest.java | 28 ++------ .../geode/redis/SortedSetsIntegrationTest.java | 47 ++++--------- .../apache/geode/redis/StringsIntegrationTest.java | 29 ++------ .../geode/redis/general/ExistsIntegrationTest.java | 33 +++------ .../redis/general/ExpireAtIntegrationTest.java | 27 ++------ .../geode/redis/general/ExpireIntegrationTest.java | 27 ++------ .../redis/general/PersistIntegrationTest.java | 31 +++------ .../redis/general/PexpireIntegrationTest.java | 28 ++------ .../geode/redis/sets/SDiffIntegrationTest.java | 30 ++------ .../geode/redis/sets/SInterIntegrationTest.java | 30 ++------ .../geode/redis/sets/SMoveIntegrationTest.java | 30 ++------ .../geode/redis/sets/SPopIntegrationTest.java | 30 ++------ .../geode/redis/sets/SRemIntegrationTest.java | 30 ++------ .../geode/redis/sets/SUnionIntegrationTest.java | 30 ++------ .../geode/redis/sets/SetsIntegrationTest.java | 30 ++------ .../geode/redis/internal/GeodeRedisServer.java | 29 ++++++-- .../geode/redis/internal/GeodeRedisService.java | 8 ++- 29 files changed, 354 insertions(+), 508 deletions(-) diff --git a/geode-core/src/main/java/org/apache/geode/distributed/ConfigurationProperties.java b/geode-core/src/main/java/org/apache/geode/distributed/ConfigurationProperties.java index edb27f7..a55ba4c 100644 --- a/geode-core/src/main/java/org/apache/geode/distributed/ConfigurationProperties.java +++ b/geode-core/src/main/java/org/apache/geode/distributed/ConfigurationProperties.java @@ -1918,11 +1918,11 @@ public interface ConfigurationProperties { * </p> * <U>Description</U>: Specifies the port used by {@code GeodeRedisServer} which enables redis * clients to connect and store data in GemFire distributed system. see {@code GeodeRedisServer} - * for other configuration options. + * for other configuration options. A value of "-1" will select a random port. * </p> - * <U>Default</U>: "0" disables GemFireMemcachedServer + * <U>Default</U>: "0" disables {@code GeodeRedisServer} * </p> - * <U>Allowed values</U>: 0..65535 + * <U>Allowed values</U>: -1..65535 */ String REDIS_PORT = "redis-port"; /** diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfig.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfig.java index 3c66211..49f45f1 100644 --- a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfig.java +++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfig.java @@ -3479,7 +3479,7 @@ public interface DistributionConfig extends Config, LogConfig, StatisticsConfig @ConfigAttributeSetter(name = REDIS_PORT) void setRedisPort(int value); - @ConfigAttribute(type = Integer.class, min = 0, max = 65535) + @ConfigAttribute(type = Integer.class, min = -1, max = 65535) String REDIS_PORT_NAME = REDIS_PORT; int DEFAULT_REDIS_PORT = 0; diff --git a/geode-redis/build.gradle b/geode-redis/build.gradle index 633c2e8..3ef3ba7 100644 --- a/geode-redis/build.gradle +++ b/geode-redis/build.gradle @@ -42,6 +42,8 @@ dependencies { testImplementation(project(':geode-junit')) testImplementation('org.mockito:mockito-core') + commonTestImplementation(project(':geode-junit')) + integrationTestImplementation(project(':geode-dunit')) integrationTestImplementation(project(':geode-junit')) integrationTestImplementation(sourceSets.commonTest.output) diff --git a/geode-redis/src/commonTest/java/org/apache/geode/redis/GeodeRedisServerRule.java b/geode-redis/src/commonTest/java/org/apache/geode/redis/GeodeRedisServerRule.java new file mode 100644 index 0000000..f46d4e9 --- /dev/null +++ b/geode-redis/src/commonTest/java/org/apache/geode/redis/GeodeRedisServerRule.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * + */ + +package org.apache.geode.redis; + +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.apache.geode.distributed.ConfigurationProperties.REDIS_PASSWORD; + +import org.apache.geode.cache.CacheFactory; +import org.apache.geode.cache.GemFireCache; +import org.apache.geode.redis.internal.GeodeRedisServer; +import org.apache.geode.redis.internal.KeyRegistrar; +import org.apache.geode.redis.internal.RedisLockService; +import org.apache.geode.redis.internal.RegionProvider; +import org.apache.geode.test.junit.rules.serializable.SerializableExternalResource; + +public class GeodeRedisServerRule extends SerializableExternalResource { + private GemFireCache cache; + private GeodeRedisServer server; + private String password; + private CacheFactory cacheFactory; + + public GeodeRedisServerRule() { + cacheFactory = new CacheFactory(); + + cacheFactory.set(LOG_LEVEL, "warn"); + cacheFactory.set(MCAST_PORT, "0"); + cacheFactory.set(LOCATORS, ""); + } + + @Override + protected void before() throws Throwable { + cache = cacheFactory.create(); + server = new GeodeRedisServer("localhost", -1); + server.start(); + } + + @Override + protected void after() { + cache.close(); + server.shutdown(); + } + + public GeodeRedisServerRule withPassword(String password) { + cacheFactory.set(REDIS_PASSWORD, password); + + return this; + } + + public int getPort() { + return server.getPort(); + } + + public KeyRegistrar getKeyRegistrar() { + return server.getKeyRegistrar(); + } + + public RegionProvider getRegionCache() { + return server.getRegionCache(); + } + + public RedisLockService getLockService() { + return server.getLockService(); + } +} diff --git a/geode-redis/src/distributedTest/java/org/apache/geode/redis/GeodeRedisServerStartupDUnitTest.java b/geode-redis/src/distributedTest/java/org/apache/geode/redis/GeodeRedisServerStartupDUnitTest.java new file mode 100644 index 0000000..7e7f527 --- /dev/null +++ b/geode-redis/src/distributedTest/java/org/apache/geode/redis/GeodeRedisServerStartupDUnitTest.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * + */ + +package org.apache.geode.redis; + +import static org.apache.geode.distributed.ConfigurationProperties.REDIS_BIND_ADDRESS; +import static org.apache.geode.distributed.ConfigurationProperties.REDIS_PORT; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Rule; +import org.junit.Test; + +import org.apache.geode.redis.internal.GeodeRedisServer; +import org.apache.geode.redis.internal.GeodeRedisService; +import org.apache.geode.test.dunit.rules.ClusterStartupRule; +import org.apache.geode.test.dunit.rules.MemberVM; + +public class GeodeRedisServerStartupDUnitTest { + + @Rule + public ClusterStartupRule cluster = new ClusterStartupRule(); + + @Test + public void startupOnDefaultPort() { + MemberVM server = cluster.startServerVM(0, s -> s + .withProperty(REDIS_PORT, "6379") + .withProperty(REDIS_BIND_ADDRESS, "localhost")); + + server.invoke(() -> { + GeodeRedisService service = ClusterStartupRule.getCache().getService(GeodeRedisService.class); + assertThat(service.getPort()).isEqualTo(GeodeRedisServer.DEFAULT_REDIS_SERVER_PORT); + }); + } + + @Test + public void startupOnRandomPort_whenPortIsNegativeOne() { + MemberVM server = cluster.startServerVM(0, s -> s + .withProperty(REDIS_PORT, "-1") + .withProperty(REDIS_BIND_ADDRESS, "localhost")); + + server.invoke(() -> { + GeodeRedisService service = ClusterStartupRule.getCache().getService(GeodeRedisService.class); + assertThat(service.getPort()).isNotEqualTo(GeodeRedisServer.DEFAULT_REDIS_SERVER_PORT); + }); + } + + @Test + public void doNotStartup_whenPortIsZero() { + MemberVM server = cluster.startServerVM(0, s -> s + .withProperty(REDIS_PORT, "0") + .withProperty(REDIS_BIND_ADDRESS, "localhost")); + + server.invoke(() -> { + assertThat(ClusterStartupRule.getCache().getService(GeodeRedisService.class)) + .as("GeodeRedisService should not exist") + .isNull(); + }); + } + +} diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/ConcurrentStartIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/ConcurrentStartIntegrationTest.java index e731321..91e8725 100644 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/ConcurrentStartIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/ConcurrentStartIntegrationTest.java @@ -28,7 +28,6 @@ import org.junit.experimental.categories.Category; import org.apache.geode.cache.Cache; import org.apache.geode.cache.CacheFactory; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePortHelper; import org.apache.geode.internal.cache.GemFireCacheImpl; import org.apache.geode.redis.internal.GeodeRedisServer; import org.apache.geode.test.junit.categories.RedisTest; @@ -73,12 +72,11 @@ public class ConcurrentStartIntegrationTest { } private void runNServers(int n) throws InterruptedException { - final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(numServers); final Thread[] threads = new Thread[n]; for (int i = 0; i < n; i++) { final int j = i; Runnable r = () -> { - GeodeRedisServer s = new GeodeRedisServer(ports[j]); + GeodeRedisServer s = new GeodeRedisServer(-1); s.start(); s.shutdown(); }; diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/GeoIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/GeoIntegrationTest.java index e00e1bf..14e5406 100755 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/GeoIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/GeoIntegrationTest.java @@ -14,9 +14,6 @@ */ package org.apache.geode.redis; -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 static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -30,6 +27,7 @@ import java.util.Map; import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Test; import org.junit.experimental.categories.Category; import redis.clients.jedis.GeoCoordinate; @@ -38,32 +36,18 @@ import redis.clients.jedis.GeoUnit; import redis.clients.jedis.Jedis; import redis.clients.jedis.params.GeoRadiusParam; -import org.apache.geode.cache.CacheFactory; -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.internal.AvailablePortHelper; -import org.apache.geode.redis.internal.GeodeRedisServer; import org.apache.geode.test.junit.categories.RedisTest; @Category({RedisTest.class}) public class GeoIntegrationTest { static Jedis jedis; - private static GeodeRedisServer server; - private static GemFireCache cache; - private static int port = 6379; + + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); @BeforeClass public static void setUp() { - CacheFactory cf = new CacheFactory(); - // cf.set("log-file", "redis.log"); - cf.set(LOG_LEVEL, "error"); - cf.set(MCAST_PORT, "0"); - cf.set(LOCATORS, ""); - cache = cf.create(); - port = AvailablePortHelper.getRandomAvailableTCPPort(); - server = new GeodeRedisServer("localhost", port); - - server.start(); - jedis = new Jedis("localhost", port, 10000000); + jedis = new Jedis("localhost", server.getPort(), 10000000); } @After @@ -78,8 +62,6 @@ public class GeoIntegrationTest { @AfterClass public static void tearDown() { jedis.close(); - cache.close(); - server.shutdown(); } @Test 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 2d75ab4..73a2a53 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 @@ -14,9 +14,6 @@ */ package org.apache.geode.redis; -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 static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.offset; @@ -52,6 +49,7 @@ import org.junit.After; 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.experimental.categories.Category; @@ -59,11 +57,7 @@ import redis.clients.jedis.Jedis; import redis.clients.jedis.ScanResult; import redis.clients.jedis.exceptions.JedisDataException; -import org.apache.geode.cache.CacheFactory; -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.internal.AvailablePortHelper; import org.apache.geode.redis.internal.ByteArrayWrapper; -import org.apache.geode.redis.internal.GeodeRedisServer; import org.apache.geode.test.junit.categories.RedisTest; @Category({RedisTest.class}) @@ -71,27 +65,27 @@ public class HashesIntegrationTest { static Random rand; static Jedis jedis; static Jedis jedis2; - private static GeodeRedisServer server; - private static GemFireCache cache; - private static int port = 6379; private static int ITERATION_COUNT = 4000; + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); + @BeforeClass public static void setUp() throws IOException { rand = new Random(); - CacheFactory cf = new CacheFactory(); - // cf.set("log-file", "redis.log"); - cf.set(LOG_LEVEL, "error"); - cf.set(MCAST_PORT, "0"); - cf.set(LOCATORS, ""); - cache = cf.create(); - port = AvailablePortHelper.getRandomAvailableTCPPort(); - - server = new GeodeRedisServer("localhost", port); - - server.start(); - jedis = new Jedis("localhost", port, 10000000); - jedis2 = new Jedis("localhost", port, 10000000); + jedis = new Jedis("localhost", server.getPort(), 10000000); + jedis2 = new Jedis("localhost", server.getPort(), 10000000); + } + + @After + public void flushAll() { + jedis.flushAll(); + } + + @AfterClass + public static void tearDown() { + jedis.close(); + jedis2.close(); } @Test @@ -740,20 +734,4 @@ public class HashesIntegrationTest { return RandomStringUtils.randomAlphanumeric(length); } - private int randSleepMillis() { - return rand.nextInt(10) + 5; - } - - @After - public void flushAll() { - jedis.flushAll(); - } - - @AfterClass - public static void tearDown() { - jedis.close(); - jedis2.close(); - cache.close(); - server.shutdown(); - } } diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/ListsIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/ListsIntegrationTest.java index 8ce7633..114310e 100755 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/ListsIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/ListsIntegrationTest.java @@ -14,9 +14,6 @@ */ package org.apache.geode.redis; -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.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -27,36 +24,34 @@ import java.util.Random; import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Test; import org.junit.experimental.categories.Category; 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.internal.GeodeRedisServer; import org.apache.geode.test.junit.categories.RedisTest; @Category({RedisTest.class}) public class ListsIntegrationTest { static Jedis jedis; - private static GeodeRedisServer server; - private static GemFireCache cache; private static Random rand = new Random(); - private static int port = 6379; + + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); @BeforeClass public static void setUp() { - CacheFactory cf = new CacheFactory(); - cf.set(LOG_LEVEL, "error"); - cf.set(MCAST_PORT, "0"); - cf.set(LOCATORS, ""); - cache = cf.create(); - port = AvailablePortHelper.getRandomAvailableTCPPort(); - server = new GeodeRedisServer("localhost", port); - - server.start(); - jedis = new Jedis("localhost", port, 10000000); + jedis = new Jedis("localhost", server.getPort(), 10000000); + } + + @After + public void flushAll() { + jedis.flushAll(); + } + + @AfterClass + public static void tearDown() { + jedis.close(); } @Test @@ -237,15 +232,4 @@ public class ListsIntegrationTest { return Long.toHexString(Double.doubleToLongBits(Math.random())); } - @After - public void flushAll() { - jedis.flushAll(); - } - - @AfterClass - public static void tearDown() { - jedis.close(); - cache.close(); - server.shutdown(); - } } diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/PubSubIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/PubSubIntegrationTest.java index 2d1fbe4..d4c7206 100644 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/PubSubIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/PubSubIntegrationTest.java @@ -15,9 +15,6 @@ package org.apache.geode.redis; -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 java.util.Arrays; @@ -32,10 +29,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; 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.internal.GeodeRedisServer; import org.apache.geode.redis.mocks.MockBinarySubscriber; import org.apache.geode.redis.mocks.MockSubscriber; import org.apache.geode.test.awaitility.GeodeAwaitility; @@ -47,39 +40,27 @@ public class PubSubIntegrationTest { static Jedis publisher; static Jedis subscriber; static final int REDIS_CLIENT_TIMEOUT = 100000; - private static GeodeRedisServer server; - private static GemFireCache cache; - private static int port = 6379; + + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); @ClassRule public static ExecutorServiceRule executor = new ExecutorServiceRule(); @BeforeClass public static void setUp() { - CacheFactory cf = new CacheFactory(); - cf.set(LOG_LEVEL, "info"); - cf.set(MCAST_PORT, "0"); - cf.set(LOCATORS, ""); - cache = cf.create(); - - port = AvailablePortHelper.getRandomAvailableTCPPort(); - server = new GeodeRedisServer("localhost", port); - server.start(); - - subscriber = new Jedis("localhost", port, REDIS_CLIENT_TIMEOUT); - publisher = new Jedis("localhost", port, REDIS_CLIENT_TIMEOUT); + subscriber = new Jedis("localhost", server.getPort(), REDIS_CLIENT_TIMEOUT); + publisher = new Jedis("localhost", server.getPort(), REDIS_CLIENT_TIMEOUT); } @AfterClass public static void tearDown() { subscriber.close(); publisher.close(); - cache.close(); - server.shutdown(); } public int getPort() { - return port; + return server.getPort(); } @Test 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 8b773fd..c6fe857 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 @@ -16,9 +16,6 @@ package org.apache.geode.redis; -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; @@ -28,43 +25,27 @@ import org.junit.Test; import org.junit.contrib.java.lang.system.RestoreSystemProperties; 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.internal.GeodeRedisServer; import org.apache.geode.test.awaitility.GeodeAwaitility; public class RedisLockServiceIntegrationTest { private static final int REDIS_CLIENT_TIMEOUT = 100000; - private static GeodeRedisServer server; - private static GemFireCache cache; private static Jedis jedis; - private static int port = 6379; @ClassRule public static RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties(); + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); + @BeforeClass public static void setUp() { - CacheFactory cf = new CacheFactory(); - cf.set(LOG_LEVEL, "warn"); - cf.set(MCAST_PORT, "0"); - cf.set(LOCATORS, ""); - cache = cf.create(); - - port = AvailablePortHelper.getRandomAvailableTCPPort(); - server = new GeodeRedisServer("localhost", port); - server.start(); - - jedis = new Jedis("localhost", port, REDIS_CLIENT_TIMEOUT); + jedis = new Jedis("localhost", server.getPort(), REDIS_CLIENT_TIMEOUT); } @AfterClass public static void tearDown() { jedis.close(); - cache.close(); - server.shutdown(); } @Test diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/RedisServerIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/RedisServerIntegrationTest.java index 387b01f..c83b87d 100644 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/RedisServerIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/RedisServerIntegrationTest.java @@ -29,7 +29,6 @@ import org.apache.geode.cache.Cache; import org.apache.geode.cache.CacheFactory; import org.apache.geode.cache.DataPolicy; import org.apache.geode.cache.Region; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.redis.internal.GeodeRedisServer; import org.apache.geode.test.junit.categories.RedisTest; @@ -49,7 +48,6 @@ public class RedisServerIntegrationTest { props.setProperty("mcast-port", "0"); CacheFactory cacheFactory = new CacheFactory(props); cache = cacheFactory.create(); - redisPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); } @After @@ -62,7 +60,7 @@ public class RedisServerIntegrationTest { @Test public void initializeRedisCreatesFourRegions() { - redisServer = new GeodeRedisServer(redisPort); + redisServer = new GeodeRedisServer(); redisServer.start(); assertThat(cache.rootRegions()).hasSize(4); assertThat(cache.getRegion(GeodeRedisServer.REDIS_META_DATA_REGION)).isNotNull(); @@ -70,7 +68,7 @@ public class RedisServerIntegrationTest { @Test public void initializeRedisCreatesPartitionedRegionByDefault() { - redisServer = new GeodeRedisServer(redisPort); + redisServer = new GeodeRedisServer(); redisServer.start(); Region r = cache.getRegion(GeodeRedisServer.STRING_REGION); assertThat(r.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PARTITION); @@ -80,7 +78,7 @@ public class RedisServerIntegrationTest { @Test public void initializeRedisCreatesPartitionedRegionIfSystemPropertyBogus() { System.setProperty("gemfireredis.regiontype", "bogus"); - redisServer = new GeodeRedisServer(redisPort); + redisServer = new GeodeRedisServer(); redisServer.start(); Region r = cache.getRegion(GeodeRedisServer.STRING_REGION); assertThat(r.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PARTITION); @@ -90,7 +88,7 @@ public class RedisServerIntegrationTest { @Test public void initializeRedisCreatesRegionsUsingSystemProperty() { System.setProperty("gemfireredis.regiontype", "REPLICATE"); - redisServer = new GeodeRedisServer(redisPort); + redisServer = new GeodeRedisServer(); redisServer.start(); Region r = cache.getRegion(GeodeRedisServer.STRING_REGION); assertThat(r.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.REPLICATE); diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/RenameIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/RenameIntegrationTest.java index 58c5b8e..d371717 100644 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/RenameIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/RenameIntegrationTest.java @@ -15,9 +15,6 @@ package org.apache.geode.redis; -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 static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -33,14 +30,12 @@ import java.util.concurrent.Future; import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Test; import org.junit.experimental.categories.Category; import redis.clients.jedis.Jedis; import redis.clients.jedis.exceptions.JedisDataException; -import org.apache.geode.cache.CacheFactory; -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.internal.AvailablePortHelper; import org.apache.geode.management.internal.cli.util.ThreePhraseGenerator; import org.apache.geode.redis.internal.GeodeRedisServer; import org.apache.geode.redis.internal.RedisConstants; @@ -51,35 +46,24 @@ public class RenameIntegrationTest { static Jedis jedis; static final int REDIS_CLIENT_TIMEOUT = 100000; static Random rand; - private static GeodeRedisServer server; - private static GemFireCache cache; - private static int port = 6379; private static ThreePhraseGenerator generator = new ThreePhraseGenerator(); + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); + @BeforeClass public static void setUp() { rand = new Random(); - CacheFactory cacheFactory = new CacheFactory(); - cacheFactory.set(LOG_LEVEL, "info"); - cacheFactory.set(MCAST_PORT, "0"); - cacheFactory.set(LOCATORS, ""); - cache = cacheFactory.create(); - port = AvailablePortHelper.getRandomAvailableTCPPort(); - server = new GeodeRedisServer("localhost", port); - jedis = new Jedis("localhost", port, REDIS_CLIENT_TIMEOUT); - - server.start(); + jedis = new Jedis("localhost", server.getPort(), REDIS_CLIENT_TIMEOUT); } @AfterClass public static void tearDown() { jedis.close(); - cache.close(); - server.shutdown(); } public int getPort() { - return port; + return server.getPort(); } @After diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/SortedSetsIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/SortedSetsIntegrationTest.java index c712ce0..0418049 100755 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/SortedSetsIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/SortedSetsIntegrationTest.java @@ -14,9 +14,6 @@ */ package org.apache.geode.redis; -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.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -36,37 +33,35 @@ import java.util.Set; import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Test; import org.junit.experimental.categories.Category; import redis.clients.jedis.Jedis; import redis.clients.jedis.Tuple; -import org.apache.geode.cache.CacheFactory; -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.internal.AvailablePortHelper; -import org.apache.geode.redis.internal.GeodeRedisServer; import org.apache.geode.test.junit.categories.RedisTest; @Category({RedisTest.class}) public class SortedSetsIntegrationTest { static Jedis jedis; private static Random rand = new Random(); - private static GeodeRedisServer server; - private static GemFireCache cache; - private static int port = 6379; + + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); @BeforeClass public static void setUp() { - CacheFactory cf = new CacheFactory(); - cf.set(LOG_LEVEL, "error"); - cf.set(MCAST_PORT, "0"); - cf.set(LOCATORS, ""); - cache = cf.create(); - port = AvailablePortHelper.getRandomAvailableTCPPort(); - server = new GeodeRedisServer("localhost", port); - - server.start(); - jedis = new Jedis("localhost", port, 10000000); + jedis = new Jedis("localhost", server.getPort(), 10000000); + } + + @After + public void flushAll() { + jedis.flushAll(); + } + + @AfterClass + public static void tearDown() { + jedis.close(); } @Test @@ -417,16 +412,4 @@ public class SortedSetsIntegrationTest { private String randString() { return Long.toHexString(Double.doubleToLongBits(Math.random())); } - - @After - public void flushAll() { - jedis.flushAll(); - } - - @AfterClass - public static void tearDown() { - jedis.close(); - cache.close(); - server.shutdown(); - } } diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/StringsIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/StringsIntegrationTest.java index 461cdcc..ffa2093 100755 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/StringsIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/StringsIntegrationTest.java @@ -15,9 +15,6 @@ package org.apache.geode.redis; import static java.lang.Integer.parseInt; -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.apache.geode.redis.internal.GeodeRedisServer.REDIS_META_DATA_REGION; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -39,6 +36,7 @@ import java.util.concurrent.atomic.AtomicLong; import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -46,10 +44,6 @@ import redis.clients.jedis.Jedis; import redis.clients.jedis.exceptions.JedisDataException; import redis.clients.jedis.params.SetParams; -import org.apache.geode.cache.CacheFactory; -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.internal.AvailablePortHelper; -import org.apache.geode.redis.internal.GeodeRedisServer; import org.apache.geode.redis.internal.RedisConstants; import org.apache.geode.test.awaitility.GeodeAwaitility; import org.apache.geode.test.junit.categories.RedisTest; @@ -60,25 +54,16 @@ public class StringsIntegrationTest { static Jedis jedis; static Jedis jedis2; static Random rand; - private static GeodeRedisServer server; - private static GemFireCache cache; - private static int port = 6379; private static int ITERATION_COUNT = 4000; + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); + @BeforeClass public static void setUp() { rand = new Random(); - CacheFactory cf = new CacheFactory(); - cf.set(LOG_LEVEL, "error"); - cf.set(MCAST_PORT, "0"); - cf.set(LOCATORS, ""); - cache = cf.create(); - port = AvailablePortHelper.getRandomAvailableTCPPort(); - server = new GeodeRedisServer("localhost", port); - - server.start(); - jedis = new Jedis("localhost", port, 10000000); - jedis2 = new Jedis("localhost", port, 10000000); + jedis = new Jedis("localhost", server.getPort(), 10000000); + jedis2 = new Jedis("localhost", server.getPort(), 10000000); } @After @@ -90,8 +75,6 @@ public class StringsIntegrationTest { public static void tearDown() { jedis.close(); jedis2.close(); - cache.close(); - server.shutdown(); } @Test diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/ExistsIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/ExistsIntegrationTest.java index bd5f88f..3e82fec 100644 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/ExistsIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/ExistsIntegrationTest.java @@ -15,9 +15,6 @@ 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 java.util.concurrent.atomic.AtomicLong; @@ -25,14 +22,12 @@ import java.util.concurrent.atomic.AtomicLong; import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.ClassRule; 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.ConcurrentLoopingThreads; -import org.apache.geode.redis.internal.GeodeRedisServer; +import org.apache.geode.redis.GeodeRedisServerRule; import org.apache.geode.test.awaitility.GeodeAwaitility; public class ExistsIntegrationTest { @@ -41,24 +36,16 @@ public class ExistsIntegrationTest { public static Jedis jedis2; public static Jedis jedis3; public static int REDIS_CLIENT_TIMEOUT = - Math.toIntExact(GeodeAwaitility.getTimeout().toMillis());; - private static GeodeRedisServer server; - private static GemFireCache cache; + Math.toIntExact(GeodeAwaitility.getTimeout().toMillis()); + + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); @BeforeClass public static void setUp() { - CacheFactory cf = new CacheFactory(); - cf.set(LOG_LEVEL, "error"); - cf.set(MCAST_PORT, "0"); - cf.set(LOCATORS, ""); - cache = cf.create(); - int port = AvailablePortHelper.getRandomAvailableTCPPort(); - server = new GeodeRedisServer("localhost", port); - - server.start(); - jedis = new Jedis("localhost", port, REDIS_CLIENT_TIMEOUT); - jedis2 = new Jedis("localhost", port, REDIS_CLIENT_TIMEOUT); - jedis3 = new Jedis("localhost", port, REDIS_CLIENT_TIMEOUT); + jedis = new Jedis("localhost", server.getPort(), REDIS_CLIENT_TIMEOUT); + jedis2 = new Jedis("localhost", server.getPort(), REDIS_CLIENT_TIMEOUT); + jedis3 = new Jedis("localhost", server.getPort(), REDIS_CLIENT_TIMEOUT); } @After @@ -71,8 +58,6 @@ public class ExistsIntegrationTest { jedis.close(); jedis2.close(); jedis3.close(); - cache.close(); - server.shutdown(); } @Test diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/ExpireAtIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/ExpireAtIntegrationTest.java index 598c71c..9aa29df 100644 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/ExpireAtIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/ExpireAtIntegrationTest.java @@ -15,47 +15,34 @@ 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.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.ClassRule; 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.internal.GeodeRedisServer; +import org.apache.geode.redis.GeodeRedisServerRule; import org.apache.geode.test.awaitility.GeodeAwaitility; public class ExpireAtIntegrationTest { public static Jedis jedis; public static int REDIS_CLIENT_TIMEOUT = 10000000; - private static GeodeRedisServer server; private long unixTimeStampInTheFutureInSeconds; private long unixTimeStampFromThePast = 0L; private static String key = "key"; private static String value = "value"; - private static GemFireCache cache; + + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); @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); + jedis = new Jedis("localhost", server.getPort(), REDIS_CLIENT_TIMEOUT); } @Before @@ -71,8 +58,6 @@ public class ExpireAtIntegrationTest { @AfterClass public static void classLevelTearDown() { jedis.close(); - cache.close(); - server.shutdown(); } @Test diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/ExpireIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/ExpireIntegrationTest.java index 20f49af..7763737 100644 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/ExpireIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/ExpireIntegrationTest.java @@ -15,43 +15,30 @@ 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.After; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Ignore; 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.internal.GeodeRedisServer; +import org.apache.geode.redis.GeodeRedisServerRule; import org.apache.geode.test.awaitility.GeodeAwaitility; public class ExpireIntegrationTest { public static Jedis jedis; public static int REDIS_CLIENT_TIMEOUT = 10000000; - private static GeodeRedisServer server; - private static GemFireCache cache; + + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); @BeforeClass public static void setUp() { - CacheFactory cf = new CacheFactory(); - cf.set(LOG_LEVEL, "error"); - cf.set(MCAST_PORT, "0"); - cf.set(LOCATORS, ""); - cache = cf.create(); - int port = AvailablePortHelper.getRandomAvailableTCPPort(); - server = new GeodeRedisServer("localhost", port); - - server.start(); - jedis = new Jedis("localhost", port, REDIS_CLIENT_TIMEOUT); + jedis = new Jedis("localhost", server.getPort(), REDIS_CLIENT_TIMEOUT); } @After @@ -62,8 +49,6 @@ public class ExpireIntegrationTest { @AfterClass public static void classLevelTearDown() { jedis.close(); - cache.close(); - server.shutdown(); } @Test diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/PersistIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/PersistIntegrationTest.java index 144e1ac..25cd21b 100644 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/PersistIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/general/PersistIntegrationTest.java @@ -15,9 +15,6 @@ 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 java.util.concurrent.atomic.AtomicLong; @@ -25,14 +22,12 @@ import java.util.concurrent.atomic.AtomicLong; import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Test; import redis.clients.jedis.Jedis; import redis.clients.jedis.params.SetParams; -import org.apache.geode.cache.CacheFactory; -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.internal.AvailablePortHelper; -import org.apache.geode.redis.internal.GeodeRedisServer; +import org.apache.geode.redis.GeodeRedisServerRule; import org.apache.geode.test.awaitility.GeodeAwaitility; public class PersistIntegrationTest { @@ -40,23 +35,15 @@ public class PersistIntegrationTest { public static Jedis jedis; public static Jedis jedis2; public static int REDIS_CLIENT_TIMEOUT = - Math.toIntExact(GeodeAwaitility.getTimeout().toMillis());; - private static GeodeRedisServer server; - private static GemFireCache cache; + Math.toIntExact(GeodeAwaitility.getTimeout().toMillis()); + + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); @BeforeClass public static void setUp() { - CacheFactory cf = new CacheFactory(); - cf.set(LOG_LEVEL, "error"); - cf.set(MCAST_PORT, "0"); - cf.set(LOCATORS, ""); - cache = cf.create(); - int port = AvailablePortHelper.getRandomAvailableTCPPort(); - server = new GeodeRedisServer("localhost", port); - - server.start(); - jedis = new Jedis("localhost", port, REDIS_CLIENT_TIMEOUT); - jedis2 = new Jedis("localhost", port, REDIS_CLIENT_TIMEOUT); + jedis = new Jedis("localhost", server.getPort(), REDIS_CLIENT_TIMEOUT); + jedis2 = new Jedis("localhost", server.getPort(), REDIS_CLIENT_TIMEOUT); } @After @@ -68,8 +55,6 @@ public class PersistIntegrationTest { public static void tearDown() { jedis.close(); jedis2.close(); - cache.close(); - server.shutdown(); } @Test 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 f543195..456080d 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,48 +15,32 @@ 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; import org.junit.BeforeClass; +import org.junit.ClassRule; 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.internal.GeodeRedisServer; +import org.apache.geode.redis.GeodeRedisServerRule; public class PexpireIntegrationTest { public static Jedis jedis; public static int REDIS_CLIENT_TIMEOUT = 10000000; - private static GeodeRedisServer server; - private static GemFireCache cache; + + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); @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); + jedis = new Jedis("localhost", server.getPort(), REDIS_CLIENT_TIMEOUT); } @AfterClass public static void classLevelTearDown() { jedis.close(); - cache.close(); - server.shutdown(); } @Test diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SDiffIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SDiffIntegrationTest.java index 75c92ef..1df967f 100755 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SDiffIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SDiffIntegrationTest.java @@ -14,9 +14,6 @@ */ package org.apache.geode.redis.sets; -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 java.util.ArrayList; @@ -27,47 +24,34 @@ import java.util.Set; import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.ExpectedException; 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.internal.GeodeRedisServer; +import org.apache.geode.redis.GeodeRedisServerRule; import org.apache.geode.test.junit.categories.RedisTest; @Category({RedisTest.class}) public class SDiffIntegrationTest { static Jedis jedis; static Jedis jedis2; - private static GeodeRedisServer server; - private static GemFireCache cache; - private static int port = 6379; + + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); @BeforeClass public static void setUp() { - CacheFactory cf = new CacheFactory(); - cf.set(LOG_LEVEL, "error"); - cf.set(MCAST_PORT, "0"); - cf.set(LOCATORS, ""); - cache = cf.create(); - port = AvailablePortHelper.getRandomAvailableTCPPort(); - server = new GeodeRedisServer("localhost", port); - - server.start(); - jedis = new Jedis("localhost", port, 10000000); - jedis2 = new Jedis("localhost", port, 10000000); + jedis = new Jedis("localhost", server.getPort(), 10000000); + jedis2 = new Jedis("localhost", server.getPort(), 10000000); } @AfterClass public static void tearDown() { jedis.close(); jedis2.close(); - cache.close(); - server.shutdown(); } @After diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SInterIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SInterIntegrationTest.java index 3fde7e9..95e8b85 100755 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SInterIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SInterIntegrationTest.java @@ -14,9 +14,6 @@ */ package org.apache.geode.redis.sets; -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 java.util.ArrayList; @@ -27,47 +24,34 @@ import java.util.Set; import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.ExpectedException; 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.internal.GeodeRedisServer; +import org.apache.geode.redis.GeodeRedisServerRule; import org.apache.geode.test.junit.categories.RedisTest; @Category({RedisTest.class}) public class SInterIntegrationTest { static Jedis jedis; static Jedis jedis2; - private static GeodeRedisServer server; - private static GemFireCache cache; - private static int port = 6379; + + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); @BeforeClass public static void setUp() { - CacheFactory cf = new CacheFactory(); - cf.set(LOG_LEVEL, "error"); - cf.set(MCAST_PORT, "0"); - cf.set(LOCATORS, ""); - cache = cf.create(); - port = AvailablePortHelper.getRandomAvailableTCPPort(); - server = new GeodeRedisServer("localhost", port); - - server.start(); - jedis = new Jedis("localhost", port, 10000000); - jedis2 = new Jedis("localhost", port, 10000000); + jedis = new Jedis("localhost", server.getPort(), 10000000); + jedis2 = new Jedis("localhost", server.getPort(), 10000000); } @AfterClass public static void tearDown() { jedis.close(); jedis2.close(); - cache.close(); - server.shutdown(); } @After diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SMoveIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SMoveIntegrationTest.java index 3d16900..6396a51 100755 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SMoveIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SMoveIntegrationTest.java @@ -14,9 +14,6 @@ */ package org.apache.geode.redis.sets; -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 java.util.HashSet; @@ -30,49 +27,36 @@ import java.util.concurrent.Future; import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.ExpectedException; 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.management.internal.cli.util.ThreePhraseGenerator; -import org.apache.geode.redis.internal.GeodeRedisServer; +import org.apache.geode.redis.GeodeRedisServerRule; import org.apache.geode.test.junit.categories.RedisTest; @Category({RedisTest.class}) public class SMoveIntegrationTest { static Jedis jedis; static Jedis jedis2; - private static GeodeRedisServer server; - private static GemFireCache cache; private static ThreePhraseGenerator generator = new ThreePhraseGenerator(); - private static int port = 6379; + + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); @BeforeClass public static void setUp() { - CacheFactory cf = new CacheFactory(); - cf.set(LOG_LEVEL, "error"); - cf.set(MCAST_PORT, "0"); - cf.set(LOCATORS, ""); - cache = cf.create(); - port = AvailablePortHelper.getRandomAvailableTCPPort(); - server = new GeodeRedisServer("localhost", port); - - server.start(); - jedis = new Jedis("localhost", port, 10000000); - jedis2 = new Jedis("localhost", port, 10000000); + jedis = new Jedis("localhost", server.getPort(), 10000000); + jedis2 = new Jedis("localhost", server.getPort(), 10000000); } @AfterClass public static void tearDown() { jedis.close(); jedis2.close(); - cache.close(); - server.shutdown(); } @After diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SPopIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SPopIntegrationTest.java index a85d5cd..6fb6662 100755 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SPopIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SPopIntegrationTest.java @@ -14,9 +14,6 @@ */ package org.apache.geode.redis.sets; -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 java.util.ArrayList; @@ -26,47 +23,34 @@ import java.util.Set; import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.ExpectedException; 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.internal.GeodeRedisServer; +import org.apache.geode.redis.GeodeRedisServerRule; import org.apache.geode.test.junit.categories.RedisTest; @Category({RedisTest.class}) public class SPopIntegrationTest { static Jedis jedis; static Jedis jedis2; - private static GeodeRedisServer server; - private static GemFireCache cache; - private static int port = 6379; + + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); @BeforeClass public static void setUp() { - CacheFactory cf = new CacheFactory(); - cf.set(LOG_LEVEL, "error"); - cf.set(MCAST_PORT, "0"); - cf.set(LOCATORS, ""); - cache = cf.create(); - port = AvailablePortHelper.getRandomAvailableTCPPort(); - server = new GeodeRedisServer("localhost", port); - - server.start(); - jedis = new Jedis("localhost", port, 10000000); - jedis2 = new Jedis("localhost", port, 10000000); + jedis = new Jedis("localhost", server.getPort(), 10000000); + jedis2 = new Jedis("localhost", server.getPort(), 10000000); } @AfterClass public static void tearDown() { jedis.close(); jedis2.close(); - cache.close(); - server.shutdown(); } @After diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SRemIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SRemIntegrationTest.java index 1c2062d..7e92818 100755 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SRemIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SRemIntegrationTest.java @@ -14,9 +14,6 @@ */ package org.apache.geode.redis.sets; -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 static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.catchThrowable; @@ -35,6 +32,7 @@ import java.util.concurrent.atomic.AtomicLong; import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; @@ -43,42 +41,28 @@ import org.junit.rules.ExpectedException; import redis.clients.jedis.Jedis; import redis.clients.jedis.exceptions.JedisDataException; -import org.apache.geode.cache.CacheFactory; -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.internal.AvailablePortHelper; +import org.apache.geode.redis.GeodeRedisServerRule; import org.apache.geode.redis.internal.ByteArrayWrapper; -import org.apache.geode.redis.internal.GeodeRedisServer; import org.apache.geode.test.junit.categories.RedisTest; @Category({RedisTest.class}) public class SRemIntegrationTest { static Jedis jedis; static Jedis jedis2; - private static GeodeRedisServer server; - private static GemFireCache cache; - private static int port = 6379; + + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); @BeforeClass public static void setUp() { - CacheFactory cf = new CacheFactory(); - cf.set(LOG_LEVEL, "error"); - cf.set(MCAST_PORT, "0"); - cf.set(LOCATORS, ""); - cache = cf.create(); - port = AvailablePortHelper.getRandomAvailableTCPPort(); - server = new GeodeRedisServer("localhost", port); - - server.start(); - jedis = new Jedis("localhost", port, 10000000); - jedis2 = new Jedis("localhost", port, 10000000); + jedis = new Jedis("localhost", server.getPort(), 10000000); + jedis2 = new Jedis("localhost", server.getPort(), 10000000); } @AfterClass public static void tearDown() { jedis.close(); jedis2.close(); - cache.close(); - server.shutdown(); } @After diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SUnionIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SUnionIntegrationTest.java index 2907010..b9f02ce 100755 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SUnionIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SUnionIntegrationTest.java @@ -14,9 +14,6 @@ */ package org.apache.geode.redis.sets; -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 java.util.ArrayList; @@ -27,47 +24,34 @@ import java.util.Set; import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.ExpectedException; 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.internal.GeodeRedisServer; +import org.apache.geode.redis.GeodeRedisServerRule; import org.apache.geode.test.junit.categories.RedisTest; @Category({RedisTest.class}) public class SUnionIntegrationTest { static Jedis jedis; static Jedis jedis2; - private static GeodeRedisServer server; - private static GemFireCache cache; - private static int port = 6379; + + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); @BeforeClass public static void setUp() { - CacheFactory cf = new CacheFactory(); - cf.set(LOG_LEVEL, "error"); - cf.set(MCAST_PORT, "0"); - cf.set(LOCATORS, ""); - cache = cf.create(); - port = AvailablePortHelper.getRandomAvailableTCPPort(); - server = new GeodeRedisServer("localhost", port); - - server.start(); - jedis = new Jedis("localhost", port, 10000000); - jedis2 = new Jedis("localhost", port, 10000000); + jedis = new Jedis("localhost", server.getPort(), 10000000); + jedis2 = new Jedis("localhost", server.getPort(), 10000000); } @AfterClass public static void tearDown() { jedis.close(); jedis2.close(); - cache.close(); - server.shutdown(); } @After diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SetsIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SetsIntegrationTest.java index 6a8a481..e9108db 100755 --- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SetsIntegrationTest.java +++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/sets/SetsIntegrationTest.java @@ -14,9 +14,6 @@ */ package org.apache.geode.redis.sets; -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 java.util.HashSet; @@ -30,6 +27,7 @@ import java.util.concurrent.Future; import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -37,11 +35,8 @@ import org.junit.rules.ExpectedException; import redis.clients.jedis.Jedis; import redis.clients.jedis.exceptions.JedisDataException; -import org.apache.geode.cache.CacheFactory; -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.internal.AvailablePortHelper; import org.apache.geode.management.internal.cli.util.ThreePhraseGenerator; -import org.apache.geode.redis.internal.GeodeRedisServer; +import org.apache.geode.redis.GeodeRedisServerRule; import org.apache.geode.redis.internal.RedisConstants; import org.apache.geode.test.junit.categories.RedisTest; @@ -49,32 +44,21 @@ import org.apache.geode.test.junit.categories.RedisTest; public class SetsIntegrationTest { static Jedis jedis; static Jedis jedis2; - private static GeodeRedisServer server; - private static GemFireCache cache; private static ThreePhraseGenerator generator = new ThreePhraseGenerator(); - private static int port = 6379; + + @ClassRule + public static GeodeRedisServerRule server = new GeodeRedisServerRule(); @BeforeClass public static void setUp() { - CacheFactory cf = new CacheFactory(); - cf.set(LOG_LEVEL, "error"); - cf.set(MCAST_PORT, "0"); - cf.set(LOCATORS, ""); - cache = cf.create(); - port = AvailablePortHelper.getRandomAvailableTCPPort(); - server = new GeodeRedisServer("localhost", port); - - server.start(); - jedis = new Jedis("localhost", port, 10000000); - jedis2 = new Jedis("localhost", port, 10000000); + jedis = new Jedis("localhost", server.getPort(), 10000000); + jedis2 = new Jedis("localhost", server.getPort(), 10000000); } @AfterClass public static void tearDown() { jedis.close(); jedis2.close(); - cache.close(); - server.shutdown(); } @After diff --git a/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java b/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java index fb3866e..723fcbf 100644 --- a/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java +++ b/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java @@ -168,6 +168,8 @@ public class GeodeRedisServer { */ public static final int DEFAULT_REDIS_SERVER_PORT = 6379; + private static final int RANDOM_PORT_INDICATOR = -1; + /** * The number of threads that will work on handling requests */ @@ -181,7 +183,7 @@ public class GeodeRedisServer { /** * The actual port being used by the server */ - private final int serverPort; + private int serverPort; /** * The address to bind to @@ -336,6 +338,14 @@ public class GeodeRedisServer { } /** + * Constructor for {@code GeodeRedisServer} that will start the server on a random port and bind + * to the first non-loopback address + */ + public GeodeRedisServer() { + this(null, -1, null); + } + + /** * Constructor for {@code GeodeRedisServer} that will start the server on the given port and bind * to the first non-loopback address * @@ -366,11 +376,12 @@ public class GeodeRedisServer { * * @param bindAddress The address to which the server will attempt to bind to * @param port The port the server will bind to, will use {@value #DEFAULT_REDIS_SERVER_PORT} - * by default if argument is less than or equal to 0 + * by default if argument is less than -1. If the port is {@value #RANDOM_PORT_INDICATOR} + * a random port is assigned. * @param logLevel The logging level to be used by GemFire */ public GeodeRedisServer(String bindAddress, int port, String logLevel) { - serverPort = port <= 0 ? DEFAULT_REDIS_SERVER_PORT : port; + serverPort = port < RANDOM_PORT_INDICATOR ? DEFAULT_REDIS_SERVER_PORT : port; this.bindAddress = bindAddress; this.logLevel = logLevel; numWorkerThreads = setNumWorkerThreads(); @@ -594,8 +605,14 @@ public class GeodeRedisServer { private Channel createBoundChannel(ServerBootstrap serverBootstrap) throws InterruptedException, UnknownHostException { ChannelFuture channelFuture = - serverBootstrap.bind(new InetSocketAddress(getBindAddress(), serverPort)).sync(); + serverBootstrap.bind(new InetSocketAddress(getBindAddress(), + serverPort == RANDOM_PORT_INDICATOR ? 0 : serverPort)) + .sync(); + + serverPort = ((InetSocketAddress) channelFuture.channel().localAddress()).getPort(); + logStartupMessage(); + return channelFuture.channel(); } @@ -755,6 +772,10 @@ public class GeodeRedisServer { } } + public int getPort() { + return serverPort; + } + /** * Static main method that allows the {@code GeodeRedisServer} to be started from the command * line. The supported command line arguments are diff --git a/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisService.java b/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisService.java index f756537..466c3fa 100644 --- a/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisService.java +++ b/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisService.java @@ -36,7 +36,9 @@ public class GeodeRedisService implements CacheService, ResourceEventsListener { this.cache = (InternalCache) cache; this.cache.getInternalDistributedSystem().addResourceListener(this); - return true; + int port = this.cache.getInternalDistributedSystem().getConfig().getRedisPort(); + + return port != 0; } @Override @@ -86,4 +88,8 @@ public class GeodeRedisService implements CacheService, ResourceEventsListener { public CacheServiceMBeanBase getMBean() { return null; } + + public int getPort() { + return redisServer.getPort(); + } }