@Test
  public void testGrabBackupBuckets() throws Exception {
    redundantCopies = 1;

    datastoreVM0.invoke(() -> createPRsAndAwaitRecovery(200, redundantCopies, totalNumBuckets));

    // Do put operations on these 2 PRs asynchronously (this test does not currently do this)

    try (IgnoredException ie = addIgnoredException(PartitionedRegionStorageException.class)) {
      datastoreVM0.invoke(this::putsInDatastoreVM0);
    }

    // At this point redundancy criterion is not meet.
    // now if we create PRs on more VMs, it should create those "supposed to
    // be redundant" buckets on these nodes, if it can accommodate the data
    // (localMaxMemory>0).
    datastoreVM2.invoke(() -> createPRsAndAwaitRecovery(200, redundantCopies, totalNumBuckets));

    datastoreVM0.invoke(this::putsInDatastoreVM0);

    accessorVM3.invoke(() -> {
      Cache cache = getCache();
      for (int i = 0; i < numberOfRegions; i++) {
        String regionName = prNamePrefix + i;
        createPartitionedRegion(cache, regionName, 0, redundantCopies, totalNumBuckets);
      }
    });

    for (int i = 0; i < numberOfRegions; i++) {
      final int whichRegion = i;

      int vm2LBRsize =
          (Integer) datastoreVM2.invoke(() -> validateLocalBucket2RegionMapSize(whichRegion));
      int vm3LBRsize =
          (Integer) accessorVM3.invoke(() -> validateLocalBucket2RegionMapSize(whichRegion));

      // This would mean that up coming node didn't pick up any buckets
      assertThat(vm2LBRsize).isGreaterThan(0);

      // This accessor should NOT have picked up any buckets.
      assertThat(vm3LBRsize).isEqualTo(0);

      int vm2B2Nsize = (Integer) datastoreVM2.invoke(() -> validateBucketsOnNode(whichRegion));
      assertThat(vm2LBRsize).isEqualTo(vm2B2Nsize);
    }
  }
Test to ensure that we have proper bucket failover, with no data loss, in the face of
sequential cache.close() events.
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionHADUnitTest.java