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

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


The following commit(s) were added to refs/heads/sni by this push:
     new 6947349  set --hostname-for-clients on locator and server for SNI
6947349 is described below

commit 69473499820fc52b8905893d36092347f3dd7d23
Author: Bill Burcham <bburc...@pivotal.io>
AuthorDate: Thu May 21 18:39:04 2020 -0700

    set --hostname-for-clients on locator and server for SNI
---
 README.md                                          |  4 ++-
 .../apache/geode/benchmark/parameters/Utils.java   |  4 +--
 .../tasks/DefineHostNamingsOffPlatformTask.java    |  7 +++++
 .../apache/geode/benchmark/tasks/StartLocator.java | 14 ++++++++++
 .../geode/benchmark/tasks/StartLocatorSNI.java     | 28 ++++++++++++++++++++
 .../apache/geode/benchmark/tasks/StartServer.java  | 30 ++++++++++++++++++++--
 .../geode/benchmark/tasks/StartServerSNI.java      | 25 ++++++++++++++++++
 .../topology/ClientServerTopologyWithSNIProxy.java | 11 ++++----
 .../org/apache/geode/benchmark/topology/Roles.java |  8 ++++++
 9 files changed, 120 insertions(+), 11 deletions(-)

diff --git a/README.md b/README.md
index 9e53cb6..aed3c4c 100644
--- a/README.md
+++ b/README.md
@@ -162,12 +162,14 @@ Also we have to provide `-DwithSsl=true` for an SNI test 
even though no SNI test
 * ~~verify `StartSniProxy` runs on proxy node~~
 * ~~don't require operator to supply `-PwithSSL`/`-DwithSSL=true` when running 
SNI tests~~
 * ~~generate `haproxy.cfg` with client-visible SNI hostnames~~
-* ~~turn on SNI via `setPoolSocketFactory` in a new `StartClientSNI` task~~ 
+* ~~turn on SNI via `setPoolSocketFactory` in a new `StartClientSNI` task~~
+* ~~set `--hostname-for-clients` on locator and servers for SNI~~ 
 * make topology orthogonal to tests so all tests can run with SNI; have a 
`-Psni`/`-Dsni` flag
 * fix borken `PartitionedPutBenchmarkSNITest`: 
`DefineHostNamingsOffPlatformTask` breaks when running multiple roles on a 
single host
 
 ## TODO (General)
 * move Geode keystore/truststore setting out of `harness` module and up into 
`geode-benchmarks` i.e. set 'em in properties sent to 
`Locator.startLocatorAndDS` in `StartLocator`, `StartServer` and eliminate 
`harness` module dependency on Geode entirely
+* move `docker-compose.yml` distribution out of `harness` module up into 
`geode-benchmarks` so it gets distributed whenever it changes (without 
requiring rebuilding AWS AMI and cluster on AWS) 
 * generate 2048-bit keys (instead of 1024-bit ones) for TLS; will slow TLS 
handshakes which may necessitate a new baseline
 * `./run_tests.sh` often seems to hang after benchmarks have completed, 
requiring operator to enter ^C to un-stick it
 * make `rsync:` Git "scheme" work in `run_tests.sh` script for benchmark repo 
(not just for geode repo)
diff --git 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/parameters/Utils.java
 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/parameters/Utils.java
index b90f707..7e4e0f1 100644
--- 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/parameters/Utils.java
+++ 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/parameters/Utils.java
@@ -44,9 +44,7 @@ public class Utils {
    * @param args
    */
   public static void configureGeodeProductJvms(final TestConfig config, final 
String... args) {
-    Arrays.stream(Roles.values())
-        .filter(role -> role.roleKind == GEODE_PRODUCT)
-        .forEach(role -> jvmArgs(config,role,args));
+    Roles.rolesFor(GEODE_PRODUCT).forEach(role -> jvmArgs(config,role,args));
   }
 
   public static void addToTestConfig(TestConfig testConfig, String 
systemPropertyKey,
diff --git 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/DefineHostNamingsOffPlatformTask.java
 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/DefineHostNamingsOffPlatformTask.java
index 0d2b7ac..f203f3e 100644
--- 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/DefineHostNamingsOffPlatformTask.java
+++ 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/DefineHostNamingsOffPlatformTask.java
@@ -4,6 +4,7 @@ import static org.apache.geode.benchmark.topology.Roles.LOCATOR;
 import static org.apache.geode.benchmark.topology.Roles.SERVER;
 
 import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -19,6 +20,12 @@ public class DefineHostNamingsOffPlatformTask implements 
Task {
 
   public static final String HOST_NAMINGS_OFF_PLATFORM = 
"HOST_NAMINGS_OFF_PLATFORM";
 
+  static String getOffPlatformHostName(final TestContext context) throws 
UnknownHostException {
+    final Map<InetAddress, String> namings =
+        (Map<InetAddress, String>) 
context.getAttribute(HOST_NAMINGS_OFF_PLATFORM);
+    return namings.get(InetAddress.getLocalHost());
+  }
+
   @Override
   public void run(final TestContext context) throws Exception {
     final Map<InetAddress, String>
diff --git 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartLocator.java
 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartLocator.java
index c5f53ff..2e94fa0 100644
--- 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartLocator.java
+++ 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartLocator.java
@@ -20,6 +20,7 @@ package org.apache.geode.benchmark.tasks;
 import static 
org.apache.geode.benchmark.parameters.GeodeProperties.locatorProperties;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.InetAddress;
 import java.util.Properties;
 
@@ -46,6 +47,19 @@ public class StartLocator implements Task {
     properties.setProperty(ConfigurationProperties.STATISTIC_ARCHIVE_FILE, 
statsFile);
 
     properties.setProperty(ConfigurationProperties.NAME, "locator-" + 
InetAddress.getLocalHost());
+    startLocator(properties, locatorPort, context);
+  }
+
+  /**
+   * Starts locator as a side-effect.
+   *
+   * @param properties
+   * @param locatorPort
+   * @param context
+   * @throws IOException
+   */
+  protected void startLocator(final Properties properties, final int 
locatorPort,
+                               final TestContext context) throws IOException {
     Locator.startLocatorAndDS(locatorPort, null, properties);
   }
 }
diff --git 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartLocatorSNI.java
 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartLocatorSNI.java
new file mode 100644
index 0000000..6edc76f
--- /dev/null
+++ 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartLocatorSNI.java
@@ -0,0 +1,28 @@
+package org.apache.geode.benchmark.tasks;
+
+import static 
org.apache.geode.benchmark.tasks.DefineHostNamingsOffPlatformTask.getOffPlatformHostName;
+
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.geode.distributed.LocatorLauncher;
+import org.apache.geode.perftest.TestContext;
+
+public class StartLocatorSNI extends StartLocator {
+
+  public StartLocatorSNI(final int locatorPort) {
+    super(locatorPort);
+  }
+
+  @Override
+  protected void startLocator(final Properties properties, final int 
locatorPort,
+                                 final TestContext context) throws IOException 
{
+    new LocatorLauncher.Builder()
+        .set(properties)
+        .setPort(locatorPort)
+        .setHostnameForClients(getOffPlatformHostName(context))
+        .build()
+        .start();
+  }
+
+}
diff --git 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartServer.java
 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartServer.java
index 1402e9d..3ebd62f 100644
--- 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartServer.java
+++ 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartServer.java
@@ -21,6 +21,7 @@ import static 
org.apache.geode.benchmark.parameters.GeodeProperties.serverProper
 
 import java.io.File;
 import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.util.Properties;
 
 import org.apache.geode.cache.Cache;
@@ -57,11 +58,36 @@ public class StartServer implements Task {
         .set(ConfigurationProperties.STATISTIC_ARCHIVE_FILE, statsFile)
         .create();
     CacheServer cacheServer = cache.addCacheServer();
-    cacheServer.setPort(0);
-    cacheServer.setMaxConnections(Integer.MAX_VALUE);
+    configureCacheServer(cacheServer, context);
     cacheServer.start();
     context.setAttribute("SERVER_CACHE", cache);
 
   }
 
+  /**
+   *
+   * @param properties
+   * @param locatorString
+   * @param statsFile
+   * @param context
+   * @return
+   * @throws UnknownHostException
+   */
+
+  /**
+   * Configure the cache server
+   *
+   * Subclasses can override this. Call super first to inherit settings.
+   *
+   * @param cacheServer is modified by this method!
+   * @param context
+   */
+  protected void configureCacheServer(final CacheServer cacheServer,
+                                      final TestContext context) throws 
UnknownHostException {
+    cacheServer.setPort(0);
+    cacheServer.setMaxConnections(Integer.MAX_VALUE);
+  }
+
+
+
 }
diff --git 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartServerSNI.java
 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartServerSNI.java
new file mode 100644
index 0000000..2e6f0ad
--- /dev/null
+++ 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartServerSNI.java
@@ -0,0 +1,25 @@
+package org.apache.geode.benchmark.tasks;
+
+import static 
org.apache.geode.benchmark.tasks.DefineHostNamingsOffPlatformTask.getOffPlatformHostName;
+
+import java.net.UnknownHostException;
+import java.util.Properties;
+
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.server.CacheServer;
+import org.apache.geode.perftest.TestContext;
+
+public class StartServerSNI extends StartServer {
+
+  public StartServerSNI(final int locatorPort) {
+    super(locatorPort);
+  }
+
+  @Override
+  protected void configureCacheServer(final CacheServer cacheServer, final 
TestContext context)
+      throws UnknownHostException {
+    super.configureCacheServer(cacheServer, context);
+    cacheServer.setHostnameForClients(getOffPlatformHostName(context));
+  }
+
+}
diff --git 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/topology/ClientServerTopologyWithSNIProxy.java
 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/topology/ClientServerTopologyWithSNIProxy.java
index 302a44e..969b49a 100644
--- 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/topology/ClientServerTopologyWithSNIProxy.java
+++ 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/topology/ClientServerTopologyWithSNIProxy.java
@@ -21,11 +21,14 @@ import static org.apache.geode.benchmark.Config.role;
 import static org.apache.geode.benchmark.parameters.Utils.addToTestConfig;
 import static 
org.apache.geode.benchmark.parameters.Utils.configureGeodeProductJvms;
 import static org.apache.geode.benchmark.topology.Ports.LOCATOR_PORT;
+import static org.apache.geode.benchmark.topology.RoleKinds.GEODE_PRODUCT;
 import static org.apache.geode.benchmark.topology.Roles.CLIENT;
 import static org.apache.geode.benchmark.topology.Roles.LOCATOR;
 import static org.apache.geode.benchmark.topology.Roles.PROXY;
 import static org.apache.geode.benchmark.topology.Roles.SERVER;
 
+import java.util.stream.Stream;
+
 import org.apache.geode.benchmark.parameters.GcLoggingParameters;
 import org.apache.geode.benchmark.parameters.GcParameters;
 import org.apache.geode.benchmark.parameters.HeapParameters;
@@ -67,14 +70,12 @@ public class ClientServerTopologyWithSNIProxy {
     // TODO: peel it off over in client
     jvmArgs(config, CLIENT, "-DwithSniProxy=hostname:port");
 
-    before(config, new StartLocator(LOCATOR_PORT), LOCATOR);
+    Stream.concat(Roles.rolesFor(GEODE_PRODUCT), Stream.of(PROXY))
+        .forEach(role -> before(config, new 
DefineHostNamingsOffPlatformTask(), role));
 
+    before(config, new StartLocator(LOCATOR_PORT), LOCATOR);
     before(config, new StartServer(LOCATOR_PORT), SERVER);
-
-    before(config, new DefineHostNamingsOffPlatformTask(), PROXY);
     before(config, new StartSniProxy(LOCATOR_PORT), PROXY);
-
-    before(config, new DefineHostNamingsOffPlatformTask(), CLIENT);
     before(config, new StartClientSNI(LOCATOR_PORT), CLIENT);
 
     after(config, new StopSniProxy(), PROXY);
diff --git 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/topology/Roles.java 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/topology/Roles.java
index 3122e77..82cb9aa 100644
--- 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/topology/Roles.java
+++ 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/topology/Roles.java
@@ -17,6 +17,9 @@ package org.apache.geode.benchmark.topology;
 import static org.apache.geode.benchmark.topology.RoleKinds.GEODE_PRODUCT;
 import static org.apache.geode.benchmark.topology.RoleKinds.SUPPORTING;
 
+import java.util.Arrays;
+import java.util.stream.Stream;
+
 /**
  * All roles defined for the JVMs created for the benchmark
  */
@@ -28,6 +31,11 @@ public enum Roles {
 
   public final RoleKinds roleKind;
 
+  public static Stream<Roles> rolesFor(final RoleKinds roleKind) {
+    return Arrays.stream(Roles.values())
+        .filter(role -> role.roleKind == roleKind);
+  }
+
   Roles(final RoleKinds roleKind) {
     this.roleKind = roleKind;
   }

Reply via email to