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 2019/04/22 15:10:55 UTC

[geode] branch develop updated: GEODE-6679: Use ephemeral ports in StandaloneClientManagementAPIAcceptanceTest (#3485)

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 0adb400  GEODE-6679: Use ephemeral ports in StandaloneClientManagementAPIAcceptanceTest (#3485)
0adb400 is described below

commit 0adb400dd27180760342e7d69b431b14de48ada8
Author: Jens Deppe <jd...@pivotal.io>
AuthorDate: Mon Apr 22 08:10:41 2019 -0700

    GEODE-6679: Use ephemeral ports in StandaloneClientManagementAPIAcceptanceTest (#3485)
---
 .../StandaloneClientManagementAPIAcceptanceTest.java  | 19 ++++++++++++++-----
 .../resources/ManagementClientTestCreateRegion.java   |  5 +++--
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/rest/StandaloneClientManagementAPIAcceptanceTest.java b/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/rest/StandaloneClientManagementAPIAcceptanceTest.java
index 04819a9..6abaae5 100644
--- a/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/rest/StandaloneClientManagementAPIAcceptanceTest.java
+++ b/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/rest/StandaloneClientManagementAPIAcceptanceTest.java
@@ -38,6 +38,7 @@ import org.junit.runners.Parameterized.Parameter;
 import org.junit.runners.Parameterized.Parameters;
 import org.junit.runners.Parameterized.UseParametersRunnerFactory;
 
+import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.test.compiler.JarBuilder;
 import org.apache.geode.test.junit.rules.gfsh.GfshExecution;
 import org.apache.geode.test.junit.rules.gfsh.GfshRule;
@@ -90,27 +91,34 @@ public class StandaloneClientManagementAPIAcceptanceTest {
     File outputJar = new File(tempDir.getRoot(), "output.jar");
     jarBuilder.buildJar(outputJar, new File(filePath));
 
+    int[] availablePorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    int locatorPort = availablePorts[0];
+    int httpPort = availablePorts[1];
     GfshExecution startCluster =
-        GfshScript.of("start locator " + getSslParameters(),
-            "start server --locators=localhost[10334]")
+        GfshScript.of(String.format("start locator --port=%d --J=-Dgemfire.http-service-port=%d %s",
+            locatorPort,
+            httpPort,
+            getSslParameters()),
+            String.format("start server --locators=localhost[%d] --server-port=0", locatorPort))
             .withName("startCluster").execute(gfsh);
 
 
     assertThat(startCluster.getProcess().exitValue())
         .as("Cluster did not start correctly").isEqualTo(0);
 
-    Process process = launchClientProcess(outputJar);
+    Process process = launchClientProcess(outputJar, httpPort);
 
     boolean exited = process.waitFor(10, TimeUnit.SECONDS);
     assertThat(exited).as("Process did not exit within 10 seconds").isTrue();
     assertThat(process.exitValue()).as("Process did not exit with 0 return code").isEqualTo(0);
 
-    GfshExecution listRegionsResult = GfshScript.of("connect", "list regions")
+    GfshExecution listRegionsResult = GfshScript
+        .of(String.format("connect --locator=localhost[%d]", locatorPort), "list regions")
         .withName("listRegions").execute(gfsh);
     assertThat(listRegionsResult.getOutputText()).contains("REGION1");
   }
 
-  private Process launchClientProcess(File outputJar) throws IOException {
+  private Process launchClientProcess(File outputJar, int httpPort) throws IOException {
     Path javaBin = Paths.get(System.getProperty("java.home"), "bin", "java");
 
     ProcessBuilder pBuilder = new ProcessBuilder();
@@ -152,6 +160,7 @@ public class StandaloneClientManagementAPIAcceptanceTest {
     command.add("ManagementClientCreateRegion");
     command.add("REGION1");
     command.add(useSsl.toString());
+    command.add("" + httpPort);
 
     pBuilder.command(command);
 
diff --git a/geode-assembly/src/acceptanceTest/resources/ManagementClientTestCreateRegion.java b/geode-assembly/src/acceptanceTest/resources/ManagementClientTestCreateRegion.java
index 4892387..1b96e07 100644
--- a/geode-assembly/src/acceptanceTest/resources/ManagementClientTestCreateRegion.java
+++ b/geode-assembly/src/acceptanceTest/resources/ManagementClientTestCreateRegion.java
@@ -25,14 +25,15 @@ public class ManagementClientCreateRegion {
   public static void main(String[] args) throws Exception {
     String regionName = args[0];
     boolean useSsl = Boolean.parseBoolean(args[1]);
+    int httpPort = Integer.parseInt(args[2]);
 
     ClusterManagementService cms;
     if (useSsl) {
       // The default SSLContext will pull in all necessary javax.net.ssl properties
-      cms = ClusterManagementServiceProvider.getService("localhost", 7070,
+      cms = ClusterManagementServiceProvider.getService("localhost", httpPort,
           SSLContext.getDefault(), null, null, null);
     } else {
-      cms = ClusterManagementServiceProvider.getService("localhost", 7070);
+      cms = ClusterManagementServiceProvider.getService("localhost", httpPort);
     }
 
     RegionConfig config = new RegionConfig();