You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2020/06/23 20:05:57 UTC

[GitHub] [geode] kirklund commented on a change in pull request #5268: GEODE-8250: Create new custom log config acceptance tests

kirklund commented on a change in pull request #5268:
URL: https://github.com/apache/geode/pull/5268#discussion_r444476057



##########
File path: geode-assembly/src/acceptanceTest/java/org/apache/geode/logging/LocatorWithCustomLogConfigAcceptanceTest.java
##########
@@ -0,0 +1,291 @@
+/*
+ * 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 org.apache.geode.logging;
+
+import static java.nio.file.Files.copy;
+import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPorts;
+import static org.apache.geode.test.assertj.LogFileAssert.assertThat;
+import static org.apache.geode.test.awaitility.GeodeAwaitility.await;
+import static org.apache.geode.test.util.ResourceUtils.createFileFromResource;
+import static org.apache.geode.test.util.ResourceUtils.getResource;
+
+import java.nio.file.Path;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.junit.rules.TestName;
+
+import org.apache.geode.test.junit.rules.RequiresGeodeHome;
+import org.apache.geode.test.junit.rules.gfsh.GfshRule;
+
+public class LocatorWithCustomLogConfigAcceptanceTest {
+
+  private static final String CONFIG_WITH_GEODE_PLUGINS_FILE_NAME =
+      "LocatorWithCustomLogConfigAcceptanceTestWithGeodePlugins.xml";
+  private static final String CONFIG_WITHOUT_GEODE_PLUGINS_FILE_NAME =
+      "LocatorWithCustomLogConfigAcceptanceTestWithoutGeodePlugins.xml";
+
+  private String locatorName;
+  private Path workingDir;
+  private int locatorPort;
+  private int httpPort;
+  private int rmiPort;
+  private Path configWithGeodePluginsFile;
+  private Path configWithoutGeodePluginsFile;
+  private Path locatorLogFile;
+  private Path pulseLogFile;
+  private Path customLogFile;
+
+  @Rule
+  public GfshRule gfshRule = new GfshRule();
+  @Rule
+  public RequiresGeodeHome requiresGeodeHome = new RequiresGeodeHome();
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
+  @Rule
+  public TestName testName = new TestName();
+
+  @Before
+  public void setUpLogConfigFiles() {
+    configWithGeodePluginsFile = createFileFromResource(
+        getResource(CONFIG_WITH_GEODE_PLUGINS_FILE_NAME), temporaryFolder.getRoot(),
+        CONFIG_WITH_GEODE_PLUGINS_FILE_NAME)
+            .toPath();
+
+    configWithoutGeodePluginsFile = createFileFromResource(
+        getResource(CONFIG_WITHOUT_GEODE_PLUGINS_FILE_NAME), temporaryFolder.getRoot(),
+        CONFIG_WITHOUT_GEODE_PLUGINS_FILE_NAME)
+            .toPath();
+  }
+
+  @Before
+  public void setUpOutputFiles() {
+    locatorName = testName.getMethodName();
+
+    workingDir = temporaryFolder.getRoot().toPath().toAbsolutePath();
+    locatorLogFile = workingDir.resolve(locatorName + ".log");
+    pulseLogFile = workingDir.resolve("pulse.log");
+    customLogFile = workingDir.resolve("custom.log");
+  }
+
+  @Before
+  public void setUpRandomPorts() {
+    int[] ports = getRandomAvailableTCPPorts(3);
+
+    locatorPort = ports[0];
+    httpPort = ports[1];
+    rmiPort = ports[2];
+  }
+
+  @After
+  public void stopLocator() {
+    gfshRule.execute("stop locator --dir=" + workingDir);
+  }
+
+  @Test
+  public void locatorLauncherUsesDefaultLoggingConfig() {
+    String startLocatorCommand = String.join(" ",
+        "start locator",
+        "--name=" + locatorName,
+        "--dir=" + workingDir,

Review comment:
       Unfortunately, some of these tests need to add a log4j2.xml file into the classpath (ie, in the workingDir which is then added to the classpath). I've tried making the changes you recommend, but GfshRule does leave the processes around -- it doesn't succeed in stopping them.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org