geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sai_boorlaga...@apache.org
Subject [09/15] incubator-geode git commit: GEODE-1572: add a dunit test for client server query for lucene
Date Thu, 23 Jun 2016 17:25:33 GMT
GEODE-1572: add a dunit test for client server query for lucene


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/de6105f9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/de6105f9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/de6105f9

Branch: refs/heads/feature/GEODE-1573
Commit: de6105f98021095c110bbc91ba547f8a01904ae7
Parents: 9ccb4d5
Author: zhouxh <gzhou@pivotal.io>
Authored: Tue Jun 21 10:15:21 2016 -0700
Committer: zhouxh <gzhou@pivotal.io>
Committed: Tue Jun 21 10:15:59 2016 -0700

----------------------------------------------------------------------
 .../gemfire/cache/lucene/LuceneQueriesBase.java | 10 +--
 .../lucene/LuceneQueriesClientDUnitTest.java    | 70 ++++++++++++++++++++
 2 files changed, 75 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/de6105f9/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesBase.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesBase.java
b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesBase.java
index 26cd4aa..2fdf531 100644
--- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesBase.java
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesBase.java
@@ -47,7 +47,7 @@ public abstract class LuceneQueriesBase extends LuceneDUnitTest {
   protected VM accessor;
 
   @Override
-  public final void postSetUp() throws Exception {
+  public void postSetUp() throws Exception {
     super.postSetUp();
     accessor = Host.getHost(0).getVM(3);
   }
@@ -65,7 +65,7 @@ public abstract class LuceneQueriesBase extends LuceneDUnitTest {
     accessor.invoke(() -> initAccessor(createIndex));
 
     putDataInRegion(accessor);
-    assertTrue(waitForFlushBeforeExecuteTextSearch(accessor, 60000));
+    assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, 60000));
     executeTextSearch(accessor);
   }
 
@@ -79,7 +79,7 @@ public abstract class LuceneQueriesBase extends LuceneDUnitTest {
     dataStore2.invoke(() -> initDataStore(createIndex));
     accessor.invoke(() -> initAccessor(createIndex));
     putDataInRegion(accessor);
-    assertTrue(waitForFlushBeforeExecuteTextSearch(accessor, 60000));
+    assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, 60000));
     executeTextSearch(accessor, "world", "text", 3);
     executeTextSearch(accessor, "world", "noEntriesMapped", 0);
   }
@@ -98,10 +98,10 @@ public abstract class LuceneQueriesBase extends LuceneDUnitTest {
     dataStore1.invoke(() -> pauseSender(getCache()));
     dataStore2.invoke(() -> pauseSender(getCache()));
     putDataInRegion(accessor);
-    assertFalse(waitForFlushBeforeExecuteTextSearch(accessor, 500));
+    assertFalse(waitForFlushBeforeExecuteTextSearch(dataStore1, 500));
     dataStore1.invoke(() -> resumeSender(getCache()));
     dataStore2.invoke(() -> resumeSender(getCache()));
-    assertTrue(waitForFlushBeforeExecuteTextSearch(accessor, 60000));
+    assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, 60000));
     executeTextSearch(accessor);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/de6105f9/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesClientDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesClientDUnitTest.java
b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesClientDUnitTest.java
new file mode 100755
index 0000000..1988baf
--- /dev/null
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesClientDUnitTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.lucene.test.LuceneTestUtilities.REGION_NAME;
+
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.client.ClientCacheFactory;
+import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
+import com.gemstone.gemfire.cache.server.CacheServer;
+import com.gemstone.gemfire.test.dunit.SerializableCallableIF;
+import com.gemstone.gemfire.test.dunit.SerializableRunnableIF;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+
+@Category(DistributedTest.class)
+public class LuceneQueriesClientDUnitTest extends LuceneQueriesBase {
+
+  @Override public void postSetUp() throws Exception {
+    super.postSetUp();
+    SerializableCallableIF<Integer> launchServer = () ->
+    {
+      final Cache cache = getCache();
+      final CacheServer server = cache.addCacheServer();
+      server.setPort(0);
+      server.start();
+      return server.getPort();
+    };
+    final int port1 = dataStore1.invoke(launchServer);
+    final int port2 = dataStore2.invoke(launchServer);
+
+    accessor.invoke(() -> {
+      ClientCacheFactory clientCacheFactory = new ClientCacheFactory();
+      clientCacheFactory.addPoolServer("localhost", port1);
+      clientCacheFactory.addPoolServer("localhost", port2);
+      ClientCache clientCache = getClientCache(clientCacheFactory);
+      clientCache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create(REGION_NAME);
+    });
+  }
+
+  @Override
+  protected void initAccessor(SerializableRunnableIF createIndex) throws Exception {
+  }
+
+  @Override
+  protected void initDataStore(SerializableRunnableIF createIndex) throws Exception {
+    createIndex.run();
+    getCache().createRegionFactory(RegionShortcut.PARTITION).create(REGION_NAME);
+  }
+
+}


Mime
View raw message