You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by up...@apache.org on 2016/05/24 21:21:22 UTC
incubator-geode git commit: GEODE-1389,
GEODE-1012: Moving lucene persistence tests
Repository: incubator-geode
Updated Branches:
refs/heads/develop 8a74b6657 -> d75752146
GEODE-1389, GEODE-1012: Moving lucene persistence tests
There were two tests in LuceneIndexRecoveryHAIntegrationTest that used
disk resources. Moved the overflow test too a LuceneQueriesPersistence
suite, where it will be cleaned up by the DiskRule.
The recovery test was pretty much the same as an existing test in
LuceneIndexCreationPersistent.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/d7575214
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/d7575214
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/d7575214
Branch: refs/heads/develop
Commit: d75752146cd4c1d8990576a8df568fe9c87087d6
Parents: 8a74b66
Author: Dan Smith <up...@apache.org>
Authored: Fri May 20 15:13:49 2016 -0700
Committer: Dan Smith <up...@apache.org>
Committed: Tue May 24 14:15:32 2016 -0700
----------------------------------------------------------------------
...IndexCreationPersistenceIntegrationTest.java | 3 -
...LuceneQueriesPersistenceIntegrationTest.java | 117 +++++++++++++++++++
.../LuceneIndexRecoveryHAIntegrationTest.java | 79 -------------
3 files changed, 117 insertions(+), 82 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d7575214/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java
index 96b4e93..26426ca 100644
--- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java
@@ -57,9 +57,6 @@ public class LuceneIndexCreationPersistenceIntegrationTest extends LuceneIntegra
@Rule
public DiskDirRule diskDirRule = new DiskDirRule();
- public static final String INDEX_NAME = "index";
- public static final String REGION_NAME = "region";
-
@Override
public void createCache() {
super.createCache();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d7575214/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesPersistenceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesPersistenceIntegrationTest.java b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesPersistenceIntegrationTest.java
new file mode 100644
index 0000000..4bb67d2
--- /dev/null
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesPersistenceIntegrationTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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 com.gemstone.gemfire.cache.lucene;
+
+import static com.gemstone.gemfire.cache.RegionShortcut.*;
+import static com.gemstone.gemfire.cache.lucene.test.LuceneTestUtilities.*;
+import static junitparams.JUnitParamsRunner.*;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Consumer;
+
+import com.gemstone.gemfire.cache.EvictionAction;
+import com.gemstone.gemfire.cache.EvictionAlgorithm;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionFactory;
+import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue;
+import com.gemstone.gemfire.cache.lucene.internal.LuceneServiceImpl;
+import com.gemstone.gemfire.cache.lucene.internal.repository.serializer.Type1;
+import com.gemstone.gemfire.cache.lucene.test.LuceneTestUtilities;
+import com.gemstone.gemfire.cache.lucene.test.TestObject;
+import com.gemstone.gemfire.internal.cache.EvictionAttributesImpl;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.internal.cache.LocalRegion;
+import com.gemstone.gemfire.internal.cache.PartitionedRegion;
+import com.gemstone.gemfire.test.junit.categories.FlakyTest;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.test.junit.rules.DiskDirRule;
+import com.jayway.awaitility.Awaitility;
+
+import org.apache.lucene.queryparser.classic.ParseException;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
+
+/**
+ * Tests of lucene index creation that use persistence
+ */
+@Category(IntegrationTest.class)
+@RunWith(JUnitParamsRunner.class)
+public class LuceneQueriesPersistenceIntegrationTest extends LuceneIntegrationTest {
+
+ @Rule
+ public DiskDirRule diskDirRule = new DiskDirRule();
+
+ @Override
+ public void createCache() {
+ super.createCache();
+ cache.createDiskStoreFactory()
+ .setDiskDirs(new File[] {diskDirRule.get()})
+ .setMaxOplogSize(1)
+ .create(GemFireCacheImpl.getDefaultDiskStoreName());
+ }
+
+
+ @Test
+ public void shouldReturnCorrectResultsWithEntriesOverflowedToDisk() throws Exception {
+ String aeqId = LuceneServiceImpl.getUniqueIndexName(INDEX_NAME, REGION_NAME);
+
+ LuceneService service = LuceneServiceProvider.get(cache);
+ service.createIndex(INDEX_NAME, REGION_NAME, Type1.fields);
+
+ RegionFactory<String, Type1> regionFactory = cache.createRegionFactory(RegionShortcut.PARTITION);
+ EvictionAttributesImpl evicAttr = new EvictionAttributesImpl().setAction(EvictionAction.OVERFLOW_TO_DISK);
+ evicAttr.setAlgorithm(EvictionAlgorithm.LRU_ENTRY).setMaximum(1);
+ regionFactory.setEvictionAttributes(evicAttr);
+
+ PartitionedRegion userRegion = (PartitionedRegion) regionFactory.create(REGION_NAME);
+ final LuceneIndex index = service.getIndex(INDEX_NAME, REGION_NAME);
+
+ Assert.assertEquals(0, userRegion.getDiskRegionStats().getNumOverflowOnDisk());
+
+ Type1 value = new Type1("hello world", 1, 2L, 3.0, 4.0f);
+ userRegion.put("value1", value);
+ value = new Type1("test world", 1, 2L, 3.0, 4.0f);
+ userRegion.put("value2", value);
+ value = new Type1("lucene world", 1, 2L, 3.0, 4.0f);
+ userRegion.put("value3", value);
+
+ index.waitUntilFlushed(60000);
+
+ PartitionedRegion fileRegion = (PartitionedRegion) cache.getRegion(aeqId + ".files");
+ assertNotNull(fileRegion);
+ PartitionedRegion chunkRegion = (PartitionedRegion) cache.getRegion(aeqId + ".chunks");
+ assertNotNull(chunkRegion);
+ Assert.assertTrue(0 < userRegion.getDiskRegionStats().getNumOverflowOnDisk());
+
+ LuceneQuery<Integer, Type1> query = service.createLuceneQueryFactory().create(INDEX_NAME, REGION_NAME, "s:world");
+ LuceneQueryResults<Integer, Type1> results = query.search();
+ Assert.assertEquals(3, results.size());
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d7575214/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexRecoveryHAIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexRecoveryHAIntegrationTest.java b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexRecoveryHAIntegrationTest.java
index d32e6d8..194f3c7 100644
--- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexRecoveryHAIntegrationTest.java
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexRecoveryHAIntegrationTest.java
@@ -121,87 +121,8 @@ public class LuceneIndexRecoveryHAIntegrationTest {
Assert.assertNotEquals(newRepo, repo);
}
- @Category(FlakyTest.class) // GEODE-1012: time sensitive, awaitility, short timeout
- @Test
- public void recoverPersistentIndex() throws Exception {
- String aeqId = LuceneServiceImpl.getUniqueIndexName(INDEX, REGION);
-
- LuceneService service = LuceneServiceProvider.get(cache);
- service.createIndex(INDEX, REGION, Type1.fields);
-
- RegionFactory<String, Type1> regionFactory = cache.createRegionFactory(RegionShortcut.PARTITION_PERSISTENT);
- Region<String, Type1> userRegion = regionFactory.create(REGION);
-
- Type1 value = new Type1("hello world", 1, 2L, 3.0, 4.0f);
- userRegion.put("value1", value);
- value = new Type1("test world", 1, 2L, 3.0, 4.0f);
- userRegion.put("value2", value);
- value = new Type1("lucene world", 1, 2L, 3.0, 4.0f);
- userRegion.put("value3", value);
-
- verifyIndexFinishFlushing(INDEX, REGION);
-
- LuceneQuery<Integer, Type1> query = service.createLuceneQueryFactory().create(INDEX, REGION, "s:world");
- LuceneQueryResults<Integer, Type1> results = query.search();
- Assert.assertEquals(3, results.size());
- // close the cache and all the regions
- cache.close();
- cache = new CacheFactory().set("mcast-port", "0").create();
- service = LuceneServiceProvider.get(cache);
- service.createIndex(INDEX, REGION, Type1.fields);
- regionFactory = cache.createRegionFactory(RegionShortcut.PARTITION_PERSISTENT);
- userRegion = regionFactory.create(REGION);
-
- query = service.createLuceneQueryFactory().create(INDEX, REGION, "s:world");
- results = query.search();
- Assert.assertEquals(3, results.size());
-
- PartitionedRegion chunkRegion = (PartitionedRegion) cache.getRegion(aeqId + ".chunks");
- assertNotNull(chunkRegion);
- chunkRegion.destroyRegion();
- PartitionedRegion fileRegion = (PartitionedRegion) cache.getRegion(aeqId + ".files");
- assertNotNull(fileRegion);
- fileRegion.destroyRegion();
- userRegion.destroyRegion();
- }
-
- @Category(FlakyTest.class) // GEODE-1013: time sensitive, awaitility, short timeout, possible disk pollution
- @Test
- public void overflowRegionIndex() throws Exception {
- String aeqId = LuceneServiceImpl.getUniqueIndexName(INDEX, REGION);
-
- LuceneService service = LuceneServiceProvider.get(cache);
- service.createIndex(INDEX, REGION, Type1.fields);
-
- RegionFactory<String, Type1> regionFactory = cache.createRegionFactory(RegionShortcut.PARTITION);
- EvictionAttributesImpl evicAttr = new EvictionAttributesImpl().setAction(EvictionAction.OVERFLOW_TO_DISK);
- evicAttr.setAlgorithm(EvictionAlgorithm.LRU_ENTRY).setMaximum(1);
- regionFactory.setEvictionAttributes(evicAttr);
-
- PartitionedRegion userRegion = (PartitionedRegion) regionFactory.create(REGION);
- Assert.assertEquals(0, userRegion.getDiskRegionStats().getNumOverflowOnDisk());
-
- Type1 value = new Type1("hello world", 1, 2L, 3.0, 4.0f);
- userRegion.put("value1", value);
- value = new Type1("test world", 1, 2L, 3.0, 4.0f);
- userRegion.put("value2", value);
- value = new Type1("lucene world", 1, 2L, 3.0, 4.0f);
- userRegion.put("value3", value);
-
- verifyIndexFinishFlushing(INDEX, REGION);
-
- PartitionedRegion fileRegion = (PartitionedRegion) cache.getRegion(aeqId + ".files");
- assertNotNull(fileRegion);
- PartitionedRegion chunkRegion = (PartitionedRegion) cache.getRegion(aeqId + ".chunks");
- assertNotNull(chunkRegion);
- Assert.assertTrue(0 < userRegion.getDiskRegionStats().getNumOverflowOnDisk());
-
- LuceneQuery<Integer, Type1> query = service.createLuceneQueryFactory().create(INDEX, REGION, "s:world");
- LuceneQueryResults<Integer, Type1> results = query.search();
- Assert.assertEquals(3, results.size());
- }
private void verifyIndexFinishFlushing(String indexName, String regionName) {
LuceneIndex index = LuceneServiceProvider.get(cache).getIndex(indexName, regionName);