You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kh...@apache.org on 2017/10/04 22:05:25 UTC
[geode] branch develop updated (fe2e408 -> 22b02c7)
This is an automated email from the ASF dual-hosted git repository.
khowe pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git.
from fe2e408 GEODE-3703 Document JAR resource becomes DEPLOY (#860)
new 739e80d GEODE-3539: Enhanced test coverage for alter runtime command options
new 22b02c7 GEODE-3539: refactored to reduce code duplication
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../cli/commands/AlterRuntimeCommandDUnitTest.java | 1032 +++++++++++++++++---
1 file changed, 906 insertions(+), 126 deletions(-)
--
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <co...@geode.apache.org>'].
[geode] 01/02: GEODE-3539: Enhanced test coverage for alter runtime
command options
Posted by kh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
khowe pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
commit 739e80d63ced113eda504f2912b854c791a5aa02
Author: Ken Howe <kh...@pivotal.io>
AuthorDate: Tue Oct 3 14:24:11 2017 -0700
GEODE-3539: Enhanced test coverage for alter runtime command options
---
.../cli/commands/AlterRuntimeCommandDUnitTest.java | 1044 +++++++++++++++++---
1 file changed, 927 insertions(+), 117 deletions(-)
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRuntimeCommandDUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRuntimeCommandDUnitTest.java
index c408d3f..e6e178a 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRuntimeCommandDUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRuntimeCommandDUnitTest.java
@@ -23,6 +23,7 @@ import java.util.Properties;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
+import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -111,13 +112,622 @@ public class AlterRuntimeCommandDUnitTest {
@Test
@Parameters({"true", "false"})
- public void alterRuntimeConfig_logDiskSpaceLimitWithFileSizeLimitNotSet_OK(
+ public void alterLogDiskSpaceLimitWithFileSizeLimitNotSet_OK(final boolean connectOverHttp)
+ throws Exception {
+
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10");
+
+ gfsh.executeAndVerifyCommand(csb.toString());
+
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(10);
+ });
+ }
+ }
+
+ @Test
+ @Parameters({"true", "false"})
+ public void alterLogDiskSpaceLimitWithFileSizeLimitSet_OK(final boolean connectOverHttp)
+ throws Exception {
+
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ CommandStringBuilder csbSetFileSizeLimit =
+ new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csbSetFileSizeLimit.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT, "50");
+ gfsh.executeAndVerifyCommand(csbSetFileSizeLimit.toString());
+
+ server2.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(50);
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+
+ CommandStringBuilder csbSetDiskSpaceLimit =
+ new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csbSetDiskSpaceLimit.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10");
+
+ gfsh.executeAndVerifyCommand(csbSetDiskSpaceLimit.toString());
+
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(50);
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(10);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ });
+ }
+ }
+
+ @Test
+ @Parameters({"true", "false"})
+ public void alterLogDiskSpaceLimitOnMember_OK(final boolean connectOverHttp) throws Exception {
+
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.MEMBERS, server1.getName());
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10");
+
+ gfsh.executeAndVerifyCommand(csb.toString());
+
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ int expectedLimit;
+ if (server == server1) {
+ expectedLimit = 10;
+ } else {
+ expectedLimit = 0;
+ }
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(expectedLimit);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ });
+ }
+ }
+
+ @Test
+ @Parameters({"true", "false"})
+ public void alterLogDiskSpaceLimitOnGroup_OK(final boolean connectOverHttp) throws Exception {
+
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ props.setProperty(GROUPS, "G1");
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ final int TEST_LIMIT = 10;
+ final String TEST_GROUP = "G1";
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.GROUPS, TEST_GROUP);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT,
+ String.valueOf(TEST_LIMIT));
+
+ gfsh.executeAndVerifyCommand(csb.toString());
+
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ int expectedLimit;
+ String expectedGroup;
+ if (server == server2) {
+ expectedLimit = TEST_LIMIT;
+ expectedGroup = TEST_GROUP;
+ } else {
+ expectedLimit = 0;
+ expectedGroup = "";
+ }
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getGroups()).isEqualTo(expectedGroup);
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(expectedLimit);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ });
+ }
+ }
+
+ @Test
+ @Parameters({"true", "false"})
+ public void alterLogFileSizeLimit_changesConfigOnAllServers(final boolean connectOverHttp)
+ throws Exception {
+
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT, "11");
+
+ gfsh.executeAndVerifyCommand(csb.toString());
+
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(11);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
+ }
+
+ @Test
+ @Parameters({"true", "false"})
+ public void alterLogFileSizeLimitNegative_errorCanNotSet(final boolean connectOverHttp)
+ throws Exception {
+ IgnoredException.addIgnoredException(
+ "java.lang.IllegalArgumentException: Could not set \"log-file-size-limit\"");
+
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT, "-1");
+
+ CommandResult result = gfsh.executeCommand(csb.toString());
+ assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
+ assertThat(gfsh.getGfshOutput()).contains("Could not set \"log-file-size-limit\" to \"-1\"");
+
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
+ }
+
+ @Test
+ @Parameters({"true", "false"})
+ public void alterLogFileSizeLimitTooBig_errorCanNotSet(final boolean connectOverHttp)
+ throws Exception {
+ IgnoredException.addIgnoredException(
+ "java.lang.IllegalArgumentException: Could not set \"log-file-size-limit\"");
+
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ props.setProperty(GROUPS, "G1");
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT, "1000001");
+ CommandStringBuilder csbGroup = new CommandStringBuilder(csb.toString());
+ csbGroup.addOption(GROUPS, "G1");
+
+ CommandResult result = gfsh.executeCommand(csb.toString());
+ assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
+ assertThat(gfsh.getGfshOutput())
+ .contains("Could not set \"log-file-size-limit\" to \"1,000,001\"");
+
+ csb.addOption(CliStrings.MEMBER, server2.getName());
+ result = gfsh.executeCommand(csb.toString());
+ assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
+ assertThat(gfsh.getGfshOutput())
+ .contains("Could not set \"log-file-size-limit\" to \"1,000,001\"");
+
+ result = gfsh.executeCommand(csbGroup.toString());
+ assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
+ assertThat(gfsh.getGfshOutput())
+ .contains("Could not set \"log-file-size-limit\" to \"1,000,001\"");
+
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
+ }
+
+ @Test
+ @Parameters({"true", "false"})
+ public void alterStatArchiveFile_updatesAllServerConfigs(final boolean connectOverHttp)
+ throws Exception {
+
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ final String TEST_NAME = "statisticsArchive";
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE, TEST_NAME);
+
+ CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo(TEST_NAME);
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
+ }
+
+ @Test
+ @Parameters({"true", "false"})
+ public void alterStatArchiveFileWithMember_updatesSelectedServerConfigs(
+ final boolean connectOverHttp) throws Exception {
+
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ final String TEST_NAME = "statisticsArchive";
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE, TEST_NAME);
+ csb.addOption(CliStrings.MEMBERS, server1.getName());
+
+ CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+
+ for (final MemberVM server : new MemberVM[] {server1, server2}) {
+ String expectedName;
+ if (server == server1) {
+ expectedName = TEST_NAME;
+ } else {
+ expectedName = "";
+ }
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo(expectedName);
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
+ }
+
+ @Test
+ @Parameters({"true", "false"})
+ public void alterStatArchiveFileWithGroup_updatesSelectedServerConfigs(
final boolean connectOverHttp) throws Exception {
Properties props = new Properties();
props.setProperty(LOG_LEVEL, "error");
MemberVM locator = startupRule.startLocatorVM(0, props);
MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ props.setProperty(GROUPS, "G1");
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ final String TEST_NAME = "statisticsArchive";
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE, TEST_NAME);
+ csb.addOption(CliStrings.GROUP, "G1");
+
+ CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ String expectedName;
+ if (server == server2) {
+ expectedName = TEST_NAME;
+ } else {
+ expectedName = "";
+ }
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo(expectedName);
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
+ }
+
+ @Test
+ @Parameters({"true", "false"})
+ public void alterStatSampleRate_updatesAllServerConfigs(final boolean connectOverHttp)
+ throws Exception {
+
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE, "2000");
+
+ CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(2000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
+ }
+
+ @Test
+ @Parameters({"true", "false"})
+ public void alterStatSampleRateWithMember_updatesSelectedServerConfigs(
+ final boolean connectOverHttp) throws Exception {
+
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ final int TEST_RATE = 2000;
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE,
+ String.valueOf(TEST_RATE));
+ csb.addOption(CliStrings.MEMBER, server1.getName());
+
+ CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+
+ for (final MemberVM server : new MemberVM[] {server1, server2}) {
+ int expectedSampleRate;
+ if (server == server1) {
+ expectedSampleRate = TEST_RATE;
+ } else {
+ expectedSampleRate = 1000;
+ }
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(expectedSampleRate);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
+ }
+
+ @Test
+ @Parameters({"true", "false"})
+ public void alterStatSampleRateWithGroup_updatesSelectedServerConfigs(
+ final boolean connectOverHttp) throws Exception {
+
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ props.setProperty(GROUPS, "G1");
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ final int TEST_RATE = 2500;
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE,
+ String.valueOf(TEST_RATE));
+ csb.addOption(CliStrings.GROUP, "G1");
+
+ CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ int expectedSampleRate;
+ if (server == server2) {
+ expectedSampleRate = TEST_RATE;
+ } else {
+ expectedSampleRate = 1000;
+ }
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(expectedSampleRate);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
+ }
+
+ @Test
+ @Parameters({"true", "false"})
+ public void alterStatisticSampleRateRangeIsEnforced(final boolean connectOverHttp)
+ throws Exception {
+ IgnoredException.addIgnoredException(
+ "java.lang.IllegalArgumentException: Could not set \"statistic-sample-rate");
+
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE, "99");
+
+ CommandResult result = gfsh.executeCommand(csb.toString());
+ assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
+ assertThat(gfsh.getGfshOutput()).contains("Could not set \"statistic-sample-rate\" to \"99\"");
+
+ csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE, "60001");
+
+ result = gfsh.executeCommand(csb.toString());
+ assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
+ assertThat(gfsh.getGfshOutput())
+ .contains("Could not set \"statistic-sample-rate\" to \"60,001\"");
+
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
+ }
+
+ @Test
+ @Parameters({"true", "false"})
+ public void alterArchiveDiskSpaceLimit_updatesAllServerConfigs(final boolean connectOverHttp)
+ throws Exception {
+
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
if (connectOverHttp) {
@@ -126,37 +736,31 @@ public class AlterRuntimeCommandDUnitTest {
gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
}
+ final int TEST_LIMIT = 10;
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
- csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10");
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT,
+ String.valueOf(TEST_LIMIT));
- gfsh.executeAndVerifyCommand(csb.toString());
- String resultStr = gfsh.getGfshOutput();
+ CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
- server1.invoke(() -> {
- InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
- DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
- assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
- assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
- assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
- assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
- assertThat(config.getStatisticSamplingEnabled()).isTrue();
- assertThat(config.getLogDiskSpaceLimit()).isEqualTo(10);
- });
- server2.invoke(() -> {
- InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
- DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
- assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
- assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
- assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
- assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
- assertThat(config.getStatisticSamplingEnabled()).isTrue();
- assertThat(config.getLogDiskSpaceLimit()).isEqualTo(10);
- });
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(TEST_LIMIT);
+ assertThat(config.getArchiveFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
}
@Test
@Parameters({"true", "false"})
- public void alterRuntimeConfig_logDiskSpaceLimitWithFileSizeLimitSet_OK(
+ public void alterArchiveDiskSpaceLimitWithMember_updatesSelectedServerConfigs(
final boolean connectOverHttp) throws Exception {
Properties props = new Properties();
@@ -171,52 +775,88 @@ public class AlterRuntimeCommandDUnitTest {
gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
}
- CommandStringBuilder csbSetFileSizeLimit =
- new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
- csbSetFileSizeLimit.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT, "50");
- gfsh.executeAndVerifyCommand(csbSetFileSizeLimit.toString());
+ final int TEST_LIMIT = 10;
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT,
+ String.valueOf(TEST_LIMIT));
+ csb.addOption(CliStrings.MEMBER, server1.getName());
- server2.invoke(() -> {
- InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
- DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
- assertThat(config.getLogFileSizeLimit()).isEqualTo(50);
- assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
- });
+ CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
- CommandStringBuilder csbSetDiskSpaceLimit =
- new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
- csbSetDiskSpaceLimit.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT, "50");
- csbSetDiskSpaceLimit.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10");
+ for (final MemberVM server : new MemberVM[] {server1, server2}) {
+ int expectedLimit;
+ if (server == server1) {
+ expectedLimit = TEST_LIMIT;
+ } else {
+ expectedLimit = 0;
+ }
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(expectedLimit);
+ assertThat(config.getArchiveFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
+ }
- gfsh.executeAndVerifyCommand(csbSetDiskSpaceLimit.toString());
- String resultStr = gfsh.getGfshOutput();
+ @Test
+ @Parameters({"true", "false"})
+ public void alterArchiveDiskSpaceLimitWithGroup_updatesSelectedServerConfigs(
+ final boolean connectOverHttp) throws Exception {
- server1.invoke(() -> {
- InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
- DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
- assertThat(config.getLogFileSizeLimit()).isEqualTo(50);
- assertThat(config.getLogDiskSpaceLimit()).isEqualTo(10);
- assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
- assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
- assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
- assertThat(config.getStatisticSamplingEnabled()).isTrue();
- });
- server2.invoke(() -> {
- InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
- DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
- assertThat(config.getLogFileSizeLimit()).isEqualTo(50);
- assertThat(config.getLogDiskSpaceLimit()).isEqualTo(10);
- assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
- assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
- assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
- assertThat(config.getStatisticSamplingEnabled()).isTrue();
- });
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ props.setProperty(GROUPS, "G1");
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ final int TEST_LIMIT = 25;
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT,
+ String.valueOf(TEST_LIMIT));
+ csb.addOption(CliStrings.GROUP, "G1");
+
+ CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ int expectedLimit;
+ if (server == server2) {
+ expectedLimit = TEST_LIMIT;
+ } else {
+ expectedLimit = 0;
+ }
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(expectedLimit);
+ assertThat(config.getArchiveFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
}
@Test
@Parameters({"true", "false"})
- public void alterRuntimeConfig_logDiskSpaceLimitOnMember_OK(final boolean connectOverHttp)
+ public void alterArchiveDiskSpaceLimitRangeIsEnforced(final boolean connectOverHttp)
throws Exception {
+ IgnoredException.addIgnoredException(
+ "java.lang.IllegalArgumentException: Could not set \"archive-disk-space-limit");
Properties props = new Properties();
props.setProperty(LOG_LEVEL, "error");
@@ -231,43 +871,130 @@ public class AlterRuntimeCommandDUnitTest {
}
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
- csb.addOption(CliStrings.MEMBERS, server1.getName());
- csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10");
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT, "-1");
- gfsh.executeAndVerifyCommand(csb.toString());
- String resultStr = gfsh.getGfshOutput();
+ CommandResult result = gfsh.executeCommand(csb.toString());
+ assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
+ assertThat(gfsh.getGfshOutput())
+ .contains("Could not set \"archive-disk-space-limit\" to \"-1\"");
- server1.invoke(() -> {
- InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
- DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
- assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
- assertThat(config.getLogDiskSpaceLimit()).isEqualTo(10);
- assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
- assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
- assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
- assertThat(config.getStatisticSamplingEnabled()).isTrue();
- });
- server2.invoke(() -> {
- InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
- DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
- assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
- assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
- assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
- assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
- assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
- assertThat(config.getStatisticSamplingEnabled()).isTrue();
- });
+ csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT, "1000001");
+
+ result = gfsh.executeCommand(csb.toString());
+ assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
+ assertThat(gfsh.getGfshOutput())
+ .contains("Could not set \"archive-disk-space-limit\" to \"1,000,001\"");
+
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getArchiveFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
}
@Test
@Parameters({"true", "false"})
- public void alterRuntimeConfig_logDiskSpaceLimitOnGroup_OK(final boolean connectOverHttp)
+ public void alterArchiveFileSizeLimit_updatesAllServerConfigs(final boolean connectOverHttp)
throws Exception {
Properties props = new Properties();
props.setProperty(LOG_LEVEL, "error");
MemberVM locator = startupRule.startLocatorVM(0, props);
MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ final int TEST_LIMIT = 10;
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT,
+ String.valueOf(TEST_LIMIT));
+
+ CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getArchiveFileSizeLimit()).isEqualTo(TEST_LIMIT);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
+ }
+
+ @Test
+ @Parameters({"true", "false"})
+ public void alterArchiveFileSizeLimitWithMember_updatesSelectedServerConfigs(
+ final boolean connectOverHttp) throws Exception {
+
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ final int TEST_LIMIT = 10;
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT,
+ String.valueOf(TEST_LIMIT));
+ csb.addOption(CliStrings.MEMBER, server1.getName());
+
+ CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+
+ for (final MemberVM server : new MemberVM[] {server1, server2}) {
+ int expectedLimit;
+ if (server == server1) {
+ expectedLimit = TEST_LIMIT;
+ } else {
+ expectedLimit = 0;
+ }
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getArchiveFileSizeLimit()).isEqualTo(expectedLimit);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
+ }
+
+ @Test
+ @Parameters({"true", "false"})
+ public void alterArchiveFileSizeLimitWithGroup_updatesSelectedServerConfigs(
+ final boolean connectOverHttp) throws Exception {
+
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
props.setProperty(GROUPS, "G1");
MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
@@ -277,35 +1004,118 @@ public class AlterRuntimeCommandDUnitTest {
gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
}
+ final int TEST_LIMIT = 25;
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
- csb.addOption(CliStrings.GROUPS, "G1");
- csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10");
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT,
+ String.valueOf(TEST_LIMIT));
+ csb.addOption(CliStrings.GROUP, "G1");
- gfsh.executeAndVerifyCommand(csb.toString());
- String resultStr = gfsh.getGfshOutput();
+ CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
- server1.invoke(() -> {
- InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
- DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
- assertThat(config.getGroups()).isEqualTo("");
- assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
- assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
- assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
- assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
- assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
- assertThat(config.getStatisticSamplingEnabled()).isTrue();
- });
- server2.invoke(() -> {
- InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
- DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
- assertThat(config.getGroups()).isEqualTo("G1");
- assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
- assertThat(config.getLogDiskSpaceLimit()).isEqualTo(10);
- assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
- assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
- assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
- assertThat(config.getStatisticSamplingEnabled()).isTrue();
- });
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ int expectedLimit;
+ if (server == server2) {
+ expectedLimit = TEST_LIMIT;
+ } else {
+ expectedLimit = 0;
+ }
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getArchiveFileSizeLimit()).isEqualTo(expectedLimit);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
+ }
+
+ @Test
+ @Parameters({"true", "false"})
+ public void alterArchiveFileSizeLimitRangeIsEnforced(final boolean connectOverHttp)
+ throws Exception {
+ IgnoredException.addIgnoredException(
+ "java.lang.IllegalArgumentException: Could not set \"archive-file-size-limit");
+
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT, "-1");
+
+ CommandResult result = gfsh.executeCommand(csb.toString());
+ assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
+ assertThat(gfsh.getGfshOutput())
+ .contains("Could not set \"archive-file-size-limit\" to \"-1\"");
+
+ csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT, "1000001");
+
+ result = gfsh.executeCommand(csb.toString());
+ assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
+ assertThat(gfsh.getGfshOutput())
+ .contains("Could not set \"archive-file-size-limit\" to \"1,000,001\"");
+
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getArchiveFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
+ }
+
+ @Test
+ @Parameters({"true", "false"})
+ public void alterDisableStatisticSampling(final boolean connectOverHttp) throws Exception {
+
+ Properties props = new Properties();
+ props.setProperty(LOG_LEVEL, "error");
+ MemberVM locator = startupRule.startLocatorVM(0, props);
+ MemberVM server1 = startupRule.startServerVM(1, props, locator.getPort());
+ MemberVM server2 = startupRule.startServerVM(2, props, locator.getPort());
+
+ if (connectOverHttp) {
+ gfsh.connectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http);
+ } else {
+ gfsh.connectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger);
+ }
+
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+ csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLING__ENABLED, "false");
+
+ CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+
+ for (MemberVM server : new MemberVM[] {server1, server2}) {
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isFalse();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
}
/**
@@ -314,8 +1124,8 @@ public class AlterRuntimeCommandDUnitTest {
*/
@Test
@Parameters({"true", "false"})
- public void alterRuntimeConfig_groupWithoutOptions_needsRelevantParameter(
- final boolean connectOverHttp) throws Exception {
+ public void alterGroupWithoutOptions_needsRelevantParameter(final boolean connectOverHttp)
+ throws Exception {
Properties props = new Properties();
props.setProperty(LOG_LEVEL, "error");
@@ -362,8 +1172,8 @@ public class AlterRuntimeCommandDUnitTest {
*/
@Test
@Parameters({"true", "false"})
- public void alterRuntimeConfig_memberWithoutOptions_needsRelevantParameter(
- final boolean connectOverHttp) throws Exception {
+ public void alterMemberWithoutOptions_needsRelevantParameter(final boolean connectOverHttp)
+ throws Exception {
Properties props = new Properties();
props.setProperty(LOG_LEVEL, "error");
--
To stop receiving notification emails like this one, please contact
"commits@geode.apache.org" <co...@geode.apache.org>.
[geode] 02/02: GEODE-3539: refactored to reduce code duplication
Posted by kh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
khowe pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
commit 22b02c73e52795ff9175b693a5e3121d0d3618b7
Author: Ken Howe <kh...@pivotal.io>
AuthorDate: Wed Oct 4 08:45:38 2017 -0700
GEODE-3539: refactored to reduce code duplication
---
.../cli/commands/AlterRuntimeCommandDUnitTest.java | 70 +++++++---------------
1 file changed, 20 insertions(+), 50 deletions(-)
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRuntimeCommandDUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRuntimeCommandDUnitTest.java
index e6e178a..2bc9c91 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRuntimeCommandDUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRuntimeCommandDUnitTest.java
@@ -23,7 +23,6 @@ import java.util.Properties;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
-import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -57,6 +56,22 @@ public class AlterRuntimeCommandDUnitTest {
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ private void verifyDefaultConfig(MemberVM[] servers) {
+ for (MemberVM server : servers) {
+ server.invoke(() -> {
+ InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+ DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
+ assertThat(config.getLogLevel()).isEqualTo(LogWriterImpl.ERROR_LEVEL);
+ assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
+ assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
+ assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
+ assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
+ assertThat(config.getStatisticSamplingEnabled()).isTrue();
+ assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
+ });
+ }
+ }
+
@Test
@Parameters({"true", "false"})
public void testAlterRuntimeConfig(final boolean connectOverHttp) throws Exception {
@@ -349,18 +364,7 @@ public class AlterRuntimeCommandDUnitTest {
assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
assertThat(gfsh.getGfshOutput()).contains("Could not set \"log-file-size-limit\" to \"-1\"");
- for (MemberVM server : new MemberVM[] {server1, server2}) {
- server.invoke(() -> {
- InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
- DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
- assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
- assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
- assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
- assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
- assertThat(config.getStatisticSamplingEnabled()).isTrue();
- assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
- });
- }
+ verifyDefaultConfig(new MemberVM[] {server1, server2});
}
@Test
@@ -404,18 +408,7 @@ public class AlterRuntimeCommandDUnitTest {
assertThat(gfsh.getGfshOutput())
.contains("Could not set \"log-file-size-limit\" to \"1,000,001\"");
- for (MemberVM server : new MemberVM[] {server1, server2}) {
- server.invoke(() -> {
- InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
- DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
- assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
- assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
- assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
- assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
- assertThat(config.getStatisticSamplingEnabled()).isTrue();
- assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
- });
- }
+ verifyDefaultConfig(new MemberVM[] {server1, server2});
}
@Test
@@ -705,18 +698,7 @@ public class AlterRuntimeCommandDUnitTest {
assertThat(gfsh.getGfshOutput())
.contains("Could not set \"statistic-sample-rate\" to \"60,001\"");
- for (MemberVM server : new MemberVM[] {server1, server2}) {
- server.invoke(() -> {
- InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
- DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
- assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
- assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
- assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
- assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
- assertThat(config.getStatisticSamplingEnabled()).isTrue();
- assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
- });
- }
+ verifyDefaultConfig(new MemberVM[] {server1, server2});
}
@Test
@@ -1068,19 +1050,7 @@ public class AlterRuntimeCommandDUnitTest {
assertThat(gfsh.getGfshOutput())
.contains("Could not set \"archive-file-size-limit\" to \"1,000,001\"");
- for (MemberVM server : new MemberVM[] {server1, server2}) {
- server.invoke(() -> {
- InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
- DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
- assertThat(config.getLogFileSizeLimit()).isEqualTo(0);
- assertThat(config.getArchiveDiskSpaceLimit()).isEqualTo(0);
- assertThat(config.getArchiveFileSizeLimit()).isEqualTo(0);
- assertThat(config.getStatisticSampleRate()).isEqualTo(1000);
- assertThat(config.getStatisticArchiveFile().getName()).isEqualTo("");
- assertThat(config.getStatisticSamplingEnabled()).isTrue();
- assertThat(config.getLogDiskSpaceLimit()).isEqualTo(0);
- });
- }
+ verifyDefaultConfig(new MemberVM[] {server1, server2});
}
@Test
--
To stop receiving notification emails like this one, please contact
"commits@geode.apache.org" <co...@geode.apache.org>.