You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jb...@apache.org on 2018/08/16 04:48:20 UTC
[geode] branch develop updated: GEODE-5530 Refactors shared test
source between geode-web and geode-core. (#2325)
This is an automated email from the ASF dual-hosted git repository.
jbarrett pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new aadc520 GEODE-5530 Refactors shared test source between geode-web and geode-core. (#2325)
aadc520 is described below
commit aadc520cf36f5714ce976a7d0f965a9b436483c1
Author: Jacob Barrett <jb...@pivotal.io>
AuthorDate: Wed Aug 15 21:48:13 2018 -0700
GEODE-5530 Refactors shared test source between geode-web and geode-core. (#2325)
Co-authored-by: Robert Houghton <rh...@pivotal.io>
Co-authored-by: Jacob Barrett <jb...@pivotal.io>
---
.../commands/ChangeLogLevelCommandDUnitTest.java | 105 +-----
.../internal/cli/commands/ExportLogsDUnitTest.java | 386 +--------------------
.../cli/commands/ExportLogsStatsDUnitTest.java | 144 +-------
.../cli/commands/FunctionCommandsDUnitTest.java | 256 +-------------
.../internal/cli/commands/GcCommandDUnitTest.java | 103 +-----
.../cli/commands/GemfireDataCommandsDUnitTest.java | 343 +-----------------
.../cli/commands/ListIndexCommandDUnitTest.java | 68 +---
.../cli/commands/QueryCommandDUnitTest.java | 306 +---------------
.../commands/RebalanceCommandDistributedTest.java | 85 +----
.../commands/RegionMembershipMBeanDUnitTest.java | 369 +-------------------
.../cli/commands/ShowLogCommandDUnitTest.java | 151 +-------
.../cli/commands/ShutdownCommandDUnitTest.java | 84 +----
.../cli/commands/IndexCommandsIntegrationTest.java | 303 +---------------
.../cli/commands/QueryCommandIntegrationTest.java | 269 +-------------
.../security/GfshCommandsSecurityTest.java | 194 +----------
.../internal/cache/functions/TestFunction.java | 0
.../ChangeLogLevelCommandDUnitTestBase.java | 3 +-
.../cli/commands/ExportLogsDUnitTestBase.java | 8 +-
.../cli/commands/ExportLogsStatsDUnitTestBase.java | 2 +-
.../commands/FunctionCommandsDUnitTestBase.java | 2 +-
.../cli/commands/GcCommandDUnitTestBase.java | 2 +-
.../commands/GemfireDataCommandsDUnitTestBase.java | 2 +-
.../commands/IndexCommandsIntegrationTestBase.java | 2 +-
.../commands/ListIndexCommandDUnitTestBase.java | 2 +-
.../cli/commands/QueryCommandDUnitTestBase.java | 2 +-
.../commands/QueryCommandIntegrationTestBase.java | 2 +-
.../RebalanceCommandDistributedTestBase.java | 2 +-
.../RegionMembershipMBeanDUnitTestBase.java | 2 +-
.../cli/commands/ShowLogCommandDUnitTestBase.java | 4 +-
.../cli/commands/ShutdownCommandDUnitTestBase.java | 3 +-
.../security/GfshCommandsSecurityTestBase.java | 2 +-
geode-web/build.gradle | 6 +-
.../ChangeLogLevelCommandOverHttpDUnitTest.java | 2 +-
.../ExportLogsOverHttpDistributedTest.java | 2 +-
.../commands/ExportLogsStatsOverHttpDUnitTest.java | 2 +-
.../FunctionCommandsOverHttpDUnitTest.java | 2 +-
.../cli/commands/GcCommandOverHttpDUnitTest.java | 2 +-
.../GemfireDataCommandsOverHttpDUnitTest.java | 2 +-
.../ListIndexCommandOverHttpDUnitTest.java | 2 +-
.../commands/QueryCommandOverHttpDUnitTest.java | 2 +-
.../RebalanceCommandOverHttpDistributedTest.java | 2 +-
.../RegionMembershipMBeanOverHttpDUnitTest.java | 2 +-
.../commands/ShowLogComandOverHttpDUnitTest.java | 4 +-
.../commands/ShutdownCommandOverHttpDUnitTest.java | 2 +-
.../cli/commands/IndexCommandOverHttpTest.java | 2 +-
.../cli/commands/QueryCommandOverHttpTest.java | 2 +-
.../security/GfshCommandsOverHttpSecurityTest.java | 2 +-
settings.gradle | 1 +
48 files changed, 53 insertions(+), 3192 deletions(-)
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandDUnitTest.java
index f832eb7..cd556df 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandDUnitTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandDUnitTest.java
@@ -14,108 +14,5 @@
*/
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.junit.rules.GfshCommandRule.PortType.jmxManager;
-
-import java.util.Properties;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-import org.apache.geode.test.dunit.rules.ClusterStartupRule;
-import org.apache.geode.test.dunit.rules.MemberVM;
-import org.apache.geode.test.junit.rules.GfshCommandRule;
-
-
-
-public class ChangeLogLevelCommandDUnitTest {
- private static final String MANAGER_NAME = "Manager";
- private static final String SERVER1_NAME = "Server1";
- private static final String SERVER2_NAME = "Server2";
- private static final String GROUP0 = "Group0";
- private static final String GROUP1 = "Group1";
- private static final String GROUP2 = "Group2";
-
- protected static MemberVM locator;
-
- @ClassRule
- public static ClusterStartupRule clusterStartupRule = new ClusterStartupRule();
-
- @ClassRule
- public static GfshCommandRule gfsh = new GfshCommandRule();
-
- @BeforeClass
- public static void setup() throws Exception {
- Properties managerProps = new Properties();
- managerProps.setProperty(NAME, MANAGER_NAME);
- managerProps.setProperty(GROUPS, GROUP0);
- locator =
- clusterStartupRule.startLocatorVM(0, l -> l.withHttpService().withProperties(managerProps));
-
- Properties server1Props = new Properties();
- server1Props.setProperty(NAME, SERVER1_NAME);
- server1Props.setProperty(GROUPS, GROUP1);
- clusterStartupRule.startServerVM(1, server1Props, locator.getPort());
-
- Properties server2Props = new Properties();
- server2Props.setProperty(NAME, SERVER2_NAME);
- server2Props.setProperty(GROUPS, GROUP2);
- clusterStartupRule.startServerVM(2, server2Props, locator.getPort());
- }
-
- @Before
- public void before() throws Exception {
- gfsh.connectAndVerify(locator.getJmxPort(), jmxManager);
- }
-
- @After
- public void after() throws Exception {
- gfsh.disconnect();
- }
-
-
- @Test
- public void testChangeLogLevelForGroups() {
- String commandString = "change loglevel --loglevel=finer --groups=" + GROUP1 + "," + GROUP2;
-
- gfsh.executeAndAssertThat(commandString).statusIsSuccess()
- .containsOutput(SERVER1_NAME, SERVER2_NAME).doesNotContainOutput(MANAGER_NAME);
- }
-
- @Test
- public void testChangeLogLevelForGroup() {
- String commandString = "change loglevel --loglevel=finer --groups=" + GROUP1;
-
- gfsh.executeAndAssertThat(commandString).statusIsSuccess().containsOutput(SERVER1_NAME)
- .doesNotContainOutput(SERVER2_NAME, MANAGER_NAME);
- }
-
- @Test
- public void testChangeLogLevelForMembers() {
- String commandString =
- "change loglevel --loglevel=finer --members=" + SERVER1_NAME + "," + SERVER2_NAME;
-
- gfsh.executeAndAssertThat(commandString).statusIsSuccess()
- .containsOutput(SERVER1_NAME, SERVER2_NAME).doesNotContainOutput(MANAGER_NAME);
- }
-
- @Test
- public void testChangeLogLevelForMember() {
- String commandString = "change loglevel --loglevel=finer --members=" + SERVER1_NAME;
-
- gfsh.executeAndAssertThat(commandString).statusIsSuccess().containsOutput(SERVER1_NAME)
- .doesNotContainOutput(SERVER2_NAME, MANAGER_NAME);
- }
-
- @Test
- public void testChangeLogLevelForInvalidMember() {
- String commandString = "change loglevel --loglevel=finer --members=NotAValidMember";
-
- gfsh.executeAndAssertThat(commandString).statusIsError()
- .containsOutput("No members were found matching the given member IDs or groups.");
- }
+public class ChangeLogLevelCommandDUnitTest extends ChangeLogLevelCommandDUnitTestBase {
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
index d953b4e..2e17429 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
@@ -16,389 +16,5 @@
package org.apache.geode.management.internal.cli.commands;
-import static java.util.stream.Collectors.joining;
-import static java.util.stream.Collectors.toList;
-import static java.util.stream.Collectors.toSet;
-import static org.apache.commons.io.FileUtils.listFiles;
-import static org.apache.geode.management.internal.cli.commands.ExportLogsCommand.FORMAT;
-import static org.apache.geode.management.internal.cli.commands.ExportLogsCommand.ONLY_DATE_FORMAT;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Serializable;
-import java.nio.charset.Charset;
-import java.nio.file.Path;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import java.util.stream.Stream;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.logging.log4j.Logger;
-import org.awaitility.Awaitility;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TemporaryFolder;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.distributed.ConfigurationProperties;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.management.internal.cli.functions.ExportLogsFunction;
-import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
-import org.apache.geode.management.internal.configuration.utils.ZipUtils;
-import org.apache.geode.test.dunit.IgnoredException;
-import org.apache.geode.test.dunit.rules.ClusterStartupRule;
-import org.apache.geode.test.dunit.rules.MemberVM;
-import org.apache.geode.test.junit.categories.LoggingTest;
-import org.apache.geode.test.junit.rules.GfshCommandRule;
-import org.apache.geode.test.junit.rules.Member;
-
-@Category({LoggingTest.class})
-public class ExportLogsDUnitTest {
- private static final String ERROR_LOG_PREFIX = "[IGNORE]";
-
- @Rule
- public ClusterStartupRule lsRule = new ClusterStartupRule().withLogFile();
-
- @Rule
- public GfshCommandRule gfshConnector = new GfshCommandRule();
-
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
-
- protected MemberVM locator;
- private MemberVM server1;
- private MemberVM server2;
-
- private Map<MemberVM, List<LogLine>> expectedMessages;
-
- public File getWorkingDirectory() throws Exception {
- return locator.getWorkingDir();
- }
-
- @Before
- public void setup() throws Exception {
- Properties properties = new Properties();
- properties.setProperty(ConfigurationProperties.LOG_LEVEL, "debug");
-
- locator = lsRule.startLocatorVM(0, l -> l.withProperties(properties).withHttpService());
- server1 = lsRule.startServerVM(1, properties, locator.getPort());
- server2 = lsRule.startServerVM(2, properties, locator.getPort());
-
- IgnoredException.addIgnoredException(ERROR_LOG_PREFIX);
-
- expectedMessages = new HashMap<>();
- expectedMessages.put(locator, listOfLogLines(locator, "info", "error", "debug"));
- expectedMessages.put(server1, listOfLogLines(server1, "info", "error", "debug"));
- expectedMessages.put(server2, listOfLogLines(server2, "info", "error", "debug"));
-
- // log the messages in each of the members
- for (MemberVM member : expectedMessages.keySet()) {
- List<LogLine> logLines = expectedMessages.get(member);
-
- member.invoke(() -> {
- Logger logger = LogService.getLogger();
- logLines.forEach((LogLine logLine) -> logLine.writeLog(logger));
- });
- }
-
- connect();
- }
-
- public void connect() throws Exception {
- gfshConnector.connectAndVerify(locator);
- }
-
- @After
- public void after() throws Exception {
- Stream.of(getWorkingDirectory().listFiles())
- .filter(f -> f.getName().endsWith(".zip")).forEach(file -> file.delete());
- }
-
- @Test
- public void withFiles_savedToLocatorWorkingDir() throws Exception {
- String[] extensions = {"zip"};
- // Expects locator to produce file in own working directory when connected via JMX
- gfshConnector.executeCommand("export logs");
- assertThat(listFiles(getWorkingDirectory(), extensions, false)).isNotEmpty();
- }
-
- @Test
- public void withFiles_savedToLocatorSpecifiedRelativeDir() throws Exception {
- String[] extensions = {"zip"};
- Path workingDirPath = getWorkingDirectory().toPath();
- Path subdirPath = workingDirPath.resolve("some").resolve("test").resolve("directory");
- Path relativeDir = workingDirPath.relativize(subdirPath);
- // Expects locator to produce file in own working directory when connected via JMX
- gfshConnector.executeCommand("export logs --dir=" + relativeDir.toString());
- assertThat(listFiles(getWorkingDirectory(), extensions, false)).isEmpty();
- assertThat(listFiles(getWorkingDirectory(), extensions, true)).isNotEmpty();
- assertThat(listFiles(subdirPath.toFile(), extensions, false)).isNotEmpty();
- }
-
- @Test
- public void withFiles_savedToLocatorSpecifiedAbsoluteDir() throws Exception {
- String[] extensions = {"zip"};
- Path workingDirPath = getWorkingDirectory().toPath();
- Path absoluteDirPath =
- workingDirPath.resolve("some").resolve("test").resolve("directory").toAbsolutePath();
- // Expects locator to produce file in own working directory when connected via JMX
- gfshConnector.executeCommand("export logs --dir=" + absoluteDirPath.toString());
- assertThat(listFiles(getWorkingDirectory(), extensions, false)).isEmpty();
- assertThat(listFiles(getWorkingDirectory(), extensions, true)).isNotEmpty();
- assertThat(listFiles(absoluteDirPath.toFile(), extensions, false)).isNotEmpty();
- }
-
- @Test
- public void startAndEndDateCanIncludeLogs() throws Exception {
- ZonedDateTime now = LocalDateTime.now().atZone(ZoneId.systemDefault());
- ZonedDateTime yesterday = now.minusDays(1);
- ZonedDateTime tomorrow = now.plusDays(1);
-
- DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT);
-
- CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
- commandStringBuilder.addOption("start-time", dateTimeFormatter.format(yesterday));
- commandStringBuilder.addOption("end-time", dateTimeFormatter.format(tomorrow));
- commandStringBuilder.addOption("log-level", "debug");
-
- gfshConnector.executeAndAssertThat(commandStringBuilder.toString()).statusIsSuccess();
-
- Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
- verifyZipFileContents(acceptedLogLevels);
- }
-
- @Test
- public void testExportWithStartAndEndDateTimeFiltering() throws Exception {
- ZonedDateTime cutoffTime = LocalDateTime.now().atZone(ZoneId.systemDefault());
-
- // wait for atleast 1 second to reduce flakiness on windows
- // on windows the flakiness is caused due to the cutoffTime
- // being same as the log message logged on server1.
- Awaitility.await().atLeast(1, TimeUnit.MILLISECONDS).until(() -> true);
-
- String messageAfterCutoffTime =
- "[this message should not show up since it is after cutoffTime]";
- LogLine logLineAfterCutoffTime = new LogLine(messageAfterCutoffTime, "info", true);
- server1.invoke(() -> {
- Logger logger = LogService.getLogger();
- logLineAfterCutoffTime.writeLog(logger);
- });
-
- DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(FORMAT);
- String cutoffTimeString = dateTimeFormatter.format(cutoffTime);
-
- CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
- commandStringBuilder.addOption("start-time", dateTimeFormatter.format(cutoffTime.minusDays(1)));
- commandStringBuilder.addOption("end-time", cutoffTimeString);
- commandStringBuilder.addOption("log-level", "debug");
-
- gfshConnector.executeAndAssertThat(commandStringBuilder.toString()).statusIsSuccess();
-
- expectedMessages.get(server1).add(logLineAfterCutoffTime);
- Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
- verifyZipFileContents(acceptedLogLevels);
- }
-
- @Test
- public void testExportWithThresholdLogLevelFilter() throws Exception {
-
- gfshConnector.executeAndAssertThat("export logs --log-level=info --only-log-level=false")
- .statusIsSuccess();
-
- Set<String> acceptedLogLevels = Stream.of("info", "error").collect(toSet());
- verifyZipFileContents(acceptedLogLevels);
-
- }
-
- @Test
- public void testExportWithExactLogLevelFilter() throws Exception {
- gfshConnector.executeAndAssertThat("export logs --log-level=info --only-log-level=true")
- .statusIsSuccess();
- Set<String> acceptedLogLevels = Stream.of("info").collect(toSet());
- verifyZipFileContents(acceptedLogLevels);
- }
-
- @Test
- public void testExportWithNoOptionsGiven() throws Exception {
- gfshConnector.executeAndAssertThat("export logs").statusIsSuccess();
- Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
- verifyZipFileContents(acceptedLogLevels);
- }
-
- @Test
- public void testExportWithNoFilters() throws Exception {
- gfshConnector.executeAndAssertThat("export logs --log-level=all").statusIsSuccess();
-
- Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
- verifyZipFileContents(acceptedLogLevels);
-
- // Ensure export logs region gets cleaned up
- server1.invoke(ExportLogsDUnitTest::verifyExportLogsRegionWasDestroyed);
- server2.invoke(ExportLogsDUnitTest::verifyExportLogsRegionWasDestroyed);
- locator.invoke(ExportLogsDUnitTest::verifyExportLogsRegionWasDestroyed);
- }
-
- @Test
- public void exportLogsRegionIsCleanedUpProperly() throws IOException, ClassNotFoundException {
- locator.invoke(() -> {
- GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
- ExportLogsFunction.createOrGetExistingExportLogsRegion(true, cache);
- assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNotNull();
- });
-
- server1.invoke(() -> {
- GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
- ExportLogsFunction.createOrGetExistingExportLogsRegion(false, cache);
- assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNotNull();
- });
-
- locator.invoke(() -> {
- GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
- ExportLogsFunction.destroyExportLogsRegion(cache);
-
- assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
- });
-
- server1.invoke(() -> {
- Cache cache = GemFireCacheImpl.getInstance();
- assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
- });
- }
-
-
- private void verifyZipFileContents(Set<String> acceptedLogLevels) throws Exception {
- File unzippedLogFileDir = unzipExportedLogs();
-
- Set<File> dirsFromZipFile =
- Stream.of(unzippedLogFileDir.listFiles()).filter(File::isDirectory).collect(toSet());
- assertThat(dirsFromZipFile).hasSize(expectedMessages.keySet().size());
-
- Set<String> expectedDirNames =
- expectedMessages.keySet().stream().map(Member::getName).collect(toSet());
- Set<String> actualDirNames = dirsFromZipFile.stream().map(File::getName).collect(toSet());
- assertThat(actualDirNames).isEqualTo(expectedDirNames);
-
- System.out.println("Unzipped artifacts:");
- for (File dir : dirsFromZipFile) {
- verifyLogFileContents(acceptedLogLevels, dir);
- }
- }
-
- private void verifyLogFileContents(Set<String> acceptedLogLevels, File dirForMember)
- throws IOException {
-
- String memberName = dirForMember.getName();
- MemberVM member = expectedMessages.keySet().stream()
- .filter((Member aMember) -> aMember.getName().equals(memberName)).findFirst().get();
-
- assertThat(member).isNotNull();
-
- Set<String> fileNamesInDir =
- Stream.of(dirForMember.listFiles()).map(File::getName).collect(toSet());
-
- System.out.println(dirForMember.getCanonicalPath() + " : " + fileNamesInDir);
-
- File logFileForMember = new File(dirForMember, memberName + ".log");
- assertThat(logFileForMember).exists();
-
- String logFileContents = FileUtils.readLines(logFileForMember, Charset.defaultCharset())
- .stream().collect(joining("\n"));
-
- for (LogLine logLine : expectedMessages.get(member)) {
- boolean shouldExpectLogLine =
- acceptedLogLevels.contains(logLine.level) && !logLine.shouldBeIgnoredDueToTimestamp;
-
- if (shouldExpectLogLine) {
- assertThat(logFileContents).contains(logLine.getMessage());
- } else {
- assertThat(logFileContents).doesNotContain(logLine.getMessage());
- }
- }
-
- }
-
- private File unzipExportedLogs() throws Exception {
- File locatorWorkingDir = getWorkingDirectory();
- List<File> filesInDir = Stream.of(getWorkingDirectory().listFiles()).collect(toList());
- assertThat(filesInDir).isNotEmpty();
-
-
- List<File> zipFilesInDir = Stream.of(getWorkingDirectory().listFiles())
- .filter(f -> f.getName().endsWith(".zip")).collect(toList());
- assertThat(zipFilesInDir)
- .describedAs(filesInDir.stream().map(File::getAbsolutePath).collect(joining(",")))
- .hasSize(1);
-
- File unzippedLogFileDir = temporaryFolder.newFolder("unzippedLogs");
- ZipUtils.unzip(zipFilesInDir.get(0).getCanonicalPath(), unzippedLogFileDir.getCanonicalPath());
- return unzippedLogFileDir;
- }
-
- private List<LogLine> listOfLogLines(Member member, String... levels) {
- return Stream.of(levels).map(level -> new LogLine(member, level)).collect(toList());
- }
-
- private static void verifyExportLogsRegionWasDestroyed() {
- Cache cache = GemFireCacheImpl.getInstance();
- assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
- }
-
- public static class LogLine implements Serializable {
- String level;
- String message;
- boolean shouldBeIgnoredDueToTimestamp;
-
- LogLine(String message, String level, boolean shouldBeIgnoredDueToTimestamp) {
- this.message = message;
- this.level = level;
- this.shouldBeIgnoredDueToTimestamp = shouldBeIgnoredDueToTimestamp;
- }
-
- LogLine(Member member, String level) {
- this.level = level;
- this.message = buildMessage(member.getName());
- }
-
- public String getMessage() {
- return message;
- }
-
- private String buildMessage(String memberName) {
- StringBuilder stringBuilder = new StringBuilder();
- if (Objects.equals(level, "error")) {
- stringBuilder.append(ERROR_LOG_PREFIX + "-");
- }
- stringBuilder.append(level).append("-");
-
- return stringBuilder.append(memberName).toString();
- }
-
-
- void writeLog(Logger logger) {
- switch (this.level) {
- case "info":
- logger.info(getMessage());
- break;
- case "error":
- logger.error(getMessage());
- break;
- case "debug":
- logger.debug(getMessage());
- }
- }
- }
+public class ExportLogsDUnitTest extends ExportLogsDUnitTestBase {
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTest.java
index e58f29c..f51ef3e 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTest.java
@@ -15,147 +15,5 @@
package org.apache.geode.management.internal.cli.commands;
-import static java.util.stream.Collectors.toSet;
-import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_ARCHIVE_FILE;
-import static org.apache.geode.management.internal.cli.commands.ExportLogsCommand.ONLY_DATE_FORMAT;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.File;
-import java.io.IOException;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import com.google.common.collect.Sets;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.distributed.ConfigurationProperties;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
-import org.apache.geode.test.dunit.rules.ClusterStartupRule;
-import org.apache.geode.test.dunit.rules.MemberVM;
-import org.apache.geode.test.junit.categories.LoggingTest;
-import org.apache.geode.test.junit.rules.GfshCommandRule;
-
-@Category({LoggingTest.class})
-public class ExportLogsStatsDUnitTest {
- @ClassRule
- public static ClusterStartupRule lsRule = new ClusterStartupRule().withLogFile();
-
- @ClassRule
- public static GfshCommandRule connector = new GfshCommandRule();
-
- protected static Set<String> expectedZipEntries = new HashSet<>();
- protected static MemberVM locator;
-
- @BeforeClass
- public static void beforeClass() {
- // start the locator in vm0 and then connect to it over http
- locator = lsRule.startLocatorVM(0, l -> l.withHttpService());
-
- Properties serverProperties = new Properties();
- serverProperties.setProperty(ConfigurationProperties.STATISTIC_SAMPLING_ENABLED, "true");
- serverProperties.setProperty(STATISTIC_ARCHIVE_FILE, "statistics.gfs");
- lsRule.startServerVM(1, serverProperties, locator.getPort());
-
- expectedZipEntries = Sets.newHashSet(
- "locator-0" + File.separator + "locator-0.log",
- "server-1" + File.separator + "server-1.log",
- "server-1" + File.separator + "statistics.gfs");
- }
-
- protected void connectIfNeeded() throws Exception {
- if (!connector.isConnected()) {
- connector.connect(locator);
- }
- }
-
- @Test
- public void testExportLogsAndStats() throws Exception {
- connectIfNeeded();
- connector.executeAndAssertThat("export logs").statusIsSuccess();
- String zipPath = getZipPathFromCommandResult(connector.getGfshOutput());
- Set<String> actualZipEnries = getZipEntries(zipPath);
-
- Set<String> expectedFiles = Sets.newHashSet(
- "locator-0" + File.separator + "locator-0.log",
- "server-1" + File.separator + "server-1.log",
- "server-1" + File.separator + "statistics.gfs");
- assertThat(actualZipEnries).containsAll(expectedFiles);
- // remove pulse.log if present
- actualZipEnries =
- actualZipEnries.stream().filter(x -> !x.endsWith("pulse.log")).collect(toSet());
- assertThat(actualZipEnries).hasSize(3);
- }
-
- @Test
- public void testExportLogsOnly() throws Exception {
- connectIfNeeded();
- connector.executeAndAssertThat("export logs --logs-only").statusIsSuccess();
- String zipPath = getZipPathFromCommandResult(connector.getGfshOutput());
- Set<String> actualZipEnries = getZipEntries(zipPath);
-
- Set<String> expectedFiles = Sets.newHashSet(
- "locator-0" + File.separator + "locator-0.log",
- "server-1" + File.separator + "server-1.log");
- assertThat(actualZipEnries).containsAll(expectedFiles);
- // remove pulse.log if present
- actualZipEnries =
- actualZipEnries.stream().filter(x -> !x.endsWith("pulse.log")).collect(toSet());
- assertThat(actualZipEnries).hasSize(2);
- }
-
- @Test
- public void testExportStatsOnly() throws Exception {
- connectIfNeeded();
- connector.executeAndAssertThat("export logs --stats-only").statusIsSuccess();
- String zipPath = getZipPathFromCommandResult(connector.getGfshOutput());
- Set<String> actualZipEnries = getZipEntries(zipPath);
-
- Set<String> expectedFiles = Sets.newHashSet("server-1" + File.separator + "statistics.gfs");
- assertThat(actualZipEnries).isEqualTo(expectedFiles);
- }
-
- @Test
- public void startAndEndDateCanExcludeLogs() throws Exception {
- connectIfNeeded();
- ZonedDateTime now = LocalDateTime.now().atZone(ZoneId.systemDefault());
- ZonedDateTime tomorrow = now.plusDays(1);
-
- DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT);
-
- CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
- commandStringBuilder.addOption("start-time", dateTimeFormatter.format(tomorrow));
- commandStringBuilder.addOption("log-level", "debug");
-
- connector.executeAndAssertThat(commandStringBuilder.toString()).statusIsError()
- .containsOutput("No files to be exported");
- }
-
- @Test
- public void testExportedZipFileTooBig() throws Exception {
- connectIfNeeded();
- CommandResult result = connector.executeCommand("export logs --file-size-limit=10k");
- assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
- }
-
- protected String getZipPathFromCommandResult(String message) {
- return message.replaceAll("Logs exported to the connected member's file system: ", "").trim();
- }
-
- private static Set<String> getZipEntries(String zipFilePath) throws IOException {
- return new ZipFile(zipFilePath).stream().map(ZipEntry::getName)
- .filter(x -> !x.endsWith("views.log")).collect(Collectors.toSet());
- }
+public class ExportLogsStatsDUnitTest extends ExportLogsStatsDUnitTestBase {
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTest.java
index 456220a..96254f6 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTest.java
@@ -15,259 +15,5 @@
package org.apache.geode.management.internal.cli.commands;
-import static org.apache.geode.internal.cache.functions.TestFunction.TEST_FUNCTION1;
-import static org.apache.geode.internal.cache.functions.TestFunction.TEST_FUNCTION_ALWAYS_THROWS_EXCEPTION;
-import static org.apache.geode.internal.cache.functions.TestFunction.TEST_FUNCTION_ON_ONE_MEMBER_RETURN_ARGS;
-import static org.apache.geode.internal.cache.functions.TestFunction.TEST_FUNCTION_RETURN_ARGS;
-import static org.awaitility.Awaitility.await;
-
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-
-import org.assertj.core.util.Strings;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-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.cache.execute.Function;
-import org.apache.geode.cache.execute.FunctionService;
-import org.apache.geode.internal.cache.functions.TestFunction;
-import org.apache.geode.management.DistributedSystemMXBean;
-import org.apache.geode.management.ManagementService;
-import org.apache.geode.test.dunit.rules.ClusterStartupRule;
-import org.apache.geode.test.dunit.rules.MemberVM;
-import org.apache.geode.test.junit.rules.GfshCommandRule;
-
-
-public class FunctionCommandsDUnitTest {
- private static MemberVM locator;
- private static MemberVM server1;
- private static MemberVM server2;
-
- private static final String REGION_ONE = "RegionOne";
- private static final String REGION_TWO = "RegionTwo";
- private static final String RESULT_HEADER = "Message";
-
- @ClassRule
- public static ClusterStartupRule lsRule = new ClusterStartupRule();
-
- @ClassRule
- public static GfshCommandRule gfsh = new GfshCommandRule();
-
- @BeforeClass
- public static void before() throws Exception {
- locator = lsRule.startLocatorVM(0, l -> l.withHttpService());
-
- Properties props = new Properties();
- props.setProperty("groups", "group-1");
- server1 = lsRule.startServerVM(1, props, locator.getPort());
-
- server2 = lsRule.startServerVM(2, locator.getPort());
-
- server1.invoke(() -> {
- Cache cache = ClusterStartupRule.getCache();
-
- RegionFactory<Integer, Integer> dataRegionFactory =
- cache.createRegionFactory(RegionShortcut.PARTITION);
- Region region = dataRegionFactory.create(REGION_ONE);
- for (int i = 0; i < 10; i++) {
- region.put("key" + (i + 200), "value" + (i + 200));
- }
- region = dataRegionFactory.create(REGION_TWO);
- for (int i = 0; i < 1000; i++) {
- region.put("key" + (i + 200), "value" + (i + 200));
- }
- });
-
- server2.invoke(() -> {
- Cache cache = ClusterStartupRule.getCache();
- RegionFactory<Integer, Integer> dataRegionFactory =
- cache.createRegionFactory(RegionShortcut.PARTITION);
- Region region = dataRegionFactory.create(REGION_ONE);
- for (int i = 0; i < 10000; i++) {
- region.put("key" + (i + 400), "value" + (i + 400));
- }
- region = dataRegionFactory.create(REGION_TWO);
- for (int i = 0; i < 10; i++) {
- region.put("key" + (i + 200), "value" + (i + 200));
- }
- });
-
- locator.invoke(() -> {
- Cache cache = ClusterStartupRule.getCache();
- ManagementService managementService = ManagementService.getManagementService(cache);
- DistributedSystemMXBean dsMXBean = managementService.getDistributedSystemMXBean();
-
- await().atMost(120, TimeUnit.SECONDS).until(() -> dsMXBean.getMemberCount() == 3);
- });
- }
-
- @Before
- public void setup() throws Exception {
- registerFunction(new TestFunction(true, TEST_FUNCTION1), locator, server1, server2);
- registerFunction(new TestFunction(true, TEST_FUNCTION_RETURN_ARGS), locator, server1, server2);
- registerFunction(new TestFunction(true, TEST_FUNCTION_ALWAYS_THROWS_EXCEPTION), locator,
- server1, server2);
- registerFunction(new TestFunction(true, TEST_FUNCTION_ON_ONE_MEMBER_RETURN_ARGS), locator,
- server1);
-
- connectGfsh();
- }
-
- public void connectGfsh() throws Exception {
- gfsh.connectAndVerify(getLocator().getJmxPort(), GfshCommandRule.PortType.jmxManager);
- }
-
- public MemberVM getLocator() {
- return locator;
- }
-
- private static void registerFunction(Function function, MemberVM... vms) {
- for (MemberVM vm : vms) {
- vm.invoke(() -> FunctionService.registerFunction(function));
- }
- }
-
- @Test
- public void testExecuteFunctionOnRegion() throws Exception {
- gfsh.executeAndAssertThat(
- "execute function --id=" + TEST_FUNCTION1 + " --region=/" + REGION_ONE).statusIsSuccess()
- .tableHasColumnWithValuesContaining("Member", server1.getName(), server2.getName());
- }
-
- @Test
- public void testExecuteFunctionOnUnknownRegion() throws Exception {
- gfsh.executeAndAssertThat("execute function --id=" + TEST_FUNCTION1 + " --region=/UNKNOWN")
- .statusIsError().containsOutput("No members found");
- }
-
- @Test
- public void testExecuteUnknownFunction() throws Exception {
- gfsh.executeAndAssertThat("execute function --id=UNKNOWN_FUNCTION").statusIsError()
- .containsOutput("UNKNOWN_FUNCTION is not registered on member");
- }
-
- @Test
- public void testExecuteFunctionOnRegionWithCustomResultCollector() {
- gfsh.executeAndAssertThat(
- "execute function --id=" + TEST_FUNCTION_RETURN_ARGS + " --region=" + REGION_ONE
- + " --arguments=arg1" + " --result-collector=" + ToUpperResultCollector.class.getName())
- .statusIsSuccess()
- .tableHasColumnOnlyWithValues(RESULT_HEADER, "[ARG1, ARG1]", "[ARG1, ARG1]");
- }
-
- @Test
- public void testExecuteFunctionOnMember() {
- gfsh.executeAndAssertThat(
- "execute function --id=" + TEST_FUNCTION1 + " --member=" + server1.getMember().getName())
- .statusIsSuccess().tableHasColumnWithValuesContaining("Member", server1.getName());
- }
-
- @Test
- public void testExecuteFunctionOnInvalidMember() {
- gfsh.executeAndAssertThat(
- "execute function --id=" + TEST_FUNCTION1 + " --member=INVALID_MEMBER").statusIsError();
- }
-
- @Test
- public void testExecuteFunctionOnAllMembers() {
- gfsh.executeAndAssertThat("execute function --id=" + TEST_FUNCTION1).statusIsSuccess()
- .tableHasColumnWithValuesContaining("Member", server1.getName(), server2.getName())
- .tableHasColumnWithExactValuesInAnyOrder(RESULT_HEADER, "[false]", "[false]");
- }
-
- @Test
- public void testExecuteFunctionOnMultipleMembers() {
- gfsh.executeAndAssertThat("execute function --id=" + TEST_FUNCTION1 + " --member="
- + Strings.join(server1.getName(), server2.getName()).with(",")).statusIsSuccess()
- .tableHasColumnWithValuesContaining("Member", server1.getName(), server2.getName())
- .tableHasColumnWithExactValuesInAnyOrder(RESULT_HEADER, "[false]", "[false]");
- }
-
- @Test
- public void testExecuteFunctionOnMultipleMembersWithArgsAndResultCollector() {
- gfsh.executeAndAssertThat("execute function --id=" + TEST_FUNCTION_RETURN_ARGS
- + " --arguments=arg1" + " --result-collector=" + ToUpperResultCollector.class.getName())
- .statusIsSuccess()
- .tableHasColumnWithValuesContaining("Member", server1.getName(), server2.getName())
- .tableHasColumnWithExactValuesInAnyOrder(RESULT_HEADER, "[ARG1]", "[ARG1]");
- }
-
- @Test
- public void testFunctionOnlyRegisteredOnOneMember() {
- gfsh.executeAndAssertThat("execute function --id=" + TEST_FUNCTION_ON_ONE_MEMBER_RETURN_ARGS)
- .tableHasColumnWithValuesContaining(RESULT_HEADER, "[false]",
- "Function : executeFunctionOnOneMemberToReturnArgs is not registered on member.")
- .statusIsError();
- }
-
- @Test
- public void testExecuteFunctionOnGroup() {
- gfsh.executeAndAssertThat("execute function --id=" + TEST_FUNCTION1 + " --groups=group-1")
- .statusIsSuccess().tableHasColumnWithValuesContaining("Member", server1.getName())
- .tableHasColumnWithExactValuesInAnyOrder(RESULT_HEADER, "[false]");
- }
-
- @Test
- public void testDestroyFunctionOnMember() {
- gfsh.executeAndAssertThat(
- "destroy function --id=" + TEST_FUNCTION1 + " --member=" + server1.getName())
- .statusIsSuccess();
-
- gfsh.executeAndAssertThat("list functions").statusIsSuccess()
- .tableHasColumnWithExactValuesInAnyOrder("Function", TEST_FUNCTION_RETURN_ARGS,
- TEST_FUNCTION1, TEST_FUNCTION_RETURN_ARGS, TEST_FUNCTION_ALWAYS_THROWS_EXCEPTION,
- TEST_FUNCTION_ALWAYS_THROWS_EXCEPTION, TEST_FUNCTION_ON_ONE_MEMBER_RETURN_ARGS);
- gfsh.executeAndAssertThat(
- "destroy function --id=" + TEST_FUNCTION1 + " --member=" + server2.getName())
- .statusIsSuccess();
- gfsh.executeAndAssertThat("list functions").statusIsSuccess()
- .tableHasColumnWithExactValuesInAnyOrder("Function", TEST_FUNCTION_RETURN_ARGS,
- TEST_FUNCTION_RETURN_ARGS, TEST_FUNCTION_ALWAYS_THROWS_EXCEPTION,
- TEST_FUNCTION_ALWAYS_THROWS_EXCEPTION, TEST_FUNCTION_ON_ONE_MEMBER_RETURN_ARGS);
- }
-
- @Test
- public void testDestroyFunctionOnGroup() {
- gfsh.executeAndAssertThat("destroy function --id=" + TEST_FUNCTION1 + " --groups=group-1")
- .statusIsSuccess();
- gfsh.executeAndAssertThat("list functions").statusIsSuccess()
- .tableHasColumnWithExactValuesInAnyOrder("Function", TEST_FUNCTION_RETURN_ARGS,
- TEST_FUNCTION1, TEST_FUNCTION_RETURN_ARGS, TEST_FUNCTION_ALWAYS_THROWS_EXCEPTION,
- TEST_FUNCTION_ALWAYS_THROWS_EXCEPTION, TEST_FUNCTION_ON_ONE_MEMBER_RETURN_ARGS);
- }
-
- @Test
- public void testListFunctions() {
- gfsh.executeAndAssertThat("list functions").statusIsSuccess()
- .tableHasColumnWithExactValuesInAnyOrder("Function", TEST_FUNCTION1, TEST_FUNCTION1,
- TEST_FUNCTION_RETURN_ARGS, TEST_FUNCTION_RETURN_ARGS,
- TEST_FUNCTION_ALWAYS_THROWS_EXCEPTION, TEST_FUNCTION_ALWAYS_THROWS_EXCEPTION,
- TEST_FUNCTION_ON_ONE_MEMBER_RETURN_ARGS);
-
- gfsh.executeAndAssertThat("list functions --matches=Test.*").statusIsSuccess()
- .tableHasColumnWithExactValuesInAnyOrder("Function", TEST_FUNCTION1, TEST_FUNCTION1,
- TEST_FUNCTION_ALWAYS_THROWS_EXCEPTION, TEST_FUNCTION_ALWAYS_THROWS_EXCEPTION);
-
- gfsh.executeAndAssertThat("list functions --matches=Test.* --groups=group-1").statusIsSuccess()
- .tableHasColumnWithExactValuesInAnyOrder("Function", TEST_FUNCTION1,
- TEST_FUNCTION_ALWAYS_THROWS_EXCEPTION);
-
- gfsh.executeAndAssertThat("list functions --matches=Test.* --members=" + server1.getName())
- .statusIsSuccess().tableHasColumnWithExactValuesInAnyOrder("Function", TEST_FUNCTION1,
- TEST_FUNCTION_ALWAYS_THROWS_EXCEPTION);
- }
-
- @Test
- public void testFunctionException() {
- gfsh.executeAndAssertThat("execute function --id=" + TEST_FUNCTION_ALWAYS_THROWS_EXCEPTION)
- .tableHasColumnWithValuesContaining(RESULT_HEADER, "I have been thrown from TestFunction",
- "I have been thrown from TestFunction")
- .statusIsError();
- }
+public class FunctionCommandsDUnitTest extends FunctionCommandsDUnitTestBase {
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GcCommandDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GcCommandDUnitTest.java
index f1c7d83..4e4721f 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GcCommandDUnitTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GcCommandDUnitTest.java
@@ -14,106 +14,5 @@
*/
package org.apache.geode.management.internal.cli.commands;
-import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
-import static org.apache.geode.distributed.ConfigurationProperties.NAME;
-import static org.apache.geode.test.junit.rules.GfshCommandRule.PortType.jmxManager;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.Properties;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.test.dunit.rules.ClusterStartupRule;
-import org.apache.geode.test.dunit.rules.MemberVM;
-import org.apache.geode.test.junit.rules.GfshCommandRule;
-
-
-public class GcCommandDUnitTest {
- private static final String MANAGER_NAME = "Manager";
- private static final String SERVER1_NAME = "Server1";
- private static final String SERVER2_NAME = "Server2";
- private static final String GROUP0 = "Group0";
- private static final String GROUP1 = "Group1";
- private static final String GROUP2 = "Group2";
-
- protected static MemberVM locator;
-
- @ClassRule
- public static ClusterStartupRule clusterStartupRule = new ClusterStartupRule();
-
- @ClassRule
- public static GfshCommandRule gfsh = new GfshCommandRule();
-
- @BeforeClass
- public static void setup() throws Exception {
- Properties managerProps = new Properties();
- managerProps.setProperty(NAME, MANAGER_NAME);
- managerProps.setProperty(GROUPS, GROUP0);
- managerProps.setProperty(LOG_FILE, "someLog.log");
- locator =
- clusterStartupRule.startLocatorVM(0, l -> l.withHttpService().withProperties(managerProps));
-
- Properties server1Props = new Properties();
- server1Props.setProperty(NAME, SERVER1_NAME);
- server1Props.setProperty(GROUPS, GROUP1);
- clusterStartupRule.startServerVM(1, server1Props, locator.getPort());
-
- Properties server2Props = new Properties();
- server2Props.setProperty(NAME, SERVER2_NAME);
- server2Props.setProperty(GROUPS, GROUP2);
- clusterStartupRule.startServerVM(2, server2Props, locator.getPort());
- }
-
- @Before
- public void before() throws Exception {
- gfsh.connectAndVerify(locator.getJmxPort(), jmxManager);
- }
-
- @After
- public void after() throws Exception {
- gfsh.disconnect();
- }
-
- @Test
- public void testGCForGroup() {
- String gcCommand = "gc --group=" + GROUP0;
- gfsh.executeAndAssertThat(gcCommand).statusIsSuccess();
-
- assertThat(gfsh.getGfshOutput()).contains(MANAGER_NAME);
- }
-
- @Test
- public void testGCForMemberID() {
- String gcCommand = "gc --member=" + MANAGER_NAME;
-
- gfsh.executeAndAssertThat(gcCommand).statusIsSuccess();
- assertThat(gfsh.getGfshOutput()).contains(MANAGER_NAME);
- }
-
- @Test
- public void testGCForEntireCluster() {
- String command = "gc";
- gfsh.executeAndAssertThat(command).statusIsSuccess();
-
- String output = gfsh.getGfshOutput();
- assertThat(output).contains(SERVER1_NAME);
- assertThat(output).contains(SERVER2_NAME);
- assertThat(output).doesNotContain(MANAGER_NAME);
- }
-
- @Test
- public void testGCForInvalidMember() throws Exception {
- String gcCommand = "gc --member=NotAValidMember";
-
- CommandResult result = gfsh.executeCommand(gcCommand);
- assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
- assertThat(gfsh.getGfshOutput()).contains("Member NotAValidMember could not be found.");
- }
+public class GcCommandDUnitTest extends GcCommandDUnitTestBase {
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GemfireDataCommandsDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GemfireDataCommandsDUnitTest.java
index 7ce158c..b596f9a 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GemfireDataCommandsDUnitTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GemfireDataCommandsDUnitTest.java
@@ -15,346 +15,5 @@
package org.apache.geode.management.internal.cli.commands;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
-import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
-import static org.apache.geode.distributed.ConfigurationProperties.NAME;
-import static org.apache.geode.distributed.ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER;
-import static org.apache.geode.test.dunit.Assert.assertEquals;
-import static org.apache.geode.test.dunit.Assert.assertNotNull;
-import static org.apache.geode.test.dunit.Assert.fail;
-import static org.assertj.core.api.Java6Assertions.assertThat;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.PartitionAttributes;
-import org.apache.geode.cache.PartitionAttributesFactory;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionFactory;
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.distributed.ConfigurationProperties;
-import org.apache.geode.internal.AvailablePortHelper;
-import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.management.DistributedRegionMXBean;
-import org.apache.geode.management.ManagementService;
-import org.apache.geode.management.internal.cli.domain.DataCommandResult;
-import org.apache.geode.management.internal.cli.dto.Value1;
-import org.apache.geode.management.internal.cli.dto.Value2;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.management.internal.cli.result.ResultData;
-import org.apache.geode.management.internal.cli.result.model.DataResultModel;
-import org.apache.geode.management.internal.cli.result.model.ResultModel;
-import org.apache.geode.test.dunit.SerializableRunnableIF;
-import org.apache.geode.test.dunit.rules.ClusterStartupRule;
-import org.apache.geode.test.dunit.rules.MemberVM;
-import org.apache.geode.test.junit.rules.GfshCommandRule;
-
-/**
- * Dunit class for testing gemfire data commands : get, put, remove
- */
-@SuppressWarnings("serial")
-public class GemfireDataCommandsDUnitTest {
-
-
- private static final String DATA_REGION_NAME = "GemfireDataCommandsTestRegion";
- private static final String DATA_REGION_NAME_VM1 = "GemfireDataCommandsTestRegion_Vm1";
- private static final String DATA_REGION_NAME_VM2 = "GemfireDataCommandsTestRegion_Vm2";
- private static final String DATA_REGION_NAME_PATH = "/GemfireDataCommandsTestRegion";
- private static final String DATA_REGION_NAME_VM1_PATH = "/GemfireDataCommandsTestRegion_Vm1";
- private static final String DATA_REGION_NAME_VM2_PATH = "/GemfireDataCommandsTestRegion_Vm2";
-
- private static final String DATA_PAR_REGION_NAME = "GemfireDataCommandsTestParRegion";
- private static final String DATA_PAR_REGION_NAME_VM1 = "GemfireDataCommandsTestParRegion_Vm1";
- private static final String DATA_PAR_REGION_NAME_VM2 = "GemfireDataCommandsTestParRegion_Vm2";
- private static final String DATA_PAR_REGION_NAME_PATH = "/GemfireDataCommandsTestParRegion";
- private static final String DATA_PAR_REGION_NAME_VM1_PATH =
- "/GemfireDataCommandsTestParRegion_Vm1";
- private static final String DATA_PAR_REGION_NAME_VM2_PATH =
- "/GemfireDataCommandsTestParRegion_Vm2";
-
- private static final String DATA_REGION_NAME_CHILD_1 = "ChildRegionRegion1";
- private static final String DATA_REGION_NAME_CHILD_1_2 = "ChildRegionRegion12";
-
- private static final String SERIALIZATION_FILTER =
- "org.apache.geode.management.internal.cli.**";
-
-
- @Rule
- public GfshCommandRule gfsh = new GfshCommandRule();
-
- @Rule
- public ClusterStartupRule cluster = new ClusterStartupRule();
-
- protected MemberVM locator, server1, server2;
-
- public void before() throws Exception {
- locator = cluster.startLocatorVM(0, locatorProperties());
- server1 = cluster.startServerVM(1, locator.getPort());
- server2 = cluster.startServerVM(2, locator.getPort());
- connectToLocator();
- }
-
- // extracted for convenience overriding in GemfireDataCommandsOverHttpDUnitTest to connect via
- // http
- public void connectToLocator() throws Exception {
- gfsh.connectAndVerify(locator);
- }
-
- private static void setupRegions(String regionName, String parRegionName) {
- InternalCache cache = ClusterStartupRule.getCache();
- RegionFactory regionFactory =
- cache.createRegionFactory(RegionShortcut.REPLICATE);
-
- Region dataRegion = regionFactory.create(DATA_REGION_NAME);
- assertNotNull(dataRegion);
-
- dataRegion =
- dataRegion.createSubregion(DATA_REGION_NAME_CHILD_1, dataRegion.getAttributes());
- assertNotNull(dataRegion);
-
- dataRegion =
- dataRegion.createSubregion(DATA_REGION_NAME_CHILD_1_2, dataRegion.getAttributes());
- assertNotNull(dataRegion);
-
- dataRegion = regionFactory.create(regionName);
- assertNotNull(dataRegion);
-
- PartitionAttributes partitionAttrs =
- new PartitionAttributesFactory().setRedundantCopies(2).create();
- RegionFactory<Object, Object> partitionRegionFactory =
- cache.createRegionFactory(RegionShortcut.PARTITION);
- partitionRegionFactory.setPartitionAttributes(partitionAttrs);
- Region dataParRegion = partitionRegionFactory.create(DATA_PAR_REGION_NAME);
- assertNotNull(dataParRegion);
- dataParRegion = partitionRegionFactory.create(parRegionName);
- assertNotNull(dataParRegion);
- }
-
-
-
- void setupForGetPutRemoveLocateEntry(String testName) throws Exception {
- Properties props = locatorProperties();
- props.setProperty(SERIALIZABLE_OBJECT_FILTER, SERIALIZATION_FILTER);
- props.setProperty(NAME, testName + "Manager");
-
- Properties serverProps = new Properties();
- serverProps.setProperty(SERIALIZABLE_OBJECT_FILTER, SERIALIZATION_FILTER);
- locator = cluster.startLocatorVM(0, props);
- server1 = cluster.startServerVM(1, serverProps, locator.getPort());
- server2 = cluster.startServerVM(2, serverProps, locator.getPort());
-
- gfsh.connectAndVerify(locator);
-
- server1.invoke(() -> setupRegions(DATA_REGION_NAME_VM1, DATA_PAR_REGION_NAME_VM1));
-
- server2.invoke(() -> {
- setupRegions(DATA_REGION_NAME_VM2, DATA_PAR_REGION_NAME_VM2);
- });
-
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_PATH, 2);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_PATH, 2);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_VM1_PATH, 1);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_VM2_PATH, 1);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_PAR_REGION_NAME_PATH, 2);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_PAR_REGION_NAME_VM1_PATH, 1);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_PAR_REGION_NAME_VM2_PATH, 1);
-
- locator.invoke(() -> {
- InternalCache cache = ClusterStartupRule.getCache();
- final ManagementService service = ManagementService.getManagementService(cache);
-
- assertNotNull(service.getMemberMXBean());
- assertNotNull(service.getManagerMXBean());
- DistributedRegionMXBean bean = service.getDistributedRegionMXBean(DATA_REGION_NAME_PATH);
- assertNotNull(bean);
-
- String regions[] = {DATA_REGION_NAME_PATH, DATA_REGION_NAME_VM1_PATH,
- DATA_REGION_NAME_VM2_PATH, DATA_PAR_REGION_NAME_PATH, DATA_PAR_REGION_NAME_VM1_PATH,
- DATA_PAR_REGION_NAME_VM2_PATH};
-
- for (String region : regions) {
- bean = service.getDistributedRegionMXBean(region);
- assertNotNull(bean);
-
- if (bean.getMemberCount() < 1) {
- fail("Even after waiting mbean reports number of member hosting region "
- + DATA_REGION_NAME_VM1_PATH + " is less than one");
- }
- }
- });
- }
-
- @Test
- public void testPrimitivesWithDataCommands() throws Exception {
- setupForGetPutRemoveLocateEntry("testPrimitives");
- Byte byteKey = Byte.parseByte("41");
- Byte byteValue = Byte.parseByte("31");
- Short shortKey = Short.parseShort("123");
- Short shortValue = Short.parseShort("121");
- Integer integerKey = Integer.parseInt("123456");
- Integer integerValue = Integer.parseInt("12345678");
- Float floatKey = Float.valueOf("12432.2325");
- Float floatValue = Float.valueOf("111111.1111");
- Double doubleKey = Double.valueOf("12432.235425");
- Double doubleValue = Double.valueOf("111111.111111");
-
- // Testing Byte Wrappers
- testGetPutLocateEntryFromShellAndGemfire(byteKey, byteValue, Byte.class, true, true);
- // Testing Short Wrappers
- testGetPutLocateEntryFromShellAndGemfire(shortKey, shortValue, Short.class, true, true);
- // Testing Integer Wrappers
- testGetPutLocateEntryFromShellAndGemfire(integerKey, integerValue, Integer.class, true, true);
- // Testing Float Wrappers
- testGetPutLocateEntryFromShellAndGemfire(floatKey, floatValue, Float.class, true, true);
- // Testing Double Wrappers
- testGetPutLocateEntryFromShellAndGemfire(doubleKey, doubleValue, Double.class, true, true);
- }
-
-
-
- private void testGetPutLocateEntryFromShellAndGemfire(final Serializable key,
- final Serializable value, Class klass, boolean addRegionPath, boolean expResult) {
-
- SerializableRunnableIF putTask = () -> {
- Cache cache = ClusterStartupRule.getCache();
- Region region = cache.getRegion(DATA_REGION_NAME_PATH);
- assertNotNull(region);
- region.clear();
- region.put(key, value);
- };
-
- SerializableRunnableIF getTask = () -> {
- Cache cache = ClusterStartupRule.getCache();
- Region region = cache.getRegion(DATA_REGION_NAME_PATH);
- assertNotNull(region);
- assertEquals(true, region.containsKey(key));
- assertEquals(value, region.get(key));
- };
-
- SerializableRunnableIF removeTask = () -> {
- Cache cache = ClusterStartupRule.getCache();
- Region region = cache.getRegion(DATA_REGION_NAME_PATH);
- assertNotNull(region);
- assertEquals(true, region.containsKey(key));
- region.remove(key);
- };
-
-
- SerializableRunnableIF clearTask = () -> {
- Cache cache = ClusterStartupRule.getCache();
- Region region = cache.getRegion(DATA_REGION_NAME_PATH);
- assertNotNull(region);
- region.clear();
- };
-
- String canonicalName = klass.getCanonicalName();
- String getCommand = "get --key=" + key + " --key-class=" + canonicalName
- + " --value-class=" + canonicalName;
- if (addRegionPath)
- getCommand += " --region=" + DATA_REGION_NAME_PATH;
-
- String locateEntryCommand = "locate entry --key=" + key + " --key-class="
- + canonicalName + " --value-class=" + canonicalName;
- if (addRegionPath)
- locateEntryCommand += " --region=" + DATA_REGION_NAME_PATH;
-
- String removeCommand = "remove --key=" + key + " --key-class=" + canonicalName;
- if (addRegionPath)
- removeCommand += " --region=" + DATA_REGION_NAME_PATH;
- String putCommand = "put --key=" + key + " --key-class=" + canonicalName
- + " --value=" + value + " --value-class=" + canonicalName;
- if (addRegionPath)
- putCommand += " --region=" + DATA_REGION_NAME_PATH;
-
- if (expResult) {
- // Do put from shell check gemfire get do gemfire remove
- CommandResult cmdResult = gfsh.executeCommand(putCommand);
- validateResult(cmdResult, true);
- server1.invoke(getTask);
- server1.invoke(removeTask);
-
- server1.invoke(clearTask);
-
- // Do put from gemfire check from shell do gemfire remove
- server1.invoke(putTask);
- cmdResult = gfsh.executeCommand(getCommand);
- validateResult(cmdResult, true);
- cmdResult = gfsh.executeCommand(locateEntryCommand);
- validateResult(cmdResult, true);
- server1.invoke(removeTask);
-
- server1.invoke(clearTask);
-
- // Do put from shell check from gemfire do remove from shell get from shell expect false
- cmdResult = gfsh.executeCommand(putCommand);
- validateResult(cmdResult, true);
- server1.invoke(getTask);
- cmdResult = gfsh.executeCommand(removeCommand);
- validateResult(cmdResult, true);
- cmdResult = gfsh.executeCommand(getCommand);
- validateResult(cmdResult, false);
- cmdResult = gfsh.executeCommand(locateEntryCommand);
- validateResult(cmdResult, false);
- } else {
- // Do put from shell check gemfire get do gemfire remove
- CommandResult cmdResult = gfsh.executeCommand(putCommand);
- validateResult(cmdResult, false);
- server1.invoke(clearTask);
-
- // Do put from gemfire check from shell do gemfire remove
- server1.invoke(putTask);
- cmdResult = gfsh.executeCommand(getCommand);
- validateResult(cmdResult, false);
- cmdResult = gfsh.executeCommand(locateEntryCommand);
- validateResult(cmdResult, false);
- server1.invoke(removeTask);
- server1.invoke(clearTask);
-
- // Do put from shell check from gemfire do remove from shell get from shell exepct false
- cmdResult = gfsh.executeCommand(putCommand);
- validateResult(cmdResult, false);
- }
- }
-
- private void validateResult(CommandResult cmdResult, Boolean expected) {
- if (ResultData.TYPE_MODEL.equals(cmdResult.getType())) {
- ResultModel rd = (ResultModel) cmdResult.getResultData();
- DataResultModel result = rd.getDataSection(DataCommandResult.DATA_INFO_SECTION);
- assertThat(result.getContent().get("Result")).isEqualTo(expected.toString());
- } else
- fail("Expected CompositeResult Returned Result Type " + cmdResult.getType());
- }
-
- private Properties locatorProperties() {
- int jmxPort = AvailablePortHelper.getRandomAvailableTCPPort();
- Properties props = new Properties();
- props.setProperty(MCAST_PORT, "0");
- props.setProperty(LOG_LEVEL, "fine");
- props.setProperty(ConfigurationProperties.JMX_MANAGER_HOSTNAME_FOR_CLIENTS, "localhost");
- props.setProperty(ConfigurationProperties.JMX_MANAGER_PORT, "" + jmxPort);
-
- return props;
- }
-
- public static class Value1WithValue2 extends Value1 {
- private Value2 value2 = null;
-
- public Value1WithValue2(int i) {
- super(i);
- value2 = new Value2(i);
- }
-
- public Value2 getValue2() {
- return value2;
- }
-
- public void setValue2(Value2 value2) {
- this.value2 = value2;
- }
- }
-
+public class GemfireDataCommandsDUnitTest extends GemfireDataCommandsDUnitTestBase {
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTest.java
index fb6702a..8749bcf 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTest.java
@@ -15,71 +15,5 @@
package org.apache.geode.management.internal.cli.commands;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-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.management.internal.cli.domain.Stock;
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.test.dunit.rules.ClusterStartupRule;
-import org.apache.geode.test.dunit.rules.MemberVM;
-import org.apache.geode.test.junit.categories.OQLIndexTest;
-import org.apache.geode.test.junit.rules.GfshCommandRule;
-
-@Category({OQLIndexTest.class})
-public class ListIndexCommandDUnitTest {
-
- private static final String REGION_1 = "REGION1";
- private static final String INDEX_REGION_NAME = "/REGION1";
- private static final String INDEX_1 = "INDEX1";
-
- private MemberVM locator, server;
-
- @Rule
- public ClusterStartupRule lsRule = new ClusterStartupRule();
-
- @Rule
- public GfshCommandRule gfsh = new GfshCommandRule();
-
- @Before
- public void before() throws Exception {
- locator = lsRule.startLocatorVM(0, l -> l.withHttpService());
- server = lsRule.startServerVM(1, locator.getPort());
-
- server.invoke(() -> {
- Cache cache = ClusterStartupRule.getCache();
- RegionFactory factory = cache.createRegionFactory(RegionShortcut.REPLICATE);
- Region region = factory.create(REGION_1);
-
- cache.getQueryService().createIndex(INDEX_1, "key", INDEX_REGION_NAME);
- region.put(1, new Stock("SUNW", 10));
- region.get(1);
- });
-
- connectGfsh(locator);
- }
-
- public void connectGfsh(MemberVM vm) throws Exception {
- gfsh.connectAndVerify(vm.getJmxPort(), GfshCommandRule.PortType.jmxManager);
- }
-
- @Test
- public void testListIndexes() throws Exception {
- gfsh.executeAndAssertThat(CliStrings.LIST_INDEX).statusIsSuccess()
- .tableHasColumnWithExactValuesInAnyOrder("Member Name", server.getName());
- }
-
- @Test
- public void testListIndexesWithStats() throws Exception {
- gfsh.executeAndAssertThat(CliStrings.LIST_INDEX + " --with-stats").statusIsSuccess()
- .tableHasColumnWithExactValuesInAnyOrder("Member Name", server.getName())
- .tableHasColumnWithExactValuesInAnyOrder("Updates", "1")
- .tableHasColumnWithExactValuesInAnyOrder("Keys", "1")
- .tableHasColumnWithExactValuesInAnyOrder("Values", "1");
- }
+public class ListIndexCommandDUnitTest extends ListIndexCommandDUnitTestBase {
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTest.java
index 660c385..1105b8e 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTest.java
@@ -14,309 +14,5 @@
*/
package org.apache.geode.management.internal.cli.commands;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
-import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
-import static org.apache.geode.distributed.ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER;
-import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException;
-import static org.apache.geode.test.junit.rules.GfshCommandRule.PortType.jmxManager;
-import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.junit.Assert.fail;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Random;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.geode.cache.EvictionAction;
-import org.apache.geode.cache.EvictionAlgorithm;
-import org.apache.geode.cache.PartitionAttributes;
-import org.apache.geode.cache.PartitionAttributesFactory;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionFactory;
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.cache.query.QueryInvalidException;
-import org.apache.geode.cache.query.data.Portfolio;
-import org.apache.geode.distributed.ConfigurationProperties;
-import org.apache.geode.internal.AvailablePortHelper;
-import org.apache.geode.internal.cache.EvictionAttributesImpl;
-import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.internal.i18n.LocalizedStrings;
-import org.apache.geode.management.ManagementService;
-import org.apache.geode.management.MemberMXBean;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.domain.DataCommandResult;
-import org.apache.geode.management.internal.cli.dto.Value1;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.management.internal.cli.result.ResultData;
-import org.apache.geode.management.internal.cli.result.model.ResultModel;
-import org.apache.geode.test.dunit.IgnoredException;
-import org.apache.geode.test.dunit.rules.ClusterStartupRule;
-import org.apache.geode.test.dunit.rules.MemberVM;
-import org.apache.geode.test.junit.rules.GfshCommandRule;
-
-@SuppressWarnings("serial")
-public class QueryCommandDUnitTest {
- private static final String DATA_REGION_NAME = "GemfireDataCommandsTestRegion";
- private static final String DATA_REGION_NAME_PATH = "/" + DATA_REGION_NAME;
- private static final String DATA_REGION_WITH_EVICTION_NAME =
- "GemfireDataCommandsTestRegionWithEviction";
- private static final String DATA_REGION_WITH_EVICTION_NAME_PATH =
- "/" + DATA_REGION_WITH_EVICTION_NAME;
- private static final String DATA_PAR_REGION_NAME = "GemfireDataCommandsTestParRegion";
- private static final String DATA_PAR_REGION_NAME_PATH = "/" + DATA_PAR_REGION_NAME;
-
- private static final String SERIALIZATION_FILTER =
- "org.apache.geode.management.internal.cli.dto.**";
-
- static final int COUNT = 5;
-
- @Rule
- public GfshCommandRule gfsh = new GfshCommandRule();
-
- @Rule
- public ClusterStartupRule cluster = new ClusterStartupRule();
-
- protected MemberVM locator, server1, server2;
-
- @Before
- public void before() throws Exception {
- Properties locatorProps = locatorProperties();
- locator = cluster.startLocatorVM(0, l -> l.withHttpService().withProperties(locatorProps));
- server1 = cluster.startServerVM(1, serverProperties(), locator.getPort());
- server2 = cluster.startServerVM(2, serverProperties(), locator.getPort());
-
- server1.invoke(() -> setupReplicatedRegion(DATA_REGION_NAME));
- server2.invoke(() -> setupReplicatedRegion(DATA_REGION_NAME));
- server1.invoke(() -> setupPartitionedRegion(DATA_PAR_REGION_NAME));
-
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_PATH, 2);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_PAR_REGION_NAME_PATH, 1);
-
- connectToLocator();
- }
-
- public void connectToLocator() throws Exception {
- gfsh.connectAndVerify(locator.getJmxPort(), jmxManager);
- }
-
- @Test
- public void testWithGfshEnvironmentVariables() {
- String query =
- "query --query=\"select ID , status , createTime , pk, floatMinValue from ${DATA_REGION} where ID <= ${PORTFOLIO_ID}"
- + " and status=${STATUS}" + "\" --interactive=false";
- gfsh.executeCommand("set variable --name=DATA_REGION --value=" + DATA_REGION_NAME_PATH);
- gfsh.executeCommand("set variable --name=PORTFOLIO_ID --value=3");
- gfsh.executeCommand("set variable --name=STATUS --value=inactive");
- CommandResult cmdResult = gfsh.executeCommand(query);
- assertThat(cmdResult.getStatus()).isEqualTo(Result.Status.OK);
- }
-
- @Test
- public void testWithUnsetGfshEnvironmentVariables() {
- IgnoredException ex =
- addIgnoredException(QueryInvalidException.class.getSimpleName(), locator.getVM());
- try {
- String query =
- "query --query=\"select ID , status , createTime , pk, floatMinValue from ${UNSET_REGION} where ID <= ${UNSET_PORTFOLIO_ID}"
- + " and status=${UNSET_STATUS}" + "\" --interactive=false";
- CommandResult result = gfsh.executeCommand(query);
- assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
- assertThat(result.getResultData().toString())
- .contains(LocalizedStrings.QCompiler_SYNTAX_ERROR_IN_QUERY_0.toLocalizedString(""));
- } finally {
- ex.remove();
- }
- }
-
- @Test
- public void testSimpleQuery() {
- server1.invoke(() -> prepareDataForRegion(DATA_PAR_REGION_NAME_PATH));
- Random random = new Random(System.nanoTime());
- int randomInteger = random.nextInt(COUNT);
- String query = "query --query=\"select ID , status , createTime , pk, floatMinValue from "
- + DATA_PAR_REGION_NAME_PATH + " where ID <= " + randomInteger + "\" --interactive=false";
- CommandResult commandResult = gfsh.executeCommand(query);
- validateSelectResult(commandResult, true, (randomInteger + 1),
- new String[] {"ID", "status", "createTime", "pk", "floatMinValue"});
- }
-
- @Test
- public void testSimpleQueryOnLocator() {
- server1.invoke(() -> prepareDataForRegion(DATA_PAR_REGION_NAME_PATH));
-
- locator.invoke(() -> {
- String query = "query --query=\"select ID , status , createTime , pk, floatMinValue from "
- + DATA_PAR_REGION_NAME_PATH + " where ID <= 4"
- + "\" --interactive=false";
- ManagementService service =
- ManagementService.getExistingManagementService(ClusterStartupRule.getCache());
- MemberMXBean member = service.getMemberMXBean();
- String cmdResult = member.processCommand(query);
-
- assertThat(cmdResult).contains("ID");
- assertThat(cmdResult).contains("status");
- assertThat(cmdResult).contains("createTime");
- assertThat(cmdResult).contains("pk");
- assertThat(cmdResult).contains("floatMinValue");
- assertThat(cmdResult).contains("\"Rows\":\"5\"");
- });
- }
-
- @Test
- public void testQueryEvictedDataDeserializable() {
- server1.invoke(() -> setupReplicatedRegionWithEviction(DATA_REGION_WITH_EVICTION_NAME));
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_WITH_EVICTION_NAME_PATH, 1);
- server1.invoke(() -> prepareDeserializableDataForRegion(DATA_REGION_WITH_EVICTION_NAME_PATH));
-
- String query = "query --query=\"select Value from " + DATA_REGION_WITH_EVICTION_NAME_PATH
- + "\" --interactive=false";
- CommandResult commandResult = gfsh.executeCommand(query);
- validateSelectResult(commandResult, Boolean.TRUE, 10, new String[] {"Value"});
- }
-
- @Test
- public void testQueryEvictedDataNotDeserializable() {
- IgnoredException ex =
- addIgnoredException(Exception.class.getSimpleName(), locator.getVM());
-
- server1.invoke(() -> setupReplicatedRegionWithEviction(DATA_REGION_WITH_EVICTION_NAME));
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_WITH_EVICTION_NAME_PATH, 1);
- server1
- .invoke(() -> prepareNotDeserializableDataForRegion(DATA_REGION_WITH_EVICTION_NAME_PATH));
-
- String query = "query --query=\"select Value from " + DATA_REGION_WITH_EVICTION_NAME_PATH
- + "\" --interactive=false";
- CommandResult commandResult = gfsh.executeCommand(query);
- validateSelectResult(commandResult, Boolean.FALSE, -1, new String[] {"Value"});
- assertThat(commandResult.getResultData().toString())
- .contains(LocalizedStrings.EntryEventImpl_AN_IOEXCEPTION_WAS_THROWN_WHILE_DESERIALIZING
- .toLocalizedString());
-
- ex.remove();
- }
-
- private static void prepareDataForRegion(String regionPath) {
- InternalCache cache = ClusterStartupRule.getCache();
- Region dataRegion = cache.getRegion(regionPath);
-
- for (int j = 0; j < 10; j++) {
- dataRegion.put(new Integer(j), new Portfolio(j));
- }
- }
-
- private static void prepareNotDeserializableDataForRegion(String regionPath) {
- InternalCache cache = ClusterStartupRule.getCache();
- Region dataRegion = cache.getRegion(regionPath);
-
- for (int j = 0; j < 10; j++) {
- dataRegion.put(new Integer(j), new shouldFailSerializationFilter(j));
- }
- }
-
- private static void prepareDeserializableDataForRegion(String regionPath) {
- InternalCache cache = ClusterStartupRule.getCache();
- Region dataRegion = cache.getRegion(regionPath);
-
- for (int j = 0; j < 10; j++) {
- dataRegion.put(new Integer(j), new Value1(j));
- }
- }
-
- private static void setupReplicatedRegionWithEviction(String regionName) {
- InternalCache cache = ClusterStartupRule.getCache();
- EvictionAttributesImpl evictionAttributes = new EvictionAttributesImpl();
- evictionAttributes.setMaximum(1).setAction(EvictionAction.OVERFLOW_TO_DISK)
- .setAlgorithm(EvictionAlgorithm.LRU_ENTRY);
- RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE)
- .setEvictionAttributes(evictionAttributes);
-
- Region dataRegion = regionFactory.create(regionName);
- assertThat(dataRegion).isNotNull();
- assertThat(dataRegion.getFullPath()).contains(regionName);
- }
-
- private static void setupPartitionedRegion(String regionName) {
- InternalCache cache = ClusterStartupRule.getCache();
- PartitionAttributes partitionAttrs =
- new PartitionAttributesFactory().setRedundantCopies(2).create();
- RegionFactory<Object, Object> partitionRegionFactory =
- cache.createRegionFactory(RegionShortcut.PARTITION);
-
- partitionRegionFactory.setPartitionAttributes(partitionAttrs);
- Region dataParRegion = partitionRegionFactory.create(regionName);
-
- assertThat(dataParRegion).isNotNull();
- assertThat(dataParRegion.getFullPath()).contains(regionName);
- }
-
- private static void setupReplicatedRegion(String regionName) {
- InternalCache cache = ClusterStartupRule.getCache();
- RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE);
-
- Region dataRegion = regionFactory.create(regionName);
- assertThat(dataRegion).isNotNull();
- assertThat(dataRegion.getFullPath()).contains(regionName);
- }
-
- private void validateSelectResult(CommandResult cmdResult, Boolean expectSuccess,
- Integer expectedRows, String[] cols) {
- if (ResultData.TYPE_MODEL.equals(cmdResult.getType())) {
- ResultModel rd = (ResultModel) cmdResult.getResultData();
-
- Map<String, String> data =
- rd.getDataSection(DataCommandResult.DATA_INFO_SECTION).getContent();
- assertThat(data.get("Result")).isEqualTo(expectSuccess.toString());
-
- if (expectSuccess && expectedRows != -1) {
- assertThat(data.get("Rows")).isEqualTo(expectedRows.toString());
-
- if (expectedRows > 0 && cols != null) {
- Map<String, List<String>> table =
- rd.getTableSection(DataCommandResult.QUERY_SECTION).getContent();
- assertThat(table.keySet()).contains(cols);
- }
- }
- } else {
- fail("Expected CompositeResult Returned Result Type " + cmdResult.getType());
- }
- }
-
- private Properties locatorProperties() {
- int jmxPort = AvailablePortHelper.getRandomAvailableTCPPort();
- Properties props = new Properties();
- props.setProperty(MCAST_PORT, "0");
- props.setProperty(LOG_LEVEL, "fine");
- props.setProperty(SERIALIZABLE_OBJECT_FILTER, SERIALIZATION_FILTER);
- props.setProperty(ConfigurationProperties.JMX_MANAGER_HOSTNAME_FOR_CLIENTS, "localhost");
- props.setProperty(ConfigurationProperties.JMX_MANAGER_PORT, "" + jmxPort);
-
- return props;
- }
-
- private Properties serverProperties() {
- Properties props = new Properties();
- props.setProperty(SERIALIZABLE_OBJECT_FILTER, SERIALIZATION_FILTER);
-
- return props;
- }
-
- public static class shouldFailSerializationFilter extends Value1 {
- private Value1 value1 = null;
-
- public shouldFailSerializationFilter(int i) {
- super(i);
- }
-
- public Value1 getValue1() {
- return value1;
- }
-
- public void setValue1(Value1 value1) {
- this.value1 = value1;
- }
- }
+public class QueryCommandDUnitTest extends QueryCommandDUnitTestBase {
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandDistributedTest.java
index e12d1b5..c224dd5 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandDistributedTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandDistributedTest.java
@@ -14,88 +14,5 @@
*/
package org.apache.geode.management.internal.cli.commands;
-
-import static org.apache.geode.test.junit.rules.GfshCommandRule.PortType.jmxManager;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-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.test.dunit.rules.ClusterStartupRule;
-import org.apache.geode.test.dunit.rules.MemberVM;
-import org.apache.geode.test.junit.rules.GfshCommandRule;
-
-@SuppressWarnings("serial")
-public class RebalanceCommandDistributedTest {
-
- @ClassRule
- public static ClusterStartupRule cluster = new ClusterStartupRule();
-
- @ClassRule
- public static GfshCommandRule gfsh = new GfshCommandRule();
-
- protected static MemberVM locator, server1, server2;
-
- @BeforeClass
- public static void beforeClass() {
- locator = cluster.startLocatorVM(0, l -> l.withHttpService());
-
- int locatorPort = locator.getPort();
- server1 = cluster.startServerVM(1, "localhost", locatorPort);
- server2 = cluster.startServerVM(2, "localhost", locatorPort);
-
- setUpRegions();
- }
-
- @Before
- public void before() throws Exception {
- gfsh.connect(locator.getJmxPort(), jmxManager);
- }
-
- @Test
- public void testSimulateForEntireDSWithTimeout() {
- // check if DistributedRegionMXBean is available so that command will not fail
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers("/region-1", 2);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers("/region-2", 1);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers("/region-3", 1);
-
- String command = "rebalance --simulate=true --time-out=-1";
-
- gfsh.executeAndAssertThat(command).statusIsSuccess();
- }
-
- private static void setUpRegions() {
- server1.invoke(() -> {
- Cache cache = ClusterStartupRule.getCache();
- RegionFactory<Integer, Integer> dataRegionFactory =
- cache.createRegionFactory(RegionShortcut.PARTITION);
- Region region = dataRegionFactory.create("region-1");
- for (int i = 0; i < 10; i++) {
- region.put("key" + (i + 200), "value" + (i + 200));
- }
- region = dataRegionFactory.create("region-2");
- for (int i = 0; i < 100; i++) {
- region.put("key" + (i + 200), "value" + (i + 200));
- }
- });
- server2.invoke(() -> {
- // no need to close cache as it will be closed as part of teardown2
- Cache cache = ClusterStartupRule.getCache();
- RegionFactory<Integer, Integer> dataRegionFactory =
- cache.createRegionFactory(RegionShortcut.PARTITION);
- Region region = dataRegionFactory.create("region-1");
- for (int i = 0; i < 100; i++) {
- region.put("key" + (i + 400), "value" + (i + 400));
- }
- region = dataRegionFactory.create("region-3");
- for (int i = 0; i < 10; i++) {
- region.put("key" + (i + 200), "value" + (i + 200));
- }
- });
- }
+public class RebalanceCommandDistributedTest extends RebalanceCommandDistributedTestBase {
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RegionMembershipMBeanDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RegionMembershipMBeanDUnitTest.java
index b3a8595..dd7f2a9 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RegionMembershipMBeanDUnitTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RegionMembershipMBeanDUnitTest.java
@@ -14,372 +14,5 @@
*/
package org.apache.geode.management.internal.cli.commands;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
-import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
-import static org.apache.geode.distributed.ConfigurationProperties.NAME;
-import static org.apache.geode.distributed.ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER;
-import static org.apache.geode.test.junit.rules.GfshCommandRule.PortType.jmxManager;
-import static org.assertj.core.api.Java6Assertions.assertThat;
-
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-import org.awaitility.Awaitility;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.PartitionAttributes;
-import org.apache.geode.cache.PartitionAttributesFactory;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionFactory;
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.distributed.ConfigurationProperties;
-import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.internal.AvailablePortHelper;
-import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.management.DistributedRegionMXBean;
-import org.apache.geode.management.ManagementService;
-import org.apache.geode.management.internal.cli.CliUtil;
-import org.apache.geode.test.dunit.rules.ClusterStartupRule;
-import org.apache.geode.test.dunit.rules.MemberVM;
-import org.apache.geode.test.junit.rules.GfshCommandRule;
-
-@SuppressWarnings("serial")
-public class RegionMembershipMBeanDUnitTest {
- private static final String DATA_REGION_NAME = "GemfireDataCommandsTestRegion";
- private static final String DATA_REGION_NAME_VM1 = "GemfireDataCommandsTestRegion_Vm1";
- private static final String DATA_REGION_NAME_VM2 = "GemfireDataCommandsTestRegion_Vm2";
- private static final String DATA_REGION_NAME_PATH = "/GemfireDataCommandsTestRegion";
- private static final String DATA_REGION_NAME_VM1_PATH = "/GemfireDataCommandsTestRegion_Vm1";
- private static final String DATA_REGION_NAME_VM2_PATH = "/GemfireDataCommandsTestRegion_Vm2";
-
- private static final String DATA_PAR_REGION_NAME = "GemfireDataCommandsTestParRegion";
- private static final String DATA_PAR_REGION_NAME_VM1 = "GemfireDataCommandsTestParRegion_Vm1";
- private static final String DATA_PAR_REGION_NAME_VM2 = "GemfireDataCommandsTestParRegion_Vm2";
- private static final String DATA_PAR_REGION_NAME_PATH = "/GemfireDataCommandsTestParRegion";
- private static final String DATA_PAR_REGION_NAME_VM1_PATH =
- "/GemfireDataCommandsTestParRegion_Vm1";
- private static final String DATA_PAR_REGION_NAME_VM2_PATH =
- "/GemfireDataCommandsTestParRegion_Vm2";
- private static final String DATA_REGION_NAME_CHILD_1 = "ChildRegionRegion1";
- private static final String DATA_REGION_NAME_CHILD_1_PATH =
- "/GemfireDataCommandsTestRegion/ChildRegionRegion1";
- private static final String DATA_REGION_NAME_CHILD_1_2 = "ChildRegionRegion12";
- private static final String DATA_REGION_NAME_CHILD_1_2_PATH =
- "/GemfireDataCommandsTestRegion/ChildRegionRegion1/ChildRegionRegion12";
-
- private static final String SERIALIZATION_FILTER =
- "org.apache.geode.management.internal.cli.**";
-
- @Rule
- public GfshCommandRule gfsh = new GfshCommandRule();
-
- @Rule
- public ClusterStartupRule cluster = new ClusterStartupRule();
-
- protected MemberVM locator, server1, server2;
-
- @Before
- public void before() throws Exception {
- Properties props = locatorProperties();
- props.setProperty(SERIALIZABLE_OBJECT_FILTER, SERIALIZATION_FILTER);
- props.setProperty(NAME, "locator");
-
- Properties serverProps = new Properties();
- serverProps.setProperty(SERIALIZABLE_OBJECT_FILTER, SERIALIZATION_FILTER);
- locator = cluster.startLocatorVM(0, l -> l.withHttpService().withProperties(props));
- server1 = cluster.startServerVM(1, serverProps, locator.getPort());
- server2 = cluster.startServerVM(2, serverProps, locator.getPort());
-
- connectToLocator();
- }
-
- // extracted in order to override in RegionMembershipMBeanOverHttpDUnitTest to use http connection
- public void connectToLocator() throws Exception {
- gfsh.connectAndVerify(locator.getJmxPort(), jmxManager);
- }
-
- private static void setupDataRegionAndSubregions() {
- InternalCache cache = ClusterStartupRule.getCache();
- RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE);
-
- Region dataRegion = regionFactory.create(DATA_REGION_NAME);
- assertThat(dataRegion).isNotNull();
-
- Region dataSubRegion = regionFactory.createSubregion(dataRegion, DATA_REGION_NAME_CHILD_1);
- assertThat(dataSubRegion).isNotNull();
-
- dataSubRegion = regionFactory.createSubregion(dataSubRegion, DATA_REGION_NAME_CHILD_1_2);
- assertThat(dataSubRegion).isNotNull();
- assertThat(dataRegion).isNotNull();
- }
-
- private static void setupReplicatedRegion(String regionName) {
- InternalCache cache = ClusterStartupRule.getCache();
- RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE);
-
- Region dataRegion = regionFactory.create(regionName);
- assertThat(dataRegion).isNotNull();
- assertThat(dataRegion.getFullPath()).contains(regionName);
- }
-
- private static void setupPartitionedRegion(String regionName) {
- InternalCache cache = ClusterStartupRule.getCache();
- PartitionAttributes partitionAttrs =
- new PartitionAttributesFactory().setRedundantCopies(2).create();
- RegionFactory<Object, Object> partitionRegionFactory =
- cache.createRegionFactory(RegionShortcut.PARTITION);
-
- partitionRegionFactory.setPartitionAttributes(partitionAttrs);
- Region dataParRegion = partitionRegionFactory.create(regionName);
-
- assertThat(dataParRegion).isNotNull();
- assertThat(dataParRegion.getFullPath()).contains(regionName);
- }
-
- @Test
- public void testReplicatedRegionOnOneMember() {
- server1.invoke(() -> setupReplicatedRegion(DATA_REGION_NAME));
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_PATH, 1);
-
- Integer memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_PATH);
- Integer memSizeFromFunctionCall =
- distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_PATH);
- assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean).isEqualTo(1);
- }
-
- @Test
- public void testMultipleReplicatedRegionsAndSubregions() {
- server1.invoke(() -> setupDataRegionAndSubregions());
- server1.invoke(() -> setupReplicatedRegion(DATA_REGION_NAME_VM1));
-
- server2.invoke(() -> setupDataRegionAndSubregions());
- server2.invoke(() -> setupReplicatedRegion(DATA_REGION_NAME_VM2));
-
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_PATH, 2);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_CHILD_1_PATH, 2);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_CHILD_1_2_PATH, 2);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_VM1_PATH, 1);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_VM2_PATH, 1);
-
- Integer memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_PATH);
- Integer memSizeFromFunctionCall =
- distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_PATH);
- assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean);
-
- memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_CHILD_1_PATH);
- memSizeFromFunctionCall =
- distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_CHILD_1_PATH);
- assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean);
-
- memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_CHILD_1_2_PATH);
- memSizeFromFunctionCall =
- distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_CHILD_1_2_PATH);
- assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean);
-
- memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_VM1_PATH);
- memSizeFromFunctionCall = distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_VM1_PATH);
- assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean);
-
- memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_VM2_PATH);
- memSizeFromFunctionCall = distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_VM2_PATH);
- assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean);
- }
-
- @Test
- public void testAddRmNewMemberWithReplicatedRegionsAndSubregions() {
- server1.invoke(() -> setupDataRegionAndSubregions());
- server2.invoke(() -> setupDataRegionAndSubregions());
-
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_PATH, 2);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_CHILD_1_PATH, 2);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_CHILD_1_2_PATH, 2);
-
- Integer initialMemberSizeFromMBean =
- distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_PATH);
- Integer initialMemberSizeFromFunction =
- distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_PATH);
- assertThat(initialMemberSizeFromFunction).isEqualTo(initialMemberSizeFromMBean);
-
- Integer initialMemberSizeChild1FromMBean =
- distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_CHILD_1_PATH);
- Integer initialMemberSizeChild1FromFunction =
- distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_CHILD_1_PATH);
- assertThat(initialMemberSizeChild1FromFunction).isEqualTo(initialMemberSizeChild1FromMBean);
-
- Integer initialMemberSizeChild2FromMBean =
- distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_CHILD_1_2_PATH);
- Integer initialMemberSizeChild2FromFunction =
- distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_CHILD_1_2_PATH);
- assertThat(initialMemberSizeChild2FromFunction).isEqualTo(initialMemberSizeChild2FromMBean);
-
- MemberVM server3 = cluster.startServerVM(3, locator.getPort());
- server3.invoke(() -> setupDataRegionAndSubregions());
-
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_PATH, 3);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_CHILD_1_PATH, 3);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_CHILD_1_2_PATH, 3);
-
- Integer intermediateMemberSizeFromMBean =
- distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_PATH);
- Integer intermediateMemberSizeFromFunction =
- distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_PATH);
- assertThat(intermediateMemberSizeFromFunction).isEqualTo(intermediateMemberSizeFromMBean)
- .isEqualTo(initialMemberSizeFromFunction + 1);
-
- Integer intermediateMemberSizeChild1FromMBean =
- distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_CHILD_1_PATH);
- Integer intermediateMemberSizeChild1FromFunction =
- distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_CHILD_1_PATH);
- assertThat(intermediateMemberSizeChild1FromMBean)
- .isEqualTo(intermediateMemberSizeChild1FromFunction)
- .isEqualTo(initialMemberSizeChild1FromFunction + 1);
-
- Integer intermediateMemberSizeChild2FromMBean =
- distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_CHILD_1_2_PATH);
- Integer intermediateMemberSizeChild2FromFunction =
- distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_CHILD_1_2_PATH);
- assertThat(intermediateMemberSizeChild2FromFunction)
- .isEqualTo(intermediateMemberSizeChild2FromMBean)
- .isEqualTo(initialMemberSizeChild2FromMBean + 1);
-
- server3.stop(Boolean.TRUE);
-
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_PATH, 2);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_CHILD_1_PATH, 2);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_CHILD_1_2_PATH, 2);
-
- Integer finalMemberSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_PATH);
- Integer finalMemberSizeFromFunction =
- distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_PATH);
- assertThat(finalMemberSizeFromFunction).isEqualTo(finalMemberSizeFromMBean)
- .isEqualTo(initialMemberSizeFromFunction);
-
- Integer finalMemberSizeChild1FromMBean =
- distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_CHILD_1_PATH);
- Integer finalMemberSizeChild1FromFunction =
- distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_CHILD_1_PATH);
- assertThat(finalMemberSizeChild1FromMBean).isEqualTo(finalMemberSizeChild1FromFunction)
- .isEqualTo(initialMemberSizeChild1FromFunction);
-
- Integer finalMemberSizeChild2FromMBean =
- distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_CHILD_1_2_PATH);
- Integer finalMemberSizeChild2FromFunction =
- distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_CHILD_1_2_PATH);
- assertThat(finalMemberSizeChild2FromFunction).isEqualTo(finalMemberSizeChild2FromMBean)
- .isEqualTo(initialMemberSizeChild2FromMBean);
- }
-
- @Test
- public void testPartitionedRegionOnOneMember() {
- server1.invoke(() -> setupPartitionedRegion(DATA_PAR_REGION_NAME));
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_PAR_REGION_NAME_PATH, 1);
-
- Integer memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_PAR_REGION_NAME_PATH);
- Integer memSizeFromFunctionCall =
- distributedRegionMembersSizeFromFunction(DATA_PAR_REGION_NAME_PATH);
- assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean).isEqualTo(1);
- }
-
- @Test
- public void testMultiplePartitionedRegions() {
- server1.invoke(() -> setupPartitionedRegion(DATA_PAR_REGION_NAME));
- server1.invoke(() -> setupReplicatedRegion(DATA_PAR_REGION_NAME_VM1));
-
- server2.invoke(() -> setupPartitionedRegion(DATA_PAR_REGION_NAME));
- server2.invoke(() -> setupReplicatedRegion(DATA_PAR_REGION_NAME_VM2));
-
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_PAR_REGION_NAME_PATH, 2);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_PAR_REGION_NAME_VM1_PATH, 1);
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_PAR_REGION_NAME_VM2_PATH, 1);
-
- Integer memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_PAR_REGION_NAME_PATH);
- Integer memSizeFromFunctionCall =
- distributedRegionMembersSizeFromFunction(DATA_PAR_REGION_NAME_PATH);
- assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean);
-
- memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_PAR_REGION_NAME_VM1_PATH);
- memSizeFromFunctionCall =
- distributedRegionMembersSizeFromFunction(DATA_PAR_REGION_NAME_VM1_PATH);
- assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean);
-
- memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_PAR_REGION_NAME_VM2_PATH);
- memSizeFromFunctionCall =
- distributedRegionMembersSizeFromFunction(DATA_PAR_REGION_NAME_VM2_PATH);
- assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean);
- }
-
- @Test
- public void testAddRmNewMemberWithPartitionedRegions() {
- server1.invoke(() -> setupPartitionedRegion(DATA_PAR_REGION_NAME));
- server2.invoke(() -> setupPartitionedRegion(DATA_PAR_REGION_NAME));
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_PAR_REGION_NAME_PATH, 2);
-
- Integer initialMemberSizeFromMBean =
- distributedRegionMembersSizeFromMBean(DATA_PAR_REGION_NAME_PATH);
- Integer initialMemberSizeFromFunctionCall =
- distributedRegionMembersSizeFromFunction(DATA_PAR_REGION_NAME_PATH);
- assertThat(initialMemberSizeFromFunctionCall).isEqualTo(initialMemberSizeFromMBean);
-
- MemberVM server3 = cluster.startServerVM(3, locator.getPort());
- server3.invoke(() -> setupPartitionedRegion(DATA_PAR_REGION_NAME));
- locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_PAR_REGION_NAME_PATH, 3);
-
- Integer intermediateMemberSizeFromMBean =
- distributedRegionMembersSizeFromMBean(DATA_PAR_REGION_NAME_PATH);
- Integer intermediateMemberSizeFromFunctionCall =
- distributedRegionMembersSizeFromFunction(DATA_PAR_REGION_NAME_PATH);
- assertThat(intermediateMemberSizeFromFunctionCall).isEqualTo(intermediateMemberSizeFromMBean)
- .isEqualTo(initialMemberSizeFromMBean + 1);
-
- server3.stop(Boolean.TRUE);
-
- Integer finalMemberSizeFromMBean =
- distributedRegionMembersSizeFromMBean(DATA_PAR_REGION_NAME_PATH);
- Integer finalMemberSizeFromFunctionCall =
- distributedRegionMembersSizeFromFunction(DATA_PAR_REGION_NAME_PATH);
- assertThat(finalMemberSizeFromFunctionCall).isEqualTo(finalMemberSizeFromMBean)
- .isEqualTo(initialMemberSizeFromFunctionCall);
- }
-
- private Integer distributedRegionMembersSizeFromFunction(String regionName) {
- return locator.invoke(() -> {
- InternalCache cache = ClusterStartupRule.getCache();
- Set<DistributedMember> distributedMembers =
- CliUtil.getRegionAssociatedMembers(regionName, cache, true);
-
- return distributedMembers.size();
- });
- }
-
- private Integer distributedRegionMembersSizeFromMBean(String regionPath) {
- return locator.invoke(() -> {
- Cache cache = ClusterStartupRule.getCache();
-
- Awaitility.waitAtMost(20, TimeUnit.SECONDS).until(() -> {
- DistributedRegionMXBean bean = ManagementService.getManagementService(cache)
- .getDistributedRegionMXBean(regionPath);
- assertThat(bean).isNotNull();
- });
-
- DistributedRegionMXBean bean = ManagementService.getManagementService(cache)
- .getDistributedRegionMXBean(regionPath);
- String[] membersName = bean.getMembers();
- return membersName.length;
- });
- }
-
- private Properties locatorProperties() {
- int jmxPort = AvailablePortHelper.getRandomAvailableTCPPort();
- Properties props = new Properties();
- props.setProperty(MCAST_PORT, "0");
- props.setProperty(LOG_LEVEL, "fine");
- props.setProperty(ConfigurationProperties.JMX_MANAGER_HOSTNAME_FOR_CLIENTS, "localhost");
- props.setProperty(ConfigurationProperties.JMX_MANAGER_PORT, "" + jmxPort);
-
- return props;
- }
+public class RegionMembershipMBeanDUnitTest extends RegionMembershipMBeanDUnitTestBase {
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShowLogCommandDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShowLogCommandDUnitTest.java
index 7e73f2d..93496c3 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShowLogCommandDUnitTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShowLogCommandDUnitTest.java
@@ -14,154 +14,5 @@
*/
package org.apache.geode.management.internal.cli.commands;
-import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
-import static org.apache.geode.distributed.ConfigurationProperties.NAME;
-import static org.apache.geode.test.junit.rules.GfshCommandRule.PortType.jmxManager;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.Serializable;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-
-import org.awaitility.Awaitility;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.CliUtil;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.test.dunit.rules.ClusterStartupRule;
-import org.apache.geode.test.dunit.rules.MemberVM;
-import org.apache.geode.test.junit.rules.GfshCommandRule;
-
-
-public class ShowLogCommandDUnitTest implements Serializable {
- private static final String MANAGER_NAME = "Manager";
- private static final String SERVER1_NAME = "Server1";
- private static final String SERVER2_NAME = "Server2";
- private static final String GROUP0 = "Group0";
- private static final String GROUP1 = "Group1";
- private static final String GROUP2 = "Group2";
- private static final String MESSAGE_ON_MANAGER = "someLogMessageOnManager";
- private static final String MESSAGE_ON_SERVER1 = "someLogMessageOnServer1";
- private static final String MESSAGE_ON_SERVER2 = "someLogMessageOnServer2";
- protected static MemberVM locator;
- private static MemberVM server1;
- private static MemberVM server2;
- @ClassRule
- public static ClusterStartupRule clusterStartupRule = new ClusterStartupRule();
-
- @ClassRule
- public static GfshCommandRule gfsh = new GfshCommandRule();
-
- @BeforeClass
- public static void setup() throws Exception {
- Properties managerProps = new Properties();
- managerProps.setProperty(NAME, MANAGER_NAME);
- managerProps.setProperty(GROUPS, GROUP0);
- managerProps.setProperty(LOG_FILE, MANAGER_NAME + ".log");
- managerProps.setProperty(LOG_LEVEL, "info");
-
- locator =
- clusterStartupRule.startLocatorVM(0, l -> l.withHttpService().withProperties(managerProps));
-
- Properties server1Props = new Properties();
- server1Props.setProperty(NAME, SERVER1_NAME);
- server1Props.setProperty(GROUPS, GROUP1);
- server1Props.setProperty(LOG_FILE, SERVER1_NAME + ".log");
- managerProps.setProperty(LOG_LEVEL, "info");
-
- server1 = clusterStartupRule.startServerVM(1, server1Props, locator.getPort());
-
- Properties server2Props = new Properties();
- server2Props.setProperty(NAME, SERVER2_NAME);
- server2Props.setProperty(GROUPS, GROUP2);
- server2Props.setProperty(LOG_FILE, SERVER2_NAME + ".log");
- managerProps.setProperty(LOG_LEVEL, "info");
-
- server2 = clusterStartupRule.startServerVM(2, server2Props, locator.getPort());
- }
-
- @Before
- public void before() throws Exception {
- gfsh.connectAndVerify(locator.getJmxPort(), jmxManager);
-
- Awaitility.await().atMost(2, TimeUnit.MINUTES)
- .until(ShowLogCommandDUnitTest::allMembersAreConnected);
- }
-
- @After
- public void after() throws Exception {
- gfsh.disconnect();
- }
-
- private void writeLogMessages() {
- locator.invoke(() -> LogService.getLogger().info(MESSAGE_ON_MANAGER));
- server1.invoke(() -> LogService.getLogger().info(MESSAGE_ON_SERVER1));
- server2.invoke(() -> LogService.getLogger().info(MESSAGE_ON_SERVER2));
-
- }
-
- @Test
- public void testShowLogDefault() {
- writeLogMessages();
- String command = "show log --member=" + MANAGER_NAME;
-
- gfsh.executeAndAssertThat(command).statusIsSuccess();
- assertThat(gfsh.getGfshOutput()).contains(MESSAGE_ON_MANAGER);
- assertThat(gfsh.getGfshOutput()).doesNotContain(MESSAGE_ON_SERVER1);
- assertThat(gfsh.getGfshOutput()).doesNotContain(MESSAGE_ON_SERVER2);
- }
-
- @Test
- public void testShowLogNumLines() throws InterruptedException {
- writeLogMessages();
-
- String command = "show log --member=" + SERVER1_NAME + " --lines=50";
-
- gfsh.executeAndAssertThat(command).statusIsSuccess();
-
- String output = gfsh.getGfshOutput();
- assertThat(output).contains(MESSAGE_ON_SERVER1);
- assertThat(gfsh.getGfshOutput()).doesNotContain(MESSAGE_ON_MANAGER);
- assertThat(gfsh.getGfshOutput()).doesNotContain(MESSAGE_ON_SERVER2);
-
- assertThat(output.split(System.getProperty("line.separator"))).hasSize(51);
- }
-
- @Test
- public void testShowLogInvalidMember() throws Exception {
- writeLogMessages();
-
- String command = "show log --member=NotAValidMember";
-
- CommandResult result = gfsh.executeCommand(command);
- assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
-
- String output = gfsh.getGfshOutput();
- assertThat(output).contains("Member NotAValidMember could not be found");
- }
-
- protected static boolean allMembersAreConnected() {
- return locator.getVM().invoke(() -> {
- DistributedMember server1 =
- CliUtil.getDistributedMemberByNameOrId(SERVER1_NAME, ClusterStartupRule.getCache());
- DistributedMember server2 =
- CliUtil.getDistributedMemberByNameOrId(SERVER2_NAME, ClusterStartupRule.getCache());
-
- ShowLogCommand showLogCommand = new ShowLogCommand();
- showLogCommand.setCache(ClusterStartupRule.getCache());
-
- boolean server1isConnected = showLogCommand.getMemberMxBean(server1) != null;
- boolean server2isConnected = showLogCommand.getMemberMxBean(server2) != null;
- return server1isConnected && server2isConnected;
- });
- }
+public class ShowLogCommandDUnitTest extends ShowLogCommandDUnitTestBase {
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandDUnitTest.java
index abe17c5..ba2e8b1 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandDUnitTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandDUnitTest.java
@@ -14,87 +14,5 @@
*/
package org.apache.geode.management.internal.cli.commands;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.TimeUnit;
-
-import org.awaitility.Awaitility;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheClosedException;
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.test.dunit.SerializableCallableIF;
-import org.apache.geode.test.dunit.rules.ClusterStartupRule;
-import org.apache.geode.test.dunit.rules.MemberVM;
-import org.apache.geode.test.junit.rules.GfshCommandRule;
-
-
-
-public class ShutdownCommandDUnitTest {
-
- private MemberVM locator;
- private MemberVM server1;
- private MemberVM server2;
-
- @Rule
- public ClusterStartupRule clusterStartupRule = new ClusterStartupRule();
-
- @Rule
- public GfshCommandRule gfsh = new GfshCommandRule();
-
-
- @Before
- public void setup() throws Exception {
- locator = clusterStartupRule.startLocatorVM(0, l -> l.withHttpService());
- server1 = clusterStartupRule.startServerVM(1, locator.getPort());
- server2 = clusterStartupRule.startServerVM(2, locator.getPort());
- connect(locator);
- }
-
- void connect(MemberVM locator) throws Exception {
- gfsh.connectAndVerify(locator);
- }
-
- @Test
- public void testShutdownServers() {
- String command = "shutdown";
-
- gfsh.executeAndAssertThat(command).statusIsSuccess().containsOutput("Shutdown is triggered");
- verifyShutDown(server1, server2);
-
- // Make sure the locator is still running
- gfsh.executeAndAssertThat("list members").statusIsSuccess();
- assertThat(gfsh.getGfshOutput()).contains("locator-0");
- }
-
- @Test
- public void testShutdownAll() {
- String command = "shutdown --include-locators=true";
-
- gfsh.executeAndAssertThat(command).statusIsSuccess().containsOutput("Shutdown is triggered");
- verifyShutDown(server1, server2, locator);
- }
-
- private void verifyShutDown(MemberVM... members) {
- SerializableCallableIF<Boolean> isCacheOpenInThisVM = () -> {
- boolean cacheExists;
- try {
- Cache cacheInstance = CacheFactory.getAnyInstance();
- cacheExists = cacheInstance.getDistributedSystem().isConnected();
- } catch (CacheClosedException e) {
- cacheExists = false;
- }
- return cacheExists;
- };
-
- for (MemberVM member : members) {
- Callable<Boolean> isMemberShutDown = () -> !member.getVM().invoke(isCacheOpenInThisVM);
-
- Awaitility.await().atMost(2, TimeUnit.MINUTES).until(isMemberShutDown);
- }
- }
+public class ShutdownCommandDUnitTest extends ShutdownCommandDUnitTestBase {
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/IndexCommandsIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/IndexCommandsIntegrationTest.java
index 0bd0cb3..598841f 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/IndexCommandsIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/IndexCommandsIntegrationTest.java
@@ -14,306 +14,5 @@
*/
package org.apache.geode.management.internal.cli.commands;
-import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.DataPolicy;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionFactory;
-import org.apache.geode.cache.query.Index;
-import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.domain.Stock;
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.management.internal.cli.result.model.ResultModel;
-import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
-import org.apache.geode.test.junit.categories.GfshTest;
-import org.apache.geode.test.junit.rules.GfshCommandRule;
-import org.apache.geode.test.junit.rules.Server;
-import org.apache.geode.test.junit.rules.ServerStarterRule;
-
-/**
- * this test class test: CreateIndexCommand, DestroyIndexCommand, ListIndexCommand
- */
-@Category({GfshTest.class})
-public class IndexCommandsIntegrationTest {
- private static final String regionName = "regionA";
- private static final String groupName = "groupA";
- private static final String indexName = "indexA";
-
-
- @ClassRule
- public static ServerStarterRule server =
- new ServerStarterRule().withProperty(GROUPS, groupName).withJMXManager().withHttpService()
- .withAutoStart();
-
- @BeforeClass
- public static void beforeClass() throws Exception {
- InternalCache cache = server.getCache();
- Region region = createPartitionedRegion(regionName, cache, String.class, Stock.class);
- region.put("VMW", new Stock("VMW", 98));
- region.put("APPL", new Stock("APPL", 600));
- }
-
- @Rule
- public GfshCommandRule gfsh = new GfshCommandRule();
-
- @Before
- public void before() throws Exception {
- connect(server);
- }
-
- @After
- public void after() throws Exception {
- // destroy all existing indexes
- Collection<Index> indices = server.getCache().getQueryService().getIndexes();
- indices.stream().map(Index::getName).forEach(indexName -> {
- gfsh.executeAndAssertThat("destroy index --name=" + indexName).statusIsSuccess();
- });
-
- gfsh.executeAndAssertThat("list index").statusIsSuccess();
- assertThat(gfsh.getGfshOutput()).contains("No Indexes Found");
- }
-
- public void connect(Server server) throws Exception {
- gfsh.connectAndVerify(server.getJmxPort(), GfshCommandRule.PortType.jmxManager);
- }
-
- @Test
- public void testCreate() throws Exception {
- createSimpleIndexA();
- }
-
- @Test
- public void testCreateIndexWithMultipleIterators() throws Exception {
- CommandStringBuilder createStringBuilder = new CommandStringBuilder(CliStrings.CREATE_INDEX);
- createStringBuilder.addOption(CliStrings.CREATE_INDEX__NAME, "indexA");
- createStringBuilder.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "\"h.low\"");
- createStringBuilder.addOption(CliStrings.CREATE_INDEX__REGION,
- "\"/" + regionName + " s, s.history h\"");
-
- gfsh.executeAndAssertThat(createStringBuilder.toString()).statusIsSuccess();
- assertThat(gfsh.getGfshOutput()).contains("Index successfully created");
-
- gfsh.executeAndAssertThat("list index").statusIsSuccess();
- assertThat(gfsh.getGfshOutput()).contains("indexA");
- }
-
- @Test
- public void testListIndexValidField() throws Exception {
- CommandStringBuilder createStringBuilder = new CommandStringBuilder(CliStrings.CREATE_INDEX);
- createStringBuilder.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
- createStringBuilder.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "\"h.low\"");
- createStringBuilder.addOption(CliStrings.CREATE_INDEX__REGION,
- "\"/" + regionName + " s, s.history h\"");
-
- gfsh.executeAndAssertThat(createStringBuilder.toString()).statusIsSuccess();
- assertThat(gfsh.getGfshOutput()).contains("Index successfully created");
-
- gfsh.executeAndAssertThat("list index").statusIsSuccess();
- assertThat(gfsh.getGfshOutput()).contains("indexA");
- }
-
- @Test
- public void testCannotCreateIndexWithExistingIndexName() throws Exception {
- createSimpleIndexA();
-
- // CREATE the same index
- CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
- csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
- csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
- csb.addOption(CliStrings.CREATE_INDEX__REGION, "/" + regionName);
- csb.addOption(CliStrings.CREATE_INDEX__TYPE, "hash");
-
- CommandResult result = gfsh.executeCommand(csb.toString());
- assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
- }
-
- @Test
- public void creatIndexWithNoBeginningSlash() throws Exception {
- CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
- csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
- csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
- csb.addOption(CliStrings.CREATE_INDEX__REGION, regionName);
- gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
- assertThat(gfsh.getGfshOutput()).contains("Index successfully created");
-
- gfsh.executeAndAssertThat("list index").statusIsSuccess();
- assertThat(gfsh.getGfshOutput()).contains("indexA");
- }
-
- @Test
- public void testCannotCreateIndexInIncorrectRegion() throws Exception {
- // Create index on a wrong regionPath
- CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
- csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
- csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
- csb.addOption(CliStrings.CREATE_INDEX__REGION, "/InvalidRegionName");
- csb.addOption(CliStrings.CREATE_INDEX__TYPE, "hash");
-
- CommandResult result = gfsh.executeCommand(csb.toString());
- assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
- assertThat(gfsh.getGfshOutput()).contains("Region not found : \"/InvalidRegionName\"");
- }
-
- @Test
- public void cannotCreateWithTheSameName() throws Exception {
- createSimpleIndexA();
- gfsh.executeAndAssertThat("create index --name=indexA --expression=key --region=/regionA")
- .statusIsError()
- .containsOutput("Index \"indexA\" already exists. Create failed due to duplicate name");
- }
-
- @Test
- public void testCannotCreateIndexWithInvalidIndexExpression() throws Exception {
- // Create index with wrong expression
- CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
- csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
- csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "InvalidExpressionOption");
- csb.addOption(CliStrings.CREATE_INDEX__REGION, "/" + regionName);
- csb.addOption(CliStrings.CREATE_INDEX__TYPE, "hash");
-
- CommandResult result = gfsh.executeCommand(csb.toString());
- assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
- }
-
- @Test
- public void testCannotDestroyIndexWithInvalidIndexName() throws Exception {
- // Destroy index with incorrect indexName
- CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
- csb.addOption(CliStrings.DESTROY_INDEX__NAME, "IncorrectIndexName");
- CommandResult result = gfsh.executeCommand(csb.toString());
- assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
- assertThat(gfsh.getGfshOutput()).contains(
- CliStrings.format(CliStrings.DESTROY_INDEX__INDEX__NOT__FOUND, "IncorrectIndexName"));
- }
-
- @Test
- public void testCannotDestroyIndexWithInvalidRegion() throws Exception {
- // Destroy index with incorrect region
- CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
- csb.addOption(CliStrings.DESTROY_INDEX__NAME, indexName);
- csb.addOption(CliStrings.DESTROY_INDEX__REGION, "IncorrectRegion");
- CommandResult result = gfsh.executeCommand(csb.toString());
- assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
- assertThat(gfsh.getGfshOutput()).contains("ERROR", "Region \"IncorrectRegion\" not found");
- }
-
- @Test
- public void testCannotDestroyIndexWithInvalidMember() throws Exception {
- // Destroy index with incorrect member name
- CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
- csb.addOption(CliStrings.DESTROY_INDEX__NAME, indexName);
- csb.addOption(CliStrings.DESTROY_INDEX__REGION, "Region");
- csb.addOption(CliStrings.MEMBER, "InvalidMemberName");
- CommandResult result = gfsh.executeCommand(csb.toString());
- assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
- assertThat(gfsh.getGfshOutput()).contains("No Members Found");
- }
-
- @Test
- public void testCannotDestroyIndexWithNoOptions() throws Exception {
- // Destroy index with no option
- CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
- CommandResult result = gfsh.executeCommand(csb.toString());
- assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
- assertThat(gfsh.getGfshOutput()).contains("requires that one or more parameters be provided.");
- }
-
- @Test
- public void testDestroyIndexViaRegion() throws Exception {
- createSimpleIndexA();
-
- CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
- csb.addOption(CliStrings.DESTROY_INDEX__REGION, regionName);
- gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
- .containsOutput("Destroyed all indexes on region regionA");
- }
-
- @Test
- public void testDestroyIndexViaGroup() throws Exception {
- createSimpleIndexA();
-
- CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
- csb.addOption(CliStrings.GROUP, groupName);
- gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
- .containsOutput("Destroyed all indexes");
- }
-
- @Test
- public void testFailWhenDestroyIndexIsNotIdempotent() throws Exception {
- createSimpleIndexA();
-
- CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
- csb.addOption(CliStrings.DESTROY_INDEX__NAME, indexName);
- csb.addOption(CliStrings.IFEXISTS, "false");
- gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
- .containsOutput("Destroyed index " + indexName);
- gfsh.executeAndAssertThat(csb.toString()).statusIsError()
- .containsOutput("Index named \"" + indexName + "\" not found");
- }
-
- @Test
- public void testDestroyIndexOnRegionIsIdempotent() throws Exception {
- createSimpleIndexA();
-
- CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
- csb.addOption(CliStrings.DESTROY_INDEX__REGION, regionName);
- csb.addOption(CliStrings.IFEXISTS, "true");
- gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
- .containsOutput("Destroyed all indexes on region regionA");
- gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
- .containsOutput("Destroyed all indexes on region regionA");
- }
-
- @Test
- public void testDestroyIndexByNameIsIdempotent() throws Exception {
- createSimpleIndexA();
-
- CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
- csb.addOption(CliStrings.DESTROY_INDEX__NAME, indexName);
- csb.addOption(CliStrings.IFEXISTS);
- gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
- .containsOutput("Destroyed index " + indexName);
- CommandResult result = gfsh.executeCommand(csb.toString());
- assertThat(result.getStatus()).isEqualTo(Result.Status.OK);
-
- Map<String, List<String>> table =
- result.getMapFromTableContent(ResultModel.MEMBER_STATUS_SECTION);
- assertThat(table.get("Status")).containsExactly("IGNORED");
- assertThat(table.get("Message")).containsExactly("Index named \"" + indexName + "\" not found");
- }
-
- private void createSimpleIndexA() throws Exception {
- CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
- csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
- csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
- csb.addOption(CliStrings.CREATE_INDEX__REGION, "/" + regionName);
- gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
- .containsOutput("Index successfully created");
- }
-
- private static Region<?, ?> createPartitionedRegion(String regionName, Cache cache,
- Class keyConstraint, Class valueConstraint) {
- RegionFactory regionFactory = cache.createRegionFactory();
- regionFactory.setDataPolicy(DataPolicy.PARTITION);
- regionFactory.setKeyConstraint(keyConstraint);
- regionFactory.setValueConstraint(valueConstraint);
- return regionFactory.create(regionName);
- }
-
+public class IndexCommandsIntegrationTest extends IndexCommandsIntegrationTestBase {
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandIntegrationTest.java
index 726fa8e..e4b6490 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandIntegrationTest.java
@@ -14,272 +14,5 @@
*/
package org.apache.geode.management.internal.cli.commands;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.File;
-import java.io.Serializable;
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import com.google.common.io.Files;
-import org.apache.commons.io.FileUtils;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TemporaryFolder;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.domain.DataCommandResult;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.management.internal.cli.shell.Gfsh;
-import org.apache.geode.test.junit.categories.GfshTest;
-import org.apache.geode.test.junit.rules.GfshCommandRule;
-import org.apache.geode.test.junit.rules.Server;
-import org.apache.geode.test.junit.rules.ServerStarterRule;
-
-@Category({GfshTest.class})
-public class QueryCommandIntegrationTest {
-
- private final String DEFAULT_FETCH_SIZE = String.valueOf(Gfsh.DEFAULT_APP_FETCH_SIZE);
-
- @ClassRule
- public static ServerStarterRule server =
- new ServerStarterRule().withJMXManager()
- .withHttpService()
- .withRegion(RegionShortcut.REPLICATE, "simpleRegion")
- .withRegion(RegionShortcut.REPLICATE, "complexRegion");
-
- @Rule
- public GfshCommandRule gfsh = new GfshCommandRule();
-
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
-
- @BeforeClass
- public static void populateRegions() {
- Cache cache = server.getCache();
- Region<String, String> simpleRegion = cache.getRegion("simpleRegion");
- Region<String, Customer> complexRegion = cache.getRegion("complexRegion");
-
- for (int i = 0; i < Gfsh.DEFAULT_APP_FETCH_SIZE + 1; i++) {
- String key = "key" + i;
-
- simpleRegion.put(key, "value" + i);
- complexRegion.put(key, new Customer("name" + i, "Main Street " + i, "Hometown"));
- }
- }
-
- @Before
- public void before() throws Exception {
- connect(server);
- }
-
- protected void connect(Server server) throws Exception {
- gfsh.connectAndVerify(server.getJmxPort(), GfshCommandRule.PortType.jmxManager);
- }
-
- @Test
- public void doesShowLimitIfLimitNotInQuery() throws Exception {
- gfsh.executeAndAssertThat("query --query='select * from /simpleRegion'")
- .containsKeyValuePair("Rows", DEFAULT_FETCH_SIZE)
- .containsKeyValuePair("Limit", DEFAULT_FETCH_SIZE).hasResult();
- }
-
- @Test
- public void doesNotShowLimitIfLimitInQuery() throws Exception {
- gfsh.executeAndAssertThat("query --query='select * from /simpleRegion limit 50'")
- .containsKeyValuePair("Rows", "50").doesNotContainOutput("Limit").hasResult();
- }
-
- @Test
- public void invalidQueryShouldNotCreateFile() throws Exception {
- File outputFile = temporaryFolder.newFile("queryOutput.txt");
- FileUtils.deleteQuietly(outputFile);
-
- gfsh.executeAndAssertThat(
- "query --query='invalid query' --file=" + outputFile.getAbsolutePath()).hasNoResult()
- .doesNotContainOutput("Query results output to");
-
- assertThat(outputFile).doesNotExist();
- }
-
- @Test
- public void queryWithInvalidRegionNameDoesNotCreateFile() throws Exception {
- File outputFile = temporaryFolder.newFile("queryOutput.txt");
- FileUtils.deleteQuietly(outputFile);
-
- gfsh.executeAndAssertThat(
- "query --query='select * from /nonExistentRegion' --file=" + outputFile.getAbsolutePath())
- .hasNoResult().doesNotContainOutput("Query results output to");
-
- assertThat(outputFile).doesNotExist();
- }
-
- @Test
- public void outputToFileStillDisplaysResultMetaData() throws Exception {
- File outputFile = temporaryFolder.newFile("queryOutput.txt");
- FileUtils.deleteQuietly(outputFile);
-
- gfsh.executeAndAssertThat(
- "query --query='select * from /simpleRegion' --file=" + outputFile.getAbsolutePath())
- .hasResult().containsOutput("Rows").containsOutput("Limit")
- .containsOutput("Query results output to");
- }
-
- @Test
- public void doesNotOverwriteExistingFile() throws Exception {
- File outputFile = temporaryFolder.newFile("queryOutput.txt");
- assertThat(outputFile).exists();
-
- gfsh.executeAndAssertThat(
- "query --query='select * from /simpleRegion' --file=" + outputFile.getAbsolutePath())
- .statusIsError().containsOutput("The specified output file already exists.");
- }
-
- @Test
- public void canOutputSimpleRegionToFile() throws Exception {
- File outputFile = temporaryFolder.newFile("queryOutput.txt");
- FileUtils.deleteQuietly(outputFile);
-
- CommandResult result = gfsh.executeCommand(
- "query --query='select * from /simpleRegion' --file=" + outputFile.getAbsolutePath());
- assertThat(result.getStatus()).isEqualTo(Result.Status.OK);
- // .statusIsSuccess().containsOutput(outputFile.getAbsolutePath());
-
- assertThat(outputFile).exists();
-
- List<String> lines = Files.readLines(outputFile, StandardCharsets.UTF_8);
-
- assertThat(lines.get(4)).isEqualTo("Result");
- assertThat(lines.get(5)).isEqualTo("--------");
- lines.subList(6, lines.size()).forEach(line -> assertThat(line).matches("value\\d+"));
- }
-
- @Test
- public void canOutputComplexRegionToFile() throws Exception {
- File outputFile = temporaryFolder.newFile("queryOutput.txt");
- FileUtils.deleteQuietly(outputFile);
-
- gfsh.executeAndAssertThat(
- "query --query='select c.name, c.address from /complexRegion c' --file="
- + outputFile.getAbsolutePath())
- .statusIsSuccess().containsOutput(outputFile.getAbsolutePath());
-
- assertThat(outputFile).exists();
- List<String> lines = Files.readLines(outputFile, StandardCharsets.UTF_8);
-
- assertThat(lines.get(4)).containsPattern("name\\s+\\|\\s+address");
- lines.subList(6, lines.size())
- .forEach(line -> assertThat(line).matches("name\\d+.*\"city\":\"Hometown\".*"));
- }
-
- @Test
- public void outputDisplaysResultsFromComplexRegion() throws Exception {
- String result = gfsh.execute("query --query='select c.name, c.address from /complexRegion c'");
-
- String[] resultLines = splitOnLineBreaks(result);
-
- assertThat(resultLines[0]).containsPattern("Result\\s+:\\s+true");
- assertThat(resultLines[1]).containsPattern("Limit\\s+:\\s+100");
- assertThat(resultLines[2]).containsPattern("Rows\\s+:\\s+100");
- assertThat(resultLines[3]).containsPattern("name\\s+\\|\\s+address");
- Arrays.asList(resultLines).subList(5, resultLines.length)
- .forEach(line -> assertThat(line).matches("name\\d+.*\"city\":\"Hometown\".*"));
- }
-
- @Test
- public void queryWithGfshEnvVariables() {
- gfsh.executeAndAssertThat("set variable --name=DATA_REGION --value=/complexRegion")
- .statusIsSuccess();
- gfsh.executeAndAssertThat("set variable --name=QUERY_LIMIT --value=10").statusIsSuccess();
- CommandResult result = gfsh.executeCommand(
- "query --query='select c.name, c.address from ${DATA_REGION} c limit ${QUERY_LIMIT}'");
- Map<String, String> data = result.getMapFromSection(DataCommandResult.DATA_INFO_SECTION);
-
- assertThat(data.get("Rows")).isEqualTo("10");
- }
-
- @Test
- public void queryWithInvalidRegionNameGivesDescriptiveErrorMessage() throws Exception {
- gfsh.executeAndAssertThat("query --query='select * from /nonExistentRegion'")
- .containsKeyValuePair("Result", "false")
- .containsOutput("Cannot find regions <[/nonExistentRegion]> in any of the members");
- }
-
- @Test
- public void invalidQueryGivesDescriptiveErrorMessage() {
- CommandResult result = gfsh.executeCommand("query --query='this is not a valid query'");
-
- Map<String, String> data = result.getMapFromSection(DataCommandResult.DATA_INFO_SECTION);
- assertThat(data.get("Result")).isEqualTo("false");
- assertThat(data.get("Message"))
- .startsWith("Query is invalid due to error : <Syntax error in query:");
- }
-
- @Test
- public void queryGivesDescriptiveErrorMessageIfNoQueryIsSpecified() {
- gfsh.executeAndAssertThat("query").containsOutput(
- "You should specify option (--query, --file, --interactive) for this command");
- }
-
- @Test
- public void queryReturnsUndefinedQueryResult() {
- CommandResult result =
- gfsh.executeCommand("query --query='select c.unknown from /complexRegion c limit 10'");
-
- Map<String, List<String>> table =
- result.getMapFromTableContent(DataCommandResult.QUERY_SECTION);
- assertThat(table.get("Value").size()).isEqualTo(10);
- assertThat(table.get("Value").get(0)).isEqualTo("UNDEFINED");
- }
-
- @Test
- public void queryReturnsNonSelectResult() {
- CommandResult result = gfsh.executeCommand(
- "query --query=\"(select c.address from /complexRegion c where c.name = 'name1' limit 1).size\"");
-
- Map<String, String> data = result.getMapFromSection(DataCommandResult.DATA_INFO_SECTION);
- assertThat(data.get("Rows")).isEqualTo("1");
-
- Map<String, List<String>> table =
- result.getMapFromTableContent(DataCommandResult.QUERY_SECTION);
- assertThat(table.get("Result")).contains("1");
- }
-
- private String[] splitOnLineBreaks(String multilineString) {
- return multilineString.split("[\\r\\n]+");
- }
-
- public static class Customer implements Serializable {
- public String name;
- public Address address;
-
- public Customer(String name, String street, String city) {
- this.name = name;
- this.address = new Address(street, city);
- }
-
- public String toString() {
- return name + address;
- }
- }
-
- public static class Address implements Serializable {
- public String street;
- public String city;
-
- public Address(String street, String city) {
- this.street = street;
- this.city = city;
- }
- }
-
+public class QueryCommandIntegrationTest extends QueryCommandIntegrationTestBase {
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java b/geode-core/src/integrationTest/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
index 27d852a..0336b36 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
@@ -14,197 +14,5 @@
*/
package org.apache.geode.management.internal.security;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.List;
-
-import org.apache.shiro.authz.permission.WildcardPermission;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.management.internal.cli.result.ErrorResultData;
-import org.apache.geode.management.internal.cli.result.ResultBuilder;
-import org.apache.geode.security.SimpleTestSecurityManager;
-import org.apache.geode.test.junit.categories.SecurityTest;
-import org.apache.geode.test.junit.rules.ConnectionConfiguration;
-import org.apache.geode.test.junit.rules.GfshCommandRule;
-import org.apache.geode.test.junit.rules.ServerStarterRule;
-
-@Category({SecurityTest.class})
-public class GfshCommandsSecurityTest {
- @ClassRule
- public static ServerStarterRule serverStarter =
- new ServerStarterRule().withJMXManager().withHttpService()
- .withSecurityManager(SimpleTestSecurityManager.class)
- .withRegion(RegionShortcut.REPLICATE_PERSISTENT, "persistentRegion");
-
- @Rule
- public GfshCommandRule gfshConnection =
- new GfshCommandRule(serverStarter::getJmxPort, GfshCommandRule.PortType.jmxManager);
-
- @BeforeClass
- public static void beforeClass() throws Exception {
- serverStarter.getCache().createRegionFactory(RegionShortcut.REPLICATE).create("region1");
- }
-
- @Test
- @ConnectionConfiguration(user = "data", password = "wrongPwd")
- public void testInvalidCredentials() throws Exception {
- assertThat(gfshConnection.isConnected()).isFalse();
- }
-
- @Test
- @ConnectionConfiguration(user = "data", password = "data")
- public void testValidCredentials() throws Exception {
- assertThat(gfshConnection.isConnected()).isTrue();
- }
-
- @Test
- @ConnectionConfiguration(user = "clusterRead", password = "clusterRead")
- public void testClusterReader() throws Exception {
- runCommandsPermittedAndForbiddenBy("CLUSTER:READ");
- }
-
- @Test
- @ConnectionConfiguration(user = "clusterWrite", password = "clusterWrite")
- public void testClusterWriter() throws Exception {
- runCommandsPermittedAndForbiddenBy("CLUSTER:WRITE");
- }
-
- @Test
- @ConnectionConfiguration(user = "clusterManage", password = "clusterManage")
- public void testClusterManager() throws Exception {
- runCommandsPermittedAndForbiddenBy("CLUSTER:MANAGE");
- }
-
- @Test
- @ConnectionConfiguration(user = "dataRead", password = "dataRead")
- public void testDataReader() throws Exception {
- runCommandsPermittedAndForbiddenBy("DATA:READ");
- }
-
- @Test
- @ConnectionConfiguration(user = "dataWrite", password = "dataWrite")
- public void testDataWriter() throws Exception {
- runCommandsPermittedAndForbiddenBy("DATA:WRITE");
- }
-
- @Test
- @ConnectionConfiguration(user = "dataManage", password = "dataManage")
- public void testDataManager() throws Exception {
- runCommandsPermittedAndForbiddenBy("DATA:MANAGE");
- }
-
- @Test
- @ConnectionConfiguration(user = "dataReadRegionA", password = "dataReadRegionA")
- public void testRegionAReader() throws Exception {
- runCommandsPermittedAndForbiddenBy("DATA:READ:RegionA");
- }
-
- @Test
- @ConnectionConfiguration(user = "dataWriteRegionA", password = "dataWriteRegionA")
- public void testRegionAWriter() throws Exception {
- runCommandsPermittedAndForbiddenBy("DATA:WRITE:RegionA");
- }
-
- @Test
- @ConnectionConfiguration(user = "dataManageRegionA", password = "dataManageRegionA")
- public void testRegionAManager() throws Exception {
- runCommandsPermittedAndForbiddenBy("DATA:MANAGE:RegionA");
- }
-
- @Test
- @ConnectionConfiguration(user = "data,cluster", password = "data,cluster")
- public void testRegionSuperUser() throws Exception {
- runCommandsPermittedAndForbiddenBy("*");
- }
-
- private void runCommandsPermittedAndForbiddenBy(String permission) throws Exception {
- List<TestCommand> allPermitted =
- TestCommand.getPermittedCommands(new WildcardPermission(permission, true));
-
- for (TestCommand permitted : allPermitted) {
- System.out.println("Processing authorized command: " + permitted.getCommand());
- CommandResult result = gfshConnection.executeCommand(permitted.getCommand());
- assertThat(result).isNotNull();
-
- // for permitted commands, if any error happens, it's not an Unauthorized error
- if (result.getStatus() == Result.Status.ERROR) {
- assertThat(result.getMessageFromContent()).doesNotContain("not authorized");
- }
- }
-
- // skip no permission commands
- List<TestCommand> others = TestCommand.getOnlineCommands();
- others.removeAll(allPermitted);
- for (TestCommand other : others) {
- System.out.println("Processing unauthorized command: " + other.getCommand());
- CommandResult result = gfshConnection.executeCommand(other.getCommand());
- int errorCode = ((ErrorResultData) result.getResultData()).getErrorCode();
-
- // for some commands there are pre execution checks to check for user input error, will skip
- // those commands
- if (errorCode == ResultBuilder.ERRORCODE_USER_ERROR) {
- LogService.getLogger().info("Skip user error: " + result.getMessageFromContent());
- continue;
- }
-
- assertThat(((ErrorResultData) result.getResultData()).getErrorCode())
- .describedAs(other.getCommand()).isEqualTo(ResultBuilder.ERRORCODE_UNAUTHORIZED);
- }
- }
-
- @Test
- @ConnectionConfiguration(user = "data", password = "data")
- public void testGetPostProcess() throws Exception {
- gfshConnection.executeCommand("put --region=region1 --key=key2 --value=value2");
- gfshConnection.executeCommand("put --region=region1 --key=key2 --value=value2");
- gfshConnection.executeCommand("put --region=region1 --key=key3 --value=value3");
-
- // gfsh.executeCommand("get --region=region1 --key=key1");
- gfshConnection.executeCommand("query --query=\"select * from /region1\"");
- }
-
- @Test
- @ConnectionConfiguration(user = "data", password = "data")
- public void createDiskStore() throws Exception {
- CommandResult result =
- gfshConnection.executeCommand("create disk-store --name=disk1 --dir=disk1");
-
- assertThat(result.getMessageFromContent()).contains("not authorized for CLUSTER:MANAGE:DISK");
- }
-
- @Test
- @ConnectionConfiguration(user = "dataManage,clusterWriteDisk",
- password = "dataManage,clusterWriteDisk")
- public void createPartitionedPersistentRegionWithCorrectPermissions() throws Exception {
- gfshConnection.executeAndAssertThat("create region --name=region2 --type=PARTITION_PERSISTENT")
- .statusIsSuccess();
- }
-
- @Test
- @ConnectionConfiguration(user = "dataManage", password = "dataManage")
- public void createPartitionedPersistentRegionWithoutClusterWriteDisk() throws Exception {
- CommandResult result =
- gfshConnection.executeCommand("create region --name=region2 --type=PARTITION_PERSISTENT");
-
- assertThat(result.getMessageFromContent()).contains("not authorized for CLUSTER:WRITE:DISK");
- }
-
- @Test
- @ConnectionConfiguration(user = "clusterWriteDisk", password = "clusterWriteDisk")
- public void createPartitionedPersistentRegionWithoutDataManage() throws Exception {
- CommandResult result =
- gfshConnection.executeCommand("create region --name=region2 --type=PARTITION_PERSISTENT");
-
- assertThat(result.getMessageFromContent()).contains("not authorized for DATA:MANAGE");
- }
-
+public class GfshCommandsSecurityTest extends GfshCommandsSecurityTestBase {
}
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/functions/TestFunction.java b/geode-dunit/src/main/java/org/apache/geode/internal/cache/functions/TestFunction.java
similarity index 100%
rename from geode-core/src/distributedTest/java/org/apache/geode/internal/cache/functions/TestFunction.java
rename to geode-dunit/src/main/java/org/apache/geode/internal/cache/functions/TestFunction.java
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandDUnitTest.java b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandDUnitTestBase.java
similarity index 98%
copy from geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandDUnitTest.java
copy to geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandDUnitTestBase.java
index f832eb7..27d98bd 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandDUnitTest.java
+++ b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandDUnitTestBase.java
@@ -31,8 +31,7 @@ import org.apache.geode.test.dunit.rules.MemberVM;
import org.apache.geode.test.junit.rules.GfshCommandRule;
-
-public class ChangeLogLevelCommandDUnitTest {
+public class ChangeLogLevelCommandDUnitTestBase {
private static final String MANAGER_NAME = "Manager";
private static final String SERVER1_NAME = "Server1";
private static final String SERVER2_NAME = "Server2";
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTestBase.java
similarity index 98%
copy from geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
copy to geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTestBase.java
index d953b4e..9381903 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
+++ b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTestBase.java
@@ -67,7 +67,7 @@ import org.apache.geode.test.junit.rules.GfshCommandRule;
import org.apache.geode.test.junit.rules.Member;
@Category({LoggingTest.class})
-public class ExportLogsDUnitTest {
+public class ExportLogsDUnitTestBase {
private static final String ERROR_LOG_PREFIX = "[IGNORE]";
@Rule
@@ -247,9 +247,9 @@ public class ExportLogsDUnitTest {
verifyZipFileContents(acceptedLogLevels);
// Ensure export logs region gets cleaned up
- server1.invoke(ExportLogsDUnitTest::verifyExportLogsRegionWasDestroyed);
- server2.invoke(ExportLogsDUnitTest::verifyExportLogsRegionWasDestroyed);
- locator.invoke(ExportLogsDUnitTest::verifyExportLogsRegionWasDestroyed);
+ server1.invoke(ExportLogsDUnitTestBase::verifyExportLogsRegionWasDestroyed);
+ server2.invoke(ExportLogsDUnitTestBase::verifyExportLogsRegionWasDestroyed);
+ locator.invoke(ExportLogsDUnitTestBase::verifyExportLogsRegionWasDestroyed);
}
@Test
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTest.java b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTestBase.java
similarity index 99%
copy from geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTest.java
copy to geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTestBase.java
index e58f29c..17c1092 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTest.java
+++ b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTestBase.java
@@ -49,7 +49,7 @@ import org.apache.geode.test.junit.categories.LoggingTest;
import org.apache.geode.test.junit.rules.GfshCommandRule;
@Category({LoggingTest.class})
-public class ExportLogsStatsDUnitTest {
+public class ExportLogsStatsDUnitTestBase {
@ClassRule
public static ClusterStartupRule lsRule = new ClusterStartupRule().withLogFile();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTest.java b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTestBase.java
similarity index 99%
copy from geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTest.java
copy to geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTestBase.java
index 456220a..2154211 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTest.java
+++ b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTestBase.java
@@ -44,7 +44,7 @@ import org.apache.geode.test.dunit.rules.MemberVM;
import org.apache.geode.test.junit.rules.GfshCommandRule;
-public class FunctionCommandsDUnitTest {
+public class FunctionCommandsDUnitTestBase {
private static MemberVM locator;
private static MemberVM server1;
private static MemberVM server2;
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GcCommandDUnitTest.java b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/GcCommandDUnitTestBase.java
similarity index 99%
copy from geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GcCommandDUnitTest.java
copy to geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/GcCommandDUnitTestBase.java
index f1c7d83..1e0926b 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GcCommandDUnitTest.java
+++ b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/GcCommandDUnitTestBase.java
@@ -35,7 +35,7 @@ import org.apache.geode.test.dunit.rules.MemberVM;
import org.apache.geode.test.junit.rules.GfshCommandRule;
-public class GcCommandDUnitTest {
+public class GcCommandDUnitTestBase {
private static final String MANAGER_NAME = "Manager";
private static final String SERVER1_NAME = "Server1";
private static final String SERVER2_NAME = "Server2";
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GemfireDataCommandsDUnitTest.java b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/GemfireDataCommandsDUnitTestBase.java
similarity index 99%
copy from geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GemfireDataCommandsDUnitTest.java
copy to geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/GemfireDataCommandsDUnitTestBase.java
index 7ce158c..deec94c 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GemfireDataCommandsDUnitTest.java
+++ b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/GemfireDataCommandsDUnitTestBase.java
@@ -57,7 +57,7 @@ import org.apache.geode.test.junit.rules.GfshCommandRule;
* Dunit class for testing gemfire data commands : get, put, remove
*/
@SuppressWarnings("serial")
-public class GemfireDataCommandsDUnitTest {
+public class GemfireDataCommandsDUnitTestBase {
private static final String DATA_REGION_NAME = "GemfireDataCommandsTestRegion";
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/IndexCommandsIntegrationTest.java b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommandsIntegrationTestBase.java
similarity index 99%
copy from geode-core/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/IndexCommandsIntegrationTest.java
copy to geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommandsIntegrationTestBase.java
index 0bd0cb3..7e75687 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/IndexCommandsIntegrationTest.java
+++ b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommandsIntegrationTestBase.java
@@ -50,7 +50,7 @@ import org.apache.geode.test.junit.rules.ServerStarterRule;
* this test class test: CreateIndexCommand, DestroyIndexCommand, ListIndexCommand
*/
@Category({GfshTest.class})
-public class IndexCommandsIntegrationTest {
+public class IndexCommandsIntegrationTestBase {
private static final String regionName = "regionA";
private static final String groupName = "groupA";
private static final String indexName = "indexA";
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTest.java b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTestBase.java
similarity index 98%
copy from geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTest.java
copy to geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTestBase.java
index fb6702a..adce231 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTest.java
+++ b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTestBase.java
@@ -32,7 +32,7 @@ import org.apache.geode.test.junit.categories.OQLIndexTest;
import org.apache.geode.test.junit.rules.GfshCommandRule;
@Category({OQLIndexTest.class})
-public class ListIndexCommandDUnitTest {
+public class ListIndexCommandDUnitTestBase {
private static final String REGION_1 = "REGION1";
private static final String INDEX_REGION_NAME = "/REGION1";
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTest.java b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTestBase.java
similarity index 99%
copy from geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTest.java
copy to geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTestBase.java
index 660c385..a8e4565 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTest.java
+++ b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTestBase.java
@@ -59,7 +59,7 @@ import org.apache.geode.test.dunit.rules.MemberVM;
import org.apache.geode.test.junit.rules.GfshCommandRule;
@SuppressWarnings("serial")
-public class QueryCommandDUnitTest {
+public class QueryCommandDUnitTestBase {
private static final String DATA_REGION_NAME = "GemfireDataCommandsTestRegion";
private static final String DATA_REGION_NAME_PATH = "/" + DATA_REGION_NAME;
private static final String DATA_REGION_WITH_EVICTION_NAME =
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandIntegrationTest.java b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/QueryCommandIntegrationTestBase.java
similarity index 99%
copy from geode-core/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandIntegrationTest.java
copy to geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/QueryCommandIntegrationTestBase.java
index 726fa8e..78d3bc3 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandIntegrationTest.java
+++ b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/QueryCommandIntegrationTestBase.java
@@ -46,7 +46,7 @@ import org.apache.geode.test.junit.rules.Server;
import org.apache.geode.test.junit.rules.ServerStarterRule;
@Category({GfshTest.class})
-public class QueryCommandIntegrationTest {
+public class QueryCommandIntegrationTestBase {
private final String DEFAULT_FETCH_SIZE = String.valueOf(Gfsh.DEFAULT_APP_FETCH_SIZE);
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandDistributedTest.java b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandDistributedTestBase.java
similarity index 98%
copy from geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandDistributedTest.java
copy to geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandDistributedTestBase.java
index e12d1b5..186b515 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandDistributedTest.java
+++ b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandDistributedTestBase.java
@@ -31,7 +31,7 @@ import org.apache.geode.test.dunit.rules.MemberVM;
import org.apache.geode.test.junit.rules.GfshCommandRule;
@SuppressWarnings("serial")
-public class RebalanceCommandDistributedTest {
+public class RebalanceCommandDistributedTestBase {
@ClassRule
public static ClusterStartupRule cluster = new ClusterStartupRule();
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RegionMembershipMBeanDUnitTest.java b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/RegionMembershipMBeanDUnitTestBase.java
similarity index 99%
copy from geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RegionMembershipMBeanDUnitTest.java
copy to geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/RegionMembershipMBeanDUnitTestBase.java
index b3a8595..d1da832 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RegionMembershipMBeanDUnitTest.java
+++ b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/RegionMembershipMBeanDUnitTestBase.java
@@ -48,7 +48,7 @@ import org.apache.geode.test.dunit.rules.MemberVM;
import org.apache.geode.test.junit.rules.GfshCommandRule;
@SuppressWarnings("serial")
-public class RegionMembershipMBeanDUnitTest {
+public class RegionMembershipMBeanDUnitTestBase {
private static final String DATA_REGION_NAME = "GemfireDataCommandsTestRegion";
private static final String DATA_REGION_NAME_VM1 = "GemfireDataCommandsTestRegion_Vm1";
private static final String DATA_REGION_NAME_VM2 = "GemfireDataCommandsTestRegion_Vm2";
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShowLogCommandDUnitTest.java b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/ShowLogCommandDUnitTestBase.java
similarity index 97%
copy from geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShowLogCommandDUnitTest.java
copy to geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/ShowLogCommandDUnitTestBase.java
index 7e73f2d..7445ff3 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShowLogCommandDUnitTest.java
+++ b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/ShowLogCommandDUnitTestBase.java
@@ -42,7 +42,7 @@ import org.apache.geode.test.dunit.rules.MemberVM;
import org.apache.geode.test.junit.rules.GfshCommandRule;
-public class ShowLogCommandDUnitTest implements Serializable {
+public class ShowLogCommandDUnitTestBase implements Serializable {
private static final String MANAGER_NAME = "Manager";
private static final String SERVER1_NAME = "Server1";
private static final String SERVER2_NAME = "Server2";
@@ -94,7 +94,7 @@ public class ShowLogCommandDUnitTest implements Serializable {
gfsh.connectAndVerify(locator.getJmxPort(), jmxManager);
Awaitility.await().atMost(2, TimeUnit.MINUTES)
- .until(ShowLogCommandDUnitTest::allMembersAreConnected);
+ .until(ShowLogCommandDUnitTestBase::allMembersAreConnected);
}
@After
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandDUnitTest.java b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandDUnitTestBase.java
similarity index 98%
copy from geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandDUnitTest.java
copy to geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandDUnitTestBase.java
index abe17c5..8b8ad9a 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandDUnitTest.java
+++ b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandDUnitTestBase.java
@@ -33,8 +33,7 @@ import org.apache.geode.test.dunit.rules.MemberVM;
import org.apache.geode.test.junit.rules.GfshCommandRule;
-
-public class ShutdownCommandDUnitTest {
+public class ShutdownCommandDUnitTestBase {
private MemberVM locator;
private MemberVM server1;
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java b/geode-dunit/src/main/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTestBase.java
similarity index 99%
copy from geode-core/src/integrationTest/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
copy to geode-dunit/src/main/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTestBase.java
index 27d852a..cc112ad 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
+++ b/geode-dunit/src/main/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTestBase.java
@@ -38,7 +38,7 @@ import org.apache.geode.test.junit.rules.GfshCommandRule;
import org.apache.geode.test.junit.rules.ServerStarterRule;
@Category({SecurityTest.class})
-public class GfshCommandsSecurityTest {
+public class GfshCommandsSecurityTestBase {
@ClassRule
public static ServerStarterRule serverStarter =
new ServerStarterRule().withJMXManager().withHttpService()
diff --git a/geode-web/build.gradle b/geode-web/build.gradle
index 3935613..93d2861 100755
--- a/geode-web/build.gradle
+++ b/geode-web/build.gradle
@@ -52,8 +52,7 @@ dependencies {
integrationTestCompile project(":geode-dunit")
- // TODO remove dependency on sources from other test modules
- integrationTestCompile files(project(':geode-core').sourceSets.integrationTest.output)
+ integrationTestCompile project(':geode-web/geode-web-test')
integrationTestRuntime files(war.destinationDir)
integrationTestRuntime ('org.springframework:spring-webmvc:' + project.'springframework.version') {
@@ -63,8 +62,7 @@ dependencies {
distributedTestCompile 'pl.pragmatists:JUnitParams:' + project.'JUnitParams.version'
- // TODO remove dependency on sources from other test modules
- distributedTestCompile files(project(':geode-core').sourceSets.distributedTest.output)
+ distributedTestCompile project(':geode-web/geode-web-test')
distributedTestRuntime files(war.destinationDir)
distributedTestRuntime ('org.springframework:spring-webmvc:' + project.'springframework.version') {
diff --git a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandOverHttpDUnitTest.java b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandOverHttpDUnitTest.java
index 99fd27b..c9ea7a4 100644
--- a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandOverHttpDUnitTest.java
+++ b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandOverHttpDUnitTest.java
@@ -16,7 +16,7 @@ package org.apache.geode.management.internal.cli.commands;
import static org.apache.geode.test.junit.rules.GfshCommandRule.PortType.http;
-public class ChangeLogLevelCommandOverHttpDUnitTest extends ChangeLogLevelCommandDUnitTest {
+public class ChangeLogLevelCommandOverHttpDUnitTest extends ChangeLogLevelCommandDUnitTestBase {
@Override
public void before() throws Exception {
gfsh.connect(locator.getHttpPort(), http);
diff --git a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDistributedTest.java b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDistributedTest.java
index 9325819..6096781 100644
--- a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDistributedTest.java
+++ b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDistributedTest.java
@@ -23,7 +23,7 @@ import org.apache.geode.test.junit.categories.GfshTest;
import org.apache.geode.test.junit.rules.GfshCommandRule;
@Category({GfshTest.class})
-public class ExportLogsOverHttpDistributedTest extends ExportLogsDUnitTest {
+public class ExportLogsOverHttpDistributedTest extends ExportLogsDUnitTestBase {
@Override
public void connect() throws Exception {
diff --git a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsOverHttpDUnitTest.java b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsOverHttpDUnitTest.java
index c6a1a4e..3aa3b20 100644
--- a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsOverHttpDUnitTest.java
+++ b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsOverHttpDUnitTest.java
@@ -33,7 +33,7 @@ import org.apache.geode.test.junit.categories.GfshTest;
import org.apache.geode.test.junit.rules.GfshCommandRule;
@Category({GfshTest.class})
-public class ExportLogsStatsOverHttpDUnitTest extends ExportLogsStatsDUnitTest {
+public class ExportLogsStatsOverHttpDUnitTest extends ExportLogsStatsDUnitTestBase {
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
diff --git a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsOverHttpDUnitTest.java b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsOverHttpDUnitTest.java
index abadadb..1b86b37 100644
--- a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsOverHttpDUnitTest.java
+++ b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsOverHttpDUnitTest.java
@@ -21,7 +21,7 @@ import org.apache.geode.test.junit.categories.GfshTest;
import org.apache.geode.test.junit.rules.GfshCommandRule;
@Category({GfshTest.class})
-public class FunctionCommandsOverHttpDUnitTest extends FunctionCommandsDUnitTest {
+public class FunctionCommandsOverHttpDUnitTest extends FunctionCommandsDUnitTestBase {
@Override
public void connectGfsh() throws Exception {
gfsh.connectAndVerify(getLocator().getHttpPort(), GfshCommandRule.PortType.http);
diff --git a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GcCommandOverHttpDUnitTest.java b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GcCommandOverHttpDUnitTest.java
index 6055043..47d5f8f 100644
--- a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GcCommandOverHttpDUnitTest.java
+++ b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GcCommandOverHttpDUnitTest.java
@@ -16,7 +16,7 @@ package org.apache.geode.management.internal.cli.commands;
import org.apache.geode.test.junit.rules.GfshCommandRule;
-public class GcCommandOverHttpDUnitTest extends GcCommandDUnitTest {
+public class GcCommandOverHttpDUnitTest extends GcCommandDUnitTestBase {
@Override
public void before() throws Exception {
gfsh.connectAndVerify(locator.getHttpPort(), GfshCommandRule.PortType.http);
diff --git a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GemfireDataCommandsOverHttpDUnitTest.java b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GemfireDataCommandsOverHttpDUnitTest.java
index 3fbea74..a9af44c 100644
--- a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GemfireDataCommandsOverHttpDUnitTest.java
+++ b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/GemfireDataCommandsOverHttpDUnitTest.java
@@ -16,7 +16,7 @@ package org.apache.geode.management.internal.cli.commands;
import org.apache.geode.test.junit.rules.GfshCommandRule;
-public class GemfireDataCommandsOverHttpDUnitTest extends GemfireDataCommandsDUnitTest {
+public class GemfireDataCommandsOverHttpDUnitTest extends GemfireDataCommandsDUnitTestBase {
@Override
public void connectToLocator() throws Exception {
gfsh.connectAndVerify(locator.getHttpPort(), GfshCommandRule.PortType.http);
diff --git a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandOverHttpDUnitTest.java b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandOverHttpDUnitTest.java
index 2224020..38e8b11 100644
--- a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandOverHttpDUnitTest.java
+++ b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandOverHttpDUnitTest.java
@@ -22,7 +22,7 @@ import org.apache.geode.test.junit.categories.GfshTest;
import org.apache.geode.test.junit.rules.GfshCommandRule;
@Category({GfshTest.class})
-public class ListIndexCommandOverHttpDUnitTest extends ListIndexCommandDUnitTest {
+public class ListIndexCommandOverHttpDUnitTest extends ListIndexCommandDUnitTestBase {
@Override
public void connectGfsh(MemberVM vm) throws Exception {
gfsh.connectAndVerify(vm.getHttpPort(), GfshCommandRule.PortType.http);
diff --git a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandOverHttpDUnitTest.java b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandOverHttpDUnitTest.java
index feb799c..2c48983 100644
--- a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandOverHttpDUnitTest.java
+++ b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandOverHttpDUnitTest.java
@@ -17,7 +17,7 @@ package org.apache.geode.management.internal.cli.commands;
import org.apache.geode.test.junit.rules.GfshCommandRule;
-public class QueryCommandOverHttpDUnitTest extends QueryCommandDUnitTest {
+public class QueryCommandOverHttpDUnitTest extends QueryCommandDUnitTestBase {
@Override
public void connectToLocator() throws Exception {
gfsh.connectAndVerify(locator.getHttpPort(), GfshCommandRule.PortType.http);
diff --git a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandOverHttpDistributedTest.java b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandOverHttpDistributedTest.java
index e0228b8..a4acb20 100644
--- a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandOverHttpDistributedTest.java
+++ b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandOverHttpDistributedTest.java
@@ -16,7 +16,7 @@ package org.apache.geode.management.internal.cli.commands;
import static org.apache.geode.test.junit.rules.GfshCommandRule.PortType.http;
-public class RebalanceCommandOverHttpDistributedTest extends RebalanceCommandDistributedTest {
+public class RebalanceCommandOverHttpDistributedTest extends RebalanceCommandDistributedTestBase {
@Override
public void before() throws Exception {
gfsh.connectAndVerify(locator.getHttpPort(), http);
diff --git a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RegionMembershipMBeanOverHttpDUnitTest.java b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RegionMembershipMBeanOverHttpDUnitTest.java
index be0297e..e1698fd 100644
--- a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RegionMembershipMBeanOverHttpDUnitTest.java
+++ b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RegionMembershipMBeanOverHttpDUnitTest.java
@@ -16,7 +16,7 @@ package org.apache.geode.management.internal.cli.commands;
import org.apache.geode.test.junit.rules.GfshCommandRule;
-public class RegionMembershipMBeanOverHttpDUnitTest extends RegionMembershipMBeanDUnitTest {
+public class RegionMembershipMBeanOverHttpDUnitTest extends RegionMembershipMBeanDUnitTestBase {
@Override
public void connectToLocator() throws Exception {
gfsh.connectAndVerify(locator.getHttpPort(), GfshCommandRule.PortType.http);
diff --git a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShowLogComandOverHttpDUnitTest.java b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShowLogComandOverHttpDUnitTest.java
index 0d5d701..01c5cc1 100644
--- a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShowLogComandOverHttpDUnitTest.java
+++ b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShowLogComandOverHttpDUnitTest.java
@@ -20,12 +20,12 @@ import org.awaitility.Awaitility;
import org.apache.geode.test.junit.rules.GfshCommandRule;
-public class ShowLogComandOverHttpDUnitTest extends ShowLogCommandDUnitTest {
+public class ShowLogComandOverHttpDUnitTest extends ShowLogCommandDUnitTestBase {
@Override
public void before() throws Exception {
gfsh.connectAndVerify(locator.getHttpPort(), GfshCommandRule.PortType.http);
Awaitility.await().atMost(2, TimeUnit.MINUTES)
- .until(ShowLogCommandDUnitTest::allMembersAreConnected);
+ .until(ShowLogCommandDUnitTestBase::allMembersAreConnected);
}
}
diff --git a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandOverHttpDUnitTest.java b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandOverHttpDUnitTest.java
index 8f53349..1de0123 100644
--- a/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandOverHttpDUnitTest.java
+++ b/geode-web/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandOverHttpDUnitTest.java
@@ -21,7 +21,7 @@ import org.apache.geode.test.junit.categories.GfshTest;
import org.apache.geode.test.junit.rules.GfshCommandRule;
@Category({GfshTest.class})
-public class ShutdownCommandOverHttpDUnitTest extends ShutdownCommandDUnitTest {
+public class ShutdownCommandOverHttpDUnitTest extends ShutdownCommandDUnitTestBase {
@Override
void connect(MemberVM server) throws Exception {
diff --git a/geode-web/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/IndexCommandOverHttpTest.java b/geode-web/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/IndexCommandOverHttpTest.java
index f423e09..bcb35ea 100644
--- a/geode-web/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/IndexCommandOverHttpTest.java
+++ b/geode-web/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/IndexCommandOverHttpTest.java
@@ -22,7 +22,7 @@ import org.apache.geode.test.junit.rules.GfshCommandRule;
import org.apache.geode.test.junit.rules.Server;
@Category({GfshTest.class})
-public class IndexCommandOverHttpTest extends IndexCommandsIntegrationTest {
+public class IndexCommandOverHttpTest extends IndexCommandsIntegrationTestBase {
@Override
public void connect(Server server) throws Exception {
gfsh.connectAndVerify(server.getHttpPort(), GfshCommandRule.PortType.http);
diff --git a/geode-web/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandOverHttpTest.java b/geode-web/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandOverHttpTest.java
index 7afa3f6..846da9d 100644
--- a/geode-web/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandOverHttpTest.java
+++ b/geode-web/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/QueryCommandOverHttpTest.java
@@ -21,7 +21,7 @@ import org.apache.geode.test.junit.rules.GfshCommandRule;
import org.apache.geode.test.junit.rules.Server;
@Category({GfshTest.class})
-public class QueryCommandOverHttpTest extends QueryCommandIntegrationTest {
+public class QueryCommandOverHttpTest extends QueryCommandIntegrationTestBase {
@Override
protected void connect(Server server) throws Exception {
diff --git a/geode-web/src/integrationTest/java/org/apache/geode/management/internal/security/GfshCommandsOverHttpSecurityTest.java b/geode-web/src/integrationTest/java/org/apache/geode/management/internal/security/GfshCommandsOverHttpSecurityTest.java
index 88c9579..3c3acb8 100644
--- a/geode-web/src/integrationTest/java/org/apache/geode/management/internal/security/GfshCommandsOverHttpSecurityTest.java
+++ b/geode-web/src/integrationTest/java/org/apache/geode/management/internal/security/GfshCommandsOverHttpSecurityTest.java
@@ -21,7 +21,7 @@ import org.apache.geode.test.junit.categories.SecurityTest;
import org.apache.geode.test.junit.rules.GfshCommandRule;
@Category({SecurityTest.class})
-public class GfshCommandsOverHttpSecurityTest extends GfshCommandsSecurityTest {
+public class GfshCommandsOverHttpSecurityTest extends GfshCommandsSecurityTestBase {
public GfshCommandsOverHttpSecurityTest() {
gfshConnection = new GfshCommandRule(serverStarter::getHttpPort, GfshCommandRule.PortType.http);
}
diff --git a/settings.gradle b/settings.gradle
index b74da7f..711c165 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -23,6 +23,7 @@ include 'geode-junit'
include 'geode-dunit'
include 'geode-core'
include 'geode-web'
+include 'geode-web/geode-web-test'
include 'geode-web-api'
include 'geode-pulse'
include 'geode-assembly'