Repository: geode Updated Branches: refs/heads/develop e5121abad -> bf788176b
http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart2DUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart2DUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart2DUnitTest.java deleted file mode 100644 index 2b2e524..0000000 --- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart2DUnitTest.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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.management.internal.cli.commands; - -import static org.apache.geode.test.dunit.Assert.assertEquals; -import static org.apache.geode.test.dunit.Assert.fail; -import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter; - -import org.apache.commons.io.FileUtils; -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.RegionFactory; -import org.apache.geode.cache.RegionShortcut; -import org.apache.geode.internal.logging.LogWriterImpl; -import org.apache.geode.management.cli.Result; -import org.apache.geode.management.internal.cli.result.CommandResult; -import org.apache.geode.test.dunit.Host; -import org.apache.geode.test.dunit.SerializableRunnable; -import org.apache.geode.test.dunit.VM; -import org.apache.geode.test.junit.categories.DistributedTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.File; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * Dunit class for testing gemfire function commands : export logs - */ -@Category(DistributedTest.class) -public class MiscellaneousCommandsExportLogsPart2DUnitTest extends CliCommandTestBase { - - private static final long serialVersionUID = 1L; - - void setupForExportLogs() { - final VM vm1 = Host.getHost(0).getVM(1); - setUpJmxManagerOnVm0ThenConnect(null); - - vm1.invoke(new SerializableRunnable() { - public void run() { - // no need to close cache as it will be closed as part of teardown2 - Cache cache = getCache(); - - RegionFactory<Integer, Integer> dataRegionFactory = - cache.createRegionFactory(RegionShortcut.PARTITION); - Region region = dataRegionFactory.create("testRegion"); - for (int i = 0; i < 5; i++) { - region.put("key" + (i + 200), "value" + (i + 200)); - } - } - }); - } - - String getCurrentTimeString() { - SimpleDateFormat sf = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss_SSS_z"); - Date startDate = new Date(System.currentTimeMillis()); - String formattedStartDate = sf.format(startDate); - return ("_" + formattedStartDate); - } - - @Test - public void testExportLogsForLogLevel() throws IOException { - setupForExportLogs(); - - Date startDate = new Date(System.currentTimeMillis() - 60 * 1000); - SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd"); - String start = sf.format(startDate); - - Date enddate = new Date(System.currentTimeMillis() + 60 * 1000); - String end = sf.format(enddate); - String dir = getCurrentTimeString(); - - String logLevel = LogWriterImpl.levelToString(LogWriterImpl.CONFIG_LEVEL); - - MiscellaneousCommands misc = new MiscellaneousCommands(); - getCache(); - - Result cmdResult = misc.exportLogsPreprocessing("./testExportLogsForLogLevel" + dir, null, null, - logLevel, false, false, start, end, 1); - - getLogWriter().info("testExportLogsForLogLevel command=" + cmdResult); - - if (cmdResult != null) { - String cmdStringRsult = commandResultToString((CommandResult) cmdResult); - getLogWriter().info("testExportLogsForLogLevel cmdStringRsult=" + cmdStringRsult); - assertEquals(Result.Status.OK, cmdResult.getStatus()); - } else { - fail("testExportLogsForLogLevel failed as did not get CommandResult"); - } - FileUtils.deleteDirectory(new File("testExportLogsForLogLevel" + dir)); - } - - @Test - public void testExportLogsForLogLevelWithUPTOLOGLEVEL() throws IOException { - setupForExportLogs(); - - Date startDate = new Date(System.currentTimeMillis() - 2 * 60 * 1000); - SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd"); - String start = sf.format(startDate); - - Date enddate = new Date(System.currentTimeMillis() + 2 * 60 * 60 * 1000); - String end = sf.format(enddate); - String dir = getCurrentTimeString(); - - String logLevel = LogWriterImpl.levelToString(LogWriterImpl.SEVERE_LEVEL); - - MiscellaneousCommands misc = new MiscellaneousCommands(); - getCache(); - - Result cmdResult = - misc.exportLogsPreprocessing("./testExportLogsForLogLevelWithUPTOLOGLEVEL" + dir, null, - null, logLevel, true, false, start, end, 1); - - getLogWriter().info("testExportLogsForLogLevelWithUPTOLOGLEVEL command=" + cmdResult); - - if (cmdResult != null) { - String cmdStringRsult = commandResultToString((CommandResult) cmdResult); - getLogWriter() - .info("testExportLogsForLogLevelWithUPTOLOGLEVEL cmdStringRsult=" + cmdStringRsult); - - assertEquals(Result.Status.OK, cmdResult.getStatus()); - } else { - fail("testExportLogsForLogLevelWithUPTOLOGLEVEL failed as did not get CommandResult"); - } - FileUtils.deleteDirectory(new File("testExportLogsForLogLevelWithUPTOLOGLEVEL" + dir)); - } -} http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart3DUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart3DUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart3DUnitTest.java deleted file mode 100644 index efef2c4..0000000 --- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart3DUnitTest.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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.management.internal.cli.commands; - -import static org.apache.geode.distributed.ConfigurationProperties.GROUPS; -import static org.apache.geode.distributed.ConfigurationProperties.NAME; -import static org.apache.geode.test.dunit.Assert.assertEquals; -import static org.apache.geode.test.dunit.Assert.fail; -import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter; - -import org.apache.commons.io.FileUtils; -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.RegionFactory; -import org.apache.geode.cache.RegionShortcut; -import org.apache.geode.internal.logging.LogWriterImpl; -import org.apache.geode.management.cli.Result; -import org.apache.geode.management.internal.cli.result.CommandResult; -import org.apache.geode.test.dunit.Host; -import org.apache.geode.test.dunit.SerializableRunnable; -import org.apache.geode.test.dunit.VM; -import org.apache.geode.test.junit.categories.DistributedTest; -import org.apache.geode.test.junit.categories.FlakyTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.File; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Properties; - -/** - * Dunit class for testing gemfire function commands : export logs - */ -@Category(DistributedTest.class) -public class MiscellaneousCommandsExportLogsPart3DUnitTest extends CliCommandTestBase { - - private static final long serialVersionUID = 1L; - - public String getMemberId() { - Cache cache = getCache(); - return cache.getDistributedSystem().getDistributedMember().getId(); - } - - void setupForExportLogs() { - final VM vm1 = Host.getHost(0).getVM(1); - setUpJmxManagerOnVm0ThenConnect(null); - - vm1.invoke(new SerializableRunnable() { - public void run() { - // no need to close cache as it will be closed as part of teardown2 - Cache cache = getCache(); - - RegionFactory<Integer, Integer> dataRegionFactory = - cache.createRegionFactory(RegionShortcut.PARTITION); - Region region = dataRegionFactory.create("testRegion"); - for (int i = 0; i < 5; i++) { - region.put("key" + (i + 200), "value" + (i + 200)); - } - } - }); - } - - String getCurrentTimeString() { - SimpleDateFormat sf = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss_SSS_z"); - Date startDate = new Date(System.currentTimeMillis()); - String formattedStartDate = sf.format(startDate); - return ("_" + formattedStartDate); - } - - @Category(FlakyTest.class) // GEODE-672: random ports, java.rmi.server.ExportException: Port - // already in use, HeadlessGfsh, disk IO - @Test - public void testExportLogsForGroup() throws IOException { - Properties localProps = new Properties(); - localProps.setProperty(NAME, "Manager"); - localProps.setProperty(GROUPS, "Group1"); - setUpJmxManagerOnVm0ThenConnect(localProps); - String dir = getCurrentTimeString(); - - Date startDate = new Date(System.currentTimeMillis() - 2 * 60 * 1000); - SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd"); - String start = sf.format(startDate); - - Date enddate = new Date(System.currentTimeMillis() + 2 * 60 * 60 * 1000); - String end = sf.format(enddate); - - String logLevel = LogWriterImpl.levelToString(LogWriterImpl.INFO_LEVEL); - - MiscellaneousCommands misc = new MiscellaneousCommands(); - getCache(); - String[] groups = new String[1]; - groups[0] = "Group1"; - - Result cmdResult = misc.exportLogsPreprocessing("./testExportLogsForGroup" + dir, groups, null, - logLevel, false, false, start, end, 1); - - getLogWriter().info("testExportLogsForGroup command result =" + cmdResult); - if (cmdResult != null) { - String cmdStringRsult = commandResultToString((CommandResult) cmdResult); - getLogWriter().info("testExportLogsForGroup cmdStringRsult=" + cmdStringRsult); - assertEquals(Result.Status.OK, cmdResult.getStatus()); - } else { - fail("testExportLogsForGroup failed as did not get CommandResult"); - } - FileUtils.deleteQuietly(new File("testExportLogsForGroup" + dir)); - } - - @Test - public void testExportLogsForMember() throws IOException { - setUpJmxManagerOnVm0ThenConnect(null); - - Date startDate = new Date(System.currentTimeMillis() - 2 * 60 * 1000); - SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd"); - String start = sf.format(startDate); - - Date enddate = new Date(System.currentTimeMillis() + 2 * 60 * 60 * 1000); - String end = sf.format(enddate); - - final VM vm1 = Host.getHost(0).getVM(1); - final String vm1MemberId = (String) vm1.invoke(() -> getMemberId()); - String dir = getCurrentTimeString(); - - String logLevel = LogWriterImpl.levelToString(LogWriterImpl.INFO_LEVEL); - - MiscellaneousCommands misc = new MiscellaneousCommands(); - getCache(); - - Result cmdResult = misc.exportLogsPreprocessing("./testExportLogsForMember" + dir, null, - vm1MemberId, logLevel, false, false, start, end, 1); - - getLogWriter().info("testExportLogsForMember command result =" + cmdResult); - - if (cmdResult != null) { - String cmdStringRsult = commandResultToString((CommandResult) cmdResult); - getLogWriter().info("testExportLogsForMember cmdStringRsult=" + cmdStringRsult); - assertEquals(Result.Status.OK, cmdResult.getStatus()); - } else { - fail("testExportLogsForMember failed as did not get CommandResult"); - } - FileUtils.deleteQuietly(new File("testExportLogsForMember" + dir)); - } -} http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart4DUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart4DUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart4DUnitTest.java deleted file mode 100644 index 9d64bd9..0000000 --- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommandsExportLogsPart4DUnitTest.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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.management.internal.cli.commands; - -import static org.apache.geode.test.dunit.Assert.assertEquals; -import static org.apache.geode.test.dunit.Assert.fail; -import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter; - -import org.apache.commons.io.FileUtils; -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.RegionFactory; -import org.apache.geode.cache.RegionShortcut; -import org.apache.geode.internal.logging.LogWriterImpl; -import org.apache.geode.management.cli.Result; -import org.apache.geode.management.internal.cli.result.CommandResult; -import org.apache.geode.test.dunit.Host; -import org.apache.geode.test.dunit.SerializableRunnable; -import org.apache.geode.test.dunit.VM; -import org.apache.geode.test.junit.categories.DistributedTest; -import org.apache.geode.test.junit.categories.FlakyTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.File; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * Dunit class for testing gemfire function commands : export logs - */ -@Category(DistributedTest.class) -public class MiscellaneousCommandsExportLogsPart4DUnitTest extends CliCommandTestBase { - - private static final long serialVersionUID = 1L; - - void setupForExportLogs() { - final VM vm1 = Host.getHost(0).getVM(1); - setUpJmxManagerOnVm0ThenConnect(null); - - vm1.invoke(new SerializableRunnable() { - public void run() { - // no need to close cache as it will be closed as part of teardown2 - Cache cache = getCache(); - - RegionFactory<Integer, Integer> dataRegionFactory = - cache.createRegionFactory(RegionShortcut.PARTITION); - Region region = dataRegionFactory.create("testRegion"); - for (int i = 0; i < 5; i++) { - region.put("key" + (i + 200), "value" + (i + 200)); - } - } - }); - } - - String getCurrentTimeString() { - SimpleDateFormat sf = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss_SSS_z"); - Date startDate = new Date(System.currentTimeMillis()); - String formattedStartDate = sf.format(startDate); - return ("_" + formattedStartDate); - } - - @Test - public void testExportLogsForTimeRange1() throws IOException { - setupForExportLogs(); - Date startDate = new Date(System.currentTimeMillis() - 1 * 60 * 1000); - SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd"); - String start = sf.format(startDate); - - Date enddate = new Date(System.currentTimeMillis() + 1 * 60 * 60 * 1000); - String end = sf.format(enddate); - String dir = getCurrentTimeString(); - - String logLevel = LogWriterImpl.levelToString(LogWriterImpl.INFO_LEVEL); - - MiscellaneousCommands misc = new MiscellaneousCommands(); - getCache(); - - Result cmdResult = misc.exportLogsPreprocessing("./testExportLogsForTimeRange1" + dir, null, - null, logLevel, false, false, start, end, 1); - - getLogWriter().info("testExportLogsForTimeRange1 command result =" + cmdResult); - - if (cmdResult != null) { - String cmdStringRsult = commandResultToString((CommandResult) cmdResult); - getLogWriter().info("testExportLogsForTimeRange1 cmdStringRsult=" + cmdStringRsult); - assertEquals(Result.Status.OK, cmdResult.getStatus()); - } else { - fail("testExportLogsForTimeRange1 failed as did not get CommandResult"); - } - FileUtils.deleteQuietly(new File("testExportLogsForTimeRange1" + dir)); - } - - @Category(FlakyTest.class) // GEODE-1500 (http) - @Test - public void testExportLogsForTimeRangeForOnlyStartTime() throws IOException { - setupForExportLogs(); - Date date = new Date(); - date.setTime(System.currentTimeMillis() - 30 * 1000); - SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd/HH:mm"); - String s = sf.format(date); - String dir = getCurrentTimeString(); - - String logLevel = LogWriterImpl.levelToString(LogWriterImpl.INFO_LEVEL); - - MiscellaneousCommands misc = new MiscellaneousCommands(); - getCache(); - - Result cmdResult = - misc.exportLogsPreprocessing("./testExportLogsForTimeRangeForOnlyStartTime" + dir, null, - null, logLevel, false, false, s, null, 1); - - getLogWriter().info("testExportLogsForTimeRangeForOnlyStartTime command result =" + cmdResult); - - if (cmdResult != null) { - String cmdStringRsult = commandResultToString((CommandResult) cmdResult); - getLogWriter() - .info("testExportLogsForTimeRangeForOnlyStartTime cmdStringRsult=" + cmdStringRsult); - assertEquals(Result.Status.OK, cmdResult.getStatus()); - } else { - fail("testExportLogsForTimeRangeForOnlyStartTime failed as did not get CommandResult"); - } - FileUtils.deleteQuietly(new File("testExportLogsForTimeRangeForOnlyStartTime" + dir)); - } -} http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java new file mode 100644 index 0000000..abae1de --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java @@ -0,0 +1,143 @@ +/* + * 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.management.internal.cli.functions; + + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.commons.io.FileUtils; +import org.apache.geode.cache.Cache; +import org.apache.geode.cache.execute.FunctionContext; +import org.apache.geode.cache.execute.ResultSender; +import org.apache.geode.internal.cache.GemFireCacheImpl; +import org.apache.geode.internal.cache.execute.FunctionContextImpl; +import org.apache.geode.test.dunit.rules.ServerStarterRule; +import org.apache.geode.test.junit.categories.IntegrationTest; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.contrib.java.lang.system.RestoreSystemProperties; +import org.junit.experimental.categories.Category; +import org.junit.rules.TemporaryFolder; + +import java.io.File; +import java.io.IOException; + +@Category(IntegrationTest.class) +public class ExportLogsFunctionIntegrationTest { + + @Rule + public TemporaryFolder temporaryFolder = new TemporaryFolder(); + + @Rule + public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties(); + + @Rule + public ServerStarterRule serverStarterRule = new ServerStarterRule(); + + private File serverWorkingDir; + + @Before + public void setup() throws Exception { + serverWorkingDir = temporaryFolder.newFolder("serverWorkingDir"); + System.setProperty("user.dir", serverWorkingDir.getCanonicalPath()); + + serverStarterRule.startServer(); + } + + @After + public void teardown() { + serverStarterRule.after(); + } + + @Test + public void exportLogsFunctionDoesNotBlowUp() throws Throwable { + File logFile1 = new File(serverWorkingDir, "server1.log"); + FileUtils.writeStringToFile(logFile1, "some log for server1 \n some other log line"); + File logFile2 = new File(serverWorkingDir, "server2.log"); + FileUtils.writeStringToFile(logFile2, "some log for server2 \n some other log line"); + + File notALogFile = new File(serverWorkingDir, "foo.txt"); + FileUtils.writeStringToFile(notALogFile, "some text"); + + ExportLogsFunction.Args args = new ExportLogsFunction.Args(null, null, "info", false); + + CapturingResultSender resultSender = new CapturingResultSender(); + FunctionContext context = new FunctionContextImpl("functionId", args, resultSender); + + new ExportLogsFunction().execute(context); + + if (resultSender.getThrowable() != null) { + throw resultSender.getThrowable(); + } + + Cache cache = GemFireCacheImpl.getInstance(); + assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull(); + } + + @Test + public void createOrGetExistingExportLogsRegionDoesNotBlowUp() throws Exception { + ExportLogsFunction.createOrGetExistingExportLogsRegion(false); + + Cache cache = GemFireCacheImpl.getInstance(); + assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNotNull(); + } + + @Test + public void destroyExportLogsRegionWorksAsExpectedForInitiatingMember() throws IOException, ClassNotFoundException { + ExportLogsFunction.createOrGetExistingExportLogsRegion(true); + Cache cache = GemFireCacheImpl.getInstance(); + assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNotNull(); + + ExportLogsFunction.destroyExportLogsRegion(); + assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull(); + } + + + @Test + public void argsCorrectlyBuildALogLevelFilter() { + ExportLogsFunction.Args args = new ExportLogsFunction.Args(null, null, "info", false); + + assertThat(args.getPermittedLogLevels()).contains("info"); + assertThat(args.getPermittedLogLevels()).contains("error"); + assertThat(args.getPermittedLogLevels()).doesNotContain("fine"); + } + + private static class CapturingResultSender implements ResultSender { + private Throwable t; + + public Throwable getThrowable() { + return t; + } + + @Override + public void sendResult(Object oneResult) { + + } + + @Override + public void lastResult(Object lastResult) { + + } + + @Override + public void sendException(Throwable t) { + this.t = t; + } + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterTest.java new file mode 100644 index 0000000..bd8a6ac --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterTest.java @@ -0,0 +1,104 @@ +/* + * 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.management.internal.cli.util; + +import static java.util.stream.Collectors.toList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.commons.io.FileUtils; +import org.apache.geode.management.internal.configuration.utils.ZipUtils; +import org.apache.geode.test.junit.categories.IntegrationTest; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TemporaryFolder; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.text.ParseException; +import java.util.Comparator; +import java.util.List; +import java.util.stream.Stream; + +@Category(IntegrationTest.class) +public class LogExporterTest { + @Rule + public TemporaryFolder temporaryFolder = new TemporaryFolder(); + + private LogExporter logExporter; + + @Before + public void setup() throws ParseException { + LogFilter logFilter = mock(LogFilter.class); + + when(logFilter.acceptsFile(any())).thenReturn(true); + when(logFilter.acceptsLine(any())).thenReturn(LogFilter.LineFilterResult.LINE_ACCEPTED); + + logExporter = new LogExporter(logFilter); + } + + + @Test + public void exportBuildsZipCorrectlyWithTwoLogFiles() throws Exception { + File serverWorkingDir = temporaryFolder.newFolder("serverWorkingDir"); + File logFile1 = new File(serverWorkingDir, "server1.log"); + FileUtils.writeStringToFile(logFile1, "some log for server1 \n some other log line"); + File logFile2 = new File(serverWorkingDir, "server2.log"); + FileUtils.writeStringToFile(logFile2, "some log for server2 \n some other log line"); + + File notALogFile = new File(serverWorkingDir, "foo.txt"); + FileUtils.writeStringToFile(notALogFile, "some text"); + + + Path zippedExport = logExporter.export(serverWorkingDir.toPath()); + + File unzippedExportDir = temporaryFolder.newFolder("unzippedExport"); + ZipUtils.unzip(zippedExport.toString(), unzippedExportDir.getCanonicalPath()); + + assertThat(unzippedExportDir.listFiles()).hasSize(2); + List<File> exportedFiles = Stream.of(unzippedExportDir.listFiles()) + .sorted(Comparator.comparing(File::getName)).collect(toList()); + + assertThat(exportedFiles.get(0)).hasSameContentAs(logFile1); + assertThat(exportedFiles.get(1)).hasSameContentAs(logFile2); + } + + @Test + public void findLogFilesExcludesFilesWithIncorrectExtension() throws Exception { + File workingDir = temporaryFolder.newFolder("workingDir"); + File logFile = new File(workingDir, "server.log"); + + FileUtils.writeStringToFile(logFile, "some log line"); + + File notALogFile = new File(workingDir, "foo.txt"); + FileUtils.writeStringToFile(notALogFile, "some text"); + + assertThat(logExporter.findLogFiles(workingDir.toPath())).contains(logFile.toPath()); + assertThat(logExporter.findLogFiles(workingDir.toPath())).doesNotContain(notALogFile.toPath()); + } + + @Test + public void findStatFiles() throws Exception { + + } + +} http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogFilterTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogFilterTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogFilterTest.java new file mode 100644 index 0000000..ca94fb6 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogFilterTest.java @@ -0,0 +1,126 @@ +/* + * 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.management.internal.cli.util; + +import static java.util.stream.Collectors.toSet; +import static org.apache.geode.management.internal.cli.util.LogFilter.LineFilterResult.LINE_ACCEPTED; +import static org.apache.geode.management.internal.cli.util.LogFilter.LineFilterResult.LINE_REJECTED; +import static org.apache.geode.management.internal.cli.util.LogFilter.LineFilterResult.REMAINDER_OF_FILE_REJECTED; +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.time.LocalDateTime; +import java.util.Set; +import java.util.stream.Stream; + +@Category(UnitTest.class) +public class LogFilterTest { + @Test + public void permittedLogLevelsCanFilterLines() throws Exception { + Set<String> permittedLogLevels = Stream.of("info", "finest").collect(toSet()); + + LogFilter logFilter = new LogFilter(permittedLogLevels, null, null); + + LocalDateTime now = LocalDateTime.now(); + assertThat(logFilter.acceptsLogEntry("info", now)).isEqualTo(LINE_ACCEPTED); + assertThat(logFilter.acceptsLogEntry("finest", now)).isEqualTo(LINE_ACCEPTED); + assertThat(logFilter.acceptsLogEntry("fine", now)).isEqualTo(LINE_REJECTED); + assertThat(logFilter.acceptsLogEntry("error", now)).isEqualTo(LINE_REJECTED); + } + + + @Test + public void startDateCanFilterLines() { + LocalDateTime startDate = LocalDateTime.now().minusDays(2); + + LogFilter logFilter = new LogFilter(null, startDate, null); + + assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now())).isEqualTo(LINE_ACCEPTED); + assertThat(logFilter.acceptsLogEntry("info", startDate)).isEqualTo(LINE_ACCEPTED); + assertThat(logFilter.acceptsLogEntry("fine", startDate)).isEqualTo(LINE_ACCEPTED); + + assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now().minusDays(3))) + .isEqualTo(LINE_REJECTED); + } + + @Test + public void endDateCanFilterLines() { + LocalDateTime endDate = LocalDateTime.now().minusDays(2); + + LogFilter logFilter = new LogFilter(null, null, endDate); + + assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now().minusDays(3))) + .isEqualTo(LINE_ACCEPTED); + + assertThat(logFilter.acceptsLogEntry("info", endDate)).isEqualTo(LINE_ACCEPTED); + assertThat(logFilter.acceptsLogEntry("fine", endDate)).isEqualTo(LINE_ACCEPTED); + + assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now())) + .isEqualTo(REMAINDER_OF_FILE_REJECTED); + } + + @Test + public void filterWorksWithLevelBasedAndTimeBasedFiltering() { + LocalDateTime startDate = LocalDateTime.now().minusDays(5); + LocalDateTime endDate = LocalDateTime.now().minusDays(2); + + Set<String> permittedLogLevels = Stream.of("info", "finest").collect(toSet()); + + LogFilter logFilter = new LogFilter(permittedLogLevels, startDate, endDate); + + + assertThat(logFilter.acceptsLogEntry("error", LocalDateTime.now().minusDays(6))) + .isEqualTo(LINE_REJECTED); + assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now().minusDays(6))) + .isEqualTo(LINE_REJECTED); + + assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(LINE_REJECTED); + + + assertThat(logFilter.acceptsLogEntry("error", LocalDateTime.now().minusDays(4))) + .isEqualTo(LINE_REJECTED); + assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(LINE_REJECTED); + + assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now().minusDays(4))) + .isEqualTo(LINE_ACCEPTED); + assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(LINE_ACCEPTED); + + + + assertThat(logFilter.acceptsLogEntry("error", LocalDateTime.now().minusDays(1))) + .isEqualTo(REMAINDER_OF_FILE_REJECTED); + assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(REMAINDER_OF_FILE_REJECTED); + + assertThat(logFilter.acceptsLogEntry("info", LocalDateTime.now().minusDays(1))) + .isEqualTo(REMAINDER_OF_FILE_REJECTED); + } + + @Test + public void firstLinesAreAcceptedIfParsableLineHasNotBeenSeenYet() { + LogFilter logFilter = new LogFilter(Stream.of("info").collect(toSet()), null, null); + + assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(LINE_ACCEPTED); + assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(LINE_ACCEPTED); + + assertThat(logFilter.acceptsLogEntry("error", LocalDateTime.now())).isEqualTo(LINE_REJECTED); + assertThat(logFilter.acceptsLogEntry(null)).isEqualTo(LINE_REJECTED); + + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogLevelExtractorTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogLevelExtractorTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogLevelExtractorTest.java new file mode 100644 index 0000000..320a3bc --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogLevelExtractorTest.java @@ -0,0 +1,61 @@ +/* + * 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.management.internal.cli.util; + + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.time.LocalDateTime; + +@Category(UnitTest.class) +public class LogLevelExtractorTest { + @Test + public void extractWorksCorrectlyForLineFromLogFile() throws Exception { + String logLine = + "[info 2017/02/07 11:16:36.694 PST locator1 <locator request thread[1]> tid=0x27] Mapped \"{[/v1/async-event-queues],methods=[GET]}\" onto public java.lang.String"; + + LogLevelExtractor.Result result = LogLevelExtractor.extract(logLine); + + assertThat(result).isNotNull(); + assertThat(result.getLogLevel()).isEqualTo("info"); + + assertThat(result.getLogTimestamp().toString()).isEqualTo("2017-02-07T11:16:36.694"); + } + + @Test + public void extractReturnsNullIfNoTimestamp() throws Exception { + String logLine = "[info (this line is not a valid log statement since it has no timestamp)"; + + LogLevelExtractor.Result result = LogLevelExtractor.extract(logLine); + + assertThat(result).isNull(); + } + + @Test + public void extractReturnsNullIfLineDoesNotMatchPattern() throws Exception { + String logLine = "some line containing a date like 2017/02/07 11:16:36.694 PST "; + + LogLevelExtractor.Result result = LogLevelExtractor.extract(logLine); + + assertThat(result).isNull(); + } + +} http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsTest.java new file mode 100644 index 0000000..7f4ffd4 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsTest.java @@ -0,0 +1,114 @@ +/* + * 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.management.internal.cli.util; + +import static java.util.stream.Collectors.joining; +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.commons.io.FileUtils; +import org.apache.geode.distributed.internal.DistributionConfig; +import org.apache.geode.internal.logging.LogService; +import org.apache.geode.management.cli.Result; +import org.apache.geode.test.dunit.rules.Locator; +import org.apache.geode.test.dunit.rules.LocatorServerStartupRule; +import org.apache.geode.test.dunit.rules.Server; +import org.apache.geode.test.junit.categories.DistributedTest; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.Arrays; +import java.util.Properties; + +@Category(DistributedTest.class) +public class MergeLogsTest { + @Rule + public LocatorServerStartupRule lsRule = new LocatorServerStartupRule(); + private Locator locator; + + private static final String MESSAGE_1 = "MergeLogsMessage1"; + private static final String MESSAGE_2 = "MergeLogsMessage2"; + private static final String MESSAGE_3 = "MergeLogsMessage3"; + private static final String MESSAGE_4 = "MergeLogsMessage4"; + private static final String MESSAGE_5 = "MergeLogsMessage5"; + private static final String MESSAGE_6 = "MergeLogsMessage6"; + + @Before + public void setup() throws Exception { + Properties properties = new Properties(); + properties.setProperty(DistributionConfig.LOG_LEVEL_NAME, "info"); + locator = lsRule.startLocatorVM(0, properties); + + properties + .setProperty(DistributionConfig.LOCATORS_NAME, "localhost[" + locator.getPort() + "]"); + + Server server = lsRule.startServerVM(1, properties); + Server server2 = lsRule.startServerVM(2, properties); + + locator.invoke(() -> LogService.getLogger().info(MESSAGE_1)); + server.invoke(() -> LogService.getLogger().info(MESSAGE_2)); + server2.invoke(() -> LogService.getLogger().info(MESSAGE_3)); + + locator.invoke(() -> LogService.getLogger().info(MESSAGE_4)); + server.invoke(() -> LogService.getLogger().info(MESSAGE_5)); + server2.invoke(() -> LogService.getLogger().info(MESSAGE_6)); + } + + @Test + public void testExportInProcess() throws Exception { + assertThat(MergeLogs.findLogFilesToMerge(lsRule.getTempFolder().getRoot())).hasSize(3); + + File result = MergeLogs.mergeLogFile(lsRule.getTempFolder().getRoot().getCanonicalPath()); + assertOnLogContents(result); + } + @Test + public void testExportInNewProcess() throws Throwable { + assertThat(MergeLogs.findLogFilesToMerge(lsRule.getTempFolder().getRoot())).hasSize(3); + + MergeLogs.mergeLogsInNewProcess(lsRule.getTempFolder().getRoot().toPath()); + File result = Arrays.stream(lsRule.getTempFolder().getRoot().listFiles()).filter((File f) -> f.getName().startsWith("merge")) + .findFirst().orElseThrow(() -> {throw new AssertionError("No merged log file found");}); + assertOnLogContents(result); + + } + + private void assertOnLogContents (File mergedLogFile) throws IOException { + String + mergedLines = + FileUtils.readLines(mergedLogFile, Charset.defaultCharset()).stream().collect(joining("\n")); + + assertThat(mergedLines).contains(MESSAGE_1); + assertThat(mergedLines).contains(MESSAGE_2); + assertThat(mergedLines).contains(MESSAGE_3); + assertThat(mergedLines).contains(MESSAGE_4); + assertThat(mergedLines).contains(MESSAGE_5); + assertThat(mergedLines).contains(MESSAGE_6); + + //Make sure that our merged log file contains the proper ordering + assertThat(mergedLines.indexOf(MESSAGE_1)).isLessThan(mergedLines.indexOf(MESSAGE_2)); + assertThat(mergedLines.indexOf(MESSAGE_2)).isLessThan(mergedLines.indexOf(MESSAGE_3)); + assertThat(mergedLines.indexOf(MESSAGE_3)).isLessThan(mergedLines.indexOf(MESSAGE_4)); + assertThat(mergedLines.indexOf(MESSAGE_4)).isLessThan(mergedLines.indexOf(MESSAGE_5)); + assertThat(mergedLines.indexOf(MESSAGE_5)).isLessThan(mergedLines.indexOf(MESSAGE_6)); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/configuration/EventTestCacheWriter.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/EventTestCacheWriter.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/EventTestCacheWriter.java new file mode 100644 index 0000000..27459c9 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/EventTestCacheWriter.java @@ -0,0 +1,36 @@ +/* + * 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.management.internal.configuration; + +import org.apache.geode.cache.CacheWriter; +import org.apache.geode.cache.CacheWriterException; +import org.apache.geode.cache.EntryEvent; +import org.apache.geode.cache.RegionEvent; +import org.apache.geode.cache.util.CacheWriterAdapter; + +import java.io.Serializable; + +public class EventTestCacheWriter extends CacheWriterAdapter implements Serializable { + public static boolean hasResult = false; + + @Override + public void beforeCreate(EntryEvent event) throws CacheWriterException { + System.out.println("key: " + event.getKey()); + System.out.println("value: " + event.getNewValue()); + hasResult = true; + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ZipUtilsJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ZipUtilsJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ZipUtilsJUnitTest.java index 1791574..6f13f62 100755 --- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ZipUtilsJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ZipUtilsJUnitTest.java @@ -17,6 +17,7 @@ package org.apache.geode.management.internal.configuration; import static org.junit.Assert.*; import java.io.File; +import java.io.IOException; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; @@ -107,4 +108,19 @@ public class ZipUtilsJUnitTest { assertTrue(clusterText.equals(FileUtils.readFileToString(destinationClusterTextFile))); assertTrue(groupText.equals(FileUtils.readFileToString(destinationGroupTextFile))); } + + @Test + public void zipUtilsCanCreateParentDirsIfNecessary() throws IOException { + File newFolder = new File(zipFolder, "newFolder"); + assertFalse(newFolder.exists()); + + File zipFile = new File(newFolder, "target.zip"); + assertFalse(zipFile.exists()); + assertFalse(zipFile.isFile()); + + ZipUtils.zipDirectory(sourceFolder.getCanonicalPath(), zipFile.getCanonicalPath()); + assertTrue(newFolder.exists()); + assertTrue(zipFile.exists()); + assertTrue(zipFile.isFile()); + } } http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java index 4729be3..93572fe 100644 --- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java +++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java @@ -164,6 +164,10 @@ public class GfshShellConnectionRule extends DescribedExternalResource { public CommandResult executeAndVerifyCommand(String command) throws Exception { CommandResult result = executeCommand(command); + + if (result.getStatus() != Result.Status.OK) { + System.out.println("broken"); + } assertThat(result.getStatus()).describedAs(result.getContent().toString()) .isEqualTo(Result.Status.OK); return result; http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java index 84c660c..2ec2088 100644 --- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java +++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java @@ -114,6 +114,7 @@ public class LocatorStarterRule extends ExternalResource implements Serializable } } } + locator = (InternalLocator) Locator.startLocatorAndDS(0, null, properties); int locatorPort = locator.getPort(); locator.resetInternalLocatorFileNamesWithCorrectPortNumber(locatorPort); http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java index 5f46da2..59215a3 100644 --- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java +++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java @@ -26,7 +26,7 @@ import java.io.Serializable; * A server or locator inside a DUnit {@link VM}. */ public abstract class Member implements Serializable { - private VM vm; + private transient VM vm; private int port; private File workingDir; private String name; http://git-wip-us.apache.org/repos/asf/geode/blob/4c6f3695/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java index d4869c2..3f3358d 100644 --- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java +++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java @@ -31,11 +31,7 @@ import org.apache.geode.test.junit.runner.SuiteRunner; GemfireDataCommandsDUnitTest.class, GetCommandOnRegionWithCacheLoaderDuringCacheMissDUnitTest.class, IndexCommandsDUnitTest.class, ListAndDescribeDiskStoreCommandsDUnitTest.class, ListIndexCommandDUnitTest.class, - MemberCommandsDUnitTest.class, MiscellaneousCommandsDUnitTest.class, - MiscellaneousCommandsExportLogsPart1DUnitTest.class, - MiscellaneousCommandsExportLogsPart2DUnitTest.class, - MiscellaneousCommandsExportLogsPart3DUnitTest.class, - MiscellaneousCommandsExportLogsPart4DUnitTest.class, QueueCommandsDUnitTest.class, + MemberCommandsDUnitTest.class, MiscellaneousCommandsDUnitTest.class,QueueCommandsDUnitTest.class, ShellCommandsDUnitTest.class, ShowDeadlockDUnitTest.class, ShowMetricsDUnitTest.class, ShowStackTraceDUnitTest.class, UserCommandsDUnitTest.class}) public class CommandOverHttpDUnitTest {
