geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject incubator-geode git commit: Use TemporaryFolder for ConfigDiskDir_
Date Mon, 02 May 2016 17:56:02 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-1255 cd02af01c -> 6cd078f7b


Use TemporaryFolder for ConfigDiskDir_


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

Branch: refs/heads/feature/GEODE-1255
Commit: 6cd078f7b2b08fd545a78581d0962e08b4304c30
Parents: cd02af0
Author: Kirk Lund <klund@apache.org>
Authored: Mon May 2 10:55:33 2016 -0700
Committer: Kirk Lund <klund@apache.org>
Committed: Mon May 2 10:55:33 2016 -0700

----------------------------------------------------------------------
 ...tractLocatorLauncherIntegrationTestCase.java |   7 +-
 ...ocatorLauncherRemoteIntegrationTestCase.java |  67 +++++++
 .../LocatorLauncherLocalIntegrationTest.java    |  64 +++----
 ...rRemoteWithCustomLoggingIntegrationTest.java | 189 +++++++++++++++++++
 .../SharedConfigurationTestUtils.java           |  40 ++++
 5 files changed, 329 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6cd078f7/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLocatorLauncherIntegrationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLocatorLauncherIntegrationTestCase.java
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLocatorLauncherIntegrationTestCase.java
index 93c18d1..5bdf610 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLocatorLauncherIntegrationTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLocatorLauncherIntegrationTestCase.java
@@ -27,6 +27,7 @@ import org.junit.rules.TemporaryFolder;
 import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
 import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
 import com.gemstone.gemfire.distributed.LocatorLauncher.LocatorState;
+import com.gemstone.gemfire.distributed.internal.SharedConfiguration;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.internal.DistributionLocator;
 
@@ -37,7 +38,9 @@ public abstract class AbstractLocatorLauncherIntegrationTestCase extends
Abstrac
 
   protected volatile int locatorPort;
   protected volatile LocatorLauncher launcher;
-  
+  protected volatile String workingDirectory;
+  protected volatile String clusterConfigDirectory;
+
   @Rule
   public ErrorCollector errorCollector = new ErrorCollector();
 
@@ -49,6 +52,8 @@ public abstract class AbstractLocatorLauncherIntegrationTestCase extends
Abstrac
     final int port = AvailablePortHelper.getRandomAvailableTCPPort();
     System.setProperty(DistributionLocator.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY, String.valueOf(port));
     this.locatorPort = port;
+    this.workingDirectory = this.temporaryFolder.getRoot().getCanonicalPath();
+    this.clusterConfigDirectory = this.temporaryFolder.newFolder(SharedConfiguration.CLUSTER_CONFIG_DISK_DIR_PREFIX
+ getUniqueName()).getCanonicalPath();
   }
   
   @After

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6cd078f7/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLocatorLauncherRemoteIntegrationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLocatorLauncherRemoteIntegrationTestCase.java
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLocatorLauncherRemoteIntegrationTestCase.java
new file mode 100644
index 0000000..ecfb952
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLocatorLauncherRemoteIntegrationTestCase.java
@@ -0,0 +1,67 @@
+/*
+ * 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 com.gemstone.gemfire.distributed;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+
+import com.gemstone.gemfire.internal.process.ProcessStreamReader;
+
+public abstract class AbstractLocatorLauncherRemoteIntegrationTestCase extends AbstractLocatorLauncherIntegrationTestCase
{
+
+  protected volatile Process process;
+  protected volatile ProcessStreamReader processOutReader;
+  protected volatile ProcessStreamReader processErrReader;
+
+  @Before
+  public final void setUpAbstractLocatorLauncherRemoteIntegrationTestCase() throws Exception
{
+  }
+
+  @After
+  public final void tearDownAbstractLocatorLauncherRemoteIntegrationTestCase() throws Exception
{
+    if (this.process != null) {
+      this.process.destroy();
+      this.process = null;
+    }
+    if (this.processOutReader != null && this.processOutReader.isRunning()) {
+      this.processOutReader.stop();
+    }
+    if (this.processErrReader != null && this.processErrReader.isRunning()) {
+      this.processErrReader.stop();
+    }
+  }
+
+  /**
+   * Override as needed.
+   */
+  protected List<String> getJvmArguments() {
+    final List<String> jvmArguments = new ArrayList<String>();
+    jvmArguments.add("-Dgemfire.log-level=config");
+    return jvmArguments;
+  }
+
+  /**
+   * Remove final if a test needs to override.
+   */
+  protected final AbstractLauncher.Status getExpectedStopStatusForNotRunning() {
+    return AbstractLauncher.Status.NOT_RESPONDING;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6cd078f7/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalIntegrationTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalIntegrationTest.java
index bb18a22..7e8e667 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalIntegrationTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalIntegrationTest.java
@@ -34,6 +34,7 @@ import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
 import com.gemstone.gemfire.distributed.LocatorLauncher.LocatorState;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.InternalLocator;
+import com.gemstone.gemfire.distributed.internal.SharedConfiguration;
 import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.internal.DistributionLocator;
@@ -69,13 +70,12 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
 
   @Test
   public void testBuilderSetProperties() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
     this.launcher = new Builder()
         .setForce(true)
         .setMemberName(getUniqueName())
         .setPort(this.locatorPort)
-        .setWorkingDirectory(rootFolder)
+        .setWorkingDirectory(this.workingDirectory)
+        .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
         .set(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME, "true")
         .set(DistributionConfig.LOG_LEVEL_NAME, "config")
         .set(DistributionConfig.MCAST_PORT_NAME, "0")
@@ -115,13 +115,12 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
   
   @Test
   public void testStartCreatesPidFile() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
     this.launcher = new Builder()
         .setMemberName(getUniqueName())
         .setPort(this.locatorPort)
         .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
+        .setWorkingDirectory(this.workingDirectory)
+        .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
         .set(DistributionConfig.LOG_LEVEL_NAME, "config")
         .build();
 
@@ -154,8 +153,6 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
 
   @Test
   public void testStartDeletesStaleControlFiles() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
     // create existing control files
     this.stopRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStopRequestFileName());
     this.stopRequestFile.createNewFile();
@@ -174,7 +171,8 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
         .setMemberName(getUniqueName())
         .setPort(this.locatorPort)
         .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
+        .setWorkingDirectory(this.workingDirectory)
+        .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
         .set(DistributionConfig.LOG_LEVEL_NAME, "config");
 
     assertFalse(builder.getForce());
@@ -216,8 +214,6 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
   
   @Test
   public void testStartOverwritesStalePidFile() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
     // create existing pid file
     this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
     assertFalse("Integer.MAX_VALUE shouldn't be the same as local pid " + Integer.MAX_VALUE,
Integer.MAX_VALUE == ProcessUtils.identifyPid());
@@ -228,7 +224,8 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
         .setMemberName(getUniqueName())
         .setPort(this.locatorPort)
         .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
+        .setWorkingDirectory(this.workingDirectory)
+        .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
         .set(DistributionConfig.LOG_LEVEL_NAME, "config");
 
     assertFalse(builder.getForce());
@@ -328,8 +325,6 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
   
   @Test
   public void testStartWithDefaultPortInUseFails() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
     this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.locatorPort,
50, null, -1);
     assertTrue(this.socket.isBound());
     assertFalse(this.socket.isClosed());
@@ -342,7 +337,8 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
     this.launcher = new Builder()
         .setMemberName(getUniqueName())
         .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
+        .setWorkingDirectory(this.workingDirectory)
+        .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
         .set(DistributionConfig.LOG_LEVEL_NAME, "config")
         .build();
     
@@ -492,8 +488,6 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
   
   @Test
   public void testStartUsingPort() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
     // generate one free port and then use it instead of default
     final int freeTCPPort = AvailablePortHelper.getRandomAvailableTCPPort();
     assertTrue(AvailablePort.isPortAvailable(freeTCPPort, AvailablePort.SOCKET));
@@ -502,7 +496,8 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
         .setMemberName(getUniqueName())
         .setPort(freeTCPPort)
         .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
+        .setWorkingDirectory(this.workingDirectory)
+        .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
         .set(DistributionConfig.LOG_LEVEL_NAME, "config")
         .build();
 
@@ -541,8 +536,6 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
   
   @Test
   public void testStartUsingPortInUseFails() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
     // generate one free port and then use it instead of default
     final int freeTCPPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     this.socket = SocketCreator.getDefaultInstance().createServerSocket(freeTCPPort, 50,
null, -1);
@@ -551,7 +544,8 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
         .setMemberName(getUniqueName())
         .setPort(freeTCPPort)
         .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
+        .setWorkingDirectory(this.workingDirectory)
+        .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
         .set(DistributionConfig.LOG_LEVEL_NAME, "config")
         .build();
     
@@ -607,14 +601,13 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
   
   @Test
   public void testStatusUsingPid() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-    
     // build and start the locator
     final Builder builder = new Builder()
         .setMemberName(getUniqueName())
         .setPort(this.locatorPort)
         .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
+        .setWorkingDirectory(this.workingDirectory)
+        .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
         .set(DistributionConfig.LOG_LEVEL_NAME, "config");
     
     assertFalse(builder.getForce());
@@ -645,7 +638,7 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
       assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
       assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
       assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
-      assertEquals(rootFolder + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
+      assertEquals(this.workingDirectory + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
       assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
       assertEquals(getUniqueName(), actualStatus.getMemberName());
     } catch (Throwable e) {
@@ -672,13 +665,12 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
   
   @Test
   public void testStatusUsingWorkingDirectory() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-    
     final Builder builder = new Builder()
         .setMemberName(getUniqueName())
         .setPort(this.locatorPort)
         .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
+        .setWorkingDirectory(this.workingDirectory)
+        .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
         .set(DistributionConfig.LOG_LEVEL_NAME, "config");
     
     assertFalse(builder.getForce());
@@ -696,7 +688,7 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
       assertTrue(pid > 0);
       assertEquals(ProcessUtils.identifyPid(), pid);
   
-      dirLauncher = new Builder().setWorkingDirectory(rootFolder).build();
+      dirLauncher = new Builder().setWorkingDirectory(this.workingDirectory).build();
       assertNotNull(dirLauncher);
       assertFalse(dirLauncher.isRunning());
 
@@ -709,7 +701,7 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
       assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
       assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
       assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
-      assertEquals(rootFolder + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
+      assertEquals(this.workingDirectory + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
       assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
       assertEquals(getUniqueName(), actualStatus.getMemberName());
     } catch (Throwable e) {
@@ -736,13 +728,12 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
   
   @Test
   public void testStopUsingPid() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
     final Builder builder = new Builder()
         .setMemberName(getUniqueName())
         .setPort(this.locatorPort)
         .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
+        .setWorkingDirectory(this.workingDirectory)
+        .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
         .set(DistributionConfig.LOG_LEVEL_NAME, "config");
 
     assertFalse(builder.getForce());
@@ -789,13 +780,12 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
   
   @Test
   public void testStopUsingWorkingDirectory() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-    
     final Builder builder = new Builder()
         .setMemberName(getUniqueName())
         .setPort(this.locatorPort)
         .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
+        .setWorkingDirectory(this.workingDirectory)
+        .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
         .set(DistributionConfig.LOG_LEVEL_NAME, "config");
 
     assertFalse(builder.getForce());
@@ -814,7 +804,7 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
       assertTrue(pid > 0);
       assertEquals(ProcessUtils.identifyPid(), pid);
 
-      dirLauncher = new Builder().setWorkingDirectory(rootFolder).build();
+      dirLauncher = new Builder().setWorkingDirectory(this.workingDirectory).build();
       assertNotNull(dirLauncher);
       assertFalse(dirLauncher.isRunning());
       

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6cd078f7/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java
new file mode 100644
index 0000000..b66350f
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java
@@ -0,0 +1,189 @@
+/*
+ * 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 com.gemstone.gemfire.distributed;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.internal.process.ProcessStreamReader;
+import com.gemstone.gemfire.internal.process.ProcessType;
+import com.gemstone.gemfire.internal.process.ProcessUtils;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests for launching a Locator in a forked process with custom logging configuration
+ */
+@Category(IntegrationTest.class)
+public class LocatorLauncherRemoteWithCustomLoggingIntegrationTest extends AbstractLocatorLauncherRemoteIntegrationTestCase
{
+
+  @Test
+  public void testStartUsesCustomLoggingConfiguration() throws Throwable {
+    // TODO: create working dir, copy custom xml to that dir and point log4j at it
+
+    String workingDirectory = this.temporaryFolder.getRoot().getCanonicalPath();
+    System.out.println("KIRK: workingDirectory=" + workingDirectory);
+
+
+    // build and start the locator
+    final List<String> jvmArguments = getJvmArguments();
+
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-Dlog4j.configurationFile=/Users/klund/dev/gemfire/open/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml");
+    //command.add("-D" + ConfigurationFactory.CONFIGURATION_FILE_PROPERTY + "=/Users/klund/dev/doesnotexist.xml");
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(LocatorLauncher.class.getName());
+    command.add(LocatorLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--port=" + this.locatorPort);
+    command.add("--redirect-output");
+
+    for (String line : command) {
+      System.out.println("KIRK:testStartUsesCustomLoggingConfiguration:stdout: " + line);
+    }
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(new
ToSystemOut()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(new
ToSystemOut()).build().start();
+
+    int pid = 0;
+    this.launcher = new LocatorLauncher.Builder()
+            .setWorkingDirectory(workingDirectory)
+            .build();
+    try {
+      waitForLocatorToStart(this.launcher);
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(),
logFileName).exists());
+
+      // check the status
+      final LocatorLauncher.LocatorState locatorState = this.launcher.status();
+      assertNotNull(locatorState);
+      assertEquals(AbstractLauncher.Status.ONLINE, locatorState.getStatus());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the locator
+    try {
+      assertEquals(AbstractLauncher.Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Test
+  public void testStartUsesCustomLoggingConfigurationWithLauncherLifecycleCommands() throws
Throwable {
+    // TODO: create working dir, copy custom xml to that dir and point log4j at it
+
+    // build and start the locator
+    final List<String> jvmArguments = getJvmArguments();
+
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-Dlog4j.configurationFile=/Users/klund/dev/gemfire/open/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml");
+    //command.add("-D" + ConfigurationFactory.CONFIGURATION_FILE_PROPERTY + "=/Users/klund/dev/doesnotexist.xml");
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(LocatorLauncher.class.getName());
+    command.add(LocatorLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--port=" + this.locatorPort);
+    command.add("--redirect-output");
+
+    for (String line : command) {
+      System.out.println("KIRK:testStartUsesCustomLoggingConfiguration:stdout: " + line);
+    }
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(new
ToSystemOut()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(new
ToSystemOut()).build().start();
+
+    int pid = 0;
+    String workingDirectory = this.temporaryFolder.getRoot().getCanonicalPath();
+    System.out.println("KIRK: workingDirectory=" + workingDirectory);
+    this.launcher = new LocatorLauncher.Builder()
+            .setWorkingDirectory(workingDirectory)
+            .build();
+    try {
+      waitForLocatorToStart(this.launcher);
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(),
logFileName).exists());
+
+      // check the status
+      final LocatorLauncher.LocatorState locatorState = this.launcher.status();
+      assertNotNull(locatorState);
+      assertEquals(AbstractLauncher.Status.ONLINE, locatorState.getStatus());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the locator
+    try {
+      assertEquals(AbstractLauncher.Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Override
+  protected final List<String> getJvmArguments() {
+    final List<String> jvmArguments = new ArrayList<String>();
+    jvmArguments.add("-Dgemfire.log-level=config");
+    return jvmArguments;
+  }
+
+  private static class ToSystemOut implements ProcessStreamReader.InputListener {
+    @Override
+    public void notifyInputLine(String line) {
+      System.out.println(line);
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6cd078f7/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationTestUtils.java
b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationTestUtils.java
new file mode 100644
index 0000000..235f02e
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationTestUtils.java
@@ -0,0 +1,40 @@
+/*
+ * 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 com.gemstone.gemfire.management.internal.configuration;
+
+import com.gemstone.gemfire.distributed.internal.InternalLocator;
+import com.gemstone.gemfire.distributed.internal.SharedConfiguration;
+import com.gemstone.gemfire.test.dunit.SerializableRunnable;
+import com.gemstone.gemfire.test.dunit.internal.JUnit3DistributedTestCase;
+
+public class SharedConfigurationTestUtils {
+
+  public static final SerializableRunnable cleanupLocator = new SerializableRunnable() {
+    @Override
+    public void run() {
+      InternalLocator locator = InternalLocator.getLocator();
+      if (locator != null) {
+        SharedConfiguration sharedConfig = locator.getSharedConfiguration();
+        if (sharedConfig != null) {
+          sharedConfig.destroySharedConfiguration_forTestsOnly();
+        }
+        locator.stop();
+      }
+      JUnit3DistributedTestCase.disconnectAllFromDS();
+    }
+  };
+}


Mime
View raw message