@Test
  public void testCrashDuringPreparePersistentId() throws Exception {
    addIgnoredException(CacheClosedException.class);
    addIgnoredException(DistributedSystemDisconnectedException.class);

    // Add a hook which will disconnect from the distributed
    // system when the initial image message shows up.
    vm0.invoke(() -> {
      DistributionMessageObserver.setInstance(new DistributionMessageObserver() {
        @Override
        public void beforeProcessMessage(ClusterDistributionManager dm,
            DistributionMessage message) {
          if (message instanceof PrepareNewPersistentMemberMessage) {
            DistributionMessageObserver.setInstance(null);
            system = dm.getSystem();
            disconnectFromDS();
          }
        }
      });

      createReplicateRegion(regionName, getDiskDirs(getVMId()));
      putEntry("A", "B");
      updateEntry("A", "C");
    });

    AsyncInvocation<Void> createPersistentRegionInVM1 = vm1.invokeAsync(() -> {
      Throwable thrown = catchThrowable(() -> {
        createReplicateRegion(regionName, getDiskDirs(getVMId()));
      });
      assertThat(thrown).isInstanceOf(CacheClosedException.class);
    });

    vm1.invoke(() -> {
      waitForBlockedInitialization();
      getCache().close();
    });

    createPersistentRegionInVM1.await();

    vm0.invoke(() -> {
      await().until(() -> system != null && system.isDisconnected());
    });

    for (VM vm : toArray(vm0, vm1)) {
      vm.invoke(() -> createReplicateRegion(regionName, getDiskDirs(getVMId())));
    }

    for (VM vm : toArray(vm0, vm1)) {
      vm.invoke(() -> validateEntry("A", "C"));
    }
  }
Test to make sure we don't leak any persistent ids if a member does GII while a distributed
destroy is in progress
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/persistence/PersistentRecoveryOrderDUnitTest.java