[geode] 12/20: GEODE-9132: PartitionedRegionClearWithConcurrentOperationsDUnitTest cleanup 2

2022-03-07 Thread jinmeiliao
This is an automated email from the ASF dual-hosted git repository.

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

commit e3ef06166bea60459ec2ae33beca2e547af4224c
Author: Kirk Lund 
AuthorDate: Mon Apr 19 16:16:17 2021 -0700

GEODE-9132: PartitionedRegionClearWithConcurrentOperationsDUnitTest cleanup 
2
---
 ...gionClearWithConcurrentOperationsDUnitTest.java | 782 ++---
 1 file changed, 378 insertions(+), 404 deletions(-)

diff --git 
a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearWithConcurrentOperationsDUnitTest.java
 
b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearWithConcurrentOperationsDUnitTest.java
index c9a1e5b..b2aacc0 100644
--- 
a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearWithConcurrentOperationsDUnitTest.java
+++ 
b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearWithConcurrentOperationsDUnitTest.java
@@ -72,8 +72,6 @@ public class 
PartitionedRegionClearWithConcurrentOperationsDUnitTest implements
 
   private static final int BUCKETS = 13;
   private static final String REGION_NAME = "PartitionedRegion";
-  private static final String TEST_CASE_NAME =
-  "[{index}] {method}(Coordinator:{0}, RegionType:{1})";
 
   @Rule
   public DistributedRule distributedRule = new DistributedRule(3);
@@ -84,32 +82,6 @@ public class 
PartitionedRegionClearWithConcurrentOperationsDUnitTest implements
   private VM server2;
   private VM accessor;
 
-  @SuppressWarnings("unused")
-  static TestVM[] coordinators() {
-return new TestVM[] {
-TestVM.SERVER1, TestVM.ACCESSOR
-};
-  }
-
-  @SuppressWarnings("unused")
-  static Object[] coordinatorsAndRegionTypes() {
-List parameters = new ArrayList<>();
-RegionShortcut[] regionShortcuts = regionTypes();
-
-Arrays.stream(regionShortcuts).forEach(regionShortcut -> {
-  parameters.add(new Object[] {TestVM.SERVER1, regionShortcut});
-  parameters.add(new Object[] {TestVM.ACCESSOR, regionShortcut});
-});
-
-return parameters.toArray();
-  }
-
-  private static RegionShortcut[] regionTypes() {
-return new RegionShortcut[] {
-RegionShortcut.PARTITION, RegionShortcut.PARTITION_REDUNDANT
-};
-  }
-
   @Before
   public void setUp() throws Exception {
 server1 = getVM(TestVM.SERVER1.vmNumber);
@@ -117,127 +89,414 @@ public class 
PartitionedRegionClearWithConcurrentOperationsDUnitTest implements
 accessor = getVM(TestVM.ACCESSOR.vmNumber);
   }
 
-  private void initAccessor(RegionShortcut regionShortcut) {
-PartitionAttributes attrs = new 
PartitionAttributesFactory()
-.setTotalNumBuckets(BUCKETS)
-.setLocalMaxMemory(0)
-.create();
+  /**
+   * The test does the following (clear coordinator and regionType are 
parametrized):
+   * - Launches one thread per VM to continuously execute removes, puts and 
gets for a given time.
+   * - Clears the Partition Region continuously every X milliseconds for a 
given time.
+   * - Asserts that, after the clears have finished, the Region Buckets are 
consistent across
+   * members.
+   */
+  @Test
+  @Parameters({"SERVER1,PARTITION", "ACCESSOR,PARTITION",
+  "SERVER1,PARTITION_REDUNDANT", "ACCESSOR,PARTITION_REDUNDANT"})
+  @TestCaseName("[{index}] {method}(Coordinator:{0}, RegionType:{1})")
+  public void clearWithConcurrentPutGetRemoveShouldWorkCorrectly(TestVM 
coordinatorVM,
+  RegionShortcut regionShortcut) throws InterruptedException {
+parametrizedSetup(regionShortcut);
 
-cacheRule.getCache().createRegionFactory(regionShortcut)
-.setPartitionAttributes(attrs)
-.create(REGION_NAME);
+// Let all VMs continuously execute puts and gets for 60 seconds.
+final int workMillis = 6;
+final int entries = 15000;
+List> asyncInvocationList = Arrays.asList(
+server1.invokeAsync(() -> executePuts(entries, workMillis)),
+server2.invokeAsync(() -> executeGets(entries, workMillis)),
+accessor.invokeAsync(() -> executeRemoves(entries, workMillis)));
 
-  }
+// Clear the region every second for 60 seconds.
+getVM(coordinatorVM.vmNumber).invoke(() -> executeClears(workMillis, 
1000));
 
-  private void initDataStore(RegionShortcut regionShortcut) {
-PartitionAttributes attrs = new 
PartitionAttributesFactory()
-.setTotalNumBuckets(BUCKETS)
-.create();
+// Let asyncInvocations finish.
+for (AsyncInvocation asyncInvocation : asyncInvocationList) {
+  asyncInvocation.await();
+}
 
-cacheRule.getCache().createRegionFactory(regionShortcut)
-.setPartitionAttributes(attrs)
-.create(REGION_NAME);
+// Assert Region Buckets are consistent.
+asList(accessor, server1, server2).forEach(vm -> 
vm.invoke(this::waitForSilence));
+

[geode] 12/20: GEODE-9132: PartitionedRegionClearWithConcurrentOperationsDUnitTest cleanup 2

2022-03-07 Thread jinmeiliao
This is an automated email from the ASF dual-hosted git repository.

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

commit e3ef06166bea60459ec2ae33beca2e547af4224c
Author: Kirk Lund 
AuthorDate: Mon Apr 19 16:16:17 2021 -0700

GEODE-9132: PartitionedRegionClearWithConcurrentOperationsDUnitTest cleanup 
2
---
 ...gionClearWithConcurrentOperationsDUnitTest.java | 782 ++---
 1 file changed, 378 insertions(+), 404 deletions(-)

diff --git 
a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearWithConcurrentOperationsDUnitTest.java
 
b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearWithConcurrentOperationsDUnitTest.java
index c9a1e5b..b2aacc0 100644
--- 
a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearWithConcurrentOperationsDUnitTest.java
+++ 
b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearWithConcurrentOperationsDUnitTest.java
@@ -72,8 +72,6 @@ public class 
PartitionedRegionClearWithConcurrentOperationsDUnitTest implements
 
   private static final int BUCKETS = 13;
   private static final String REGION_NAME = "PartitionedRegion";
-  private static final String TEST_CASE_NAME =
-  "[{index}] {method}(Coordinator:{0}, RegionType:{1})";
 
   @Rule
   public DistributedRule distributedRule = new DistributedRule(3);
@@ -84,32 +82,6 @@ public class 
PartitionedRegionClearWithConcurrentOperationsDUnitTest implements
   private VM server2;
   private VM accessor;
 
-  @SuppressWarnings("unused")
-  static TestVM[] coordinators() {
-return new TestVM[] {
-TestVM.SERVER1, TestVM.ACCESSOR
-};
-  }
-
-  @SuppressWarnings("unused")
-  static Object[] coordinatorsAndRegionTypes() {
-List parameters = new ArrayList<>();
-RegionShortcut[] regionShortcuts = regionTypes();
-
-Arrays.stream(regionShortcuts).forEach(regionShortcut -> {
-  parameters.add(new Object[] {TestVM.SERVER1, regionShortcut});
-  parameters.add(new Object[] {TestVM.ACCESSOR, regionShortcut});
-});
-
-return parameters.toArray();
-  }
-
-  private static RegionShortcut[] regionTypes() {
-return new RegionShortcut[] {
-RegionShortcut.PARTITION, RegionShortcut.PARTITION_REDUNDANT
-};
-  }
-
   @Before
   public void setUp() throws Exception {
 server1 = getVM(TestVM.SERVER1.vmNumber);
@@ -117,127 +89,414 @@ public class 
PartitionedRegionClearWithConcurrentOperationsDUnitTest implements
 accessor = getVM(TestVM.ACCESSOR.vmNumber);
   }
 
-  private void initAccessor(RegionShortcut regionShortcut) {
-PartitionAttributes attrs = new 
PartitionAttributesFactory()
-.setTotalNumBuckets(BUCKETS)
-.setLocalMaxMemory(0)
-.create();
+  /**
+   * The test does the following (clear coordinator and regionType are 
parametrized):
+   * - Launches one thread per VM to continuously execute removes, puts and 
gets for a given time.
+   * - Clears the Partition Region continuously every X milliseconds for a 
given time.
+   * - Asserts that, after the clears have finished, the Region Buckets are 
consistent across
+   * members.
+   */
+  @Test
+  @Parameters({"SERVER1,PARTITION", "ACCESSOR,PARTITION",
+  "SERVER1,PARTITION_REDUNDANT", "ACCESSOR,PARTITION_REDUNDANT"})
+  @TestCaseName("[{index}] {method}(Coordinator:{0}, RegionType:{1})")
+  public void clearWithConcurrentPutGetRemoveShouldWorkCorrectly(TestVM 
coordinatorVM,
+  RegionShortcut regionShortcut) throws InterruptedException {
+parametrizedSetup(regionShortcut);
 
-cacheRule.getCache().createRegionFactory(regionShortcut)
-.setPartitionAttributes(attrs)
-.create(REGION_NAME);
+// Let all VMs continuously execute puts and gets for 60 seconds.
+final int workMillis = 6;
+final int entries = 15000;
+List> asyncInvocationList = Arrays.asList(
+server1.invokeAsync(() -> executePuts(entries, workMillis)),
+server2.invokeAsync(() -> executeGets(entries, workMillis)),
+accessor.invokeAsync(() -> executeRemoves(entries, workMillis)));
 
-  }
+// Clear the region every second for 60 seconds.
+getVM(coordinatorVM.vmNumber).invoke(() -> executeClears(workMillis, 
1000));
 
-  private void initDataStore(RegionShortcut regionShortcut) {
-PartitionAttributes attrs = new 
PartitionAttributesFactory()
-.setTotalNumBuckets(BUCKETS)
-.create();
+// Let asyncInvocations finish.
+for (AsyncInvocation asyncInvocation : asyncInvocationList) {
+  asyncInvocation.await();
+}
 
-cacheRule.getCache().createRegionFactory(regionShortcut)
-.setPartitionAttributes(attrs)
-.create(REGION_NAME);
+// Assert Region Buckets are consistent.
+asList(accessor, server1, server2).forEach(vm -> 
vm.invoke(this::waitForSilence));
+

[geode] 12/20: GEODE-9132: PartitionedRegionClearWithConcurrentOperationsDUnitTest cleanup 2

2022-03-07 Thread jinmeiliao
This is an automated email from the ASF dual-hosted git repository.

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

commit e3ef06166bea60459ec2ae33beca2e547af4224c
Author: Kirk Lund 
AuthorDate: Mon Apr 19 16:16:17 2021 -0700

GEODE-9132: PartitionedRegionClearWithConcurrentOperationsDUnitTest cleanup 
2
---
 ...gionClearWithConcurrentOperationsDUnitTest.java | 782 ++---
 1 file changed, 378 insertions(+), 404 deletions(-)

diff --git 
a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearWithConcurrentOperationsDUnitTest.java
 
b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearWithConcurrentOperationsDUnitTest.java
index c9a1e5b..b2aacc0 100644
--- 
a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearWithConcurrentOperationsDUnitTest.java
+++ 
b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearWithConcurrentOperationsDUnitTest.java
@@ -72,8 +72,6 @@ public class 
PartitionedRegionClearWithConcurrentOperationsDUnitTest implements
 
   private static final int BUCKETS = 13;
   private static final String REGION_NAME = "PartitionedRegion";
-  private static final String TEST_CASE_NAME =
-  "[{index}] {method}(Coordinator:{0}, RegionType:{1})";
 
   @Rule
   public DistributedRule distributedRule = new DistributedRule(3);
@@ -84,32 +82,6 @@ public class 
PartitionedRegionClearWithConcurrentOperationsDUnitTest implements
   private VM server2;
   private VM accessor;
 
-  @SuppressWarnings("unused")
-  static TestVM[] coordinators() {
-return new TestVM[] {
-TestVM.SERVER1, TestVM.ACCESSOR
-};
-  }
-
-  @SuppressWarnings("unused")
-  static Object[] coordinatorsAndRegionTypes() {
-List parameters = new ArrayList<>();
-RegionShortcut[] regionShortcuts = regionTypes();
-
-Arrays.stream(regionShortcuts).forEach(regionShortcut -> {
-  parameters.add(new Object[] {TestVM.SERVER1, regionShortcut});
-  parameters.add(new Object[] {TestVM.ACCESSOR, regionShortcut});
-});
-
-return parameters.toArray();
-  }
-
-  private static RegionShortcut[] regionTypes() {
-return new RegionShortcut[] {
-RegionShortcut.PARTITION, RegionShortcut.PARTITION_REDUNDANT
-};
-  }
-
   @Before
   public void setUp() throws Exception {
 server1 = getVM(TestVM.SERVER1.vmNumber);
@@ -117,127 +89,414 @@ public class 
PartitionedRegionClearWithConcurrentOperationsDUnitTest implements
 accessor = getVM(TestVM.ACCESSOR.vmNumber);
   }
 
-  private void initAccessor(RegionShortcut regionShortcut) {
-PartitionAttributes attrs = new 
PartitionAttributesFactory()
-.setTotalNumBuckets(BUCKETS)
-.setLocalMaxMemory(0)
-.create();
+  /**
+   * The test does the following (clear coordinator and regionType are 
parametrized):
+   * - Launches one thread per VM to continuously execute removes, puts and 
gets for a given time.
+   * - Clears the Partition Region continuously every X milliseconds for a 
given time.
+   * - Asserts that, after the clears have finished, the Region Buckets are 
consistent across
+   * members.
+   */
+  @Test
+  @Parameters({"SERVER1,PARTITION", "ACCESSOR,PARTITION",
+  "SERVER1,PARTITION_REDUNDANT", "ACCESSOR,PARTITION_REDUNDANT"})
+  @TestCaseName("[{index}] {method}(Coordinator:{0}, RegionType:{1})")
+  public void clearWithConcurrentPutGetRemoveShouldWorkCorrectly(TestVM 
coordinatorVM,
+  RegionShortcut regionShortcut) throws InterruptedException {
+parametrizedSetup(regionShortcut);
 
-cacheRule.getCache().createRegionFactory(regionShortcut)
-.setPartitionAttributes(attrs)
-.create(REGION_NAME);
+// Let all VMs continuously execute puts and gets for 60 seconds.
+final int workMillis = 6;
+final int entries = 15000;
+List> asyncInvocationList = Arrays.asList(
+server1.invokeAsync(() -> executePuts(entries, workMillis)),
+server2.invokeAsync(() -> executeGets(entries, workMillis)),
+accessor.invokeAsync(() -> executeRemoves(entries, workMillis)));
 
-  }
+// Clear the region every second for 60 seconds.
+getVM(coordinatorVM.vmNumber).invoke(() -> executeClears(workMillis, 
1000));
 
-  private void initDataStore(RegionShortcut regionShortcut) {
-PartitionAttributes attrs = new 
PartitionAttributesFactory()
-.setTotalNumBuckets(BUCKETS)
-.create();
+// Let asyncInvocations finish.
+for (AsyncInvocation asyncInvocation : asyncInvocationList) {
+  asyncInvocation.await();
+}
 
-cacheRule.getCache().createRegionFactory(regionShortcut)
-.setPartitionAttributes(attrs)
-.create(REGION_NAME);
+// Assert Region Buckets are consistent.
+asList(accessor, server1, server2).forEach(vm -> 
vm.invoke(this::waitForSilence));
+

[geode] 12/20: GEODE-9132: PartitionedRegionClearWithConcurrentOperationsDUnitTest cleanup 2

2022-03-07 Thread jinmeiliao
This is an automated email from the ASF dual-hosted git repository.

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

commit e3ef06166bea60459ec2ae33beca2e547af4224c
Author: Kirk Lund 
AuthorDate: Mon Apr 19 16:16:17 2021 -0700

GEODE-9132: PartitionedRegionClearWithConcurrentOperationsDUnitTest cleanup 
2
---
 ...gionClearWithConcurrentOperationsDUnitTest.java | 782 ++---
 1 file changed, 378 insertions(+), 404 deletions(-)

diff --git 
a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearWithConcurrentOperationsDUnitTest.java
 
b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearWithConcurrentOperationsDUnitTest.java
index c9a1e5b..b2aacc0 100644
--- 
a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearWithConcurrentOperationsDUnitTest.java
+++ 
b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearWithConcurrentOperationsDUnitTest.java
@@ -72,8 +72,6 @@ public class 
PartitionedRegionClearWithConcurrentOperationsDUnitTest implements
 
   private static final int BUCKETS = 13;
   private static final String REGION_NAME = "PartitionedRegion";
-  private static final String TEST_CASE_NAME =
-  "[{index}] {method}(Coordinator:{0}, RegionType:{1})";
 
   @Rule
   public DistributedRule distributedRule = new DistributedRule(3);
@@ -84,32 +82,6 @@ public class 
PartitionedRegionClearWithConcurrentOperationsDUnitTest implements
   private VM server2;
   private VM accessor;
 
-  @SuppressWarnings("unused")
-  static TestVM[] coordinators() {
-return new TestVM[] {
-TestVM.SERVER1, TestVM.ACCESSOR
-};
-  }
-
-  @SuppressWarnings("unused")
-  static Object[] coordinatorsAndRegionTypes() {
-List parameters = new ArrayList<>();
-RegionShortcut[] regionShortcuts = regionTypes();
-
-Arrays.stream(regionShortcuts).forEach(regionShortcut -> {
-  parameters.add(new Object[] {TestVM.SERVER1, regionShortcut});
-  parameters.add(new Object[] {TestVM.ACCESSOR, regionShortcut});
-});
-
-return parameters.toArray();
-  }
-
-  private static RegionShortcut[] regionTypes() {
-return new RegionShortcut[] {
-RegionShortcut.PARTITION, RegionShortcut.PARTITION_REDUNDANT
-};
-  }
-
   @Before
   public void setUp() throws Exception {
 server1 = getVM(TestVM.SERVER1.vmNumber);
@@ -117,127 +89,414 @@ public class 
PartitionedRegionClearWithConcurrentOperationsDUnitTest implements
 accessor = getVM(TestVM.ACCESSOR.vmNumber);
   }
 
-  private void initAccessor(RegionShortcut regionShortcut) {
-PartitionAttributes attrs = new 
PartitionAttributesFactory()
-.setTotalNumBuckets(BUCKETS)
-.setLocalMaxMemory(0)
-.create();
+  /**
+   * The test does the following (clear coordinator and regionType are 
parametrized):
+   * - Launches one thread per VM to continuously execute removes, puts and 
gets for a given time.
+   * - Clears the Partition Region continuously every X milliseconds for a 
given time.
+   * - Asserts that, after the clears have finished, the Region Buckets are 
consistent across
+   * members.
+   */
+  @Test
+  @Parameters({"SERVER1,PARTITION", "ACCESSOR,PARTITION",
+  "SERVER1,PARTITION_REDUNDANT", "ACCESSOR,PARTITION_REDUNDANT"})
+  @TestCaseName("[{index}] {method}(Coordinator:{0}, RegionType:{1})")
+  public void clearWithConcurrentPutGetRemoveShouldWorkCorrectly(TestVM 
coordinatorVM,
+  RegionShortcut regionShortcut) throws InterruptedException {
+parametrizedSetup(regionShortcut);
 
-cacheRule.getCache().createRegionFactory(regionShortcut)
-.setPartitionAttributes(attrs)
-.create(REGION_NAME);
+// Let all VMs continuously execute puts and gets for 60 seconds.
+final int workMillis = 6;
+final int entries = 15000;
+List> asyncInvocationList = Arrays.asList(
+server1.invokeAsync(() -> executePuts(entries, workMillis)),
+server2.invokeAsync(() -> executeGets(entries, workMillis)),
+accessor.invokeAsync(() -> executeRemoves(entries, workMillis)));
 
-  }
+// Clear the region every second for 60 seconds.
+getVM(coordinatorVM.vmNumber).invoke(() -> executeClears(workMillis, 
1000));
 
-  private void initDataStore(RegionShortcut regionShortcut) {
-PartitionAttributes attrs = new 
PartitionAttributesFactory()
-.setTotalNumBuckets(BUCKETS)
-.create();
+// Let asyncInvocations finish.
+for (AsyncInvocation asyncInvocation : asyncInvocationList) {
+  asyncInvocation.await();
+}
 
-cacheRule.getCache().createRegionFactory(regionShortcut)
-.setPartitionAttributes(attrs)
-.create(REGION_NAME);
+// Assert Region Buckets are consistent.
+asList(accessor, server1, server2).forEach(vm -> 
vm.invoke(this::waitForSilence));
+