geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [13/22] geode git commit: GEODE-2737: Change Pulse UI tests to use random port for JMX connections
Date Thu, 13 Apr 2017 17:18:34 GMT
GEODE-2737: Change Pulse UI tests to use random port for JMX connections

Renamed parameter port to jmxPort in Server.java to clarify usage.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/3a64b57c
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/3a64b57c
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/3a64b57c

Branch: refs/heads/feature/GEODE-2632
Commit: 3a64b57ce433c7ed7ed0923af0d3c5811d0d4169
Parents: 60a96cc
Author: Ken Howe <khowe@pivotal.io>
Authored: Mon Apr 10 14:45:28 2017 -0700
Committer: Ken Howe <khowe@pivotal.io>
Committed: Wed Apr 12 10:13:30 2017 -0700

----------------------------------------------------------------------
 .../org/apache/geode/tools/pulse/tests/Server.java | 17 +++++++++--------
 .../geode/tools/pulse/tests/rules/ServerRule.java  | 13 ++++++++-----
 2 files changed, 17 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/3a64b57c/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
index ebf291b..087aff4 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
@@ -58,10 +58,10 @@ public class Server {
   private JMXConnectorServer cs;
   private String propFile = null;
 
-  public Server(int port, String properties, String jsonAuthFile) throws Exception {
+  public Server(int jmxPort, String properties, String jsonAuthFile) throws Exception {
     this.propFile = properties;
     mbs = ManagementFactory.getPlatformMBeanServer();
-    url = new JMXServiceURL(formJMXServiceURLString(DEFAULT_HOST, port));
+    url = new JMXServiceURL(formJMXServiceURLString(DEFAULT_HOST, jmxPort));
 
     // Load the beans first, otherwise we get access denied
     loadMBeans();
@@ -98,7 +98,7 @@ public class Server {
     }
 
     try {
-      java.rmi.registry.LocateRegistry.createRegistry(port);
+      java.rmi.registry.LocateRegistry.createRegistry(jmxPort);
       System.out.println("RMI registry ready.");
     } catch (Exception e) {
       System.out.println("Exception starting RMI registry:");
@@ -108,16 +108,17 @@ public class Server {
     cs.start();
   }
 
-  private String formJMXServiceURLString(String host, int port) throws UnknownHostException
{
+  private String formJMXServiceURLString(String host, int jmxPort) throws UnknownHostException
{
     String jmxSerURL = "";
 
     InetAddress inetAddr = InetAddress.getByName(host);
     if (inetAddr instanceof Inet4Address) {
       // Create jmx service url for IPv4 address
-      jmxSerURL = "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + port + "/jmxrmi";
+      jmxSerURL = "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + jmxPort + "/jmxrmi";
     } else if (inetAddr instanceof Inet6Address) {
       // Create jmx service url for IPv6 address
-      jmxSerURL = "service:jmx:rmi://[" + host + "]/jndi/rmi://[" + host + "]:" + port +
"/jmxrmi";
+      jmxSerURL =
+          "service:jmx:rmi://[" + host + "]/jndi/rmi://[" + host + "]:" + jmxPort + "/jmxrmi";
     }
 
     return jmxSerURL;
@@ -223,10 +224,10 @@ public class Server {
     return propVal.split(" ");
   }
 
-  public static Server createServer(int port, String properties, String jsonAuthFile) {
+  public static Server createServer(int jmxPort, String properties, String jsonAuthFile)
{
     Server s = null;
     try {
-      s = new Server(port, properties, jsonAuthFile);
+      s = new Server(jmxPort, properties, jsonAuthFile);
     } catch (Exception e) {
       e.printStackTrace();
       return null;

http://git-wip-us.apache.org/repos/asf/geode/blob/3a64b57c/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java
b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java
index af3d64b..3183f87 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java
@@ -17,6 +17,7 @@
 package org.apache.geode.tools.pulse.tests.rules;
 
 
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
 import org.awaitility.Awaitility;
 import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.internal.admin.SSLConfig;
@@ -40,15 +41,17 @@ public class ServerRule extends ExternalResource {
   public ServerRule(String jsonAuthFile) {
     ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
     String jmxPropertiesFile = classLoader.getResource("test.properties").getPath();
-    server = Server.createServer(9999, jmxPropertiesFile, jsonAuthFile);
 
-    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+    int jmxPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+    server = Server.createServer(jmxPort, jmxPropertiesFile, jsonAuthFile);
+    System.setProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_HOST, LOCALHOST);
+    System.setProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_PORT, Integer.toString(jmxPort));
 
-    jetty = JettyHelper.initJetty(LOCALHOST, port, new SSLConfig());
+    int httpPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+    jetty = JettyHelper.initJetty(LOCALHOST, httpPort, new SSLConfig());
     JettyHelper.addWebApplication(jetty, PULSE_CONTEXT, getPulseWarPath());
-    pulseURL = "http://" + LOCALHOST + ":" + port + PULSE_CONTEXT;
+    pulseURL = "http://" + LOCALHOST + ":" + httpPort + PULSE_CONTEXT;
     System.out.println("Pulse started at " + pulseURL);
-
   }
 
   public String getPulseURL() {


Mime
View raw message