usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject [16/16] usergrid git commit: Fixed failing tests and bugs -Fixed issue where query was not being passed correctly for ql search on connections -Fixed NPE for direct query -Fixed tests that were failing sometimes due to parallel execution -Fixed Collectio
Date Tue, 23 Oct 2018 03:17:54 GMT
Fixed failing tests and bugs
-Fixed issue where query was not being passed correctly for ql search on
connections
-Fixed NPE for direct query
-Fixed tests that were failing sometimes due to parallel execution
-Fixed CollectionDeleteTest so that it doesn not have to be ignored


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

Branch: refs/heads/master
Commit: 5fc3c506a14ac28a702a2c146466b9f3907e4125
Parents: 749a97f
Author: Keyur Karnik <keyur.karnik+github@gmail.com>
Authored: Mon Sep 24 01:58:40 2018 -0700
Committer: Keyur Karnik <keyur.karnik+github@gmail.com>
Committed: Mon Sep 24 17:42:11 2018 -0700

----------------------------------------------------------------------
 .../read/search/CandidateEntityFilter.java      |  4 +-
 .../service/ConnectionServiceImpl.java          |  7 ++-
 .../persistence/CollectionDeleteTest.java       | 62 ++++++++++----------
 .../TooManyDirectEntitiesExceptionMapper.java   | 18 ++++++
 .../applications/queries/AndOrQueryTest.java    |  3 +
 5 files changed, 59 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/5fc3c506/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
index cf1984d..c0db02f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
@@ -27,6 +27,7 @@ import org.apache.usergrid.corepersistence.index.IndexLocationStrategyFactory;
 import org.apache.usergrid.persistence.Schema;
 import org.apache.usergrid.persistence.index.*;
 import org.apache.usergrid.persistence.index.impl.IndexProducer;
+import org.apache.usergrid.persistence.index.query.ParsedQuery;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.persistence.model.field.DistanceField;
 import org.apache.usergrid.persistence.model.field.EntityObjectField;
@@ -103,7 +104,8 @@ public class CandidateEntityFilter extends AbstractFilter<FilterResult<Candidate
 
         boolean keepStaleEntries = pipelineContext.getKeepStaleEntries();
         String query = pipelineContext.getQuery();
-        boolean isDirectQuery = pipelineContext.getParsedQuery().isDirectQuery();
+        ParsedQuery parsedQuery = pipelineContext.getParsedQuery();
+        boolean isDirectQuery = parsedQuery == null ? false : parsedQuery.isDirectQuery();
 
         //buffer them to get a page size we can make 1 network hop
         final Observable<FilterResult<Entity>> searchIdSetObservable =

http://git-wip-us.apache.org/repos/asf/usergrid/blob/5fc3c506/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
index 259e4b9..c476f1f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
@@ -84,8 +84,11 @@ public class ConnectionServiceImpl implements ConnectionService {
         final Optional<String> query = search.getQuery();
 
         final IdBuilder pipelineBuilder =
-            pipelineBuilderFactory.create( search.getApplicationScope() ).withCursor( search.getCursor()
)
-                                  .withLimit( search.getLimit() ).fromId( search.getSourceNodeId()
);
+            pipelineBuilderFactory.create( search.getApplicationScope() )
+            	.withCursor( search.getCursor() )
+            	.withLimit( search.getLimit() )
+            	.query(query)
+            	.fromId( search.getSourceNodeId() );
 
 
         //we want to load all entities

http://git-wip-us.apache.org/repos/asf/usergrid/blob/5fc3c506/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionDeleteTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionDeleteTest.java
b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionDeleteTest.java
index ae32a58..c22a627 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionDeleteTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionDeleteTest.java
@@ -17,33 +17,31 @@
 package org.apache.usergrid.persistence;
 
 
-import com.codahale.metrics.MetricRegistry;
-import com.google.inject.Injector;
-import net.jcip.annotations.NotThreadSafe;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
 import org.apache.commons.lang.RandomStringUtils;
 import org.apache.usergrid.AbstractCoreIT;
-import org.apache.usergrid.cassandra.SpringResource;
-import org.apache.usergrid.corepersistence.index.*;
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
-import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
-import org.apache.usergrid.persistence.index.EntityIndex;
-import org.apache.usergrid.persistence.index.EntityIndexFactory;
-import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.corepersistence.index.CollectionDeleteRequestBuilder;
+import org.apache.usergrid.corepersistence.index.CollectionDeleteService;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.Ignore;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.*;
+import com.codahale.metrics.MetricRegistry;
 
-import static org.junit.Assert.*;
 
 
-@NotThreadSafe
-@Ignore("fix later")
 public class CollectionDeleteTest extends AbstractCoreIT {
     private static final Logger logger = LoggerFactory.getLogger( CollectionDeleteTest.class
);
 
@@ -201,9 +199,10 @@ public class CollectionDeleteTest extends AbstractCoreIT {
 
     private int retryReadData(EntityManager em, String collectionName, int expectedEntities,
 int retry) throws Exception {
         int count = -1;
+        Set<Entity> uniqueRemEnts = new HashSet<Entity>();
         do {
             try {
-                count = readData(em, collectionName, expectedEntities);
+                count = readData(em, collectionName, expectedEntities, uniqueRemEnts);
             } catch (Exception ignore) {
                 logger.info( "caught exception ", ignore);
             }
@@ -213,7 +212,7 @@ public class CollectionDeleteTest extends AbstractCoreIT {
         return count;
     }
 
-    private int readData(EntityManager em, String collectionName, int expectedEntities)
+    private int readData(EntityManager em, String collectionName, int expectedEntities, Set<Entity>
uniqueRemEnts)
         throws Exception {
 
         app.waitForQueueDrainAndRefreshIndex();
@@ -221,45 +220,44 @@ public class CollectionDeleteTest extends AbstractCoreIT {
         Results results = em.getCollection(em.getApplicationRef(), collectionName, null,
expectedEntities,
             Query.Level.ALL_PROPERTIES, false);
 
-        int count = 0;
-        List<Entity> list = new ArrayList<>();
+        
         while ( true ) {
 
             if (results.getEntities().size() == 0) {
                 break;
             }
+            
 
             UUID lastEntityUUID = null;
             for ( Entity e : results.getEntities() ) {
 
                 assertEquals(2000, e.getProperty("key2"));
 
-                if (count % 100 == 0) {
-                    logger.info("read {} entities", count);
+                if (uniqueRemEnts.size() % 100 == 0) {
+                    logger.info("read {} entities", uniqueRemEnts.size());
                 }
                 lastEntityUUID = e.getUuid();
-                count++;
-                list.add(e);
+                uniqueRemEnts.add(e);
+                logger.info("Found remaining entity {}", lastEntityUUID);
             }
 
             results = em.getCollection(em.getApplicationRef(), collectionName, lastEntityUUID,
expectedEntities,
                 Query.Level.ALL_PROPERTIES, false);
 
         }
-        logger.info("read {} total entities", count);
 
-        if (count != expectedEntities) {
-            logger.info("Expected {} did not match actual {}", expectedEntities, count);
-            if (count < 20) {
-                for (Entity e : list) {
+        if (uniqueRemEnts.size() != expectedEntities) {
+            logger.info("Expected {} did not match actual {}", expectedEntities, uniqueRemEnts.size());
+            if (uniqueRemEnts.size() < 20) {
+                for (Entity e : uniqueRemEnts) {
                     Object key = e.getProperty("key2");
-                    logger.info("Entity key {} ceated {}", key, e.getCreated());
+                    logger.info("Entity key {} uuid {} created {}", key,e.getUuid(), e.getCreated());
                 }
             }
         }
 
-        assertEquals( "Did not get expected entities", expectedEntities, count );
-        return count;
+        assertEquals( "Did not get expected entities", expectedEntities, uniqueRemEnts.size()
);
+        return uniqueRemEnts.size();
     }
 
     private int countEntities( EntityManager em, String collectionName, int expectedEntities)

http://git-wip-us.apache.org/repos/asf/usergrid/blob/5fc3c506/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/TooManyDirectEntitiesExceptionMapper.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/TooManyDirectEntitiesExceptionMapper.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/TooManyDirectEntitiesExceptionMapper.java
index 843086d..06226a5 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/TooManyDirectEntitiesExceptionMapper.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/TooManyDirectEntitiesExceptionMapper.java
@@ -1,3 +1,21 @@
+/*
+ * 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.usergrid.rest.exceptions;
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/5fc3c506/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
index d49460c..61e2760 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/AndOrQueryTest.java
@@ -24,6 +24,8 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import net.jcip.annotations.NotThreadSafe;
+
 import java.io.IOException;
 import java.util.List;
 
@@ -35,6 +37,7 @@ import static org.junit.Assert.*;
  *
  * @since 4.0
  */
+@NotThreadSafe
 public class AndOrQueryTest extends QueryTestBase {
     private static final Logger logger = LoggerFactory.getLogger(AndOrQueryTest.class);
 


Mime
View raw message