This is an automated email from the ASF dual-hosted git repository. klund pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/geode.git
commit f53b5a6aaa23701af15a2388e191c8b9f939e461 Author: Kirk Lund <[email protected]> AuthorDate: Thu Mar 22 16:38:42 2018 -0700 GEODE-1279: Rename Bug41091DUnitTest as BucketCreationGIIHARegressionTest * Cleanup the test. --- .../cache/BucketCreationGIIHARegressionTest.java | 120 +++++++++++++++ .../geode/internal/cache/Bug41091DUnitTest.java | 169 --------------------- 2 files changed, 120 insertions(+), 169 deletions(-) diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/BucketCreationGIIHARegressionTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/BucketCreationGIIHARegressionTest.java new file mode 100644 index 0000000..754d645 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/BucketCreationGIIHARegressionTest.java @@ -0,0 +1,120 @@ +/* + * 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.internal.cache; + +import static org.apache.geode.test.dunit.Host.getHost; +import static org.apache.geode.test.dunit.Invoke.invokeInEveryVM; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import org.apache.geode.cache.AttributesFactory; +import org.apache.geode.cache.PartitionAttributesFactory; +import org.apache.geode.cache.Region; +import org.apache.geode.distributed.internal.ClusterDistributionManager; +import org.apache.geode.distributed.internal.DistributionMessage; +import org.apache.geode.distributed.internal.DistributionMessageObserver; +import org.apache.geode.internal.cache.InitialImageOperation.RequestImageMessage; +import org.apache.geode.test.dunit.VM; +import org.apache.geode.test.dunit.cache.CacheTestCase; +import org.apache.geode.test.junit.categories.DistributedTest; +import org.apache.geode.test.junit.rules.serializable.SerializableTestName; + +/** + * This class tests that bucket regions can handle a failure of the GII target during GII. + * + * <p> + * TRAC #41091: Missing primary detected after member forcefully disconnected from DS (underlying + * InternalGemFireError: Trying to clear a bucket region that was not destroyed) + */ +@Category(DistributedTest.class) +public class BucketCreationGIIHARegressionTest extends CacheTestCase { + + private String uniqueName; + + private VM server1; + private VM server2; + private VM server3; + + @Rule + public SerializableTestName testName = new SerializableTestName(); + + @Before + public void setUp() throws Exception { + server1 = getHost(0).getVM(0); + server2 = getHost(0).getVM(1); + server3 = getHost(0).getVM(2); + + uniqueName = getClass().getSimpleName() + "_" + testName.getMethodName(); + } + + @After + public void tearDown() throws Exception { + DistributionMessageObserver.setInstance(null); + invokeInEveryVM(() -> { + DistributionMessageObserver.setInstance(null); + }); + + disconnectAllFromDS(); + } + + @Test + public void bucketCreationLosesGiiTarget() { + server1.invoke(() -> createRegion()); + server2.invoke(() -> createRegion()); + + server3.invoke(() -> { + PartitionAttributesFactory paf = new PartitionAttributesFactory(); + paf.setRedundantCopies(1); + paf.setLocalMaxMemory(0); + + AttributesFactory af = new AttributesFactory(); + af.setPartitionAttributes(paf.create()); + + Region<Integer, String> region = getCache().createRegion(uniqueName, af.create()); + + region.put(0, "a"); + }); + } + + private void createRegion() { + DistributionMessageObserver.setInstance(new MyDistributionMessageObserver()); + + PartitionAttributesFactory paf = new PartitionAttributesFactory(); + paf.setRedundantCopies(1); + + AttributesFactory af = new AttributesFactory(); + af.setPartitionAttributes(paf.create()); + + getCache().createRegion(uniqueName, af.create()); + } + + private class MyDistributionMessageObserver extends DistributionMessageObserver { + + @Override + public void beforeProcessMessage(ClusterDistributionManager dm, DistributionMessage message) { + if (message instanceof RequestImageMessage) { + RequestImageMessage rim = (RequestImageMessage) message; + Region region = getCache().getRegion(rim.regionPath); + if (region instanceof BucketRegion) { + getCache().close(); + } + } + } + } +} diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/Bug41091DUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/Bug41091DUnitTest.java deleted file mode 100644 index 2c8f496..0000000 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/Bug41091DUnitTest.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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.internal.cache; - -import static org.apache.geode.distributed.ConfigurationProperties.*; -import static org.junit.Assert.*; - -import java.io.File; -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.Properties; - -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import org.apache.geode.cache.AttributesFactory; -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.PartitionAttributesFactory; -import org.apache.geode.cache.Region; -import org.apache.geode.distributed.Locator; -import org.apache.geode.distributed.internal.ClusterDistributionManager; -import org.apache.geode.distributed.internal.DistributionMessage; -import org.apache.geode.distributed.internal.DistributionMessageObserver; -import org.apache.geode.internal.AvailablePort; -import org.apache.geode.internal.cache.InitialImageOperation.RequestImageMessage; -import org.apache.geode.test.dunit.Assert; -import org.apache.geode.test.dunit.Host; -import org.apache.geode.test.dunit.LogWriterUtils; -import org.apache.geode.test.dunit.NetworkUtils; -import org.apache.geode.test.dunit.SerializableRunnable; -import org.apache.geode.test.dunit.VM; -import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase; -import org.apache.geode.test.junit.categories.DistributedTest; - -/** - * This class tests that bucket regions can handle a failure of the GII target during GII. - */ -@Category(DistributedTest.class) -public class Bug41091DUnitTest extends JUnit4CacheTestCase { - - @Override - public final void postTearDownCacheTestCase() throws Exception { - disconnectAllFromDS(); - } - - @Test - public void test() { - final Host host = Host.getHost(0); - VM vm0 = host.getVM(0); - VM vm1 = host.getVM(1); - VM vm2 = host.getVM(2); - VM vm3 = host.getVM(3); - - final int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); - - // We need to use our own locator because we need enable network partition detection. - startLocatorInVM(vm3, locatorPort); - try { - - final SerializableRunnable createRegion = new SerializableRunnable("create the region") { - - public void run() { - DistributionMessageObserver.setInstance(new DistributionMessageObserver() { - - @Override - public void beforeProcessMessage(ClusterDistributionManager dm, - DistributionMessage message) { - if (message instanceof RequestImageMessage) { - RequestImageMessage rim = (RequestImageMessage) message; - Region region = getCache().getRegion(rim.regionPath); - if (region instanceof BucketRegion) { - // We can no longer do any puts until the bucket is completely created, - // so this will hang - // getCache().getRegion("region").put(113, "b"); - getCache().close(); - } - } - } - }); - - Properties props = new Properties(); - props.setProperty(ENABLE_NETWORK_PARTITION_DETECTION, "true"); - props.setProperty(LOCATORS, - NetworkUtils.getServerHostName(host) + "[" + locatorPort + "]"); - getSystem(props); - - - Cache cache = getCache(); - AttributesFactory af = new AttributesFactory(); - PartitionAttributesFactory paf = new PartitionAttributesFactory(); - paf.setRedundantCopies(1); - af.setPartitionAttributes(paf.create()); - cache.createRegion("region", af.create()); - } - }; - vm0.invoke(createRegion); - vm1.invoke(createRegion); - - vm2.invoke(new SerializableRunnable("create an entry") { - - public void run() { - Properties props = new Properties(); - props.setProperty(ENABLE_NETWORK_PARTITION_DETECTION, "true"); - props.setProperty(LOCATORS, - NetworkUtils.getServerHostName(host) + "[" + locatorPort + "]"); - getSystem(props); - Cache cache = getCache(); - AttributesFactory af = new AttributesFactory(); - PartitionAttributesFactory paf = new PartitionAttributesFactory(); - paf.setRedundantCopies(1); - paf.setLocalMaxMemory(0); - af.setPartitionAttributes(paf.create()); - Region region = cache.createRegion("region", af.create()); - region.put(Integer.valueOf(0), "a"); - } - }); - } finally { - SerializableRunnable stopLocator = new SerializableRunnable("Stop locator") { - public void run() { - assertTrue(Locator.hasLocator()); - Locator.getLocator().stop(); - assertFalse(Locator.hasLocator()); - } - }; - vm3.invoke(stopLocator); - } - } - - protected void startLocatorInVM(final VM vm, final int locatorPort) { - vm.invoke(new SerializableRunnable("Create Locator") { - - final String testName = getUniqueName(); - - public void run() { - disconnectFromDS(); - Properties props = new Properties(); - props.setProperty(MCAST_PORT, String.valueOf(0)); - props.setProperty(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel()); - props.setProperty(ENABLE_NETWORK_PARTITION_DETECTION, "true"); - props.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false"); - try { - File logFile = new File(testName + "-locator" + locatorPort + ".log"); - InetAddress bindAddr = null; - try { - bindAddr = InetAddress.getByName(NetworkUtils.getServerHostName(vm.getHost())); - } catch (UnknownHostException uhe) { - Assert.fail("While resolving bind address ", uhe); - } - Locator locator = Locator.startLocatorAndDS(locatorPort, logFile, bindAddr, props); - } catch (IOException ex) { - Assert.fail("While starting locator on port " + locatorPort, ex); - } - } - }); - } -} -- To stop receiving notification emails like this one, please contact [email protected].
