@Test
  public void testByteSizeWithEviction() throws Exception {
    vm0.invoke(this::createPartitionedRegionWithOverflow);

    long bucketSizeWithOneEntry = vm0.invoke(() -> {
      Region<Integer, byte[]> region = getRegion(REGION_NAME);
      region.put(0, new byte[100]);

      PartitionedRegion partitionedRegion = (PartitionedRegion) region;
      PartitionedRegionDataStore dataStore = partitionedRegion.getDataStore();
      long size = dataStore.getBucketSize(0);

      for (int i = 1; i < 100; i++) {
        region.put(i * TOTAL_NUMBER_OF_BUCKETS, new byte[100]);
      }
      await().until(() -> dataStore.getBucketsManaged() == (short) 1);
      return size;
    });

    vm0.invoke(() -> {
      Region<Integer, byte[]> region = getRegion(REGION_NAME);
      PartitionedRegion partitionedRegion = (PartitionedRegion) region;
      PartitionedRegionDataStore dataStore = partitionedRegion.getDataStore();

      // there should only be 2 items in memory
      await().until(() -> dataStore.currentAllocatedMemory() == 2 * bucketSizeWithOneEntry);

      // fault something else into memory and check again.
      region.get(82 * TOTAL_NUMBER_OF_BUCKETS);
      await().until(() -> dataStore.currentAllocatedMemory() == 2 * bucketSizeWithOneEntry);
    });
  }
Regression test for TRAC #39868

<p>
TRAC #39868: PartitionMemberDetails.getSize() reports negative PR sizes when redundancy is 0
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionSizeDUnitTest.java