geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject [12/50] [abbrv] incubator-geode git commit: GEODE-1682: Added test for the REST arguments and Use correct Properties.
Date Wed, 10 Aug 2016 19:40:58 GMT
GEODE-1682: Added test for the REST arguments and Use correct Properties.


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

Branch: refs/heads/feature/GEODE-420
Commit: 7eabd0b0a5d3d9ea442ed45e28d3661839a2ba3a
Parents: ab884e7
Author: Avinash <avinash@ampool.io>
Authored: Wed Jul 27 10:13:00 2016 +0530
Committer: Kirk Lund <klund@apache.org>
Committed: Tue Aug 2 09:04:16 2016 -0700

----------------------------------------------------------------------
 .../LauncherLifecycleCommandsJUnitTest.java     | 88 ++++++++++++++++++++
 .../cli/commands/LauncherLifecycleCommands.java |  6 +-
 2 files changed, 91 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7eabd0b0/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsJUnitTest.java
b/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsJUnitTest.java
index fe8d0be..f9be929 100755
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsJUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsJUnitTest.java
@@ -121,6 +121,47 @@ public class LauncherLifecycleCommandsJUnitTest {
     }
   }
 
+
+  @Test
+  public void testAddGemFireSystemPropertiesToCommandLineWithRestAPI() {
+    final List<String> commandLine = new ArrayList<>();
+
+    assertTrue(commandLine.isEmpty());
+
+    getLauncherLifecycleCommands().addGemFireSystemProperties(commandLine, new Properties());
+
+    assertTrue(commandLine.isEmpty());
+
+    final Properties gemfireProperties = new Properties();
+
+    gemfireProperties.setProperty(LOCATORS, "localhost[11235]");
+    gemfireProperties.setProperty(LOG_LEVEL, "config");
+    gemfireProperties.setProperty(LOG_FILE, StringUtils.EMPTY_STRING);
+    gemfireProperties.setProperty(MCAST_PORT, "0");
+    gemfireProperties.setProperty(NAME, "tidepool");
+
+    gemfireProperties.setProperty(START_DEV_REST_API, "true");
+    gemfireProperties.setProperty(HTTP_SERVICE_PORT,  "8080");
+    gemfireProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
+
+
+    getLauncherLifecycleCommands().addGemFireSystemProperties(commandLine, gemfireProperties);
+
+    assertFalse(commandLine.isEmpty());
+    assertEquals(7, commandLine.size());
+
+    for (final String propertyName : gemfireProperties.stringPropertyNames()) {
+      final String propertyValue = gemfireProperties.getProperty(propertyName);
+      if (StringUtils.isBlank(propertyValue)) {
+        for (final String systemProperty : commandLine) {
+          assertFalse(systemProperty.startsWith("-D" + DistributionConfig.GEMFIRE_PREFIX
+ "".concat(propertyName).concat("=")));
+        }
+      } else {
+        assertTrue(commandLine.contains("-D" + DistributionConfig.GEMFIRE_PREFIX + "".concat(propertyName).concat("=").concat(propertyValue)));
+      }
+    }
+  }
+
   @Test
   public void testAddInitialHeapToCommandLine() {
     final List<String> commandLine = new ArrayList<>();
@@ -445,6 +486,53 @@ public class LauncherLifecycleCommandsJUnitTest {
   }
 
   @Test
+  public void testCreateServerCommandLineWithRestAPI() throws Exception {
+    ServerLauncher serverLauncher = new ServerLauncher.Builder().setCommand(
+      ServerLauncher.Command.START).setDisableDefaultServer(true).setMemberName(
+      "testCreateServerCommandLine").setRebalance(true)
+      //.setServerBindAddress("localhost")
+      .setServerPort(41214).setCriticalHeapPercentage(95.5f).setEvictionHeapPercentage(85.0f).build();
+
+    Properties gemfireProperties = new Properties();
+    gemfireProperties.setProperty(START_DEV_REST_API, "true");
+    gemfireProperties.setProperty(HTTP_SERVICE_PORT,  "8080");
+    gemfireProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS,  "localhost");
+
+
+    String[] commandLineElements = launcherCommands.createStartServerCommandLine(serverLauncher,
null, null,
+      gemfireProperties, null, false, new String[0], false, null, null);
+
+    assertNotNull(commandLineElements);
+    assertTrue(commandLineElements.length > 0);
+
+    Set<String> expectedCommandLineElements = new HashSet<>(6);
+
+    expectedCommandLineElements.add(serverLauncher.getCommand().getName());
+    expectedCommandLineElements.add("--disable-default-server");
+    expectedCommandLineElements.add(serverLauncher.getMemberName().toLowerCase());
+    expectedCommandLineElements.add("--rebalance");
+    //expectedCommandLineElements.add(String.format("--server-bind-address=%1$s", serverLauncher.getServerBindAddress().getHostName()));
+    expectedCommandLineElements.add(String.format("--server-port=%1$d", serverLauncher.getServerPort()));
+    expectedCommandLineElements.add(
+      String.format("--critical-heap-percentage=%1$s", serverLauncher.getCriticalHeapPercentage()));
+    expectedCommandLineElements.add(
+      String.format("--eviction-heap-percentage=%1$s", serverLauncher.getEvictionHeapPercentage()));
+
+    expectedCommandLineElements.add("-d" + DistributionConfig.GEMFIRE_PREFIX + "" + START_DEV_REST_API
+ "=" + "true");
+    expectedCommandLineElements.add("-d" + DistributionConfig.GEMFIRE_PREFIX + "" + HTTP_SERVICE_PORT
+ "=" + "8080");
+    expectedCommandLineElements.add("-d" + DistributionConfig.GEMFIRE_PREFIX + "" + HTTP_SERVICE_BIND_ADDRESS
+ "=" + "localhost");
+
+
+    for (String commandLineElement : commandLineElements) {
+      expectedCommandLineElements.remove(commandLineElement.toLowerCase());
+    }
+
+    assertTrue(String.format("Expected ([]); but was (%1$s)", expectedCommandLineElements),
+      expectedCommandLineElements.isEmpty());
+  }
+
+
+  @Test
   public void testReadPidWithNonExistingFile() {
     assertEquals(LauncherLifecycleCommands.INVALID_PID,
             getLauncherLifecycleCommands().readPid(new File("/path/to/non_existing/pid.file")));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7eabd0b0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommands.java
b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommands.java
index 03eff6d..43d1558 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommands.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommands.java
@@ -1560,9 +1560,9 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport
{
       gemfireProperties.setProperty(LOCK_MEMORY, StringUtils.valueOf(lockMemory, StringUtils.EMPTY_STRING));
       gemfireProperties.setProperty(OFF_HEAP_MEMORY_SIZE, StringUtils.valueOf(offHeapMemorySize,
StringUtils.EMPTY_STRING));
 
-      gemfireProperties.setProperty(DistributionConfig.START_DEV_REST_API_NAME, StringUtils.valueOf(startRestApi,
StringUtils.EMPTY_STRING));
-      gemfireProperties.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME,  StringUtils.valueOf(httpServicePort,
StringUtils.EMPTY_STRING));
-      gemfireProperties.setProperty(DistributionConfig.HTTP_SERVICE_BIND_ADDRESS_NAME,  StringUtils.valueOf(httpServiceBindAddress,
StringUtils.EMPTY_STRING));
+      gemfireProperties.setProperty(START_DEV_REST_API, StringUtils.valueOf(startRestApi,
StringUtils.EMPTY_STRING));
+      gemfireProperties.setProperty(HTTP_SERVICE_PORT,  StringUtils.valueOf(httpServicePort,
StringUtils.EMPTY_STRING));
+      gemfireProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS,  StringUtils.valueOf(httpServiceBindAddress,
StringUtils.EMPTY_STRING));
 
 
       // read the OSProcess enable redirect system property here -- TODO: replace with new
GFSH argument


Mime
View raw message