usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [13/36] usergrid git commit: Cleaned up reindexing test, and covered a case where reindexing wasn't properly filtering values.
Date Fri, 08 Apr 2016 20:21:00 GMT
Cleaned up reindexing test, and covered a case where reindexing wasn't properly filtering values.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/975616b0
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/975616b0
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/975616b0

Branch: refs/heads/release-2.1.1
Commit: 975616b0a13187d5c87b2eacc3266b27661ac904
Parents: aebfe1b
Author: George Reyes <grey@apache.org>
Authored: Tue Mar 22 16:24:08 2016 -0700
Committer: George Reyes <grey@apache.org>
Committed: Thu Mar 24 09:14:56 2016 -0700

----------------------------------------------------------------------
 .../corepersistence/index/IndexServiceImpl.java | 13 +++++-
 .../collection/CollectionsResourceIT.java       | 47 +++++++-------------
 2 files changed, 27 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/975616b0/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
index a753dba..f8d7aa5 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
@@ -119,6 +119,9 @@ public class IndexServiceImpl implements IndexService {
         //we may have to index  we're indexing from source->target here
         final Observable<IndexEdge> sourceEdgesToIndex = edgesToTarget.map( edge ->
generateScopeFromSource( edge ) );
 
+
+
+
         //do our observable for batching
         //try to send a whole batch if we can
         final Observable<IndexOperationMessage>  batches =  sourceEdgesToIndex
@@ -131,7 +134,15 @@ public class IndexServiceImpl implements IndexService {
                     if (logger.isDebugEnabled()) {
                         logger.debug("adding edge {} to batch for entity {}", indexEdge,
entity);
                     }
-                    batch.index( indexEdge, entity );
+
+                    final Map map = getFilteredStringObjectMap( applicationScope, entity,
indexEdge );
+
+                    if(map!=null){
+                        batch.index( indexEdge, entity ,map);
+                    }
+                    else{
+                        batch.index( indexEdge,entity );
+                    }
                 } )
                     //return the future from the batch execution
                 .map( batch -> batch.build() ) );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/975616b0/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
index 026f8a1..11a1878 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
@@ -128,22 +128,24 @@ public class CollectionsResourceIT extends AbstractRestIT {
 
         //Create test collection with test entity that is full text indexed.
         Entity testEntity = new Entity();
-        testEntity.put( "one", "value" );
+        testEntity.put( "one", "value1" );
         //this field shouldn't persist after reindexing.
-        testEntity.put( "two","valuetwo" );
+        testEntity.put( "two","valuetwo1" );
 
-        //TODO: add arrays to the indexing test
-        //testEntity.put("array","array stuff here");
+        this.app().collection( "testCollection" ).post( testEntity );
+
+        testEntity.put( "one", "value2" );
+        //this field shouldn't persist after reindexing.
+        testEntity.put( "two","valuetwo2" );
+
+        this.app().collection( "testCollection" ).post( testEntity );
 
-        Entity returnedEntity = this.app().collection( "testCollection" ).post( testEntity
);
 
         //Creating schema.
         //this could be changed to a hashmap.
         ArrayList<String> indexingArray = new ArrayList<>(  );
         indexingArray.add( "one" );
 
-        //TODO: add indexing array to the backend/test once you finish the regular selective
indexing.
-        //indexingArray.add( "field.three.index.array" );
 
         //field "fields" is required.
         Entity payload = new Entity();
@@ -153,44 +155,25 @@ public class CollectionsResourceIT extends AbstractRestIT {
         Entity thing = this.app().collection( "testCollection" ).collection( "_indexes" ).post(
payload );
         refreshIndex();
 
-        //Below is what needs to be implemented along with the index call above
-
-        //Get the collection schema and verify that it contains the same schema as posted
above.
-//        Collection collection = this.app().collection( "testCollection" ).collection( "_index"
).get();
-//
-//        LinkedHashMap testCollectionSchema = (LinkedHashMap)collection.getResponse().getData();
-//        //TODO: the below will have to be replaced by the values that I deem correct.
-//        assertEquals( ( thing ).get( "lastUpdated" ), testCollectionSchema.get( "lastUpdated"
));
-//        assertEquals( ( thing ).get( "lastUpdateBy" ),testCollectionSchema.get( "lastUpdateBy"
) );
-//        assertEquals( ( thing ).get( "lastReindexed" ),testCollectionSchema.get( "lastReindexed"
) );
-//
-//        //TODO: this test doesn't check to see if create checks the schema. Only that the
reindex removes whats already there.
-//        ArrayList<String> schema = ( ArrayList<String> ) testCollectionSchema.get(
"fields" );
-//        assertEquals( "one",schema.get( 0 ) );
-
         //Reindex and verify that the entity only has field one index.
         this.app().collection( "testCollection" ).collection( "_reindex" ).post();
+        Thread.sleep( 1000 );
+        refreshIndex();
 
-        String query = "one ='value'";
+        String query = "one ='value1'";
         QueryParameters queryParameters = new QueryParameters().setQuery(query);
 
         //having a name breaks it. Need to get rid of the stack trace and also
         Collection tempEntity = this.app().collection( "testCollection" ).get(queryParameters,true);
         Entity reindexedEntity = tempEntity.getResponse().getEntity();
-        assertEquals( "value",reindexedEntity.get( "one" ) );
+        assertEquals( "value1",reindexedEntity.get( "one" ) );
+        tempEntity=null;
 
         //Verify if you can query on an entity that was not indexed and that no entities
are returned.
-        query = "two = 'valuetwo'";
+        query = "two = 'valuetwo1'";
         queryParameters = new QueryParameters().setQuery(query);
         tempEntity = this.app().collection( "testCollection" ).get(queryParameters,true);
         assertEquals(0,tempEntity.getResponse().getEntities().size());
-
-//        refreshIndex();
-//
-//        Entity reindexedEntity = this.app().collection( "testCollection" ).entity( returnedEntity.getUuid()
).get();
-//        assertEquals( "12/31/9999",reindexedEntity.get( "one" ) );
-        //not sure if this should have some kind of sleep here because this reindex will
be heavily throttled.
-
     }
 
     /**


Mime
View raw message