@Test
  @Parameters({"false, false", "false, true", "true, true"})
  public void testRegionDestroyedDuringExecution(boolean isParallelGatewaySender,
      boolean isPartitionedRegion)
      throws Exception {
    addIgnoredException("org.apache.geode.cache.RegionDestroyedException");
    final int wanCopyRegionBatchSize = 10;
    final int entries = 1000;

    final String regionName = getRegionName(isPartitionedRegion);

    // Site A
    VM locatorInA = vm0;
    VM server1InA = vm1;
    List<VM> serversInA = ImmutableList.of(server1InA);
    final String senderIdInA = "B";

    // Site B
    VM locatorInB = vm4;
    VM server1InB = vm5;
    List<VM> serversInB = Collections.singletonList(server1InB);
    VM client = vm8;

    int locatorAPort = create2WanSitesAndClient(locatorInA, serversInA, senderIdInA, locatorInB,
        serversInB, client, isPartitionedRegion, regionName);

    // Put entries
    client.invoke(() -> doPutsFrom(regionName, 0, entries));
    for (VM member : serversInA) {
      member.invoke(() -> validateRegionSize(regionName, entries));
    }

    // Create senders and receivers with replication as follows: "A" -> "B"
    createReceiverInVMs(server1InB);
    createSender(isParallelGatewaySender, serversInA, senderIdInA, 2);

    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, "5")
          .getCommandString();
      try {
        gfsh.connectAndVerify(locatorAPort, GfshCommandRule.PortType.locator);
      } catch (Exception e) {
        errorCollector.addError(e);
      }
      return gfsh.executeAndAssertThat(command);
    };

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

    // Wait for the wan-copy command to start
    waitForWanCopyRegionCommandToStart(isParallelGatewaySender, isPartitionedRegion, serversInA);

    // Destroy region in a server in A
    server1InA.invoke(() -> cache.getRegion(regionName).destroyRegion());

    CommandResultAssert result = wanCopyCommandFuture.get();
    result.statusIsError();
    result
        .hasTableSection()
        .hasColumns()
        .hasSize(3);
    result
        .hasTableSection(ResultModel.MEMBER_STATUS_SECTION)
        .hasColumn("Member")
        .hasSize(1);
    result
        .hasTableSection(ResultModel.MEMBER_STATUS_SECTION)
        .hasColumn("Message")
        .hasSize(1);
    result
        .hasTableSection(ResultModel.MEMBER_STATUS_SECTION)
        .hasColumn("Status")
        .containsExactly("ERROR");

    Condition<String> regionDestroyedError = new Condition<>(
        s -> (s.startsWith(
            "Execution failed. Error: org.apache.geode.cache.RegionDestroyedException: ")
            || s.startsWith("Error (Region destroyed) in operation after having copied")),
        "execution error");
    result
        .hasTableSection(ResultModel.MEMBER_STATUS_SECTION)
        .hasColumn("Message")
        .asList()
        .haveExactly(1, regionDestroyedError);
  }
This test creates two sites A & B, each one containing 3 servers.
A region is created in both sites, and populated in site A.
After that replication is configured from site A to site B.
WanCopyRegionFunction is called, and while it is running, a sender in site A
or a receiver in site B are killed.
geode-wan/src/distributedTest/java/org/apache/geode/cache/wan/internal/cli/commands/WanCopyRegionCommandDistributedTest.java