You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jj...@apache.org on 2018/11/27 15:12:50 UTC
[geode] branch develop updated: GEODE-5667: Fix manual-start
default value (#2822)
This is an automated email from the ASF dual-hosted git repository.
jjramos 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 dc519bb GEODE-5667: Fix manual-start default value (#2822)
dc519bb is described below
commit dc519bb08330bba4a29a027a642da8c23c3f7b69
Author: Juan José Ramos <ju...@users.noreply.github.com>
AuthorDate: Tue Nov 27 15:12:40 2018 +0000
GEODE-5667: Fix manual-start default value (#2822)
- Fixed minor warnings in test classes.
- The `create gateway-receiver` command now sets the `manual-start`
property as `true` when the parameter is specified without a value.
---
.../cli/commands/CreateGatewayReceiverCommand.java | 3 +-
.../commands/CreateGatewayReceiverCommandTest.java | 55 +++++++++++------
.../CreateGatewayReceiverCommandDUnitTest.java | 68 +++++++---------------
3 files changed, 60 insertions(+), 66 deletions(-)
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateGatewayReceiverCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateGatewayReceiverCommand.java
index bf53499..cedb65e 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateGatewayReceiverCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateGatewayReceiverCommand.java
@@ -57,7 +57,8 @@ public class CreateGatewayReceiverCommand extends SingleGfshCommand {
help = CliStrings.CREATE_GATEWAYRECEIVER__MEMBER__HELP) String[] onMember,
@CliOption(key = CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART,
- help = CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART__HELP) Boolean manualStart,
+ help = CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART__HELP,
+ specifiedDefaultValue = "true", unspecifiedDefaultValue = "false") Boolean manualStart,
@CliOption(key = CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT,
help = CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT__HELP) Integer startPort,
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateGatewayReceiverCommandTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateGatewayReceiverCommandTest.java
index 1742bea..fc95747 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateGatewayReceiverCommandTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateGatewayReceiverCommandTest.java
@@ -44,13 +44,8 @@ public class CreateGatewayReceiverCommandTest {
@ClassRule
public static GfshParserRule gfsh = new GfshParserRule();
- private final String NOT_PERSISTED_ON_MEMBER =
- "Configuration change is not persisted because the command is executed on specific member";
- private final String NOT_PERSISTED_CC_NOT_RUNNING =
- "Cluster configuration service is not running. Configuration change is not persisted";
private CreateGatewayReceiverCommand command;
- private InternalCache cache;
private List<CliFunctionResult> functionResults;
private InternalConfigurationPersistenceService ccService;
private CliFunctionResult result1;
@@ -59,21 +54,19 @@ public class CreateGatewayReceiverCommandTest {
public void before() {
command = spy(CreateGatewayReceiverCommand.class);
ccService = mock(InternalConfigurationPersistenceService.class);
- cache = mock(InternalCache.class);
+ InternalCache cache = mock(InternalCache.class);
doReturn(cache).when(command).getCache();
doReturn(ccService).when(command).getConfigurationPersistenceService();
functionResults = new ArrayList<>();
- doReturn(functionResults).when(command).executeAndGetFunctionResult(any(), any(),
- any(Set.class));
+ doReturn(functionResults).when(command).executeAndGetFunctionResult(any(), any(), any());
}
@Test
- public void testDefaultValues() {
+ public void testUnspecifiedDefaultValues() {
GfshParseResult parseResult = gfsh.parse("create gateway-receiver");
assertThat(parseResult.getParamValue(CliStrings.MEMBER)).isNull();
assertThat(parseResult.getParamValue(CliStrings.GROUP)).isNull();
- assertThat(parseResult.getParamValue(CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART)).isNull();
assertThat(parseResult.getParamValue(CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT)).isNull();
assertThat(parseResult.getParamValue(CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT)).isNull();
assertThat(parseResult.getParamValue(CliStrings.CREATE_GATEWAYRECEIVER__BINDADDRESS)).isNull();
@@ -86,8 +79,32 @@ public class CreateGatewayReceiverCommandTest {
assertThat(parseResult.getParamValue(CliStrings.CREATE_GATEWAYRECEIVER__HOSTNAMEFORSENDERS))
.isNull();
assertThat(parseResult.getParamValue(CliStrings.IFNOTEXISTS)).isEqualTo(false);
+ assertThat(parseResult.getParamValue(CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART))
+ .isEqualTo(false);
}
+ @Test
+ public void testSpecifiedDefaultValues() {
+ GfshParseResult parseResult =
+ gfsh.parse("create gateway-receiver --manual-start --if-not-exists");
+
+ assertThat(parseResult.getParamValue(CliStrings.MEMBER)).isNull();
+ assertThat(parseResult.getParamValue(CliStrings.GROUP)).isNull();
+ assertThat(parseResult.getParamValue(CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT)).isNull();
+ assertThat(parseResult.getParamValue(CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT)).isNull();
+ assertThat(parseResult.getParamValue(CliStrings.CREATE_GATEWAYRECEIVER__BINDADDRESS)).isNull();
+ assertThat(parseResult.getParamValue(CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS))
+ .isNull();
+ assertThat(parseResult.getParamValue(CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE))
+ .isNull();
+ assertThat(parseResult.getParamValue(CliStrings.CREATE_GATEWAYRECEIVER__GATEWAYTRANSPORTFILTER))
+ .isNull();
+ assertThat(parseResult.getParamValue(CliStrings.CREATE_GATEWAYRECEIVER__HOSTNAMEFORSENDERS))
+ .isNull();
+ assertThat(parseResult.getParamValue(CliStrings.IFNOTEXISTS)).isEqualTo(true);
+ assertThat(parseResult.getParamValue(CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART))
+ .isEqualTo(true);
+ }
@Test
public void endPortMustBeLargerThanStartPort() {
@@ -105,10 +122,12 @@ public class CreateGatewayReceiverCommandTest {
public void gatewayReceiverCanBeCreatedButIsNotPersistedWithoutConfigurationService() {
doReturn(mock(Set.class)).when(command).getMembers(any(), any());
doReturn(null).when(command).getConfigurationPersistenceService();
- result1 = new CliFunctionResult("member", true, "result1");
+ result1 = new CliFunctionResult("member", CliFunctionResult.StatusState.OK, "result1");
functionResults.add(result1);
+
gfsh.executeAndAssertThat(command, "create gateway-receiver").statusIsSuccess()
- .containsOutput(NOT_PERSISTED_CC_NOT_RUNNING);
+ .containsOutput(
+ "Cluster configuration service is not running. Configuration change is not persisted");
verify(ccService, never()).addXmlEntity(any(), any());
verify(ccService, never()).updateCacheConfig(any(), any());
}
@@ -117,10 +136,11 @@ public class CreateGatewayReceiverCommandTest {
public void gatewayReceiverIsCreatedButNotPersistedWithMemberOption() {
doReturn(mock(Set.class)).when(command).getMembers(any(), any());
doReturn(ccService).when(command).getConfigurationPersistenceService();
- result1 = new CliFunctionResult("member", true, "result1");
+ result1 = new CliFunctionResult("member", CliFunctionResult.StatusState.OK, "result1");
functionResults.add(result1);
gfsh.executeAndAssertThat(command, "create gateway-receiver --member=xyz").statusIsSuccess()
- .containsOutput(NOT_PERSISTED_ON_MEMBER);
+ .containsOutput(
+ "Configuration change is not persisted because the command is executed on specific member");
verify(ccService, never()).addXmlEntity(any(), any());
verify(ccService, never()).updateCacheConfig(any(), any());
}
@@ -129,7 +149,7 @@ public class CreateGatewayReceiverCommandTest {
public void configurationIsNotPersistedWhenCreationOnOnlyMemberFails() {
doReturn(mock(Set.class)).when(command).getMembers(any(), any());
doReturn(ccService).when(command).getConfigurationPersistenceService();
- result1 = new CliFunctionResult("member", false, "result1");
+ result1 = new CliFunctionResult("member", CliFunctionResult.StatusState.ERROR, "result1");
functionResults.add(result1);
// does not delete because command failed, so hasNoFailToPersistError should still be true
@@ -141,9 +161,10 @@ public class CreateGatewayReceiverCommandTest {
public void configurationIsPersistedWhenCreationOnAnyMemberFails() {
doReturn(mock(Set.class)).when(command).getMembers(any(), any());
doReturn(ccService).when(command).getConfigurationPersistenceService();
- result1 = new CliFunctionResult("member", false, "result1");
+ result1 = new CliFunctionResult("member", CliFunctionResult.StatusState.ERROR, "result1");
functionResults.add(result1);
- CliFunctionResult result2 = new CliFunctionResult("member", true, "result2");
+ CliFunctionResult result2 =
+ new CliFunctionResult("member", CliFunctionResult.StatusState.OK, "result2");
functionResults.add(result2);
// does not delete because command failed, so hasNoFailToPersistError should still be true
diff --git a/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/wancommand/CreateGatewayReceiverCommandDUnitTest.java b/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/wancommand/CreateGatewayReceiverCommandDUnitTest.java
index 4eeb892..4a7e424 100644
--- a/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/wancommand/CreateGatewayReceiverCommandDUnitTest.java
+++ b/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/wancommand/CreateGatewayReceiverCommandDUnitTest.java
@@ -33,10 +33,13 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.wan.GatewayReceiver;
@@ -51,7 +54,8 @@ import org.apache.geode.test.junit.rules.GfshCommandRule;
/**
* DUnit tests for 'create gateway-receiver' command.
*/
-@Category({WanTest.class})
+@Category(WanTest.class)
+@RunWith(JUnitParamsRunner.class)
public class CreateGatewayReceiverCommandDUnitTest {
private static final String SERVER_1 = "server-1";
@@ -104,12 +108,11 @@ public class CreateGatewayReceiverCommandDUnitTest {
server1 = clusterStartupRule.startServerVM(1, locator1Port);
server2 = clusterStartupRule.startServerVM(2, locator1Port);
String createOnS1 = CREATE_GATEWAYRECEIVER + " --member=" + server1.getName();
- String createOnBoth = CREATE_GATEWAYRECEIVER;
gfsh.executeAndAssertThat(createOnS1).statusIsSuccess()
.tableHasColumnWithExactValuesInAnyOrder("Member", SERVER_1)
.tableHasColumnWithValuesContaining("Message",
"GatewayReceiver created on member \"" + SERVER_1 + "\"");
- gfsh.executeAndAssertThat(createOnBoth).statusIsSuccess()
+ gfsh.executeAndAssertThat(CREATE_GATEWAYRECEIVER).statusIsSuccess()
.tableHasColumnWithExactValuesInAnyOrder("Member", SERVER_1, SERVER_2)
.tableHasColumnWithExactValuesInAnyOrder("Status", "ERROR", "OK")
.tableHasColumnWithValuesContaining("Message",
@@ -190,8 +193,7 @@ public class CreateGatewayReceiverCommandDUnitTest {
server3 = clusterStartupRule.startServerVM(3, locator1Port);
// Default attributes.
- String command = CliStrings.CREATE_GATEWAYRECEIVER;
- gfsh.executeAndAssertThat(command).statusIsSuccess()
+ gfsh.executeAndAssertThat(CliStrings.CREATE_GATEWAYRECEIVER).statusIsSuccess()
.tableHasColumnWithExactValuesInAnyOrder("Member", SERVER_1, SERVER_2, SERVER_3)
.tableHasColumnWithValuesContaining("Message",
"GatewayReceiver created on member \"" + SERVER_1 + "\"",
@@ -277,55 +279,22 @@ public class CreateGatewayReceiverCommandDUnitTest {
}, server1, server2, server3);
}
- /**
- * GatewayReceiver with all default attributes and bind-address in gemfire-properties
- */
- @Test
- public void testCreateGatewayReceiverWithDefaultAndBindProperty() throws Exception {
- String receiverGroup = "receiverGroup";
- Integer locator1Port = locatorSite1.getPort();
- String expectedBindAddress = getBindAddress();
-
- Properties props = new Properties();
- props.setProperty(GROUPS, receiverGroup);
- props.setProperty(BIND_ADDRESS, expectedBindAddress);
-
- server1 = clusterStartupRule.startServerVM(1, props, locator1Port);
- server2 = clusterStartupRule.startServerVM(2, props, locator1Port);
- server3 = clusterStartupRule.startServerVM(3, props, locator1Port);
-
- String command = CliStrings.CREATE_GATEWAYRECEIVER + " --" + GROUP + "=" + receiverGroup;
- gfsh.executeAndAssertThat(command).statusIsSuccess()
- .tableHasColumnWithExactValuesInAnyOrder("Member", SERVER_1, SERVER_2, SERVER_3)
- .tableHasColumnWithValuesContaining("Message",
- "GatewayReceiver created on member \"" + SERVER_1 + "\"",
- "GatewayReceiver created on member \"" + SERVER_2 + "\"",
- "GatewayReceiver created on member \"" + SERVER_3 + "\"");
-
- invokeInEveryMember(() -> {
- // verify bind-address used when provided as a gemfire property
- verifyGatewayReceiverProfile(expectedBindAddress);
- verifyGatewayReceiverServerLocations(locator1Port, expectedBindAddress);
- verifyReceiverCreationWithAttributes(!GatewayReceiver.DEFAULT_MANUAL_START,
- GatewayReceiver.DEFAULT_START_PORT, GatewayReceiver.DEFAULT_END_PORT,
- GatewayReceiver.DEFAULT_BIND_ADDRESS, GatewayReceiver.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS,
- GatewayReceiver.DEFAULT_SOCKET_BUFFER_SIZE, null,
- GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS);
- }, server1, server2, server3);
- }
/**
- * GatewayReceiver with all default attributes and server-bind-address in the gemfire properties
+ * GatewayReceiver with all default attributes and bind-address / server-bind-address in
+ * gemfire-properties
*/
@Test
- public void testCreateGatewayReceiverWithDefaultsAndServerBindAddressProperty() throws Exception {
+ @Parameters({BIND_ADDRESS, SERVER_BIND_ADDRESS})
+ public void testCreateGatewayReceiverWithDefaultsAndAddressProperties(String addressPropertyKey)
+ throws Exception {
String receiverGroup = "receiverGroup";
Integer locator1Port = locatorSite1.getPort();
String expectedBindAddress = getBindAddress();
Properties props = new Properties();
props.setProperty(GROUPS, receiverGroup);
- props.setProperty(SERVER_BIND_ADDRESS, expectedBindAddress);
+ props.setProperty(addressPropertyKey, expectedBindAddress);
server1 = clusterStartupRule.startServerVM(1, props, locator1Port);
server2 = clusterStartupRule.startServerVM(2, props, locator1Port);
@@ -340,7 +309,7 @@ public class CreateGatewayReceiverCommandDUnitTest {
"GatewayReceiver created on member \"" + SERVER_3 + "\"");
invokeInEveryMember(() -> {
- // verify server-bind-address used if provided as a gemfire property
+ // verify bind-address used when provided as a gemfire property
verifyGatewayReceiverProfile(expectedBindAddress);
verifyGatewayReceiverServerLocations(locator1Port, expectedBindAddress);
verifyReceiverCreationWithAttributes(!GatewayReceiver.DEFAULT_MANUAL_START,
@@ -573,6 +542,7 @@ public class CreateGatewayReceiverCommandDUnitTest {
invokeInEveryMember(() -> {
Cache cache = ClusterStartupRule.getCache();
+ assertThat(cache).isNotNull();
assertThat(cache.getGatewayReceivers()).isEmpty();
}, server2, server3);
}
@@ -609,6 +579,7 @@ public class CreateGatewayReceiverCommandDUnitTest {
invokeInEveryMember(() -> {
Cache cache = ClusterStartupRule.getCache();
+ assertThat(cache).isNotNull();
assertThat(cache.getGatewayReceivers()).isEmpty();
}, server3);
}
@@ -619,7 +590,7 @@ public class CreateGatewayReceiverCommandDUnitTest {
@Test
public void testCreateGatewayReceiverOnGroup() {
String groups = "receiverGroup1";
- Integer locator1Port = locatorSite1.getPort();
+ int locator1Port = locatorSite1.getPort();
server1 = startServerWithGroups(1, groups, locator1Port);
server2 = startServerWithGroups(2, groups, locator1Port);
server3 = startServerWithGroups(3, groups, locator1Port);
@@ -652,7 +623,7 @@ public class CreateGatewayReceiverCommandDUnitTest {
public void testCreateGatewayReceiverOnGroupScenario2() {
String group1 = "receiverGroup1";
String group2 = "receiverGroup2";
- Integer locator1Port = locatorSite1.getPort();
+ int locator1Port = locatorSite1.getPort();
server1 = startServerWithGroups(1, group1, locator1Port);
server2 = startServerWithGroups(2, group1, locator1Port);
server3 = startServerWithGroups(3, group2, locator1Port);
@@ -676,6 +647,7 @@ public class CreateGatewayReceiverCommandDUnitTest {
invokeInEveryMember(() -> {
Cache cache = ClusterStartupRule.getCache();
+ assertThat(cache).isNotNull();
assertThat(cache.getGatewayReceivers()).isEmpty();
}, server3);
}
@@ -685,7 +657,7 @@ public class CreateGatewayReceiverCommandDUnitTest {
*/
@Test
public void testCreateGatewayReceiverOnMultipleGroups() {
- Integer locator1Port = locatorSite1.getPort();
+ int locator1Port = locatorSite1.getPort();
server1 = startServerWithGroups(1, "receiverGroup1", locator1Port);
server2 = startServerWithGroups(2, "receiverGroup1", locator1Port);
server3 = startServerWithGroups(3, "receiverGroup2", locator1Port);