geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbarr...@apache.org
Subject [geode] branch develop updated: GEODE-5363: Fixes issue with build in IJ IDEA.
Date Wed, 18 Jul 2018 00:05:08 GMT
This is an automated email from the ASF dual-hosted git repository.

jbarrett pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 8975495  GEODE-5363: Fixes issue with build in IJ IDEA.
8975495 is described below

commit 89754953080cf3da9ce02a644bd3c0ac9afa1990
Author: Jacob Barrett <jbarrett@pivotal.io>
AuthorDate: Tue Jul 17 17:03:22 2018 -0700

    GEODE-5363: Fixes issue with build in IJ IDEA.
    
    - Splits up LuceneTestUtilities to removed duplication and compile fail.
---
 .../apache/geode/cache/lucene/LuceneDUnitTest.java |   3 +-
 .../test/LuceneDistributedTestUtilities.java       |  50 ++++
 .../cache/lucene/test/LuceneTestUtilities.java     | 311 ---------------------
 gradle/test.gradle                                 |  61 +++-
 4 files changed, 112 insertions(+), 313 deletions(-)

diff --git a/geode-lucene/src/distributedTest/java/org/apache/geode/cache/lucene/LuceneDUnitTest.java
b/geode-lucene/src/distributedTest/java/org/apache/geode/cache/lucene/LuceneDUnitTest.java
index 479f884..7b73afb 100644
--- a/geode-lucene/src/distributedTest/java/org/apache/geode/cache/lucene/LuceneDUnitTest.java
+++ b/geode-lucene/src/distributedTest/java/org/apache/geode/cache/lucene/LuceneDUnitTest.java
@@ -27,6 +27,7 @@ import org.apache.geode.cache.PartitionAttributes;
 import org.apache.geode.cache.PartitionAttributesFactory;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.cache.lucene.test.LuceneDistributedTestUtilities;
 import org.apache.geode.cache.lucene.test.LuceneTestUtilities;
 import org.apache.geode.distributed.ConfigurationProperties;
 import org.apache.geode.test.dunit.Host;
@@ -166,7 +167,7 @@ public abstract class LuceneDUnitTest extends JUnit4CacheTestCase {
     public Region createDataStore(Cache cache, String regionName) {
       if (this.equals(FIXED_PARTITION)) {
         try {
-          return LuceneTestUtilities.initDataStoreForFixedPR(cache);
+          return LuceneDistributedTestUtilities.initDataStoreForFixedPR(cache);
         } catch (Exception e) {
           e.printStackTrace();
           return null;
diff --git a/geode-lucene/src/distributedTest/java/org/apache/geode/cache/lucene/test/LuceneDistributedTestUtilities.java
b/geode-lucene/src/distributedTest/java/org/apache/geode/cache/lucene/test/LuceneDistributedTestUtilities.java
new file mode 100644
index 0000000..f403181
--- /dev/null
+++ b/geode-lucene/src/distributedTest/java/org/apache/geode/cache/lucene/test/LuceneDistributedTestUtilities.java
@@ -0,0 +1,50 @@
+/*
+ * 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.cache.lucene.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.FixedPartitionAttributes;
+import org.apache.geode.cache.Region;
+import org.apache.geode.test.dunit.VM;
+
+public class LuceneDistributedTestUtilities extends LuceneTestUtilities {
+
+
+  public static Region initDataStoreForFixedPR(final Cache cache) throws Exception {
+    List<FixedPartitionAttributes> fpaList = new ArrayList<FixedPartitionAttributes>();
+    int vmNum = VM.getCurrentVMNum();
+    if (vmNum % 2 == 0) {
+      FixedPartitionAttributes fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter1,
true);
+      FixedPartitionAttributes fpa2 =
+          FixedPartitionAttributes.createFixedPartition(Quarter2, false);
+      fpaList.clear();
+      fpaList.add(fpa1);
+      fpaList.add(fpa2);
+    } else {
+      FixedPartitionAttributes fpa1 =
+          FixedPartitionAttributes.createFixedPartition(Quarter1, false);
+      FixedPartitionAttributes fpa2 = FixedPartitionAttributes.createFixedPartition(Quarter2,
true);
+      fpaList.clear();
+      fpaList.add(fpa1);
+      fpaList.add(fpa2);
+    }
+
+    return createFixedPartitionedRegion(cache, REGION_NAME, fpaList, 40);
+  }
+
+}
diff --git a/geode-lucene/src/distributedTest/java/org/apache/geode/cache/lucene/test/LuceneTestUtilities.java
b/geode-lucene/src/distributedTest/java/org/apache/geode/cache/lucene/test/LuceneTestUtilities.java
deleted file mode 100644
index 6d2940b..0000000
--- a/geode-lucene/src/distributedTest/java/org/apache/geode/cache/lucene/test/LuceneTestUtilities.java
+++ /dev/null
@@ -1,311 +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.cache.lucene.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import java.util.function.Consumer;
-
-import org.apache.lucene.document.FloatPoint;
-import org.apache.lucene.document.IntPoint;
-import org.apache.lucene.search.Query;
-
-import org.apache.geode.cache.AttributesFactory;
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.EntryOperation;
-import org.apache.geode.cache.FixedPartitionAttributes;
-import org.apache.geode.cache.FixedPartitionResolver;
-import org.apache.geode.cache.PartitionAttributesFactory;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
-import org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl;
-import org.apache.geode.cache.lucene.LuceneIndex;
-import org.apache.geode.cache.lucene.LuceneIndexFactory;
-import org.apache.geode.cache.lucene.LuceneQuery;
-import org.apache.geode.cache.lucene.LuceneQueryException;
-import org.apache.geode.cache.lucene.LuceneQueryProvider;
-import org.apache.geode.cache.lucene.LuceneService;
-import org.apache.geode.cache.lucene.LuceneServiceProvider;
-import org.apache.geode.cache.lucene.PageableLuceneQueryResults;
-import org.apache.geode.cache.lucene.internal.LuceneIndexForPartitionedRegion;
-import org.apache.geode.cache.lucene.internal.LuceneServiceImpl;
-import org.apache.geode.cache.lucene.internal.distributed.EntryScore;
-import org.apache.geode.internal.cache.LocalRegion;
-import org.apache.geode.internal.cache.wan.AbstractGatewaySender;
-import org.apache.geode.test.dunit.VM;
-
-public class LuceneTestUtilities {
-  public static final String INDEX_NAME = "index";
-  public static final String REGION_NAME = "region";
-  public static final String DEFAULT_FIELD = "text";
-
-  public static final String CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_FIELDS =
-      "Cannot create Lucene index index on region /region with fields [field1, field2] because
another member defines the same index with fields [field1].";
-  public static final String CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_FIELDS_2 =
-      "Cannot create Lucene index index on region /region with fields [field1] because another
member defines the same index with fields [field1, field2].";
-  public static final String CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_ANALYZERS =
-      "Cannot create Lucene index index on region /region with analyzer StandardAnalyzer
on field field2 because another member defines the same index with analyzer KeywordAnalyzer
on that field.";
-  public static final String CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_ANALYZERS_1 =
-      "Cannot create Lucene index index on region /region with analyzer StandardAnalyzer
on field field1 because another member defines the same index with analyzer KeywordAnalyzer
on that field.";
-  public static final String CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_ANALYZERS_2 =
-      "Cannot create Lucene index index on region /region with analyzer KeywordAnalyzer on
field field1 because another member defines the same index with analyzer StandardAnalyzer
on that field.";
-  public static final String CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_ANALYZERS_3 =
-      "Cannot create Lucene index index on region /region with analyzer KeywordAnalyzer on
field field2 because another member defines the same index with analyzer StandardAnalyzer
on that field.";
-  public static final String CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_NAMES =
-      "Cannot create Lucene index index2 on region /region because it is not defined in another
member.";
-  public static final String CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_INDEXES_1 =
-      "Must create Lucene index index on region /region because it is defined in another
member.";
-  public static final String CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_INDEXES_2 =
-      "Cannot create Lucene index index2 on region /region because it is not defined in another
member.";
-  public static final String CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_INDEXES_3 =
-      "Cannot create Lucene index index on region /region because it is not defined in another
member.";
-  public static final String CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_SERIALIZER =
-      "Cannot create Lucene index index on region /region with serializer DummyLuceneSerializer
because another member defines the same index with different serializer HeterogeneousLuceneSerializer.";
-
-  public static String Quarter1 = "Q1";
-  public static String Quarter2 = "Q2";
-  public static String Quarter3 = "Q3";
-  public static String Quarter4 = "Q4";
-
-  public static void verifyResultOrder(Collection<EntryScore<String>> list,
-      EntryScore<String>... expectedEntries) {
-    Iterator<EntryScore<String>> iter = list.iterator();
-    for (EntryScore expectedEntry : expectedEntries) {
-      if (!iter.hasNext()) {
-        fail();
-      }
-      EntryScore toVerify = iter.next();
-      assertEquals(expectedEntry.getKey(), toVerify.getKey());
-      assertEquals(expectedEntry.getScore(), toVerify.getScore(), .0f);
-    }
-  }
-
-  public static class IntRangeQueryProvider implements LuceneQueryProvider {
-    String fieldName;
-    int lowerValue;
-    int upperValue;
-
-    private transient Query luceneQuery;
-
-    public IntRangeQueryProvider(String fieldName, int lowerValue, int upperValue) {
-      this.fieldName = fieldName;
-      this.lowerValue = lowerValue;
-      this.upperValue = upperValue;
-    }
-
-    @Override
-    public Query getQuery(LuceneIndex index) throws LuceneQueryException {
-      if (luceneQuery == null) {
-        luceneQuery = IntPoint.newRangeQuery(fieldName, lowerValue, upperValue);
-      }
-      System.out.println("IntRangeQueryProvider, using java serializable");
-      return luceneQuery;
-    }
-  }
-
-  public static class FloatRangeQueryProvider implements LuceneQueryProvider {
-    String fieldName;
-    float lowerValue;
-    float upperValue;
-
-    private transient Query luceneQuery;
-
-    public FloatRangeQueryProvider(String fieldName, float lowerValue, float upperValue)
{
-      this.fieldName = fieldName;
-      this.lowerValue = lowerValue;
-      this.upperValue = upperValue;
-    }
-
-    @Override
-    public Query getQuery(LuceneIndex index) throws LuceneQueryException {
-      if (luceneQuery == null) {
-        luceneQuery = FloatPoint.newRangeQuery(fieldName, lowerValue, upperValue);
-        // luceneQuery = DoublePoint.newRangeQuery(fieldName, lowerValue, upperValue);
-      }
-      System.out.println("IntRangeQueryProvider, using java serializable");
-      return luceneQuery;
-    }
-  }
-
-  public static Region initDataStoreForFixedPR(final Cache cache) throws Exception {
-    List<FixedPartitionAttributes> fpaList = new ArrayList<FixedPartitionAttributes>();
-    int vmNum = VM.getCurrentVMNum();
-    if (vmNum % 2 == 0) {
-      FixedPartitionAttributes fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter1,
true);
-      FixedPartitionAttributes fpa2 =
-          FixedPartitionAttributes.createFixedPartition(Quarter2, false);
-      fpaList.clear();
-      fpaList.add(fpa1);
-      fpaList.add(fpa2);
-    } else {
-      FixedPartitionAttributes fpa1 =
-          FixedPartitionAttributes.createFixedPartition(Quarter1, false);
-      FixedPartitionAttributes fpa2 = FixedPartitionAttributes.createFixedPartition(Quarter2,
true);
-      fpaList.clear();
-      fpaList.add(fpa1);
-      fpaList.add(fpa2);
-    }
-
-    return createFixedPartitionedRegion(cache, REGION_NAME, fpaList, 40);
-  }
-
-  public static Region createFixedPartitionedRegion(final Cache cache, String regionName,
-      List<FixedPartitionAttributes> fpaList, int localMaxMemory) {
-    List<String> allPartitions = new ArrayList();
-    if (fpaList != null) {
-      for (FixedPartitionAttributes fpa : fpaList) {
-        allPartitions.add(fpa.getPartitionName());
-      }
-    } else {
-      allPartitions.add("Q1");
-      allPartitions.add("Q2");
-    }
-
-    AttributesFactory fact = new AttributesFactory();
-
-    PartitionAttributesFactory pfact = new PartitionAttributesFactory();
-    pfact.setTotalNumBuckets(16);
-    pfact.setRedundantCopies(1);
-    pfact.setLocalMaxMemory(localMaxMemory);
-    if (fpaList != null) {
-      for (FixedPartitionAttributes fpa : fpaList) {
-        pfact.addFixedPartitionAttributes(fpa);
-      }
-    }
-    pfact.setPartitionResolver(new MyFixedPartitionResolver(allPartitions));
-    fact.setPartitionAttributes(pfact.create());
-    Region r = cache.createRegionFactory(fact.create()).create(regionName);
-    assertNotNull(r);
-    return r;
-  }
-
-  static class MyFixedPartitionResolver implements FixedPartitionResolver {
-
-    private final List<String> allPartitions;
-
-    public MyFixedPartitionResolver(final List<String> allPartitions) {
-      this.allPartitions = allPartitions;
-    }
-
-    @Override
-    public String getPartitionName(final EntryOperation opDetails,
-        @Deprecated final Set targetPartitions) {
-      int hash = Math.abs(opDetails.getKey().hashCode() % allPartitions.size());
-      return allPartitions.get(hash);
-    }
-
-    @Override
-    public Object getRoutingObject(final EntryOperation opDetails) {
-      return opDetails.getKey();
-    }
-
-    @Override
-    public String getName() {
-      return getClass().getName();
-    }
-
-    @Override
-    public void close() {
-
-    }
-
-  }
-
-  public static void verifyInternalRegions(LuceneService luceneService, Cache cache,
-      Consumer<LocalRegion> verify) {
-    // Get index
-    LuceneIndexForPartitionedRegion index =
-        (LuceneIndexForPartitionedRegion) luceneService.getIndex(INDEX_NAME, REGION_NAME);
-
-    LocalRegion fileRegion = (LocalRegion) cache.getRegion(index.createFileRegionName());
-    verify.accept(fileRegion);
-  }
-
-  public static AsyncEventQueue getIndexQueue(Cache cache) {
-    String aeqId = LuceneServiceImpl.getUniqueIndexName(INDEX_NAME, REGION_NAME);
-    return cache.getAsyncEventQueue(aeqId);
-  }
-
-  public static void createIndex(Cache cache, String... fieldNames) {
-    final LuceneIndexFactory indexFactory = LuceneServiceProvider.get(cache).createIndexFactory();
-    indexFactory.setFields(fieldNames).create(INDEX_NAME, REGION_NAME);
-  }
-
-  public static void verifyIndexFinishFlushing(Cache cache, String indexName, String regionName)
-      throws InterruptedException {
-    LuceneService luceneService = LuceneServiceProvider.get(cache);
-    LuceneIndex index = luceneService.getIndex(indexName, regionName);
-    boolean flushed =
-        luceneService.waitUntilFlushed(indexName, regionName, 60000, TimeUnit.MILLISECONDS);
-    assertTrue(flushed);
-  }
-
-  /**
-   * Verify that a query returns the expected list of keys. Ordering is ignored.
-   */
-  public static <K> void verifyQueryKeys(LuceneQuery<K, Object> query, K... expectedKeys)
-      throws LuceneQueryException {
-    Set<K> expectedKeySet = new HashSet<>(Arrays.asList(expectedKeys));
-    Set<K> actualKeySet = new HashSet<>(query.findKeys());
-    assertEquals(expectedKeySet, actualKeySet);
-  }
-
-  /**
-   * Verify that a query returns the expected map of key-value. Ordering is ignored.
-   */
-  public static <K> void verifyQueryKeyAndValues(LuceneQuery<K, Object> query,
-      HashMap expectedResults) throws LuceneQueryException {
-    HashMap actualResults = new HashMap<>();
-    final PageableLuceneQueryResults<K, Object> results = query.findPages();
-    while (results.hasNext()) {
-      results.next().stream().forEach(struct -> {
-        Object value = struct.getValue();
-        actualResults.put(struct.getKey(), value);
-      });
-    }
-    assertEquals(expectedResults, actualResults);
-  }
-
-  public static void pauseSender(final Cache cache) {
-    final AsyncEventQueueImpl queue = (AsyncEventQueueImpl) getIndexQueue(cache);
-    if (queue == null) {
-      return;
-    }
-    queue.getSender().pause();
-
-    AbstractGatewaySender sender = (AbstractGatewaySender) queue.getSender();
-    sender.getEventProcessor().waitForDispatcherToPause();
-  }
-
-  public static void resumeSender(final Cache cache) {
-    final AsyncEventQueueImpl queue = (AsyncEventQueueImpl) getIndexQueue(cache);
-    if (queue == null) {
-      return;
-    }
-    queue.getSender().resume();
-  }
-}
diff --git a/gradle/test.gradle b/gradle/test.gradle
index 1c8ba1a..a1be69c 100644
--- a/gradle/test.gradle
+++ b/gradle/test.gradle
@@ -92,7 +92,16 @@ subprojects {
         srcDir file('src/integrationTest/java')
       }
       resources.srcDir file('src/integrationTest/resources')
-      compiledBy(assemble)
+      apply plugin: 'idea'
+      idea {
+        module {
+          sourceDirs -= java
+          resourceDirs -= resources
+          testSourceDirs += java
+          testResourceDirs += resources
+          scopes.TEST.plus += [ configurations.integrationTestCompile ]
+        }
+      }
     }
 
     distributedTest {
@@ -102,6 +111,35 @@ subprojects {
         srcDir file('src/distributedTest/java')
       }
       resources.srcDir file('src/distributedTest/resources')
+      apply plugin: 'idea'
+      idea {
+        module {
+          sourceDirs -= java
+          resourceDirs -= resources
+          testSourceDirs += java
+          testResourceDirs += resources
+          scopes.TEST.plus += [ configurations.distributedTestCompile ]
+        }
+      }
+    }
+
+    performanceTest {
+      java {
+        compileClasspath += main.output + test.output
+        runtimeClasspath += main.output + test.output
+        srcDir file('src/performanceTest/java')
+      }
+      resources.srcDir file('src/performanceTest/resources')
+      apply plugin: 'idea'
+      idea {
+        module {
+          sourceDirs -= java
+          resourceDirs -= resources
+          testSourceDirs += java
+          testResourceDirs += resources
+          scopes.TEST.plus += [ configurations.performanceTestCompile ]
+        }
+      }
     }
 
     acceptanceTest {
@@ -111,6 +149,16 @@ subprojects {
         srcDir file('src/acceptanceTest/java')
       }
       resources.srcDir file('src/acceptanceTest/resources')
+      apply plugin: 'idea'
+      idea {
+        module {
+          sourceDirs -= java
+          resourceDirs -= resources
+          testSourceDirs += java
+          testResourceDirs += resources
+          scopes.TEST.plus += [ configurations.acceptanceTestCompile ]
+        }
+      }
     }
 
     uiTest {
@@ -120,6 +168,16 @@ subprojects {
         srcDir file('src/uiTest/java')
       }
       resources.srcDir file('src/uiTest/resources')
+      apply plugin: 'idea'
+      idea {
+        module {
+          sourceDirs -= java
+          resourceDirs -= resources
+          testSourceDirs += java
+          testResourceDirs += resources
+          scopes.TEST.plus += [ configurations.uiTestCompile ]
+        }
+      }
     }
   }
 
@@ -462,3 +520,4 @@ classes.dependsOn subprojects.compileIntegrationTestJava
 classes.dependsOn subprojects.compileDistributedTestJava
 classes.dependsOn subprojects.compileAcceptanceTestJava
 classes.dependsOn subprojects.compileUiTestJava
+


Mime
View raw message