You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jb...@apache.org on 2021/05/11 18:32:43 UTC

[geode-benchmarks] branch feature/redis updated: Test for all Redis topologies.

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

jbarrett pushed a commit to branch feature/redis
in repository https://gitbox.apache.org/repos/asf/geode-benchmarks.git


The following commit(s) were added to refs/heads/feature/redis by this push:
     new 3afc10b  Test for all Redis topologies.
3afc10b is described below

commit 3afc10b601626d1c55091c4b37dd7f5fde7d7d5d
Author: Jacob Barrett <jb...@pivotal.io>
AuthorDate: Tue May 11 11:32:30 2021 -0700

    Test for all Redis topologies.
---
 .../benchmark/tasks/redis/CreateRedisCluster.java  |  4 ++
 .../tasks/redis/InitRedisServersAttribute.java     |  4 ++
 .../topology/redis/ManualRedisTopology.java        |  2 +-
 .../topology/redis/GedisTopologyTest.java          | 75 ++++++++++++++++++++++
 .../topology/redis/ManualRedisTopologyTest.java    | 75 ++++++++++++++++++++++
 .../topology/redis/RedisTopologyTest.java          | 51 +++++++++++++++
 6 files changed, 210 insertions(+), 1 deletion(-)

diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/redis/CreateRedisCluster.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/redis/CreateRedisCluster.java
index 050ff40..e7423a5 100644
--- a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/redis/CreateRedisCluster.java
+++ b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/redis/CreateRedisCluster.java
@@ -46,6 +46,10 @@ public class CreateRedisCluster implements Task {
     this.replicas = replicas;
   }
 
+  public int getReplicas() {
+    return replicas;
+  }
+
   @Override
   public void run(final TestContext context) throws Exception {
     final List<Integer> hostsIDsForRole =
diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/redis/InitRedisServersAttribute.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/redis/InitRedisServersAttribute.java
index 5c3bed3..b976004 100644
--- a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/redis/InitRedisServersAttribute.java
+++ b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/redis/InitRedisServersAttribute.java
@@ -46,6 +46,10 @@ public class InitRedisServersAttribute implements Task {
     this.servers = servers;
   }
 
+  public Collection<InetSocketAddress> getServers() {
+    return servers;
+  }
+
   @Override
   public void run(final TestContext context) throws Exception {
     if (null == servers) {
diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/topology/redis/ManualRedisTopology.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/topology/redis/ManualRedisTopology.java
index 5dbab61..9913c43 100644
--- a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/topology/redis/ManualRedisTopology.java
+++ b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/topology/redis/ManualRedisTopology.java
@@ -44,7 +44,7 @@ public class ManualRedisTopology extends Topology {
     config.jvmArgs(CLIENT.name(), "-Dsun.net.inetaddr.ttl=0", "-Dsun.net.inetaddr.negative.ttl=0");
 
     final String serversProperty = System.getProperty(WITH_REDIS_SERVERS_PROPERTY);
-    if (null == serversProperty) {
+    if (null == serversProperty || serversProperty.trim().isEmpty()) {
       throw new IllegalArgumentException(
           WITH_REDIS_SERVERS_PROPERTY + " must be set to server address(es).");
     }
diff --git a/geode-benchmarks/src/test/java/org/apache/geode/benchmark/topology/redis/GedisTopologyTest.java b/geode-benchmarks/src/test/java/org/apache/geode/benchmark/topology/redis/GedisTopologyTest.java
new file mode 100644
index 0000000..a9371e4
--- /dev/null
+++ b/geode-benchmarks/src/test/java/org/apache/geode/benchmark/topology/redis/GedisTopologyTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.benchmark.topology.redis;
+
+import static org.apache.geode.benchmark.parameters.NettyParameters.WITH_NETTY_THREADS;
+import static org.apache.geode.benchmark.tests.GeodeBenchmark.WITH_BUCKETS;
+import static org.apache.geode.benchmark.tests.GeodeBenchmark.WITH_REPLICAS;
+import static org.apache.geode.benchmark.topology.Roles.SERVER;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.ClearSystemProperty;
+import org.junitpioneer.jupiter.SetSystemProperty;
+
+import org.apache.geode.perftest.TestConfig;
+
+public class GedisTopologyTest {
+
+  @Test
+  @ClearSystemProperty(key = WITH_REPLICAS)
+  @ClearSystemProperty(key = WITH_BUCKETS)
+  @ClearSystemProperty(key = WITH_NETTY_THREADS)
+  public void gedisTopologySetsDefaultJvmArgs() {
+    final TestConfig testConfig = new TestConfig();
+    GedisTopology.configure(testConfig);
+
+    assertThat(testConfig.getJvmArgs().get(SERVER.name()))
+        .contains("-Denable-unsupported-commands=true", "-Dredis.replicas=1",
+            "-Dredis.region.buckets=128", "-Djava.lang.Integer.IntegerCache.high=128")
+        .doesNotContainSubsequence("-Dio.netty.eventLoopThreads=");
+  }
+
+  @Test
+  @SetSystemProperty(key = WITH_REPLICAS, value = "3")
+  public void gedisTopologySetsReplicas() {
+    final TestConfig testConfig = new TestConfig();
+    GedisTopology.configure(testConfig);
+
+    assertThat(testConfig.getJvmArgs().get(SERVER.name())).contains("-Dredis.replicas=3");
+  }
+
+  @Test
+  @SetSystemProperty(key = WITH_BUCKETS, value = "123")
+  public void gedisTopologySetsBuckets() {
+    final TestConfig testConfig = new TestConfig();
+    GedisTopology.configure(testConfig);
+
+    assertThat(testConfig.getJvmArgs().get(SERVER.name()))
+        .contains("-Dredis.region.buckets=123", "-Djava.lang.Integer.IntegerCache.high=123");
+  }
+
+  @Test
+  @SetSystemProperty(key = WITH_NETTY_THREADS, value = "3")
+  public void gedisTopologySetsNettyThreads() {
+    final TestConfig testConfig = new TestConfig();
+    GedisTopology.configure(testConfig);
+
+    assertThat(testConfig.getJvmArgs().get(SERVER.name()))
+        .contains("-Dio.netty.eventLoopThreads=3");
+  }
+
+}
diff --git a/geode-benchmarks/src/test/java/org/apache/geode/benchmark/topology/redis/ManualRedisTopologyTest.java b/geode-benchmarks/src/test/java/org/apache/geode/benchmark/topology/redis/ManualRedisTopologyTest.java
new file mode 100644
index 0000000..ea49a77
--- /dev/null
+++ b/geode-benchmarks/src/test/java/org/apache/geode/benchmark/topology/redis/ManualRedisTopologyTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.benchmark.topology.redis;
+
+import static java.net.InetSocketAddress.createUnresolved;
+import static org.apache.geode.benchmark.topology.Ports.REDIS_PORT;
+import static org.apache.geode.benchmark.topology.redis.ManualRedisTopology.WITH_REDIS_SERVERS_PROPERTY;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.ClearSystemProperty;
+import org.junitpioneer.jupiter.SetSystemProperty;
+
+import org.apache.geode.benchmark.tasks.redis.InitRedisServersAttribute;
+import org.apache.geode.perftest.TestConfig;
+import org.apache.geode.perftest.TestStep;
+
+public class ManualRedisTopologyTest {
+
+  @Test
+  @SetSystemProperty(key = WITH_REDIS_SERVERS_PROPERTY, value = "a")
+  public void configureWithOneServer() {
+    final TestConfig testConfig = new TestConfig();
+    ManualRedisTopology.configure(testConfig);
+    assertThat(testConfig.getBefore().stream().map(TestStep::getTask)
+        .filter(InitRedisServersAttribute.class::isInstance)
+        .map(InitRedisServersAttribute.class::cast)
+        .findFirst()).hasValueSatisfying(t -> assertThat(t.getServers()).containsExactly(
+            createUnresolved("a", REDIS_PORT)));
+  }
+
+  @Test
+  @SetSystemProperty(key = WITH_REDIS_SERVERS_PROPERTY, value = "a;b;c")
+  public void configureWithMultipleServer() {
+    final TestConfig testConfig = new TestConfig();
+    ManualRedisTopology.configure(testConfig);
+    assertThat(testConfig.getBefore().stream().map(TestStep::getTask)
+        .filter(InitRedisServersAttribute.class::isInstance)
+        .map(InitRedisServersAttribute.class::cast)
+        .findFirst()).hasValueSatisfying(t -> assertThat(t.getServers()).containsExactly(
+            createUnresolved("a", REDIS_PORT), createUnresolved("b", REDIS_PORT),
+            createUnresolved("c", REDIS_PORT)));
+  }
+
+  @Test
+  @ClearSystemProperty(key = WITH_REDIS_SERVERS_PROPERTY)
+  public void configureWithNoServersThrows() {
+    final TestConfig testConfig = new TestConfig();
+    assertThatThrownBy(() -> ManualRedisTopology.configure(testConfig))
+        .isInstanceOf(IllegalArgumentException.class);
+  }
+
+  @Test
+  @SetSystemProperty(key = WITH_REDIS_SERVERS_PROPERTY, value = "")
+  public void configureWithNoEmptyThrows() {
+    final TestConfig testConfig = new TestConfig();
+    assertThatThrownBy(() -> ManualRedisTopology.configure(testConfig))
+        .isInstanceOf(IllegalArgumentException.class);
+  }
+
+}
diff --git a/geode-benchmarks/src/test/java/org/apache/geode/benchmark/topology/redis/RedisTopologyTest.java b/geode-benchmarks/src/test/java/org/apache/geode/benchmark/topology/redis/RedisTopologyTest.java
new file mode 100644
index 0000000..e1e69ed
--- /dev/null
+++ b/geode-benchmarks/src/test/java/org/apache/geode/benchmark/topology/redis/RedisTopologyTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.benchmark.topology.redis;
+
+import static org.apache.geode.benchmark.tests.GeodeBenchmark.WITH_REPLICAS;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.ClearSystemProperty;
+import org.junitpioneer.jupiter.SetSystemProperty;
+
+import org.apache.geode.benchmark.tasks.redis.CreateRedisCluster;
+import org.apache.geode.perftest.TestConfig;
+import org.apache.geode.perftest.TestStep;
+
+public class RedisTopologyTest {
+
+  @Test
+  @ClearSystemProperty(key = WITH_REPLICAS)
+  public void createRedisClusterDefaultReplicas() {
+    final TestConfig testConfig = new TestConfig();
+    RedisTopology.configure(testConfig);
+    assertThat(testConfig.getBefore().stream().map(TestStep::getTask)
+        .filter(CreateRedisCluster.class::isInstance).map(CreateRedisCluster.class::cast)
+        .findFirst()).hasValueSatisfying(t -> assertThat(t.getReplicas()).isEqualTo(1));
+  }
+
+  @Test
+  @SetSystemProperty(key = WITH_REPLICAS, value = "3")
+  public void createRedisClusterSetsReplicas() {
+    final TestConfig testConfig = new TestConfig();
+    RedisTopology.configure(testConfig);
+    assertThat(testConfig.getBefore().stream().map(TestStep::getTask)
+        .filter(CreateRedisCluster.class::isInstance).map(CreateRedisCluster.class::cast)
+        .findFirst()).hasValueSatisfying(t -> assertThat(t.getReplicas()).isEqualTo(3));
+  }
+
+}