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 cd3ff6d748f854c8e3a2d025bd14bfe19fdbd8de Author: Kirk Lund <[email protected]> AuthorDate: Tue Mar 20 16:47:58 2018 -0700 GEODE-1279: Rename Bug34583JUnitTest as RegionValuesIteratorAfterLocalInvalidateRegressionTest --- .../geode/internal/cache/Bug34583JUnitTest.java | 96 -------------------- ...IteratorAfterLocalInvalidateRegressionTest.java | 101 +++++++++++++++++++++ 2 files changed, 101 insertions(+), 96 deletions(-) diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/Bug34583JUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/Bug34583JUnitTest.java deleted file mode 100644 index 10ff741..0000000 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/Bug34583JUnitTest.java +++ /dev/null @@ -1,96 +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.MCAST_PORT; -import static org.junit.Assert.assertEquals; - -import java.util.Collection; -import java.util.Iterator; -import java.util.Properties; - -import org.junit.After; -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.CacheFactory; -import org.apache.geode.cache.Region; -import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.test.junit.categories.IntegrationTest; - -/** - * Confirm that bug 34583 is fixed. Cause of bug is recursion is entries iterator that causes stack - * overflow. - */ -@Category(IntegrationTest.class) -public class Bug34583JUnitTest { - - public Bug34583JUnitTest() {} - - public void setup() {} - - @After - public void tearDown() {} - - - - @Test - public void testBunchOfInvalidEntries() throws Exception { - Properties props = new Properties(); - props.setProperty(MCAST_PORT, "0"); - DistributedSystem ds = DistributedSystem.connect(props); - try { - AttributesFactory factory = new AttributesFactory(); - Cache cache = null; - cache = CacheFactory.create(ds); - - Region r = cache.createRegion("testRegion", factory.create()); - final int ENTRY_COUNT = 25000; - { - for (int i = 1; i <= ENTRY_COUNT; i++) { - r.put("key" + i, "value" + i); - } - } - { // make sure iterator works while values are valid - Collection c = r.values(); - assertEquals(ENTRY_COUNT, c.size()); - Iterator it = c.iterator(); - int count = 0; - while (it.hasNext()) { - it.next(); - count++; - } - assertEquals(ENTRY_COUNT, count); - } - r.localInvalidateRegion(); - // now we expect iterator to stackOverflow if bug 34583 - { - Collection c = r.values(); - assertEquals(0, c.size()); - Iterator it = c.iterator(); - int count = 0; - while (it.hasNext()) { - it.next(); - count++; - } - assertEquals(0, count); - } - } finally { - ds.disconnect(); - } - } -} diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/RegionValuesIteratorAfterLocalInvalidateRegressionTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/RegionValuesIteratorAfterLocalInvalidateRegressionTest.java new file mode 100644 index 0000000..7ee9f81 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/RegionValuesIteratorAfterLocalInvalidateRegressionTest.java @@ -0,0 +1,101 @@ +/* + * 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.LOCATORS; +import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Collection; +import java.util.Iterator; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; + +import org.apache.geode.cache.Cache; +import org.apache.geode.cache.CacheFactory; +import org.apache.geode.cache.Region; +import org.apache.geode.cache.RegionFactory; +import org.apache.geode.cache.RegionShortcut; +import org.apache.geode.test.junit.categories.IntegrationTest; + +/** + * Confirm that bug 34583 is fixed. Cause of bug is recursion is entries iterator that causes stack + * overflow. + * + * <p> + * TRAC #34583: StackOverflowError while performing region.put() at bridge client. + */ +@Category(IntegrationTest.class) +public class RegionValuesIteratorAfterLocalInvalidateRegressionTest { + + private static final int PUT_COUNT = 25000; + + private Cache cache; + private Region<String, String> region; + + @Rule + public TestName testName = new TestName(); + + @Before + public void setUp() { + String uniqueName = getClass().getSimpleName() + "_" + testName.getMethodName(); + + cache = new CacheFactory().set(LOCATORS, "").set(MCAST_PORT, "0").create(); + + RegionFactory<String, String> regionFactory = cache.createRegionFactory(RegionShortcut.LOCAL); + region = regionFactory.create(uniqueName); + + for (int i = 1; i <= PUT_COUNT; i++) { + region.put("key" + i, "value" + i); + } + } + + @After + public void tearDown() { + cache.close(); + } + + @Test + public void testBunchOfInvalidEntries() throws Exception { + // make sure iterator works while values are valid + Collection<String> valuesBefore = region.values(); + assertThat(valuesBefore).hasSize(PUT_COUNT); + + int iteratorCount = 0; + for (Iterator iterator = valuesBefore.iterator(); iterator.hasNext(); iterator.next()) { + iteratorCount++; + } + + assertThat(iteratorCount).isEqualTo(PUT_COUNT); + + region.localInvalidateRegion(); + + // now we expect iterator to stackOverflow if bug 34583 exists + Collection<String> valuesAfter = region.values(); + assertThat(valuesAfter).isEmpty(); + + iteratorCount = 0; + for (Iterator iterator = valuesAfter.iterator(); iterator.hasNext(); iterator.next()) { + iteratorCount++; + } + + assertThat(iteratorCount).isZero(); + } +} -- To stop receiving notification emails like this one, please contact [email protected].
