@Test
  public void testSubscriptionQueueWanTrafficWhileRebalanced() throws Exception {
    configureSites("3", false);
    verifyGatewaySenderIsRunningAndNotPaused();

    List<MemberVM> allMembers = new ArrayList<>();
    allMembers.add(server1Site2);
    allMembers.add(server2Site2);
    allMembers.add(server3Site2);

    server1Site2.invoke(() -> PartitionRegionHelper.assignBucketsToPartitions(
        Objects.requireNonNull(ClusterStartupRule.getCache()).getRegion(REGION_NAME)));

    // check that bucketToTempQueueMap is empty on all members
    for (MemberVM member : allMembers) {
      member.invoke(() -> validateBucketToTempQueueMapIsEmpty("ln"));
    }

    // Choose server with bucket to be stopped
    MemberVM serverToStop = getServerToStop(allMembers);
    int bucketId = serverToStop.invoke(this::getPrimaryBucketList).iterator().next();
    serverToStop.stop(true);

    // remove from list the member that has been previously stopped
    allMembers.remove(serverToStop);

    startDurableClient();
    createDurableCQs(REGION_CQ);

    // configure hook on running members
    for (MemberVM member : allMembers) {
      configureHooksOnRunningMember(member, bucketId);
    }

    // perform rebalance operation to trigger bucket redundancy recovery on running servers
    String command = new CommandStringBuilder(CliStrings.REBALANCE)
        .getCommandString();
    gfsh.executeAndAssertThat(command).statusIsSuccess();

    for (MemberVM member : allMembers) {
      // All members after redundancy is recovered should have empty temporary queue
      member.invoke(() -> validateBucketToTempQueueMapIsEmpty("ln"));
      // If hook has been triggered on member, then check if member temporarily queued
      // events while getting initial image from primary server
      if (member.invoke(ParallelGatewaySenderAndCQDurableClientDUnitTest::isHookTriggered)) {
        assertThat(member.invoke(ParallelGatewaySenderAndCQDurableClientDUnitTest::isTempQueueUsed))
            .isTrue();
      }
    }

    // reset all hooks
    for (MemberVM member : allMembers) {
      resetHooks(member);
    }
  }
This test case verifies that the server during bucket recovery enqueues all events intended for
that bucket in temporary queue, and that after bucket redundancy is restored events are
transferred from temporary queue to real bucket queue.
geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/parallel/ParallelGatewaySenderAndCQDurableClientDUnitTest.java