albertogpz commented on a change in pull request #6833: URL: https://github.com/apache/geode/pull/6833#discussion_r708398125
########## File path: geode-wan/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/WanCopyRegionCommandDUnitTest.java ########## @@ -0,0 +1,1417 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.apache.geode.management.internal.cli.commands; + +import static org.apache.geode.cache.Region.SEPARATOR; +import static org.apache.geode.distributed.ConfigurationProperties.DISTRIBUTED_SYSTEM_ID; +import static org.apache.geode.distributed.ConfigurationProperties.REMOTE_LOCATORS; +import static org.apache.geode.management.internal.i18n.CliStrings.WAN_COPY_REGION; +import static org.apache.geode.management.internal.i18n.CliStrings.WAN_COPY_REGION__BATCHSIZE; +import static org.apache.geode.management.internal.i18n.CliStrings.WAN_COPY_REGION__CANCEL; +import static org.apache.geode.management.internal.i18n.CliStrings.WAN_COPY_REGION__MAXRATE; +import static org.apache.geode.management.internal.i18n.CliStrings.WAN_COPY_REGION__MSG__CANCELED__BEFORE__HAVING__COPIED; +import static org.apache.geode.management.internal.i18n.CliStrings.WAN_COPY_REGION__MSG__COPIED__ENTRIES; +import static org.apache.geode.management.internal.i18n.CliStrings.WAN_COPY_REGION__MSG__EXECUTION__CANCELED; +import static org.apache.geode.management.internal.i18n.CliStrings.WAN_COPY_REGION__MSG__NO__RUNNING__COMMAND; +import static org.apache.geode.management.internal.i18n.CliStrings.WAN_COPY_REGION__MSG__REGION__NOT__FOUND; +import static org.apache.geode.management.internal.i18n.CliStrings.WAN_COPY_REGION__MSG__SENDER__NOT__FOUND; +import static org.apache.geode.management.internal.i18n.CliStrings.WAN_COPY_REGION__MSG__SENDER__SERIAL__AND__NOT__PRIMARY; +import static org.apache.geode.management.internal.i18n.CliStrings.WAN_COPY_REGION__REGION; +import static org.apache.geode.management.internal.i18n.CliStrings.WAN_COPY_REGION__SENDERID; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertNotNull; + +import java.util.Arrays; +import java.util.List; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.FutureTask; +import java.util.stream.Collectors; +import java.util.stream.LongStream; + +import com.google.common.collect.ImmutableList; +import org.assertj.core.api.Condition; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import org.apache.geode.cache.DataPolicy; +import org.apache.geode.cache.Region; +import org.apache.geode.cache.RegionShortcut; +import org.apache.geode.cache.Scope; +import org.apache.geode.cache.client.ClientCacheFactory; +import org.apache.geode.cache.client.ClientRegionShortcut; +import org.apache.geode.cache.wan.GatewaySender; +import org.apache.geode.internal.cache.wan.InternalGatewaySender; +import org.apache.geode.internal.cache.wan.WANTestBase; +import org.apache.geode.logging.internal.executors.LoggingExecutors; +import org.apache.geode.management.internal.cli.result.model.ResultModel; +import org.apache.geode.management.internal.cli.util.CommandStringBuilder; +import org.apache.geode.management.internal.i18n.CliStrings; +import org.apache.geode.test.dunit.AsyncInvocation; +import org.apache.geode.test.dunit.IgnoredException; +import org.apache.geode.test.dunit.VM; +import org.apache.geode.test.junit.assertions.CommandResultAssert; +import org.apache.geode.test.junit.categories.WanTest; +import org.apache.geode.test.junit.rules.GfshCommandRule; +import org.apache.geode.test.junit.rules.LocatorLauncherStartupRule; + +@Category({WanTest.class}) +public class WanCopyRegionCommandDUnitTest extends WANTestBase { + + private static final long serialVersionUID = 1L; + + private enum Gateway { + SENDER, RECEIVER + } + + public WanCopyRegionCommandDUnitTest() { + super(); + } + + @Test + public void testUnsuccessfulExecution_RegionNotFound() throws Exception { + List<VM> serversInA = Arrays.asList(vm5, vm6, vm7); + VM serverInB = vm3; + VM serverInC = vm4; + VM client = vm8; + String senderIdInA = "B"; + String senderIdInB = "C"; + + Integer senderLocatorPort = create3WanSitesAndClient(true, vm0, + vm1, vm2, serversInA, serverInB, serverInC, client, + senderIdInA, senderIdInB); + + int wanCopyRegionBatchSize = 20; + String regionName = "foo"; + + // Execute wan-copy region command + GfshCommandRule gfsh = new GfshCommandRule(); Review comment: Good point. Done. In `testSuccessfulCancelCommand()` I had to create an instance of `GfshCommandRule` to run the canceling of the command while an execution was ongoing. Using the same instance (the member instance) did not work in this case because the output of both commands did not come always in the same order. However I did not have to explicitely close the created instance because the member rule would close it (closes all) when the method finished. Using two member rules did not work because there was a double close that provoked some `NullPointerException`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
