@Test
  public void testCrashDuringGII() throws Exception {
    for (VM vm : toArray(vm0, vm1)) {
      vm.invoke(() -> createReplicateRegion(regionName, getDiskDirs(getVMId())));
    }

    vm0.invoke(() -> {
      putEntry("A", "B");
      getCache().getRegion(regionName).close();
    });

    vm1.invoke(() -> {
      updateEntry("A", "C");
      getCache().getRegion(regionName).close();
    });

    // This ought to wait for VM1 to come back
    AsyncInvocation<Void> createPersistentRegionInVM0 = vm0.invokeAsync(() -> {
      createReplicateRegion(regionName, getDiskDirs(getVMId()));
    });
    vm0.invoke(this::waitForBlockedInitialization);
    assertThat(createPersistentRegionInVM0.isAlive()).isTrue();

    vm1.invoke(() -> {
      // Add a hook which will disconnect from the system when the initial image message shows up.
      SAW_REQUEST_IMAGE_MESSAGE.set(false);
      DistributionMessageObserver.setInstance(new DistributionMessageObserver() {
        @Override
        public void beforeProcessMessage(ClusterDistributionManager dm,
            DistributionMessage message) {
          if (message instanceof RequestImageMessage) {
            DistributionMessageObserver.setInstance(null);
            system = dm.getSystem();
            disconnectFromDS();
            synchronized (SAW_REQUEST_IMAGE_MESSAGE) {
              SAW_REQUEST_IMAGE_MESSAGE.set(true);
              SAW_REQUEST_IMAGE_MESSAGE.notifyAll();
            }
          }
        }
      });

      createReplicateRegion(regionName, getDiskDirs(getVMId()));

      synchronized (SAW_REQUEST_IMAGE_MESSAGE) {
        try {
          while (!SAW_REQUEST_IMAGE_MESSAGE.get()) {
            SAW_REQUEST_IMAGE_MESSAGE.wait(TIMEOUT_MILLIS);
          }
        } catch (InterruptedException e) {
          errorCollector.addError(e);
        }
      }

      await().until(() -> system != null && system.isDisconnected());

      // Now create the region again. The initialization should
      // work (the observer was cleared when we disconnected from the DS.
      createReplicateRegion(regionName, getDiskDirs(getVMId()));
    });


    createPersistentRegionInVM0.await();

    for (VM vm : toArray(vm0, vm1)) {
      vm.invoke(() -> validateEntry("A", "C"));
    }

    vm1.invoke(() -> validateDiskRegionInitializationStats(true));
    vm0.invoke(() -> validateDiskRegionInitializationStats(false));
  }
Test to make sure that if if a member crashes while a GII is in progress, we wait for the
member to come back for starting.
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/persistence/PersistentRecoveryOrderDUnitTest.java