@Test
  public void testCrashWhileCreatingABucket() {
    for (VM vm : toArray(vm1, vm2)) {
      vm.invoke(() -> {
        DistributionMessageObserver.setInstance(new CrashMemberBeforeManageBucketMessage(vm0));

        PartitionAttributesFactory<?, ?> partitionAttributesFactory =
            new PartitionAttributesFactory();
        partitionAttributesFactory.setRedundantCopies(1);
        partitionAttributesFactory.setRecoveryDelay(0);

        RegionFactory<?, ?> regionFactory = getCache().createRegionFactory(PARTITION);
        regionFactory.setPartitionAttributes(partitionAttributesFactory.create());

        regionFactory.create(regionName);
      });
    }

    vm0.invoke(() -> {
      PartitionAttributesFactory<?, ?> partitionAttributesFactory =
          new PartitionAttributesFactory<>();
      partitionAttributesFactory.setRedundantCopies(1);
      partitionAttributesFactory.setLocalMaxMemory(0);

      RegionFactory<String, String> regionFactory = getCache().createRegionFactory(PARTITION);
      regionFactory.setPartitionAttributes(partitionAttributesFactory.create());

      Region<String, String> region = regionFactory.create(regionName);

      // trigger the creation of a bucket, which should trigger the destruction of this VM.
      assertThatThrownBy(() -> region.put("ping", "pong")).isInstanceOf(CancelException.class);
    });

    for (VM vm : toArray(vm1, vm2)) {
      vm.invoke(() -> {
        PartitionedRegion pr = (PartitionedRegion) getCache().getRegion(regionName);
        int totalNumBuckets = pr.getAttributes().getPartitionAttributes().getTotalNumBuckets();
        for (int i = 0; i < totalNumBuckets; i++) {
          int bucketId = i;

          await().until(() -> {
            try {
              return pr.getBucketOwnersForValidation(bucketId) != null;
            } catch (ForceReattemptException e) {
              return false;
            }
          });

          if (pr.getBucketOwnersForValidation(bucketId).isEmpty()) {
            continue;
          }

          await().untilAsserted(() -> {
            assertThat(pr.getBucketOwnersForValidation(bucketId)).hasSize(2);
          });
        }
      });
    }
  }
This tests the case where the VM forcing other VMs to create a bucket crashes while creating
the bucket.
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/BucketCreationCrashCompletesRegressionTest.java