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/18 17:28:44 UTC

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

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



##########
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);

Review comment:
       GfshRule itself will try to stop all the processes it starts using the rule if you allow it to host the working dir of all the servers/locators it started. Using the gfshRule.getWorkingDir will get the temp folder that gfsh uses and all the servers/locators' working dir will be under there. That way, when tests finish, GfshRule will kill all the members automatically.

##########
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();

Review comment:
       in order to use GfshRule you have to have geode home set already (it will give you an error if you don't). so you don't really need this rule here.

##########
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:
       so basically, no need to give a dir here if you allow gfshrule to manage the dir




----------------------------------------------------------------
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