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 7794553  GEODE-9958: Add gfsh-specific tests for Radish startup (#7297)
7794553 is described below

commit 77945531fafd566a0cbca7d05b5347b8ea299efc
Author: Jens Deppe <[email protected]>
AuthorDate: Fri Jan 21 19:57:42 2022 -0800

    GEODE-9958: Add gfsh-specific tests for Radish startup (#7297)
---
 .../GeodeRedisServerStartupAcceptanceTest.java     |  5 --
 ...eRedisServerStartupUsingGfshAcceptanceTest.java | 65 ++++++++++++++++++++++
 2 files changed, 65 insertions(+), 5 deletions(-)

diff --git 
a/geode-for-redis/src/acceptanceTest/java/org/apache/geode/redis/GeodeRedisServerStartupAcceptanceTest.java
 
b/geode-for-redis/src/acceptanceTest/java/org/apache/geode/redis/GeodeRedisServerStartupAcceptanceTest.java
index f16214c..523e63c 100644
--- 
a/geode-for-redis/src/acceptanceTest/java/org/apache/geode/redis/GeodeRedisServerStartupAcceptanceTest.java
+++ 
b/geode-for-redis/src/acceptanceTest/java/org/apache/geode/redis/GeodeRedisServerStartupAcceptanceTest.java
@@ -28,7 +28,6 @@ import java.net.BindException;
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 
-import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -43,16 +42,12 @@ import org.apache.geode.test.dunit.rules.ClusterStartupRule;
 import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.dunit.rules.RedisClusterStartupRule;
 import org.apache.geode.test.junit.categories.IgnoreInRepeatTestTasks;
-import org.apache.geode.test.junit.rules.GfshCommandRule;
 
 public class GeodeRedisServerStartupAcceptanceTest {
 
   @Rule
   public RedisClusterStartupRule cluster = new RedisClusterStartupRule();
 
-  @ClassRule
-  public static GfshCommandRule gfsh = new GfshCommandRule();
-
   @Category(IgnoreInRepeatTestTasks.class)
   @Test
   public void startupOnDefaultPort() {
diff --git 
a/geode-for-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/commands/executor/GeodeRedisServerStartupUsingGfshAcceptanceTest.java
 
b/geode-for-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/commands/executor/GeodeRedisServerStartupUsingGfshAcceptanceTest.java
index 5827ccb..6ce72a5 100644
--- 
a/geode-for-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/commands/executor/GeodeRedisServerStartupUsingGfshAcceptanceTest.java
+++ 
b/geode-for-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/commands/executor/GeodeRedisServerStartupUsingGfshAcceptanceTest.java
@@ -15,7 +15,9 @@
 
 package org.apache.geode.redis.internal.commands.executor;
 
+import static 
org.apache.geode.test.dunit.rules.RedisClusterStartupRule.BIND_ADDRESS;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
@@ -23,8 +25,12 @@ import java.net.ServerSocket;
 
 import org.junit.Rule;
 import org.junit.Test;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.exceptions.JedisConnectionException;
 
+import org.apache.geode.distributed.ConfigurationProperties;
 import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.internal.inet.LocalHostUtil;
 import org.apache.geode.test.junit.rules.gfsh.GfshExecution;
 import org.apache.geode.test.junit.rules.gfsh.GfshRule;
 import org.apache.geode.test.junit.rules.gfsh.GfshScript;
@@ -99,4 +105,63 @@ public class GeodeRedisServerStartupUsingGfshAcceptanceTest 
{
     assertThat(execution.getOutputText()).containsIgnoringCase(
         "The geode-for-redis-bind-address 1.1.1.1 is not a valid address for 
this machine");
   }
+
+  @Test
+  public void gfshStartsRedisServer_whenRedisEnabled() {
+    String command =
+        "start server --J=-Dgemfire." + 
ConfigurationProperties.GEODE_FOR_REDIS_ENABLED + "=true";
+    gfshRule.execute(command);
+
+    try (Jedis jedis = new Jedis(BIND_ADDRESS, 6379)) {
+      assertThat(jedis.ping()).isEqualTo("PONG");
+    }
+  }
+
+  @Test
+  public void gfshStartsRedisServer_whenCustomPort() {
+    int port = AvailablePortHelper.getRandomAvailableTCPPort();
+    String command =
+        "start server --J=-Dgemfire." + 
ConfigurationProperties.GEODE_FOR_REDIS_ENABLED + "=true"
+            + " --J=-Dgemfire." + ConfigurationProperties.GEODE_FOR_REDIS_PORT 
+ "=" + port;
+
+    gfshRule.execute(command);
+
+    try (Jedis jedis = new Jedis(BIND_ADDRESS, port)) {
+      assertThat(jedis.ping()).isEqualTo("PONG");
+    }
+  }
+
+  @Test
+  public void gfshStartsRedisServer_whenCustomPortAndBindAddress() {
+    int port = AvailablePortHelper.getRandomAvailableTCPPort();
+    String anyLocal = LocalHostUtil.getAnyLocalAddress().getHostAddress();
+    String command =
+        "start server --J=-Dgemfire." + 
ConfigurationProperties.GEODE_FOR_REDIS_ENABLED + "=true"
+            + " --J=-Dgemfire." + ConfigurationProperties.GEODE_FOR_REDIS_PORT 
+ "=" + port
+            + " --J=-Dgemfire." + 
ConfigurationProperties.GEODE_FOR_REDIS_BIND_ADDRESS + "="
+            + anyLocal;
+
+    gfshRule.execute(command);
+
+    try (Jedis jedis = new Jedis(anyLocal, port)) {
+      assertThat(jedis.ping()).isEqualTo("PONG");
+    }
+  }
+
+  @Test
+  public void gfshDoesNotStartRedisServer_whenNotRedisEnabled() {
+    int port = AvailablePortHelper.getRandomAvailableTCPPort();
+    String anyLocal = LocalHostUtil.getAnyLocalAddress().getHostAddress();
+    String command =
+        "start server --J=-Dgemfire." + 
ConfigurationProperties.GEODE_FOR_REDIS_PORT + "=" + port
+            + " --J=-Dgemfire." + 
ConfigurationProperties.GEODE_FOR_REDIS_BIND_ADDRESS + "="
+            + anyLocal;
+
+    gfshRule.execute(command);
+
+    try (Jedis jedis = new Jedis(BIND_ADDRESS, port)) {
+      assertThatThrownBy(() -> 
jedis.ping()).isInstanceOf(JedisConnectionException.class);
+    }
+  }
+
 }

Reply via email to