You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by nn...@apache.org on 2017/10/23 18:37:52 UTC

[geode] branch develop updated: GEODE-3520: Additional tests for corrupt index

This is an automated email from the ASF dual-hosted git repository.

nnag 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 bbb097a  GEODE-3520: Additional tests for corrupt index
bbb097a is described below

commit bbb097a005ab1528919440d42df4b7a23dccef4c
Author: nabarunnag <na...@cs.wisc.edu>
AuthorDate: Sat Oct 7 12:27:41 2017 -0700

    GEODE-3520: Additional tests for corrupt index
    
    	* Additional tests was added to make sure new entries are not added to a corrupted index
---
 .../query/dunit/CorruptedIndexIntegrationTest.java | 55 ++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/geode-core/src/test/java/org/apache/geode/cache/query/dunit/CorruptedIndexIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/cache/query/dunit/CorruptedIndexIntegrationTest.java
index 64ff11e..baa2555 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/query/dunit/CorruptedIndexIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/query/dunit/CorruptedIndexIntegrationTest.java
@@ -168,6 +168,61 @@ public class CorruptedIndexIntegrationTest extends JUnit4CacheTestCase {
   }
 
   @Test
+  public void putMustSucceedButShouldNotbeAddedtoIndexWhenTheRangeIndexIsCorrupted()
+      throws Exception {
+    String regionName = "portfolio";
+    String INDEX_NAME = "key_index1";
+
+    PartitionAttributesFactory partitionAttributes = new PartitionAttributesFactory();
+    partitionAttributes.setTotalNumBuckets(1);
+
+    Cache cache = getCache();
+    Region region = cache.createRegionFactory().setDataPolicy(DataPolicy.PARTITION)
+        .setPartitionAttributes(partitionAttributes.create()).create(regionName);
+
+    Portfolio p = new Portfolio(1, 2);
+    HashMap map1 = new HashMap();
+    map1.put("SUN", 1);
+    map1.put("IBM", 2);
+    map1.put("AOL", 4);
+    p.positions = map1;
+    region.put(1, p);
+
+    QueryService queryService = cache.getQueryService();
+    Index keyIndex1 = queryService.createIndex(INDEX_NAME, "positions[*]", "/portfolio");
+
+    Portfolio p2 = new Portfolio(3, 4);
+    HashMap map2 = new HashMap();
+    map2.put("APPL", 3);
+    map2.put("AOL", "hello");
+    p2.positions = map2;
+    region.put(2, p2);
+
+    Portfolio p3 = new Portfolio(5, 6);
+    HashMap map3 = new HashMap();
+    map3.put("APPL", 4);
+    map3.put("AOL", "world");
+    p3.positions = map3;
+    region.put(3, p3);
+
+    assertEquals("Put must be successful", 3, region.size());
+    assertEquals("Index must be invalid at this point ", false, keyIndex1.isValid());
+    assertEquals("No new entries must be added to the corrupted index", 4,
+        keyIndex1.getStatistics().getNumberOfValues());
+
+    QueryObserverImpl observer = new QueryObserverImpl();
+    QueryObserverHolder.setInstance(observer);
+
+    SelectResults results = (SelectResults) queryService
+        .newQuery(
+            "select * from /portfolio p where p.positions['AOL'] = 'hello' OR p.positions['IBM'] = 2")
+        .execute();
+    assertEquals("Correct results expected from the query execution ", 2, results.size());
+    assertEquals("No index must be used while executing the query ", 0,
+        observer.indexesUsed.size());
+  }
+
+  @Test
   public void rangeIndexCreationMustFailIfRegionEntriesAreNotCompatible() throws Exception {
     String regionName = "portfolio";
     String INDEX_NAME = "key_index1";

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <co...@geode.apache.org>'].