@Test
  public void testRebalanceDuringRecovery() throws Exception {
    // Create the PRs on two members
    for (VM vm : toArray(vm0, vm1)) {
      vm.invoke(() -> {
        createCache();
        createDiskStore(diskStoreName1);
        createPR_withPersistence(regionName, diskStoreName1, DEFAULT_RECOVERY_DELAY, 1,
            DEFAULT_STARTUP_RECOVERY_DELAY);
        createChildPR_withPersistence(regionName, childRegionName1, diskStoreName1,
            DEFAULT_RECOVERY_DELAY, 1, DEFAULT_STARTUP_RECOVERY_DELAY);
      });
    }

    // Create some buckets.
    vm0.invoke(() -> {
      createData(regionName, "a");
      createData(childRegionName1, "a");
    });

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

    vm1.invoke(() -> {
      PartitionedRegionObserverHolder.setInstance(new PRObserver(childRegionName1));
    });
    try {
      for (VM vm : toArray(vm0, vm1)) {
        addAsync(vm.invokeAsync(() -> {
          createCache();
          createDiskStore(diskStoreName1);
          createPR_withPersistence(regionName, diskStoreName1, DEFAULT_RECOVERY_DELAY, 1,
              DEFAULT_STARTUP_RECOVERY_DELAY);
          createChildPR_withPersistence(regionName, childRegionName1, diskStoreName1,
              DEFAULT_RECOVERY_DELAY, 1, DEFAULT_STARTUP_RECOVERY_DELAY);
        }));
      }

      vm1.invoke(() -> {
        PRObserver observer = (PRObserver) PartitionedRegionObserverHolder.getInstance();
        observer.waitForCreate();
      });

      // Now create the parent region on vm-2. vm-2 did not
      // previous host the child region.
      vm2.invoke(() -> {
        createCache();
        createDiskStore(diskStoreName1);
        createPR_withPersistence(regionName, diskStoreName1, DEFAULT_RECOVERY_DELAY, 1,
            DEFAULT_STARTUP_RECOVERY_DELAY);
        createChildPR_withPersistence(regionName, childRegionName1, diskStoreName1,
            DEFAULT_RECOVERY_DELAY, 1, DEFAULT_STARTUP_RECOVERY_DELAY);
      });

      // Try to forcibly move some buckets to vm2 (this should not succeed).
      moveBucket(0, vm1, vm2);
      moveBucket(1, vm1, vm2);

    } finally {
      vm1.invoke(() -> {
        PRObserver observer = (PRObserver) PartitionedRegionObserverHolder.getInstance();
        observer.tearDown();
        PartitionedRegionObserverHolder.setInstance(new PartitionedRegionObserverAdapter());
      });
    }

    awaitAllAsync();

    vm0.invoke(() -> {
      // Validate the data
      validateData(regionName, "a");
      validateData(childRegionName1, "a");

      // Make sure we can actually use the buckets in the child region.
      createData(childRegionName1, "c");
    });

    // Make sure the system is recoverable by restarting it

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

    for (VM vm : toArray(vm0, vm1, vm2)) {
      addAsync(vm.invokeAsync(() -> {
        createCache();
        createDiskStore(diskStoreName1);
        createPR_withPersistence(regionName, diskStoreName1, DEFAULT_RECOVERY_DELAY, 1,
            DEFAULT_STARTUP_RECOVERY_DELAY);
        createChildPR_withPersistence(regionName, childRegionName1, diskStoreName1,
            DEFAULT_RECOVERY_DELAY, 1, DEFAULT_STARTUP_RECOVERY_DELAY);
      }));
    }
    awaitAllAsync();
  }
Test that a rebalance will regions are in the middle of recovery doesn't cause issues.

This is slightly different than {@link #testRebalanceWithOfflineChildRegion(String)} because
in this case all of the regions have been created, but they are in the middle of actually
recovering buckets from disk.
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PersistentColocatedPartitionedRegionDistributedTest.java