geode-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GEODE-3987) Enforce the uniqueness of a single gateway-receiver per member
Date Wed, 29 Nov 2017 18:34:00 GMT

    [ https://issues.apache.org/jira/browse/GEODE-3987?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16271314#comment-16271314 ] 

ASF GitHub Bot commented on GEODE-3987:
---------------------------------------

boglesby closed pull request #1086: GEODE-3987: enforce GatewayReceiver uniqueness per member.
URL: https://github.com/apache/geode/pull/1086
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/geode-core/src/main/resources/META-INF/schemas/geode.apache.org/schema/cache/cache-1.0.xsd b/geode-core/src/main/resources/META-INF/schemas/geode.apache.org/schema/cache/cache-1.0.xsd
index f2124901bf..a8a65de75d 100755
--- a/geode-core/src/main/resources/META-INF/schemas/geode.apache.org/schema/cache/cache-1.0.xsd
+++ b/geode-core/src/main/resources/META-INF/schemas/geode.apache.org/schema/cache/cache-1.0.xsd
@@ -205,7 +205,7 @@ declarative caching XML file elements unless indicated otherwise.
           </xsd:complexType>
         </xsd:element>
 
-        <xsd:element maxOccurs="unbounded" minOccurs="0" name="gateway-receiver">
+        <xsd:element maxOccurs="1" minOccurs="0" name="gateway-receiver">
           <xsd:complexType>
             <xsd:sequence>
               <xsd:element maxOccurs="unbounded" minOccurs="0" name="gateway-transport-filter" type="gf:class-with-parameters-type" />
diff --git a/geode-core/src/main/resources/org/apache/geode/cache/doc-files/cache8_0.dtd b/geode-core/src/main/resources/org/apache/geode/cache/doc-files/cache8_0.dtd
index f02c6b04e3..a28a17f585 100644
--- a/geode-core/src/main/resources/org/apache/geode/cache/doc-files/cache8_0.dtd
+++ b/geode-core/src/main/resources/org/apache/geode/cache/doc-files/cache8_0.dtd
@@ -144,7 +144,7 @@ contains, if any.
     dynamic-region-factory?,
     gateway-hub*,
     gateway-sender*,
-    gateway-receiver*,
+    gateway-receiver?,
     gateway-conflict-resolver?,
     async-event-queue*,
     cache-server*,
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.java
new file mode 100644
index 0000000000..989ef5456b
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+/**
+ *
+ */
+package org.apache.geode.internal.cache.wan;
+
+import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
+import static org.powermock.api.mockito.PowerMockito.when;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+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.TestName;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.modules.junit4.PowerMockRunnerDelegate;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.CacheXmlException;
+import org.apache.geode.cache.wan.GatewayReceiverFactory;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
+import org.apache.geode.util.test.TestUtil;
+
+@RunWith(PowerMockRunner.class)
+@Category(IntegrationTest.class)
+@PrepareForTest(WANServiceProvider.class)
+@PowerMockRunnerDelegate(Parameterized.class)
+@PowerMockIgnore({"javax.management.*", "javax.security.*", "*.IntegrationTest"})
+public class GatewayReceiverXmlParsingValidationsJUnitTest {
+  private Cache cache;
+  private GatewayReceiverFactory receiverFactory;
+
+  @Parameterized.Parameter
+  public static String validationStrategy;
+
+  @Rule
+  public TestName testName = new SerializableTestName();
+
+  @Parameterized.Parameters(name = "{0}")
+  public static Collection<String> strategies() throws Exception {
+    return Arrays.asList("DTD", "XSD");
+  }
+
+  @Before
+  public void setUp() throws Exception {
+    mockStatic(WANServiceProvider.class);
+    receiverFactory = spy(GatewayReceiverFactory.class);
+    when(WANServiceProvider.createGatewayReceiverFactory(any())).thenReturn(receiverFactory);
+  }
+
+  @Test(expected = CacheXmlException.class)
+  public void multipleReceiversShouldThrowException() {
+    String cacheXmlFileName = TestUtil.getResourcePath(getClass(),
+        getClass().getSimpleName() + "." + testName.getMethodName() + ".cache.xml");
+    cache = new CacheFactory().set(MCAST_PORT, "0").set(CACHE_XML_FILE, cacheXmlFileName).create();
+  }
+
+  @Test
+  public void correctConfiguration() {
+    String cacheXmlFileName = TestUtil.getResourcePath(getClass(),
+        getClass().getSimpleName() + "." + testName.getMethodName() + ".cache.xml");
+    cache = new CacheFactory().set(MCAST_PORT, "0").set(CACHE_XML_FILE, cacheXmlFileName).create();
+
+    assertThat(cache.getGatewayReceivers()).isNotNull();
+    verify(receiverFactory, times(1)).setEndPort(1501);
+    verify(receiverFactory, times(1)).setStartPort(1500);
+    verify(receiverFactory, times(1)).setManualStart(true);
+    verify(receiverFactory, times(1)).setSocketBufferSize(32768);
+    verify(receiverFactory, times(1)).setBindAddress("localhost");
+    verify(receiverFactory, times(1)).setHostnameForSenders("localhost");
+    verify(receiverFactory, times(1)).setMaximumTimeBetweenPings(60000);
+    verify(receiverFactory, times(1)).create();
+  }
+
+  @After
+  public void tearDown() {
+    if (cache != null) {
+      cache.close();
+    }
+  }
+}
diff --git a/geode-core/src/test/resources/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.correctConfiguration[DTD].cache.xml b/geode-core/src/test/resources/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.correctConfiguration[DTD].cache.xml
new file mode 100755
index 0000000000..3ea3edfa6c
--- /dev/null
+++ b/geode-core/src/test/resources/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.correctConfiguration[DTD].cache.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!DOCTYPE cache PUBLIC
+        "-//GemStone Systems, Inc.//GemFire Declarative Caching 8.0//EN"
+        "http://www.gemstone.com/dtd/cache8_0.dtd">
+<cache>
+  <gateway-receiver start-port="1500" end-port="1501" manual-start="true" bind-address="localhost" hostname-for-senders="localhost" maximum-time-between-pings="60000" socket-buffer-size="32768"/>
+</cache>
+
diff --git a/geode-core/src/test/resources/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.correctConfiguration[XSD].cache.xml b/geode-core/src/test/resources/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.correctConfiguration[XSD].cache.xml
new file mode 100755
index 0000000000..f2cc41b0ce
--- /dev/null
+++ b/geode-core/src/test/resources/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.correctConfiguration[XSD].cache.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<cache
+        xmlns="http://geode.apache.org/schema/cache"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd"
+        version="1.0">
+
+    <gateway-receiver start-port="1500" end-port="1501" manual-start="true" bind-address="localhost" hostname-for-senders="localhost" maximum-time-between-pings="60000" socket-buffer-size="32768"/>
+</cache>
diff --git a/geode-core/src/test/resources/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.multipleReceiversShouldThrowException[DTD].cache.xml b/geode-core/src/test/resources/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.multipleReceiversShouldThrowException[DTD].cache.xml
new file mode 100755
index 0000000000..1bc5ce060f
--- /dev/null
+++ b/geode-core/src/test/resources/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.multipleReceiversShouldThrowException[DTD].cache.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!DOCTYPE cache PUBLIC
+        "-//GemStone Systems, Inc.//GemFire Declarative Caching 8.0//EN"
+        "http://www.gemstone.com/dtd/cache8_0.dtd">
+<cache>
+  <gateway-receiver start-port="1500" end-port="1501"/>
+  <gateway-receiver start-port="2500" end-port="2501"/>
+</cache>
+
diff --git a/geode-core/src/test/resources/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.multipleReceiversShouldThrowException[XSD].cache.xml b/geode-core/src/test/resources/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.multipleReceiversShouldThrowException[XSD].cache.xml
new file mode 100755
index 0000000000..8b0fac892d
--- /dev/null
+++ b/geode-core/src/test/resources/org/apache/geode/internal/cache/wan/GatewayReceiverXmlParsingValidationsJUnitTest.multipleReceiversShouldThrowException[XSD].cache.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<cache
+        xmlns="http://geode.apache.org/schema/cache"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd"
+        version="1.0">
+
+    <gateway-receiver start-port="1500" end-port="1501"/>
+    <gateway-receiver start-port="2500" end-port="2501"/>
+</cache>
diff --git a/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewayReceiverFactoryImpl.java b/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewayReceiverFactoryImpl.java
index a5c09d354b..be2aeff9cd 100644
--- a/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewayReceiverFactoryImpl.java
+++ b/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewayReceiverFactoryImpl.java
@@ -110,6 +110,12 @@ public GatewayReceiver create() {
       throw new IllegalStateException(
           "Please specify either start port a value which is less than end port.");
     }
+
+    if ((this.cache.getGatewayReceivers() != null)
+        && (!this.cache.getGatewayReceivers().isEmpty())) {
+      throw new IllegalStateException("A Gateway Receiver already exists on this member.");
+    }
+
     GatewayReceiver recv = null;
     if (this.cache instanceof GemFireCacheImpl) {
       recv = new GatewayReceiverImpl(this.cache, this.startPort, this.endPort, this.timeBetPings,
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewayReceiverFactoryImplJUnitTest.java b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewayReceiverFactoryImplJUnitTest.java
new file mode 100644
index 0000000000..7b88477c07
--- /dev/null
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewayReceiverFactoryImplJUnitTest.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.cache.wan;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import org.apache.geode.cache.wan.GatewayReceiver;
+import org.apache.geode.cache.wan.GatewayTransportFilter;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.cache.xmlcache.CacheCreation;
+import org.apache.geode.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+@RunWith(Parameterized.class)
+public class GatewayReceiverFactoryImplJUnitTest {
+  @Parameterized.Parameter
+  public static InternalCache cache;
+  private GatewayReceiverFactoryImpl gatewayReceiverFactory;
+
+  @Parameterized.Parameters(name = "{0}")
+  public static Collection<InternalCache> cacheTypes() throws Exception {
+    InternalCache gemfireCacheImpl = spy(mock(GemFireCacheImpl.class, "GemFireCacheImpl"));
+    when(gemfireCacheImpl.getDistributedSystem()).thenReturn(mock(InternalDistributedSystem.class));
+
+    InternalCache declarativeCacheImpl = spy(mock(CacheCreation.class, "CacheCreation"));
+
+    return Arrays.asList(new InternalCache[] {gemfireCacheImpl, declarativeCacheImpl});
+  }
+
+  @Before
+  public void setUp() {
+    gatewayReceiverFactory = spy(new GatewayReceiverFactoryImpl(cache));
+    gatewayReceiverFactory.setManualStart(true);
+  }
+
+  @Test
+  public void createWithDefaultAttributes() {
+    GatewayReceiver receiver = gatewayReceiverFactory.create();
+
+    assertThat(receiver.isManualStart()).isTrue();
+    assertThat(receiver.getGatewayTransportFilters()).isEmpty();
+    assertThat(receiver.getEndPort()).isEqualTo(GatewayReceiver.DEFAULT_END_PORT);
+    assertThat(receiver.getStartPort()).isEqualTo(GatewayReceiver.DEFAULT_START_PORT);
+    assertThat(receiver.getBindAddress()).isEqualTo(GatewayReceiver.DEFAULT_BIND_ADDRESS);
+    assertThat(receiver.getSocketBufferSize())
+        .isEqualTo(GatewayReceiver.DEFAULT_SOCKET_BUFFER_SIZE);
+    assertThat(receiver.getHostnameForSenders())
+        .isEqualTo(GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS);
+    assertThat(receiver.getMaximumTimeBetweenPings())
+        .isEqualTo(GatewayReceiver.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS);
+
+    verify(cache, times(1)).addGatewayReceiver(receiver);
+  }
+
+  @Test
+  public void createWithCustomAttributes() {
+    int endPort = 2500;
+    int startPort = 1500;
+    int socketBufferSize = 128;
+    int timeoutBetweenPings = 1;
+    String bindAddress = "kaos";
+    String hostnameForSenders = "kaos.com";
+    GatewayTransportFilter gatewayTransportFilter = mock(GatewayTransportFilter.class);
+
+    gatewayReceiverFactory.setEndPort(endPort);
+    gatewayReceiverFactory.setStartPort(startPort);
+    gatewayReceiverFactory.setBindAddress(bindAddress);
+    gatewayReceiverFactory.setSocketBufferSize(socketBufferSize);
+    gatewayReceiverFactory.setHostnameForSenders(hostnameForSenders);
+    gatewayReceiverFactory.setMaximumTimeBetweenPings(timeoutBetweenPings);
+    gatewayReceiverFactory.addGatewayTransportFilter(gatewayTransportFilter);
+    GatewayReceiver receiver = gatewayReceiverFactory.create();
+
+    assertThat(receiver.isManualStart()).isTrue();
+    assertThat(receiver.getEndPort()).isEqualTo(endPort);
+    assertThat(receiver.getStartPort()).isEqualTo(startPort);
+    assertThat(receiver.getBindAddress()).isEqualTo(bindAddress);
+    assertThat(receiver.getGatewayTransportFilters()).isNotEmpty();
+    assertThat(receiver.getSocketBufferSize()).isEqualTo(socketBufferSize);
+    assertThat(receiver.getHostnameForSenders()).isEqualTo(hostnameForSenders);
+    assertThat(receiver.getMaximumTimeBetweenPings()).isEqualTo(timeoutBetweenPings);
+    assertThat(receiver.getGatewayTransportFilters()).contains(gatewayTransportFilter);
+
+    verify(cache, times(1)).addGatewayReceiver(receiver);
+  }
+
+  @Test(expected = IllegalStateException.class)
+  public void createShouldThrowExceptionWhenPortRangeIsInvalid() {
+    gatewayReceiverFactory.setEndPort(1400);
+    gatewayReceiverFactory.setStartPort(1500);
+    gatewayReceiverFactory.create();
+
+    fail("Exception should have been thrown: endPort < startPort.");
+  }
+
+  @Test(expected = IllegalStateException.class)
+  public void createShouldThrownExceptionWhenGatewayReceiverAlreadyExists() {
+    Set mockReceivers = new HashSet();
+    mockReceivers.add(mock(GatewayReceiver.class));
+    when(cache.getGatewayReceivers()).thenReturn(mockReceivers);
+    gatewayReceiverFactory.create();
+
+    fail("Exception should have been thrown: a GatewayReceiver already exists on this cache.");
+  }
+}
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/CreateGatewayReceiverCommandDUnitTest.java b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/CreateGatewayReceiverCommandDUnitTest.java
index d8d7fdeb8e..c9c6754d2e 100644
--- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/CreateGatewayReceiverCommandDUnitTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/CreateGatewayReceiverCommandDUnitTest.java
@@ -17,17 +17,13 @@
 import static org.apache.geode.distributed.ConfigurationProperties.BIND_ADDRESS;
 import static org.apache.geode.distributed.ConfigurationProperties.DISTRIBUTED_SYSTEM_ID;
 import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
-import static org.apache.geode.distributed.ConfigurationProperties.REMOTE_LOCATORS;
 import static org.apache.geode.distributed.ConfigurationProperties.SERVER_BIND_ADDRESS;
 import static org.apache.geode.internal.cache.wan.wancommand.WANCommandUtils.getMemberIdCallable;
 import static org.apache.geode.internal.cache.wan.wancommand.WANCommandUtils.verifyGatewayReceiverProfile;
 import static org.apache.geode.internal.cache.wan.wancommand.WANCommandUtils.verifyGatewayReceiverServerLocations;
 import static org.apache.geode.internal.cache.wan.wancommand.WANCommandUtils.verifyReceiverCreationWithAttributes;
 import static org.apache.geode.management.internal.cli.i18n.CliStrings.GROUP;
-import static org.apache.geode.test.dunit.Assert.assertEquals;
-import static org.apache.geode.test.dunit.Assert.assertTrue;
-import static org.apache.geode.test.dunit.Assert.fail;
-import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
+import static org.assertj.core.api.Assertions.assertThat;
 
 import java.net.InetAddress;
 import java.util.ArrayList;
@@ -39,13 +35,11 @@
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.wan.GatewayReceiver;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.net.SocketCreator;
-import org.apache.geode.management.cli.Result;
 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.TabularResultData;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
@@ -56,8 +50,8 @@
  */
 @Category(DistributedTest.class)
 public class CreateGatewayReceiverCommandDUnitTest {
-
-  private static final long serialVersionUID = 1L;
+  private MemberVM locatorSite1;
+  private MemberVM server1, server2, server3;
 
   @Rule
   public LocatorServerStartupRule locatorServerStartupRule = new LocatorServerStartupRule();
@@ -65,97 +59,126 @@
   @Rule
   public GfshCommandRule gfsh = new GfshCommandRule();
 
-  private MemberVM locatorSite1;
-  private MemberVM locatorSite2;
-  private MemberVM server1;
-  private MemberVM server2;
-  private MemberVM server3;
-
   @Before
   public void before() throws Exception {
     Properties props = new Properties();
     props.setProperty(DISTRIBUTED_SYSTEM_ID, "" + 1);
     locatorSite1 = locatorServerStartupRule.startLocatorVM(1, props);
 
-    props.setProperty(DISTRIBUTED_SYSTEM_ID, "" + 2);
-    props.setProperty(REMOTE_LOCATORS, "localhost[" + locatorSite1.getPort() + "]");
-    locatorSite2 = locatorServerStartupRule.startLocatorVM(2, props);
-
     // Connect Gfsh to locator.
     gfsh.connectAndVerify(locatorSite1);
   }
 
+  private String getHostName() throws Exception {
+    return SocketCreator.getLocalHost().getCanonicalHostName();
+  }
+
+  private String getBindAddress() throws Exception {
+    return InetAddress.getLocalHost().getHostAddress();
+  }
+
+  private MemberVM startServerWithGroups(int index, String groups, int locPort) throws Exception {
+    Properties props = new Properties();
+    props.setProperty(GROUPS, groups);
+    return locatorServerStartupRule.startServerVM(index, props, locPort);
+  }
+
   /**
-   * GatewayReceiver with all default attributes
+   * GatewayReceiver with given attributes. Error scenario where startPort is greater than endPort.
    */
   @Test
-  public void testCreateGatewayReceiverWithDefault() throws Exception {
+  public void testCreateGatewayReceiverErrorOnInvalidPortRange() throws Exception {
+    Integer locator1Port = locatorSite1.getPort();
+    server1 = locatorServerStartupRule.startServerVM(3, locator1Port);
+    server2 = locatorServerStartupRule.startServerVM(4, locator1Port);
+    server3 = locatorServerStartupRule.startServerVM(5, locator1Port);
 
+    String command =
+        CliStrings.CREATE_GATEWAYRECEIVER + " --" + CliStrings.CREATE_GATEWAYRECEIVER__BINDADDRESS
+            + "=localhost" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT + "=11000" + " --"
+            + CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT + "=10000" + " --"
+            + CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --"
+            + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000";
+    gfsh.executeAndAssertThat(command).statusIsSuccess()
+        .tableHasColumnWithExactValuesInAnyOrder("Member", "server-3", "server-4", "server-5")
+        .tableHasColumnWithExactValuesInAnyOrder("Status",
+            "ERROR: Please specify either start port a value which is less than end port.",
+            "ERROR: Please specify either start port a value which is less than end port.",
+            "ERROR: Please specify either start port a value which is less than end port.");
+  }
+
+  /**
+   * GatewayReceiver with given attributes. Error scenario where the user tries to create more than
+   * one receiver per member.
+   */
+  @Test
+  public void testCreateGatewayReceiverErrorWhenGatewayReceiverAlreadyExists() throws Exception {
     Integer locator1Port = locatorSite1.getPort();
+    server1 = locatorServerStartupRule.startServerVM(3, locator1Port);
+    server2 = locatorServerStartupRule.startServerVM(4, locator1Port);
+    server3 = locatorServerStartupRule.startServerVM(5, locator1Port);
+
+    // Initial Creation should succeed
+    String command =
+        CliStrings.CREATE_GATEWAYRECEIVER + " --" + CliStrings.CREATE_GATEWAYRECEIVER__BINDADDRESS
+            + "=localhost" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT + "=10000" + " --"
+            + CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT + "=11000" + " --"
+            + CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --"
+            + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000";
+    gfsh.executeAndAssertThat(command).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\"");
+
+    MemberVM.invokeInEveryMember(() -> {
+      verifyReceiverCreationWithAttributes(!GatewayReceiver.DEFAULT_MANUAL_START, 10000, 11000,
+          "localhost", 100000, 512000, null, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS);
+    }, server1, server2, server3);
+
+    // This should fail as there's already a gateway receiver created on the member.
+    gfsh.executeAndAssertThat(command).statusIsSuccess()
+        .tableHasColumnWithExactValuesInAnyOrder("Member", "server-3", "server-4", "server-5")
+        .tableHasColumnWithExactValuesInAnyOrder("Status",
+            "ERROR: A Gateway Receiver already exists on this member.",
+            "ERROR: A Gateway Receiver already exists on this member.",
+            "ERROR: A Gateway Receiver already exists on this member.");
+  }
 
-    // setup servers in Site #1
+  /**
+   * GatewayReceiver with all default attributes
+   */
+  @Test
+  public void testCreateGatewayReceiverWithDefault() throws Exception {
+    Integer locator1Port = locatorSite1.getPort();
     server1 = locatorServerStartupRule.startServerVM(3, locator1Port);
     server2 = locatorServerStartupRule.startServerVM(4, locator1Port);
     server3 = locatorServerStartupRule.startServerVM(5, locator1Port);
 
+    // Default attributes.
     String command = CliStrings.CREATE_GATEWAYRECEIVER;
-    executeCommandAndVerifyStatus(command, 3);
-
-    // if neither bind-address or hostname-for-senders is set, profile
+    gfsh.executeAndAssertThat(command).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\"");
+
+    // If neither bind-address or hostname-for-senders is set, profile
     // uses AcceptorImpl.getExternalAddress() to derive canonical hostname
     // when the Profile (and ServerLocation) are created
     String hostname = getHostName();
 
-    server1.invoke(() -> verifyGatewayReceiverProfile(hostname));
-    server2.invoke(() -> verifyGatewayReceiverProfile(hostname));
-    server3.invoke(() -> verifyGatewayReceiverProfile(hostname));
-
-    server1.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, hostname));
-    server2.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, hostname));
-    server3.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, hostname));
-
-    server1.invoke(() -> 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));
-    server2.invoke(() -> 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));
-    server3.invoke(() -> 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));
-  }
-
-  private String getHostName() throws Exception {
-    return SocketCreator.getLocalHost().getCanonicalHostName();
-  }
-
-  private String getBindAddress() throws Exception {
-    return InetAddress.getLocalHost().getHostAddress();
-  }
-
-  private void executeCommandAndVerifyStatus(String command, int numGatewayReceivers) {
-    CommandResult cmdResult = gfsh.executeCommand(command);
-    if (cmdResult != null) {
-      String strCmdResult = cmdResult.toString();
-      getLogWriter().info("testCreateGatewayReceiver stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(numGatewayReceivers, status.size());
-      // verify there is no error in the status
-      for (String stat : status) {
-        assertTrue("GatewayReceiver creation failed with: " + stat, !stat.contains("ERROR:"));
-      }
-    } else {
-      fail("testCreateGatewayReceiver failed as did not get CommandResult");
-    }
+    MemberVM.invokeInEveryMember(() -> {
+      verifyGatewayReceiverProfile(hostname);
+      verifyGatewayReceiverServerLocations(locator1Port, hostname);
+      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);
   }
 
   /**
@@ -163,10 +186,7 @@ private void executeCommandAndVerifyStatus(String command, int numGatewayReceive
    */
   @Test
   public void testCreateGatewayReceiver() throws Exception {
-
     Integer locator1Port = locatorSite1.getPort();
-
-    // setup servers in Site #1
     server1 = locatorServerStartupRule.startServerVM(3, locator1Port);
     server2 = locatorServerStartupRule.startServerVM(4, locator1Port);
     server3 = locatorServerStartupRule.startServerVM(5, locator1Port);
@@ -178,16 +198,17 @@ public void testCreateGatewayReceiver() throws Exception {
             + CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT + "=11000" + " --"
             + CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --"
             + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000";
-    executeCommandAndVerifyStatus(command, 3);
-
-    // cannot verify Profile/ServerLocation when manualStart is true
-
-    server1.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
-        100000, 512000, null, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
-    server2.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
-        100000, 512000, null, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
-    server3.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
-        100000, 512000, null, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
+    gfsh.executeAndAssertThat(command).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\"");
+
+    MemberVM.invokeInEveryMember(() -> {
+      verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost", 100000, 512000, null,
+          GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS);
+    }, server1, server2, server3);
   }
 
   /**
@@ -195,10 +216,7 @@ public void testCreateGatewayReceiver() throws Exception {
    */
   @Test
   public void testCreateGatewayReceiverWithHostnameForSenders() throws Exception {
-
     Integer locator1Port = locatorSite1.getPort();
-
-    // setup servers in Site #1
     server1 = locatorServerStartupRule.startServerVM(3, locator1Port);
     server2 = locatorServerStartupRule.startServerVM(4, locator1Port);
     server3 = locatorServerStartupRule.startServerVM(5, locator1Port);
@@ -211,23 +229,20 @@ public void testCreateGatewayReceiverWithHostnameForSenders() throws Exception {
             + " --" + CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT + "=11000" + " --"
             + CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --"
             + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000";
-    executeCommandAndVerifyStatus(command, 3);
-
-    // verify hostname-for-senders is used when configured
-    server1.invoke(() -> verifyGatewayReceiverProfile(hostnameForSenders));
-    server2.invoke(() -> verifyGatewayReceiverProfile(hostnameForSenders));
-    server3.invoke(() -> verifyGatewayReceiverProfile(hostnameForSenders));
-
-    server1.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, hostnameForSenders));
-    server2.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, hostnameForSenders));
-    server3.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, hostnameForSenders));
-
-    server1.invoke(() -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "", 100000,
-        512000, null, hostnameForSenders));
-    server2.invoke(() -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "", 100000,
-        512000, null, hostnameForSenders));
-    server3.invoke(() -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "", 100000,
-        512000, null, hostnameForSenders));
+    gfsh.executeAndAssertThat(command).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\"");
+
+    MemberVM.invokeInEveryMember(() -> {
+      // verify hostname-for-senders is used when configured
+      verifyGatewayReceiverProfile(hostnameForSenders);
+      verifyGatewayReceiverServerLocations(locator1Port, hostnameForSenders);
+      verifyReceiverCreationWithAttributes(true, 10000, 11000, "", 100000, 512000, null,
+          hostnameForSenders);
+    }, server1, server2, server3);
   }
 
   /**
@@ -235,48 +250,36 @@ public void testCreateGatewayReceiverWithHostnameForSenders() throws Exception {
    */
   @Test
   public void testCreateGatewayReceiverWithDefaultAndBindProperty() throws Exception {
-
+    String receiverGroup = "receiverGroup";
     Integer locator1Port = locatorSite1.getPort();
-
-    // setup servers in Site #1
     String expectedBindAddress = getBindAddress();
-    String receiverGroup = "receiverGroup";
 
     Properties props = new Properties();
-    props.setProperty(BIND_ADDRESS, expectedBindAddress);
     props.setProperty(GROUPS, receiverGroup);
+    props.setProperty(BIND_ADDRESS, expectedBindAddress);
 
     server1 = locatorServerStartupRule.startServerVM(3, props, locator1Port);
     server2 = locatorServerStartupRule.startServerVM(4, props, locator1Port);
     server3 = locatorServerStartupRule.startServerVM(5, props, locator1Port);
 
     String command = CliStrings.CREATE_GATEWAYRECEIVER + " --" + GROUP + "=" + receiverGroup;
-    executeCommandAndVerifyStatus(command, 3);
-
-    // verify bind-address used when provided as a gemfire property
-    server1.invoke(() -> verifyGatewayReceiverProfile(expectedBindAddress));
-    server2.invoke(() -> verifyGatewayReceiverProfile(expectedBindAddress));
-    server3.invoke(() -> verifyGatewayReceiverProfile(expectedBindAddress));
-
-    server1.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, expectedBindAddress));
-    server2.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, expectedBindAddress));
-    server3.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, expectedBindAddress));
-
-    server1.invoke(() -> 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));
-    server2.invoke(() -> 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));
-    server3.invoke(() -> 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));
+    gfsh.executeAndAssertThat(command).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\"");
+
+    MemberVM.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);
   }
 
   /**
@@ -284,48 +287,36 @@ public void testCreateGatewayReceiverWithDefaultAndBindProperty() throws Excepti
    */
   @Test
   public void testCreateGatewayReceiverWithDefaultsAndServerBindAddressProperty() throws Exception {
-
+    String receiverGroup = "receiverGroup";
     Integer locator1Port = locatorSite1.getPort();
-
-    // setup servers in Site #1
     String expectedBindAddress = getBindAddress();
-    String receiverGroup = "receiverGroup";
 
     Properties props = new Properties();
-    props.setProperty(SERVER_BIND_ADDRESS, expectedBindAddress);
     props.setProperty(GROUPS, receiverGroup);
+    props.setProperty(SERVER_BIND_ADDRESS, expectedBindAddress);
 
     server1 = locatorServerStartupRule.startServerVM(3, props, locator1Port);
     server2 = locatorServerStartupRule.startServerVM(4, props, locator1Port);
     server3 = locatorServerStartupRule.startServerVM(5, props, locator1Port);
 
     String command = CliStrings.CREATE_GATEWAYRECEIVER + " --" + GROUP + "=" + receiverGroup;
-    executeCommandAndVerifyStatus(command, 3);
-
-    // verify server-bind-address used if provided as a gemfire property
-    server1.invoke(() -> verifyGatewayReceiverProfile(expectedBindAddress));
-    server2.invoke(() -> verifyGatewayReceiverProfile(expectedBindAddress));
-    server3.invoke(() -> verifyGatewayReceiverProfile(expectedBindAddress));
-
-    server1.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, expectedBindAddress));
-    server2.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, expectedBindAddress));
-    server3.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, expectedBindAddress));
-
-    server1.invoke(() -> 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));
-    server2.invoke(() -> 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));
-    server3.invoke(() -> 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));
+    gfsh.executeAndAssertThat(command).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\"");
+
+    MemberVM.invokeInEveryMember(() -> {
+      // verify server-bind-address used if 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);
   }
 
   /**
@@ -334,74 +325,59 @@ public void testCreateGatewayReceiverWithDefaultsAndServerBindAddressProperty()
   @Test
   public void testCreateGatewayReceiverWithDefaultsAndMultipleBindAddressProperties()
       throws Exception {
-
-    Integer locator1Port = locatorSite1.getPort();
-
-    // setup servers in Site #1
     String extraBindAddress = "localhost";
-    String expectedBindAddress = getBindAddress();
     String receiverGroup = "receiverGroup";
+    Integer locator1Port = locatorSite1.getPort();
+    String expectedBindAddress = getBindAddress();
 
     Properties props = new Properties();
+    props.setProperty(GROUPS, receiverGroup);
     props.setProperty(BIND_ADDRESS, extraBindAddress);
     props.setProperty(SERVER_BIND_ADDRESS, expectedBindAddress);
-    props.setProperty(GROUPS, receiverGroup);
 
     server1 = locatorServerStartupRule.startServerVM(3, props, locator1Port);
     server2 = locatorServerStartupRule.startServerVM(4, props, locator1Port);
     server3 = locatorServerStartupRule.startServerVM(5, props, locator1Port);
 
     String command = CliStrings.CREATE_GATEWAYRECEIVER + " --" + GROUP + "=" + receiverGroup;
-    executeCommandAndVerifyStatus(command, 3);
-
-    // verify server-bind-address used if provided as a gemfire property
-    server1.invoke(() -> verifyGatewayReceiverProfile(expectedBindAddress));
-    server2.invoke(() -> verifyGatewayReceiverProfile(expectedBindAddress));
-    server3.invoke(() -> verifyGatewayReceiverProfile(expectedBindAddress));
-
-    server1.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, expectedBindAddress));
-    server2.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, expectedBindAddress));
-    server3.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, expectedBindAddress));
-
-    server1.invoke(() -> 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));
-    server2.invoke(() -> 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));
-    server3.invoke(() -> 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));
+    gfsh.executeAndAssertThat(command).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\"");
+
+    MemberVM.invokeInEveryMember(() -> {
+      // verify server-bind-address used if 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 hostnameForSenders
    */
   @Test
   public void testCreateGatewayReceiverWithHostnameForSendersAndServerBindAddressProperty()
       throws Exception {
-
+    String receiverGroup = "receiverGroup";
+    String hostnameForSenders = getHostName();
+    String serverBindAddress = getBindAddress();
     Integer locator1Port = locatorSite1.getPort();
 
-    // setup servers in Site #1
     Properties props = new Properties();
-    String serverBindAddress = getBindAddress();
-    String receiverGroup = "receiverGroup";
-    props.setProperty(SERVER_BIND_ADDRESS, serverBindAddress);
     props.setProperty(GROUPS, receiverGroup);
+    props.setProperty(SERVER_BIND_ADDRESS, serverBindAddress);
 
     server1 = locatorServerStartupRule.startServerVM(3, props, locator1Port);
     server2 = locatorServerStartupRule.startServerVM(4, props, locator1Port);
     server3 = locatorServerStartupRule.startServerVM(5, props, locator1Port);
 
-    String hostnameForSenders = getHostName();
     String command =
         CliStrings.CREATE_GATEWAYRECEIVER + " --" + CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART
             + "=false" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__HOSTNAMEFORSENDERS + "="
@@ -410,23 +386,20 @@ public void testCreateGatewayReceiverWithHostnameForSendersAndServerBindAddressP
             + CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --"
             + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000" + " --" + GROUP + "="
             + receiverGroup;
-    executeCommandAndVerifyStatus(command, 3);
-
-    // verify server-bind-address takes precedence over hostname-for-senders
-    server1.invoke(() -> verifyGatewayReceiverProfile(hostnameForSenders));
-    server2.invoke(() -> verifyGatewayReceiverProfile(hostnameForSenders));
-    server3.invoke(() -> verifyGatewayReceiverProfile(hostnameForSenders));
-
-    server1.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, hostnameForSenders));
-    server2.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, hostnameForSenders));
-    server3.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, hostnameForSenders));
-
-    server1.invoke(() -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "", 100000,
-        512000, null, hostnameForSenders));
-    server2.invoke(() -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "", 100000,
-        512000, null, hostnameForSenders));
-    server3.invoke(() -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "", 100000,
-        512000, null, hostnameForSenders));
+    gfsh.executeAndAssertThat(command).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\"");
+
+    MemberVM.invokeInEveryMember(() -> {
+      // verify server-bind-address takes precedence over hostname-for-senders
+      verifyGatewayReceiverProfile(hostnameForSenders);
+      verifyGatewayReceiverServerLocations(locator1Port, hostnameForSenders);
+      verifyReceiverCreationWithAttributes(true, 10000, 11000, "", 100000, 512000, null,
+          hostnameForSenders);
+    }, server1, server2, server3);
   }
 
   /**
@@ -435,21 +408,19 @@ public void testCreateGatewayReceiverWithHostnameForSendersAndServerBindAddressP
   @Test
   public void testCreateGatewayReceiverWithHostnameForSendersAndBindAddressProperty()
       throws Exception {
-
+    String receiverGroup = "receiverGroup";
+    String hostnameForSenders = getHostName();
     Integer locator1Port = locatorSite1.getPort();
+    String expectedBindAddress = getBindAddress();
 
-    // setup servers in Site #1
     Properties props = new Properties();
-    String expectedBindAddress = getBindAddress();
-    String receiverGroup = "receiverGroup";
-    props.setProperty(BIND_ADDRESS, expectedBindAddress);
     props.setProperty(GROUPS, receiverGroup);
+    props.setProperty(BIND_ADDRESS, expectedBindAddress);
 
     server1 = locatorServerStartupRule.startServerVM(3, props, locator1Port);
     server2 = locatorServerStartupRule.startServerVM(4, props, locator1Port);
     server3 = locatorServerStartupRule.startServerVM(5, props, locator1Port);
 
-    String hostnameForSenders = getHostName();
     String command =
         CliStrings.CREATE_GATEWAYRECEIVER + " --" + CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART
             + "=false" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__HOSTNAMEFORSENDERS + "="
@@ -458,22 +429,19 @@ public void testCreateGatewayReceiverWithHostnameForSendersAndBindAddressPropert
             + CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --"
             + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000" + " --" + GROUP + "="
             + receiverGroup;
-    executeCommandAndVerifyStatus(command, 3);
-
-    server1.invoke(() -> verifyGatewayReceiverProfile(hostnameForSenders));
-    server2.invoke(() -> verifyGatewayReceiverProfile(hostnameForSenders));
-    server3.invoke(() -> verifyGatewayReceiverProfile(hostnameForSenders));
-
-    server1.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, hostnameForSenders));
-    server2.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, hostnameForSenders));
-    server3.invoke(() -> verifyGatewayReceiverServerLocations(locator1Port, hostnameForSenders));
-
-    server1.invoke(() -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "", 100000,
-        512000, null, hostnameForSenders));
-    server2.invoke(() -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "", 100000,
-        512000, null, hostnameForSenders));
-    server3.invoke(() -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "", 100000,
-        512000, null, hostnameForSenders));
+    gfsh.executeAndAssertThat(command).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\"");
+
+    MemberVM.invokeInEveryMember(() -> {
+      verifyGatewayReceiverProfile(hostnameForSenders);
+      verifyGatewayReceiverServerLocations(locator1Port, hostnameForSenders);
+      verifyReceiverCreationWithAttributes(true, 10000, 11000, "", 100000, 512000, null,
+          hostnameForSenders);
+    }, server1, server2, server3);
   }
 
   /**
@@ -481,10 +449,7 @@ public void testCreateGatewayReceiverWithHostnameForSendersAndBindAddressPropert
    */
   @Test
   public void testCreateGatewayReceiverWithGatewayTransportFilter() throws Exception {
-
     Integer locator1Port = locatorSite1.getPort();
-
-    // setup servers in Site #1
     server1 = locatorServerStartupRule.startServerVM(3, locator1Port);
     server2 = locatorServerStartupRule.startServerVM(4, locator1Port);
     server3 = locatorServerStartupRule.startServerVM(5, locator1Port);
@@ -498,16 +463,19 @@ public void testCreateGatewayReceiverWithGatewayTransportFilter() throws Excepti
             + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000" + " --"
             + CliStrings.CREATE_GATEWAYRECEIVER__GATEWAYTRANSPORTFILTER
             + "=org.apache.geode.cache30.MyGatewayTransportFilter1";
-    executeCommandAndVerifyStatus(command, 3);
-    List<String> transportFilters = new ArrayList<String>();
+    gfsh.executeAndAssertThat(command).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\"");
+
+    List<String> transportFilters = new ArrayList<>();
     transportFilters.add("org.apache.geode.cache30.MyGatewayTransportFilter1");
-
-    server1.invoke(() -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "localhost",
-        100000, 512000, transportFilters, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
-    server2.invoke(() -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "localhost",
-        100000, 512000, transportFilters, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
-    server3.invoke(() -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "localhost",
-        100000, 512000, transportFilters, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
+    MemberVM.invokeInEveryMember(() -> {
+      verifyReceiverCreationWithAttributes(true, 10000, 11000, "localhost", 100000, 512000,
+          transportFilters, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS);
+    }, server1, server2, server3);
   }
 
   /**
@@ -515,10 +483,7 @@ public void testCreateGatewayReceiverWithGatewayTransportFilter() throws Excepti
    */
   @Test
   public void testCreateGatewayReceiverWithMultipleGatewayTransportFilters() throws Exception {
-
     Integer locator1Port = locatorSite1.getPort();
-
-    // setup servers in Site #1
     server1 = locatorServerStartupRule.startServerVM(3, locator1Port);
     server2 = locatorServerStartupRule.startServerVM(4, locator1Port);
     server3 = locatorServerStartupRule.startServerVM(5, locator1Port);
@@ -531,75 +496,34 @@ public void testCreateGatewayReceiverWithMultipleGatewayTransportFilters() throw
         + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000" + " --"
         + CliStrings.CREATE_GATEWAYRECEIVER__GATEWAYTRANSPORTFILTER
         + "=org.apache.geode.cache30.MyGatewayTransportFilter1,org.apache.geode.cache30.MyGatewayTransportFilter2";
-    executeCommandAndVerifyStatus(command, 3);
-    List<String> transportFilters = new ArrayList<String>();
+    gfsh.executeAndAssertThat(command).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\"");
+
+    List<String> transportFilters = new ArrayList<>();
     transportFilters.add("org.apache.geode.cache30.MyGatewayTransportFilter1");
     transportFilters.add("org.apache.geode.cache30.MyGatewayTransportFilter2");
 
-    server1.invoke(() -> verifyReceiverCreationWithAttributes(!GatewayReceiver.DEFAULT_MANUAL_START,
-        10000, 11000, "localhost", 100000, 512000, transportFilters,
-        GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
-    server2.invoke(() -> verifyReceiverCreationWithAttributes(!GatewayReceiver.DEFAULT_MANUAL_START,
-        10000, 11000, "localhost", 100000, 512000, transportFilters,
-        GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
-    server3.invoke(() -> verifyReceiverCreationWithAttributes(!GatewayReceiver.DEFAULT_MANUAL_START,
-        10000, 11000, "localhost", 100000, 512000, transportFilters,
-        GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
-  }
-
-  /**
-   * GatewayReceiver with given attributes. Error scenario where startPort is greater than endPort.
-   */
-  @Test
-  public void testCreateGatewayReceiver_Error() throws Exception {
-
-    Integer locator1Port = locatorSite1.getPort();
-
-    // setup servers in Site #1
-    server1 = locatorServerStartupRule.startServerVM(3, locator1Port);
-    server2 = locatorServerStartupRule.startServerVM(4, locator1Port);
-    server3 = locatorServerStartupRule.startServerVM(5, locator1Port);
-
-    String command =
-        CliStrings.CREATE_GATEWAYRECEIVER + " --" + CliStrings.CREATE_GATEWAYRECEIVER__BINDADDRESS
-            + "=localhost" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT + "=11000" + " --"
-            + CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT + "=10000" + " --"
-            + CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --"
-            + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000";
-    CommandResult cmdResult = gfsh.executeCommand(command);
-    if (cmdResult != null) {
-      String strCmdResult = cmdResult.toString();
-      getLogWriter().info("testCreateGatewayReceiver stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(3, status.size());
-
-      // verify there is no error in the status
-      for (String stat : status) {
-        assertTrue("GatewayReceiver creation should have failed", stat.contains("ERROR:"));
-      }
-    } else {
-      fail("testCreateGatewayReceiver failed as did not get CommandResult");
-    }
+    MemberVM.invokeInEveryMember(() -> {
+      verifyReceiverCreationWithAttributes(!GatewayReceiver.DEFAULT_MANUAL_START, 10000, 11000,
+          "localhost", 100000, 512000, transportFilters,
+          GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS);
+    }, server1, server2, server3);
   }
 
   /**
    * GatewayReceiver with given attributes on the given member.
    */
   @Test
-  public void testCreateGatewayReceiver_onMember() throws Exception {
-
+  public void testCreateGatewayReceiverOnSingleMember() throws Exception {
     Integer locator1Port = locatorSite1.getPort();
-
-    // setup servers in Site #1
     server1 = locatorServerStartupRule.startServerVM(3, locator1Port);
     server2 = locatorServerStartupRule.startServerVM(4, locator1Port);
     server3 = locatorServerStartupRule.startServerVM(5, locator1Port);
-
-    final DistributedMember server1Member =
-        (DistributedMember) server1.invoke(getMemberIdCallable());
+    final DistributedMember server1Member = server1.invoke(getMemberIdCallable());
 
     String command =
         CliStrings.CREATE_GATEWAYRECEIVER + " --" + CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART
@@ -609,46 +533,33 @@ public void testCreateGatewayReceiver_onMember() throws Exception {
             + CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --"
             + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000" + " --"
             + CliStrings.MEMBER + "=" + server1Member.getId();
-    CommandResult cmdResult = gfsh.executeCommand(command);
-    if (cmdResult != null) {
-      String strCmdResult = cmdResult.toString();
-      getLogWriter().info("testCreateGatewayReceiver stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(1, status.size());
-      // verify there is no error in the status
-      for (String stat : status) {
-        assertTrue("GatewayReceiver creation failed with: " + stat, !stat.contains("ERROR:"));
-      }
-    } else {
-      fail("testCreateGatewayReceiver failed as did not get CommandResult");
-    }
-
-    // cannot verify Profile/ServerLocation when manualStart is true
-
-    server1.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
-        100000, 512000, null, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
+    gfsh.executeAndAssertThat(command).statusIsSuccess()
+        .tableHasColumnWithExactValuesInAnyOrder("Member", "server-3")
+        .tableHasColumnWithValuesContaining("Status",
+            "GatewayReceiver created on member \"server-3\"");
+
+    MemberVM.invokeInEveryMember(() -> {
+      verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost", 100000, 512000, null,
+          GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS);
+    }, server1);
+
+    MemberVM.invokeInEveryMember(() -> {
+      Cache cache = LocatorServerStartupRule.getCache();
+      assertThat(cache.getGatewayReceivers()).isEmpty();
+    }, server2, server3);
   }
 
   /**
    * GatewayReceiver with given attributes on multiple members.
    */
   @Test
-  public void testCreateGatewayReceiver_onMultipleMembers() throws Exception {
-
+  public void testCreateGatewayReceiverOnMultipleMembers() throws Exception {
     Integer locator1Port = locatorSite1.getPort();
-
-    // setup servers in Site #1
     server1 = locatorServerStartupRule.startServerVM(3, locator1Port);
     server2 = locatorServerStartupRule.startServerVM(4, locator1Port);
     server3 = locatorServerStartupRule.startServerVM(5, locator1Port);
-
-    final DistributedMember server1Member =
-        (DistributedMember) server1.invoke(getMemberIdCallable());
-    final DistributedMember server2Member =
-        (DistributedMember) server2.invoke(getMemberIdCallable());
+    final DistributedMember server1Member = server1.invoke(getMemberIdCallable());
+    final DistributedMember server2Member = server2.invoke(getMemberIdCallable());
 
     String command =
         CliStrings.CREATE_GATEWAYRECEIVER + " --" + CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART
@@ -658,41 +569,30 @@ public void testCreateGatewayReceiver_onMultipleMembers() throws Exception {
             + CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --"
             + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000" + " --"
             + CliStrings.MEMBER + "=" + server1Member.getId() + "," + server2Member.getId();
-    CommandResult cmdResult = gfsh.executeCommand(command);
-    if (cmdResult != null) {
-      String strCmdResult = cmdResult.toString();
-      getLogWriter().info("testCreateGatewayReceiver stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(2, status.size());
-      // verify there is no error in the status
-      for (String stat : status) {
-        assertTrue("GatewayReceiver creation failed with: " + stat, !stat.contains("ERROR:"));
-      }
-    } else {
-      fail("testCreateGatewayReceiver failed as did not get CommandResult");
-    }
-
-    // cannot verify Profile/ServerLocation when manualStart is true
-
-    server1.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
-        100000, 512000, null, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
-    server2.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
-        100000, 512000, null, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
+    gfsh.executeAndAssertThat(command).statusIsSuccess()
+        .tableHasColumnWithExactValuesInAnyOrder("Member", "server-3", "server-4")
+        .tableHasColumnWithValuesContaining("Status",
+            "GatewayReceiver created on member \"server-3\"",
+            "GatewayReceiver created on member \"server-4\"");
+
+    MemberVM.invokeInEveryMember(() -> {
+      verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost", 100000, 512000, null,
+          GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS);
+    }, server1, server2);
+
+    MemberVM.invokeInEveryMember(() -> {
+      Cache cache = LocatorServerStartupRule.getCache();
+      assertThat(cache.getGatewayReceivers()).isEmpty();
+    }, server3);
   }
 
   /**
    * GatewayReceiver with given attributes on the given group.
    */
   @Test
-  public void testCreateGatewayReceiver_onGroup() throws Exception {
-
-    Integer locator1Port = locatorSite1.getPort();
-
-    // setup servers in Site #1
+  public void testCreateGatewayReceiverOnGroup() throws Exception {
     String groups = "receiverGroup1";
+    Integer locator1Port = locatorSite1.getPort();
     server1 = startServerWithGroups(3, groups, locator1Port);
     server2 = startServerWithGroups(4, groups, locator1Port);
     server3 = startServerWithGroups(5, groups, locator1Port);
@@ -705,31 +605,17 @@ public void testCreateGatewayReceiver_onGroup() throws Exception {
             + CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --"
             + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000" + " --" + GROUP
             + "=receiverGroup1";
-    CommandResult cmdResult = gfsh.executeCommand(command);
-    if (cmdResult != null) {
-      String strCmdResult = cmdResult.toString();
-      getLogWriter().info("testCreateGatewayReceiver stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(3, status.size());//
-      // verify there is no error in the status
-      for (String stat : status) {
-        assertTrue("GatewayReceiver creation failed with: " + stat, !stat.contains("ERROR:"));
-      }
-    } else {
-      fail("testCreateGatewayReceiver failed as did not get CommandResult");
-    }
-
-    // cannot verify Profile/ServerLocation when manualStart is true
-
-    server1.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
-        100000, 512000, null, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
-    server2.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
-        100000, 512000, null, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
-    server3.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
-        100000, 512000, null, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
+    gfsh.executeAndAssertThat(command).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\"");
+
+    MemberVM.invokeInEveryMember(() -> {
+      verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost", 100000, 512000, null,
+          GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS);
+    }, server1, server2, server3);
   }
 
   /**
@@ -737,13 +623,10 @@ public void testCreateGatewayReceiver_onGroup() throws Exception {
    * group.
    */
   @Test
-  public void testCreateGatewayReceiver_onGroup_Scenario2() throws Exception {
-
-    Integer locator1Port = locatorSite1.getPort();
-
-    // setup servers in Site #1
+  public void testCreateGatewayReceiverOnGroupScenario2() throws Exception {
     String group1 = "receiverGroup1";
     String group2 = "receiverGroup2";
+    Integer locator1Port = locatorSite1.getPort();
     server1 = startServerWithGroups(3, group1, locator1Port);
     server2 = startServerWithGroups(4, group1, locator1Port);
     server3 = startServerWithGroups(5, group2, locator1Port);
@@ -756,40 +639,29 @@ public void testCreateGatewayReceiver_onGroup_Scenario2() throws Exception {
             + CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --"
             + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000" + " --" + GROUP
             + "=receiverGroup1";
-    CommandResult cmdResult = gfsh.executeCommand(command);
-    if (cmdResult != null) {
-      String strCmdResult = cmdResult.toString();
-      getLogWriter().info("testCreateGatewayReceiver stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(2, status.size());//
-      // verify there is no error in the status
-      for (String stat : status) {
-        assertTrue("GatewayReceiver creation failed with: " + stat, !stat.contains("ERROR:"));
-      }
-    } else {
-      fail("testCreateGatewayReceiver failed as did not get CommandResult");
-    }
-
-    // cannot verify Profile/ServerLocation when manualStart is true
-
-    server1.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
-        100000, 512000, null, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
-    server2.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
-        100000, 512000, null, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
+    gfsh.executeAndAssertThat(command).statusIsSuccess()
+        .tableHasColumnWithExactValuesInAnyOrder("Member", "server-3", "server-4")
+        .tableHasColumnWithValuesContaining("Status",
+            "GatewayReceiver created on member \"server-3\"",
+            "GatewayReceiver created on member \"server-4\"");
+
+    MemberVM.invokeInEveryMember(() -> {
+      verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost", 100000, 512000, null,
+          GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS);
+    }, server1, server2);
+
+    MemberVM.invokeInEveryMember(() -> {
+      Cache cache = LocatorServerStartupRule.getCache();
+      assertThat(cache.getGatewayReceivers()).isEmpty();
+    }, server3);
   }
 
   /**
    * GatewayReceiver with given attributes on multiple groups.
    */
   @Test
-  public void testCreateGatewayReceiver_onMultipleGroups() throws Exception {
-
+  public void testCreateGatewayReceiverOnMultipleGroups() throws Exception {
     Integer locator1Port = locatorSite1.getPort();
-
-    // setup servers in Site #1
     server1 = startServerWithGroups(3, "receiverGroup1", locator1Port);
     server2 = startServerWithGroups(4, "receiverGroup1", locator1Port);
     server3 = startServerWithGroups(5, "receiverGroup2", locator1Port);
@@ -802,36 +674,16 @@ public void testCreateGatewayReceiver_onMultipleGroups() throws Exception {
             + CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --"
             + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000" + " --" + GROUP
             + "=receiverGroup1,receiverGroup2";
-    CommandResult cmdResult = gfsh.executeCommand(command);
-    if (cmdResult != null) {
-      String strCmdResult = cmdResult.toString();
-      getLogWriter().info("testCreateGatewayReceiver stringResult : " + strCmdResult + ">>>>");
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-
-      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
-      List<String> status = resultData.retrieveAllValues("Status");
-      assertEquals(3, status.size());//
-      // verify there is no error in the status
-      for (String stat : status) {
-        assertTrue("GatewayReceiver creation failed with: " + stat, !stat.contains("ERROR:"));
-      }
-    } else {
-      fail("testCreateGatewayReceiver failed as did not get CommandResult");
-    }
-
-    // cannot verify Profile/ServerLocation when manualStart is true
-
-    server1.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
-        100000, 512000, null, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
-    server2.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
-        100000, 512000, null, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
-    server3.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
-        100000, 512000, null, GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS));
-  }
-
-  private MemberVM startServerWithGroups(int index, String groups, int locPort) throws Exception {
-    Properties props = new Properties();
-    props.setProperty(GROUPS, groups);
-    return locatorServerStartupRule.startServerVM(index, props, locPort);
+    gfsh.executeAndAssertThat(command).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\"");
+
+    MemberVM.invokeInEveryMember(() -> {
+      verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost", 100000, 512000, null,
+          GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS);
+    }, server1, server2, server3);
   }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Enforce the uniqueness of a single gateway-receiver per member
> --------------------------------------------------------------
>
>                 Key: GEODE-3987
>                 URL: https://issues.apache.org/jira/browse/GEODE-3987
>             Project: Geode
>          Issue Type: Bug
>            Reporter: Juan José Ramos Cassella
>            Assignee: Juan José Ramos Cassella
>
> Within the documentation, both in [Configure Gateway Receivers|http://geode.apache.org/docs/guide/13/topologies_and_comm/multi_site_configuration/setting_up_a_multisite_system.html#setting_up_a_multisite_system__section_E3A44F85359046C7ADD12861D261637B] and [gfsh create gateway-receiver|http://geode.apache.org/docs/guide/13/tools_modules/gfsh/command-pages/create.html#topic_a4x_pb1_dk], we state that only one {{gateway-receiver}} is allowed per member. However, there is no enforcement of this rule within the code nor within the schema for the {{cache.xml}} file, so the user might end up having more than one {{gateway-receiver}} per host.
> It's unknown which {{gateway-receiver}} is going to be used after a restart, making it hard to configure firewall rules between clusters, if any. The following exception is also printed in the logs whenever we try to register (only the first one is succesfull) the MBean for the {{gateway-receiver}}:
> {noformat}
> [warning 2017/11/16 15:27:46.156 PST host1-server1 <Function Execution Processor1> tid=0x44] javax.management.InstanceAlreadyExistsException: GemFire:service=GatewayReceiver,type=Member,member=host1-server1
> org.apache.geode.management.ManagementException: javax.management.InstanceAlreadyExistsException: GemFire:service=GatewayReceiver,type=Member,member=host1-server1
> 	at org.apache.geode.management.internal.MBeanJMXAdapter.registerMBean(MBeanJMXAdapter.java:110)
> 	at org.apache.geode.management.internal.SystemManagementService.registerInternalMBean(SystemManagementService.java:368)
> 	at org.apache.geode.management.internal.beans.ManagementAdapter.createGatewayReceiverMBean(ManagementAdapter.java:471)
> 	at org.apache.geode.management.internal.beans.ManagementAdapter.handleGatewayReceiverStart(ManagementAdapter.java:493)
> 	at org.apache.geode.management.internal.beans.ManagementListener.handleEvent(ManagementListener.java:134)
> 	at org.apache.geode.distributed.internal.InternalDistributedSystem.notifyResourceEventListeners(InternalDistributedSystem.java:2175)
> 	at org.apache.geode.distributed.internal.InternalDistributedSystem.handleResourceEvent(InternalDistributedSystem.java:562)
> 	at org.apache.geode.internal.cache.wan.GatewayReceiverImpl.start(GatewayReceiverImpl.java:194)
> 	at org.apache.geode.internal.cache.wan.GatewayReceiverFactoryImpl.create(GatewayReceiverFactoryImpl.java:141)
> 	at org.apache.geode.management.internal.cli.functions.GatewayReceiverCreateFunction.createGatewayReceiver(GatewayReceiverCreateFunction.java:164)
> 	at org.apache.geode.management.internal.cli.functions.GatewayReceiverCreateFunction.execute(GatewayReceiverCreateFunction.java:63)
> 	at org.apache.geode.internal.cache.MemberFunctionStreamingMessage.process(MemberFunctionStreamingMessage.java:186)
> 	at org.apache.geode.distributed.internal.DistributionMessage.scheduleAction(DistributionMessage.java:374)
> 	at org.apache.geode.distributed.internal.DistributionMessage$1.run(DistributionMessage.java:440)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> 	at org.apache.geode.distributed.internal.DistributionManager.runUntilShutdown(DistributionManager.java:668)
> 	at org.apache.geode.distributed.internal.DistributionManager$9$1.run(DistributionManager.java:1114)
> 	at java.lang.Thread.run(Thread.java:745)
> Caused by: javax.management.InstanceAlreadyExistsException: GemFire:service=GatewayReceiver,type=Member,member=host1-server1
> 	at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437)
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898)
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966)
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900)
> 	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324)
> 	at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
> 	at org.apache.geode.management.internal.MBeanJMXAdapter.registerMBean(MBeanJMXAdapter.java:105)
> 	... 18 more
> {noformat}
> The fix implies:
> . Change the {{maxOccurs}} attribute from {{unbounded}} to {{1}} in the {{cache-1.0.xsd}} file.
> . Add the validation to the {{GatewayReceiverFactoryImpl.create()}} method, as this is the single entry point for {{GatewayReceiver}} instance creations.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message