You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2022/02/01 20:44:07 UTC

[geode] 01/02: GEODE-9958: Add gfsh-specific tests for Radish startup (#7297)

This is an automated email from the ASF dual-hosted git repository.

jensdeppe pushed a commit to branch support/1.15
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 9f021cf6f6216f9a8db6d395b07b9b74745cf75d
Author: Jens Deppe <jd...@vmware.com>
AuthorDate: Fri Jan 21 19:57:42 2022 -0800

    GEODE-9958: Add gfsh-specific tests for Radish startup (#7297)
    
    (cherry picked from commit 77945531fafd566a0cbca7d05b5347b8ea299efc)
---
 .../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);
+    }
+  }
+
 }