@Test
  @Parameters({"true, true", "true, false", "false, false"})
  public void testCommandDoesNotCopyEntriesUpdatedAfterCommandStarted(
      boolean isPartitionedRegion,
      boolean isParallelGatewaySender) throws Exception {
    List<VM> serversInA = Arrays.asList(vm5, vm6, vm7);
    List<VM> serversInB = Collections.singletonList(vm3);
    VM serverInC = vm4;
    VM client = vm8;
    String senderIdInA = "B";
    String senderIdInB = "C";

    int senderLocatorPort = create3WanSitesAndClient(isPartitionedRegion, vm0,
        vm1, vm2, serversInA, serversInB, serverInC, client,
        senderIdInA, senderIdInB, true);

    int entries = 50000;
    String regionName = getRegionName(isPartitionedRegion);
    // Put entries
    client.invoke(() -> doPutsFrom(regionName, 0, entries));

    // Check that entries are put in the region
    for (VM member : serversInA) {
      member.invoke(() -> validateRegionSize(regionName, entries));
    }

    // Create senders and receivers
    createSender(isParallelGatewaySender, serversInA, senderIdInA, 2);
    createSender(isParallelGatewaySender, serversInB, senderIdInB, 3);
    createReceivers(serversInB, serverInC);

    int wanCopyRegionBatchSize = 20;
    // Let maxRate be a 5th of the number of entries in order to have the
    // command running for about 5 seconds so that there is time
    // for the random operations to be done at the same time
    // as the command is running.
    // The rate is divided by the number of servers in case the sender is parallel
    int maxRate = (entries / 5) / (isParallelGatewaySender ? serversInA.size() : 1);

    // Execute wan-copy region command
    Callable<CommandResultAssert> wanCopyCommandCallable = () -> {
      String command = new CommandStringBuilder(WAN_COPY_REGION)
          .addOption(WAN_COPY_REGION__REGION, regionName)
          .addOption(WAN_COPY_REGION__SENDERID, senderIdInA)
          .addOption(WAN_COPY_REGION__BATCHSIZE, String.valueOf(wanCopyRegionBatchSize))
          .addOption(WAN_COPY_REGION__MAXRATE, String.valueOf(maxRate))
          .getCommandString();
      try {
        gfsh.connectAndVerify(senderLocatorPort, GfshCommandRule.PortType.locator);
      } catch (Exception e) {
        errorCollector.addError(e);
      }
      return gfsh.executeAndAssertThat(command);
    };

    Future<CommandResultAssert> wanCopyCommandFuture =
        executorServiceRule.submit(wanCopyCommandCallable);

    // Wait for the command to have copied at least one entry.
    // This way, the below puts will not be replicated by the command.
    await().untilAsserted(
        () -> assertThat(serversInB.get(0).invoke(() -> getRegionSize(regionName)))
            .isGreaterThan(0));

    // While the command is running, send some random operations over a different set of keys
    client.invoke(() -> doPutsFrom(regionName, entries, entries + 2000));

    // Check command status and output
    CommandResultAssert command = wanCopyCommandFuture.get();
    verifyStatusIsOk(command, serversInA.size());

    // Wait for entries to be replicated (replication queues empty)
    for (VM server : serversInA) {
      server.invoke(() -> getSenderStats(senderIdInA, 0));
    }

    // Check that the region's data is the same in sites "A" and "B"
    checkEqualRegionData(regionName, serversInA.get(0), serversInB.get(0), true);

    // Check that the number of entries copied is equal to the number of
    // entries put before the command was executed.
    assertThat(getCopiedEntries(command)).isEqualTo(entries);
  }
Scenario with 2 WAN sites: "A" and "B".
Initially, no replication is configured between sites.
Several entries are put in WAN site "A".

The following gateway senders are created and started:
- In "A" site: to replicate region entries to "B" site. Sender called "B".
(Replication is as follows: A -> B)

The "wan-copy region" command is run from "A" site passing sender "B".
Simultaneously, some put operations for entries with keys different
to the ones previously put are run.

When the command finishes and the puts finish it
must be verified that the number of entries copied by it
is equal to the number of entries put before the command
was run.
Also it must be verified that the
entries in the region in site "A"
are the same as the ones in region in site "B".
geode-wan/src/distributedTest/java/org/apache/geode/cache/wan/internal/cli/commands/WanCopyRegionCommandDistributedTest.java