@Test
  public void testColocatedPRsRecoveryOneMemberLater() throws Exception {
    for (VM vm : toArray(vm0, vm1, vm2)) {
      vm.invoke(() -> {
        createCache();
        createDiskStore(diskStoreName1);
        createPR_withPersistence(regionName, diskStoreName1, DEFAULT_RECOVERY_DELAY, 1,
            DEFAULT_STARTUP_RECOVERY_DELAY);
      });
    }

    for (VM vm : toArray(vm0, vm1, vm2)) {
      vm.invoke(() -> createChildPR_withRecovery(regionName, childRegionName1,
          DEFAULT_RECOVERY_DELAY, 1, DEFAULT_STARTUP_RECOVERY_DELAY));
    }

    vm0.invoke(() -> {
      createData(regionName, "a");
      createData(childRegionName1, "b");
    });

    Map<Integer, Set<Integer>> bucketIdsInVM = new HashMap<>();
    for (VM vm : toArray(vm0, vm1, vm2)) {
      bucketIdsInVM.put(vm.getId(), vm.invoke(() -> {
        Set<Integer> bucketIds = getBucketIds(regionName);
        assertThat(getBucketIds(childRegionName1)).isEqualTo(bucketIds);
        return bucketIds;
      }));
    }

    for (VM vm : toArray(vm0, vm1, vm2)) {
      vm.invoke(() -> {
        Set<Integer> primaryBucketIds = getPrimaryBucketIds(regionName);
        assertThat(getPrimaryBucketIds(childRegionName1)).isEqualTo(primaryBucketIds);
      });
    }

    vm0.invoke(() -> {
      assertThat(getCache().getDistributionManager().getDistributionManagerIds()).hasSize(4);
    });

    vm2.invoke(this::closeCache);

    // Make sure the other members notice that vm2 has gone
    for (VM vm : toArray(vm0, vm1)) {
      vm.invoke(() -> {
        await().untilAsserted(() -> {
          assertThat(getCache().getDistributionManager().getDistributionManagerIds()).hasSize(3);
        });
      });
    }

    for (VM vm : toArray(vm0, vm1)) {
      vm.invoke(this::closeCache);
    }

    // Create the members, but don't initialize VM2 yet
    for (VM vm : toArray(vm0, vm1)) {
      addAsync(vm.invokeAsync(() -> {
        createCache();
        createDiskStore(diskStoreName1);
        createPR_withPersistence(regionName, diskStoreName1, DEFAULT_RECOVERY_DELAY, 1,
            DEFAULT_STARTUP_RECOVERY_DELAY);
      }));
    }
    awaitAllAsync();

    for (VM vm : toArray(vm0, vm1)) {
      vm.invoke(() -> createChildPR_withRecovery(regionName, childRegionName1,
          DEFAULT_RECOVERY_DELAY, 1, DEFAULT_STARTUP_RECOVERY_DELAY));
    }

    for (VM vm : toArray(vm0, vm1)) {
      Set<Integer> bucketIds = bucketIdsInVM.get(vm.getId());
      vm.invoke(() -> waitForBucketRecovery(regionName, bucketIds));
    }

    vm0.invoke(() -> {
      validateData(regionName, "a");
      // region 2 didn't have persistent data, so it nothing should be recovered
      validateData(childRegionName1, null);
      // Make sure can do a put in all of the buckets in vm2
      createData(childRegionName1, "c");
      // Now all of those buckets should exist
      validateData(childRegionName1, "c");
    });

    // Now we initialize vm2.
    Set<Integer> bucketIds = bucketIdsInVM.get(vm2.getId());
    vm2.invoke(() -> {
      createCache();
      createDiskStore(diskStoreName1);
      createPR_withPersistence(regionName, diskStoreName1, DEFAULT_RECOVERY_DELAY, 1,
          DEFAULT_STARTUP_RECOVERY_DELAY);

      // Make sure vm2 hasn't created any buckets in the parent PR yet
      // We don't want any buckets until the child PR is created
      assertThat(getBucketIds(regionName)).isEmpty();

      createChildPR_withRecovery(regionName, childRegionName1, DEFAULT_RECOVERY_DELAY, 1,
          DEFAULT_STARTUP_RECOVERY_DELAY);

      // Now vm2 should have created all of the appropriate buckets.
      assertThat(getBucketIds(regionName)).isEqualTo(bucketIds);
      assertThat(getBucketIds(childRegionName1)).isEqualTo(bucketIds);
    });

    for (VM vm : toArray(vm0, vm1, vm2)) {
      vm.invoke(() -> {
        Set<Integer> buckets = getPrimaryBucketIds(regionName);
        assertThat(getPrimaryBucketIds(childRegionName1)).isEqualTo(buckets);
      });
    }
  }
Testing what happens we we recreate colocated persistent PRs by creating one PR everywhere and
then the other PR everywhere.
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PersistentColocatedPartitionedRegionDistributedTest.java