geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kh...@apache.org
Subject [geode] branch develop updated: GEODE-2668: Better handling of configuration updates (#1892)
Date Tue, 08 May 2018 17:25:26 GMT
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


The following commit(s) were added to refs/heads/develop by this push:
     new 6284169  GEODE-2668: Better handling of configuration updates (#1892)
6284169 is described below

commit 62841692a06de682059529a28a73ed3ae9638ec8
Author: Kenneth Howe <khowe@pivotal.io>
AuthorDate: Tue May 8 10:25:22 2018 -0700

    GEODE-2668: Better handling of configuration updates (#1892)
    
    In cases where destroying GWRs may fail on some or all servers, control
    configuration updating based on state of --if-exists option.
    --if-exists == true --> update config
    --if-exists == false --> do not update config
    
    Added tests for edge cases with failures on servers.
---
 .../commands/DestroyGatewayReceiverCommand.java    |   7 +-
 .../DestroyGatewayReceiverCommandDUnitTest.java    | 122 ++++++++++++++++++++-
 2 files changed, 125 insertions(+), 4 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DestroyGatewayReceiverCommand.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DestroyGatewayReceiverCommand.java
index a7a6c8d..e5e0de8 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DestroyGatewayReceiverCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DestroyGatewayReceiverCommand.java
@@ -57,7 +57,7 @@ public class DestroyGatewayReceiverCommand extends InternalGfshCommand {
       @CliOption(key = CliStrings.IFEXISTS, help = CliStrings.IFEXISTS_HELP,
           specifiedDefaultValue = "true", unspecifiedDefaultValue = "false") boolean ifExists)
{
 
-    boolean persisted = false;
+    boolean persisted = true;
     Set<DistributedMember> members = getMembers(onGroups, onMember);
 
     List<CliFunctionResult> functionResults =
@@ -68,7 +68,9 @@ public class DestroyGatewayReceiverCommand extends InternalGfshCommand {
     // Only update the cluster config if the command is not executed on specific members.
     InternalConfigurationPersistenceService service =
         (InternalConfigurationPersistenceService) getConfigurationPersistenceService();
-    if (onMember == null && result.getStatus().equals(Result.Status.OK) &&
service != null) {
+    if (onMember != null || service == null) {
+      persisted = false;
+    } else if (result.getStatus().equals(Result.Status.OK) && service != null) {
       if (onGroups == null) {
         onGroups = new String[] {"cluster"};
       }
@@ -82,7 +84,6 @@ public class DestroyGatewayReceiverCommand extends InternalGfshCommand {
         }
         return cc;
       }));
-      persisted = true;
     }
 
     result.setCommandPersisted(persisted);
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/DestroyGatewayReceiverCommandDUnitTest.java
b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/DestroyGatewayReceiverCommandDUnitTest.java
index 949c665..83ef572 100644
--- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/DestroyGatewayReceiverCommandDUnitTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/DestroyGatewayReceiverCommandDUnitTest.java
@@ -180,6 +180,113 @@ public class DestroyGatewayReceiverCommandDUnitTest {
   }
 
   @Test
+  public void destroyOnCluster_receiverExistsOnSubsetOfMembers_confgIsUpdated() {
+    Integer locator1Port = locatorSite1.getPort();
+    server3 = clusterStartupRule.startServerVM(3, locator1Port);
+    server4 = clusterStartupRule.startServerVM(4, locator1Port);
+    server5 = clusterStartupRule.startServerVM(5, locator1Port);
+
+    gfsh.executeAndAssertThat(createGatewayReceiverCommand("false")).statusIsSuccess()
+        .tableHasColumnWithExactValuesInAnyOrder("Member", "server-3", "server-4", "server-5")
+        .tableHasColumnWithValuesContaining("Status",
+            "GatewayReceiver created on member \"server-3\"",
+            "GatewayReceiver created on member \"server-4\"",
+            "GatewayReceiver created on member \"server-5\"");
+    verifyConfigHasGatewayReceiver("cluster");
+
+    VMProvider
+        .invokeInEveryMember(
+            () -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "localhost",
100000,
+                512000, null, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS),
+            server3, server4, server5);
+
+    CommandStringBuilder csb =
+        new CommandStringBuilder(DestroyGatewayReceiverCommand.DESTROY_GATEWAYRECEIVER)
+            .addOption(CliStrings.MEMBER, server3.getName());
+    gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
+        .containsOutput("change is not persisted")
+        .tableHasColumnWithExactValuesInAnyOrder("Member", "server-3");
+    verifyConfigHasGatewayReceiver("cluster");
+
+    csb = new CommandStringBuilder(DestroyGatewayReceiverCommand.DESTROY_GATEWAYRECEIVER);
+    gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
+        .tableHasColumnWithExactValuesInAnyOrder("Member", "server-3", "server-4", "server-5");
+    verifyConfigDoesNotHaveGatewayReceiver("cluster");
+
+    VMProvider.invokeInEveryMember(WANCommandUtils::verifyReceiverDoesNotExist, server3,
server4,
+        server5);
+  }
+
+  @Test
+  public void destroyOnCluster_receiverExistsInConfigButNotOnMembers_errorConfigNotUpdated()
{
+    Integer locator1Port = locatorSite1.getPort();
+    server3 = clusterStartupRule.startServerVM(3, locator1Port);
+
+    gfsh.executeAndAssertThat(createGatewayReceiverCommand("false")).statusIsSuccess()
+        .tableHasColumnWithExactValuesInAnyOrder("Member", "server-3")
+        .tableHasColumnWithValuesContaining("Status",
+            "GatewayReceiver created on member \"server-3\"");
+    verifyConfigHasGatewayReceiver("cluster");
+
+    VMProvider
+        .invokeInEveryMember(
+            () -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "localhost",
100000,
+                512000, null, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS),
+            server3/* , server4, server5 */);
+
+    CommandStringBuilder csb =
+        new CommandStringBuilder(DestroyGatewayReceiverCommand.DESTROY_GATEWAYRECEIVER)
+            .addOption(CliStrings.MEMBER, server3.getName());
+    gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
+        .containsOutput("change is not persisted")
+        .tableHasColumnWithExactValuesInAnyOrder("Member", "server-3");
+    verifyConfigHasGatewayReceiver("cluster");
+
+    csb = new CommandStringBuilder(DestroyGatewayReceiverCommand.DESTROY_GATEWAYRECEIVER);
+    gfsh.executeAndAssertThat(csb.toString()).statusIsError()
+        .doesNotContainOutput("change is not persisted")
+        .tableHasColumnWithExactValuesInAnyOrder("Member", "server-3");
+    verifyConfigHasGatewayReceiver("cluster");
+
+    VMProvider.invokeInEveryMember(WANCommandUtils::verifyReceiverDoesNotExist, server3);
+  }
+
+  @Test
+  public void destroyOnCluster_receiverExistsInConfigButNotOnMembers_ifExistsConfigIsUpdated()
{
+    Integer locator1Port = locatorSite1.getPort();
+    server3 = clusterStartupRule.startServerVM(3, locator1Port);
+
+    gfsh.executeAndAssertThat(createGatewayReceiverCommand("false")).statusIsSuccess()
+        .tableHasColumnWithExactValuesInAnyOrder("Member", "server-3")
+        .tableHasColumnWithValuesContaining("Status",
+            "GatewayReceiver created on member \"server-3\"");
+    verifyConfigHasGatewayReceiver("cluster");
+
+    VMProvider
+        .invokeInEveryMember(
+            () -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "localhost",
100000,
+                512000, null, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS),
+            server3/* , server4, server5 */);
+
+    CommandStringBuilder csb =
+        new CommandStringBuilder(DestroyGatewayReceiverCommand.DESTROY_GATEWAYRECEIVER)
+            .addOption(CliStrings.MEMBER, server3.getName());
+    gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
+        .containsOutput("change is not persisted")
+        .tableHasColumnWithExactValuesInAnyOrder("Member", "server-3");
+    verifyConfigHasGatewayReceiver("cluster");
+
+    csb = new CommandStringBuilder(DestroyGatewayReceiverCommand.DESTROY_GATEWAYRECEIVER)
+        .addOption(CliStrings.IFEXISTS);
+    gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
+        .doesNotContainOutput("change is not persisted")
+        .tableHasColumnWithExactValuesInAnyOrder("Member", "server-3");
+    verifyConfigDoesNotHaveGatewayReceiver("cluster");
+
+    VMProvider.invokeInEveryMember(WANCommandUtils::verifyReceiverDoesNotExist, server3);
+  }
+
+  @Test
   public void destroyUnstartedGatewayReceiver_destroysReceiverOnlyOnSpecificMembers() {
     Integer locator1Port = locatorSite1.getPort();
     server3 = clusterStartupRule.startServerVM(3, locator1Port);
@@ -212,7 +319,7 @@ public class DestroyGatewayReceiverCommandDUnitTest {
   }
 
   @Test
-  public void destroyWithoutGatewayReceivers_isError() {
+  public void destroyWithoutGatewayReceiverOnMember_isError() {
     Integer locator1Port = locatorSite1.getPort();
     server3 = clusterStartupRule.startServerVM(3, locator1Port);
     server4 = clusterStartupRule.startServerVM(4, locator1Port);
@@ -234,6 +341,19 @@ public class DestroyGatewayReceiverCommandDUnitTest {
   }
 
   @Test
+  public void destroyGatewayReceiverClusterNotInConfig_isError_noNotPersistMessage() {
+    Integer locator1Port = locatorSite1.getPort();
+    server3 = clusterStartupRule.startServerVM(3, locator1Port);
+    server4 = clusterStartupRule.startServerVM(4, locator1Port);
+
+    CommandStringBuilder csb =
+        new CommandStringBuilder(DestroyGatewayReceiverCommand.DESTROY_GATEWAYRECEIVER);
+    gfsh.executeAndAssertThat(csb.toString()).statusIsError()
+        .doesNotContainOutput("change is not persisted")
+        .tableHasColumnWithExactValuesInAnyOrder("Member", "server-3", "server-4");
+  }
+
+  @Test
   public void destroyIfExistsWithoutGatewayReceivers_isSkipping() {
     Integer locator1Port = locatorSite1.getPort();
     server3 = clusterStartupRule.startServerVM(3, locator1Port);

-- 
To stop receiving notification emails like this one, please contact
khowe@apache.org.

Mime
View raw message