usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [5/5] git commit: Fixes to StaleEntityCleapupTest, which is looking good now, also some import cleanups.
Date Tue, 04 Nov 2014 16:11:49 GMT
Fixes to StaleEntityCleapupTest, which is looking good now, also some import cleanups.


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

Branch: refs/heads/two-dot-o-events
Commit: 3d3bbedc2da0f84c9e1180fed17c9fd39fc1a605
Parents: 5706b2c
Author: Dave Johnson <dmjohnson@apigee.com>
Authored: Tue Nov 4 11:11:33 2014 -0500
Committer: Dave Johnson <dmjohnson@apigee.com>
Committed: Tue Nov 4 11:11:33 2014 -0500

----------------------------------------------------------------------
 .../usergrid/corepersistence/GuiceModule.java   |  1 -
 .../events/EntityVersionCreatedHandler.java     |  9 +----
 .../corepersistence/StaleIndexCleanupTest.java  | 39 ++++++--------------
 .../corepersistence/TestGuiceModule.java        |  2 -
 .../impl/EntityVersionCreatedTaskTest.java      | 20 ----------
 .../index/impl/EsEntityIndexBatchImpl.java      |  5 ---
 6 files changed, 12 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3d3bbedc/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
index 3b868b3..e63f272 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
@@ -17,7 +17,6 @@ package org.apache.usergrid.corepersistence;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.multibindings.Multibinder;
-import com.google.inject.name.Names;
 
 import org.apache.usergrid.corepersistence.events.EntityDeletedHandler;
 import org.apache.usergrid.corepersistence.events.EntityVersionCreatedHandler;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3d3bbedc/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionCreatedHandler.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionCreatedHandler.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionCreatedHandler.java
index ff09119..94a673a 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionCreatedHandler.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionCreatedHandler.java
@@ -17,13 +17,8 @@
  */
 package org.apache.usergrid.corepersistence.events;
 
-import java.util.Properties;
-
-import org.elasticsearch.common.inject.Guice;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 import org.apache.usergrid.corepersistence.CpEntityManagerFactory;
 import org.apache.usergrid.corepersistence.CpSetup;
@@ -34,8 +29,6 @@ import org.apache.usergrid.persistence.index.EntityIndex;
 import org.apache.usergrid.persistence.index.EntityIndexBatch;
 import org.apache.usergrid.persistence.model.entity.Entity;
 
-import com.google.inject.Inject;
-import com.google.inject.name.Named;
 
 
 /**
@@ -65,7 +58,7 @@ public class EntityVersionCreatedHandler implements EntityVersionCreated
{
 
         EntityIndexBatch batch = ei.createBatch();
 
-        if(System.getProperty( "allow.stale.entities","false" ).equals( "false" )) {
+        if ( System.getProperty( "allow.stale.entities", "false" ).equals( "false" )) {
             batch.deindexPreviousVersions( entity );
             batch.execute();
         }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3d3bbedc/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
index 97a7288..dff2f59 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
@@ -18,20 +18,16 @@
 package org.apache.usergrid.corepersistence;
 
 import com.fasterxml.uuid.UUIDComparator;
-import com.google.inject.Guice;
-import com.google.inject.Inject;
-import com.google.inject.name.Named;
 
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
-import java.util.Properties;
 import java.util.UUID;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.usergrid.AbstractCoreIT;
-import org.apache.usergrid.CoreITSuite;
 import org.apache.usergrid.corepersistence.util.CpNamingUtils;
-import org.apache.usergrid.count.SimpleBatcher;
 import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.EntityRef;
@@ -60,8 +56,6 @@ import org.junit.After;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 
 //need to create system properties in test that can get applied
@@ -75,11 +69,13 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
     private static final long writeDelayMs = 50;
     private static final long readDelayMs = 50;
 
+    Lock sequential = new ReentrantLock();
+
     @Before
     public void before() {
-        //set the batcher to block the submit so we wait for results when testing
-        System.setProperty( "allow.stale.entities","true" );
 
+        // if tests run in parallel there will likely be a conflict over the allow.stale.entities
+        sequential.lock();
     }
 
     @After
@@ -117,8 +113,6 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
 
         assertTrue( "New version is greater than old", 
                 UUIDComparator.staticCompare( newVersion, oldVersion ) > 0 );
-
-        assertEquals( 2, queryCollectionCp("things", "select *").size() );
     }
 
 
@@ -131,7 +125,8 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
 
         logger.info("Started testCleanupOnRead()");
 
-        // TODO: turn off post processing stuff that cleans up stale entities 
+        // turn off post processing stuff that cleans up stale entities 
+        System.setProperty( "allow.stale.entities", "true" );
 
         final EntityManager em = app.getEntityManager();
 
@@ -177,6 +172,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
 
             maxVersions.add( toUpdate );
         }
+
         em.refreshIndex();
 
         // query Core Persistence directly for total number of result candidates
@@ -239,7 +235,8 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
 
         logger.info("Started testStaleIndexCleanup()");
 
-        // TODO: turn off index cleanup on read
+        // turn off post processing stuff that cleans up stale entities 
+        System.setProperty( "allow.stale.entities", "true" );
 
         final EntityManager em = app.getEntityManager();
 
@@ -313,12 +310,8 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
     @Test(timeout=10000)
     public void testCleanupOnUpdate() throws Exception {
 
-        System.setProperty( "allow.stale.entities","false" );
-
         logger.info( "Started testCleanupOnUpdate()" );
 
-        // TODO: turn off index cleanup on read
-
         final EntityManager em = app.getEntityManager();
 
         final int numEntities = 10;
@@ -366,16 +359,6 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
         // query Core Persistence directly for total number of result candidates
         crs = queryCollectionCp("things", "select *");
         Assert.assertEquals( "Expect candidates without earlier stale entities", numEntities,
crs.size() );
-
-        // wait for indexes to be cleared for the deleted entities
-        do {
-            Thread.sleep(100);
-            crs = queryCollectionCp("things", "select *");
-        } while ( crs.size() > 0 );
-
-        // will never get here if test times out
-        Assert.assertEquals( "Expect no candidates", 0, crs.size() );
-        System.clearProperty( "allow.stale.entities" );
     }
 
     

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3d3bbedc/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestGuiceModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestGuiceModule.java
b/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestGuiceModule.java
index cdf4c01..7d1bd69 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestGuiceModule.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestGuiceModule.java
@@ -19,8 +19,6 @@
 package org.apache.usergrid.corepersistence;
 
 import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.name.Names;
 
 
 public class TestGuiceModule extends AbstractModule {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3d3bbedc/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCreatedTaskTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCreatedTaskTest.java
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCreatedTaskTest.java
index 9d72665..92bb3ce 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCreatedTaskTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCreatedTaskTest.java
@@ -17,45 +17,25 @@
  */
 package org.apache.usergrid.persistence.collection.impl;
 
-import com.google.common.base.Optional;
 import com.google.common.util.concurrent.ListenableFuture;
-import com.netflix.astyanax.Keyspace;
-import com.netflix.astyanax.MutationBatch;
 import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
 
-import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
 import java.util.Set;
-import java.util.UUID;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
 import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.MvccEntity;
 import org.apache.usergrid.persistence.collection.event.EntityVersionCreated;
-import org.apache.usergrid.persistence.collection.event.EntityVersionDeleted;
-import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
-import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy;
-import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
-import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
-import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy;
-import org.apache.usergrid.persistence.collection.util.LogEntryMock;
 import org.apache.usergrid.persistence.core.task.NamedTaskExecutorImpl;
 import org.apache.usergrid.persistence.core.task.TaskExecutor;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 
 import org.junit.AfterClass;
 import org.junit.Test;
 
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.same;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3d3bbedc/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
index 7f6cf70..ad15fff 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
@@ -23,20 +23,15 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 import java.util.Set;
 import java.util.UUID;
 
-import org.elasticsearch.action.ActionFuture;
 import org.elasticsearch.action.bulk.BulkItemResponse;
 import org.elasticsearch.action.bulk.BulkRequestBuilder;
 import org.elasticsearch.action.bulk.BulkResponse;
-import org.elasticsearch.action.get.GetRequest;
-import org.elasticsearch.action.get.GetResponse;
 import org.elasticsearch.client.Client;
 import org.elasticsearch.index.query.FilterBuilders;
 import org.elasticsearch.index.query.FilteredQueryBuilder;
-import org.elasticsearch.index.query.QueryStringQueryBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 


Mime
View raw message