geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jche...@apache.org
Subject [geode] branch feature/GEODE-6273 updated: Add multiple server group to mapping command
Date Thu, 24 Jan 2019 00:57:41 GMT
This is an automated email from the ASF dual-hosted git repository.

jchen21 pushed a commit to branch feature/GEODE-6273
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/feature/GEODE-6273 by this push:
     new 6435e2f  Add multiple server group to mapping command
6435e2f is described below

commit 6435e2f8deef9695131aa3d3e53f81fe7e82e25a
Author: Jianxia Chen <jchen@pivotal.io>
AuthorDate: Wed Jan 23 16:57:01 2019 -0800

    Add multiple server group to mapping command
    
    Co-authored-by: Ben Ross <bross@pivotal.io>
    Co-authored-by: Jianxia Chen <jchen@pivotal.io>
---
 .../cli/CreateMappingCommandDUnitTest.java         | 117 ++++++++++++---------
 1 file changed, 69 insertions(+), 48 deletions(-)

diff --git a/geode-connectors/src/distributedTest/java/org/apache/geode/connectors/jdbc/internal/cli/CreateMappingCommandDUnitTest.java
b/geode-connectors/src/distributedTest/java/org/apache/geode/connectors/jdbc/internal/cli/CreateMappingCommandDUnitTest.java
index 5552e82..9d77034 100644
--- a/geode-connectors/src/distributedTest/java/org/apache/geode/connectors/jdbc/internal/cli/CreateMappingCommandDUnitTest.java
+++ b/geode-connectors/src/distributedTest/java/org/apache/geode/connectors/jdbc/internal/cli/CreateMappingCommandDUnitTest.java
@@ -62,6 +62,7 @@ public class CreateMappingCommandDUnitTest {
   private static final String TEST_REGION = "testRegion";
   private static final String GROUP1_REGION = "group1Region";
   private static final String GROUP2_REGION = "group2Region";
+  private static final String GROUP1_GROUP2_REGION = "group1Group2Region";
   private static final String TEST_GROUP1 = "testGroup1";
   private static final String TEST_GROUP2 = "testGroup2";
 
@@ -238,26 +239,12 @@ public class CreateMappingCommandDUnitTest {
     // TEST_GROUP1 only contains server2 and server 4
     server2.invoke(() -> {
       RegionMapping mapping = getRegionMappingFromService(regionName);
-      assertThat(mapping.getDataSourceName()).isEqualTo("connection");
-      assertThat(mapping.getTableName()).isEqualTo("myTable");
-      assertThat(mapping.getPdxName()).isEqualTo("myPdxClass");
-      assertThat(mapping.getIds()).isEqualTo("myId");
-      assertThat(mapping.getCatalog()).isEqualTo("myCatalog");
-      assertThat(mapping.getSchema()).isEqualTo("mySchema");
-      validateRegionAlteredOnServer(regionName, false);
-      validateAsyncEventQueueCreatedOnServer(regionName, false);
+      assertValidMapping(mapping, regionName, false, false);
     });
 
     server4.invoke(() -> {
       RegionMapping mapping = getRegionMappingFromService(regionName);
-      assertThat(mapping.getDataSourceName()).isEqualTo("connection");
-      assertThat(mapping.getTableName()).isEqualTo("myTable");
-      assertThat(mapping.getPdxName()).isEqualTo("myPdxClass");
-      assertThat(mapping.getIds()).isEqualTo("myId");
-      assertThat(mapping.getCatalog()).isEqualTo("myCatalog");
-      assertThat(mapping.getSchema()).isEqualTo("mySchema");
-      validateRegionAlteredOnServer(regionName, false);
-      validateAsyncEventQueueCreatedOnServer(regionName, false);
+      assertValidMapping(mapping, regionName, false,false);
     });
 
     server1.invoke(() -> {
@@ -303,26 +290,12 @@ public class CreateMappingCommandDUnitTest {
     // TEST_GROUP2 only contains server3 and server4
     server3.invoke(() -> {
       RegionMapping mapping = getRegionMappingFromService(regionName);
-      assertThat(mapping.getDataSourceName()).isEqualTo("connection");
-      assertThat(mapping.getTableName()).isEqualTo("myTable");
-      assertThat(mapping.getPdxName()).isEqualTo("myPdxClass");
-      assertThat(mapping.getIds()).isEqualTo("myId");
-      assertThat(mapping.getCatalog()).isEqualTo("myCatalog");
-      assertThat(mapping.getSchema()).isEqualTo("mySchema");
-      validateRegionAlteredOnServer(regionName, false);
-      validateAsyncEventQueueCreatedOnServer(regionName, true);
+      assertValidMapping(mapping, regionName, false, true);
     });
 
     server4.invoke(() -> {
       RegionMapping mapping = getRegionMappingFromService(regionName);
-      assertThat(mapping.getDataSourceName()).isEqualTo("connection");
-      assertThat(mapping.getTableName()).isEqualTo("myTable");
-      assertThat(mapping.getPdxName()).isEqualTo("myPdxClass");
-      assertThat(mapping.getIds()).isEqualTo("myId");
-      assertThat(mapping.getCatalog()).isEqualTo("myCatalog");
-      assertThat(mapping.getSchema()).isEqualTo("mySchema");
-      validateRegionAlteredOnServer(regionName, false);
-      validateAsyncEventQueueCreatedOnServer(regionName, true);
+      assertValidMapping(mapping, regionName, false, true);
     });
 
     server1.invoke(() -> {
@@ -349,6 +322,68 @@ public class CreateMappingCommandDUnitTest {
   }
 
   @Test
+  @Parameters({GROUP1_GROUP2_REGION, "/" + GROUP1_GROUP2_REGION})
+  public void createMappingReplicatedUpdatesServiceAndClusterConfigForMultiServerGroup(
+          String regionName) {
+    setupGroupReplicate(regionName, TEST_GROUP1 + "," + TEST_GROUP2);
+    CommandStringBuilder csb = new CommandStringBuilder(CREATE_MAPPING);
+    csb.addOption(REGION_NAME, regionName);
+    csb.addOption(DATA_SOURCE_NAME, "connection");
+    csb.addOption(TABLE_NAME, "myTable");
+    csb.addOption(PDX_NAME, "myPdxClass");
+    csb.addOption(ID_NAME, "myId");
+    csb.addOption(CATALOG_NAME, "myCatalog");
+    csb.addOption(SCHEMA_NAME, "mySchema");
+    csb.addOption(GROUP_NAME, TEST_GROUP1 + "," + TEST_GROUP2);
+
+    gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
+
+    // TEST_GROUP1 and TEST_GROUP2 only contains server 2, server 3, and server 4
+    server2.invoke(() -> {
+      RegionMapping mapping = getRegionMappingFromService(regionName);
+      assertValidMapping(mapping, regionName, false, false);
+    });
+
+    server3.invoke(() -> {
+      RegionMapping mapping = getRegionMappingFromService(regionName);
+      assertValidMapping(mapping, regionName, false, false);
+    });
+
+    server4.invoke(() -> {
+      RegionMapping mapping = getRegionMappingFromService(regionName);
+      assertValidMapping(mapping, regionName, false, false);
+    });
+
+    server1.invoke(() -> {
+      RegionMapping mapping = getRegionMappingFromService(regionName);
+      assertThat(mapping).isNull();
+    });
+
+    locator.invoke(() -> {
+      RegionMapping regionMapping = getRegionMappingFromClusterConfig(regionName, TEST_GROUP1);
+      assertThat(regionMapping.getDataSourceName()).isEqualTo("connection");
+      assertThat(regionMapping.getTableName()).isEqualTo("myTable");
+      assertThat(regionMapping.getPdxName()).isEqualTo("myPdxClass");
+      assertThat(regionMapping.getIds()).isEqualTo("myId");
+      assertThat(regionMapping.getCatalog()).isEqualTo("myCatalog");
+      assertThat(regionMapping.getSchema()).isEqualTo("mySchema");
+      validateRegionAlteredInClusterConfig(regionName, TEST_GROUP1, false);
+      validateAsyncEventQueueCreatedInClusterConfig(regionName, TEST_GROUP1, false);
+    });
+  }
+
+  private static void assertValidMapping(RegionMapping mapping, String regionName, boolean
synchronous, boolean isParallel) {
+    assertThat(mapping.getDataSourceName()).isEqualTo("connection");
+    assertThat(mapping.getTableName()).isEqualTo("myTable");
+    assertThat(mapping.getPdxName()).isEqualTo("myPdxClass");
+    assertThat(mapping.getIds()).isEqualTo("myId");
+    assertThat(mapping.getCatalog()).isEqualTo("myCatalog");
+    assertThat(mapping.getSchema()).isEqualTo("mySchema");
+    validateRegionAlteredOnServer(regionName, synchronous);
+    validateAsyncEventQueueCreatedOnServer(regionName, isParallel);
+  }
+
+  @Test
   @Parameters({TEST_REGION, "/" + TEST_REGION})
   public void createMappingUpdatesServiceAndClusterConfig(String regionName) {
     setupReplicate(regionName);
@@ -365,28 +400,14 @@ public class CreateMappingCommandDUnitTest {
 
     server1.invoke(() -> {
       RegionMapping mapping = getRegionMappingFromService(regionName);
-      assertThat(mapping.getDataSourceName()).isEqualTo("connection");
-      assertThat(mapping.getTableName()).isEqualTo("myTable");
-      assertThat(mapping.getPdxName()).isEqualTo("myPdxClass");
-      assertThat(mapping.getIds()).isEqualTo("myId");
-      assertThat(mapping.getCatalog()).isEqualTo("myCatalog");
-      assertThat(mapping.getSchema()).isEqualTo("mySchema");
-      validateRegionAlteredOnServer(regionName, false);
-      validateAsyncEventQueueCreatedOnServer(regionName, false);
+      assertValidMapping(mapping, regionName, false, false);
     });
 
     // without specifying 'group/groups', the region and regionmapping will be created on
all
     // servers
     server2.invoke(() -> {
       RegionMapping mapping = getRegionMappingFromService(regionName);
-      assertThat(mapping.getDataSourceName()).isEqualTo("connection");
-      assertThat(mapping.getTableName()).isEqualTo("myTable");
-      assertThat(mapping.getPdxName()).isEqualTo("myPdxClass");
-      assertThat(mapping.getIds()).isEqualTo("myId");
-      assertThat(mapping.getCatalog()).isEqualTo("myCatalog");
-      assertThat(mapping.getSchema()).isEqualTo("mySchema");
-      validateRegionAlteredOnServer(regionName, false);
-      validateAsyncEventQueueCreatedOnServer(regionName, false);
+      assertValidMapping(mapping, regionName, false, false);
     });
 
     locator.invoke(() -> {


Mime
View raw message