Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
tests are passing
Browse files Browse the repository at this point in the history
  • Loading branch information
Shawn Feldman committed Mar 3, 2015
1 parent 2b31015 commit b9408de
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ public void deleteApplication(UUID applicationId) throws Exception {
em.delete(appToDelete);
// create new Entity in deleted_appinfos collection, with same UUID and properties as deleted appinfo
em.create("deleted_appinfo", appToDelete.getProperties());
em.refreshIndex();
}

// delete the application's index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,21 +336,20 @@ public void testCleanupOnUpdate() throws Exception {

final EntityManager em = app.getEntityManager();

final int numEntities = 20;
final int numUpdates = 40;
final int numEntities = 10;
final int numUpdates = 5;

// create lots of entities
final List<Entity> things = new ArrayList<Entity>(numEntities);
final List<Entity> dogs = new ArrayList<Entity>(numEntities);
for ( int i=0; i<numEntities; i++) {
final String thingName = "thing" + i;
things.add( em.create("thing", new HashMap<String, Object>() {{
put("name", thingName);
final String dogName = "dog" + i;
dogs.add( em.create("dog", new HashMap<String, Object>() {{
put("name", dogName);
}}));
// Thread.sleep( writeDelayMs );
}
em.refreshIndex();

CandidateResults crs = queryCollectionCp( "things", "thing", "select *");
CandidateResults crs = queryCollectionCp( "dogs", "dog", "select *");
Assert.assertEquals( "Expect no stale candidates yet", numEntities, crs.size() );

// turn off post processing stuff that cleans up stale entities
Expand All @@ -360,16 +359,13 @@ public void testCleanupOnUpdate() throws Exception {

List<Entity> maxVersions = new ArrayList<>(numEntities);
int count = 0;
for ( Entity thing : things ) {
for ( Entity dog : dogs ) {
Entity toUpdate = null;

for ( int j=0; j<numUpdates; j++) {
toUpdate = em.get( thing.getUuid() );
toUpdate = em.get( dog.getUuid() );
toUpdate.setProperty( "property" + j, RandomStringUtils.randomAlphanumeric(10));

em.update(toUpdate);

Thread.sleep( writeDelayMs );
count++;
if ( count % 100 == 0 ) {
logger.info("Updated {} of {} times", count, numEntities * numUpdates);
Expand All @@ -383,11 +379,11 @@ public void testCleanupOnUpdate() throws Exception {
// wait for indexes to be cleared for the deleted entities
count = 0;
do {
if(count>0){Thread.sleep(200);}
crs = queryCollectionCp("things", "thing", "select *");
} while ( crs.size() == numEntities && count++ < 1000 );
Thread.sleep(100);
crs = queryCollectionCp("dogs", "dog", "select *");
} while ( crs.size() == numEntities && count++ < 15 );

Assert.assertEquals("Expect candidates without earlier stale entities", crs.size(),numEntities);
Assert.assertEquals("Expect candidates without earlier stale entities", crs.size(), numEntities);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

@NotThreadSafe
public class EntityManagerFactoryImplIT extends AbstractCoreIT {

private static final Logger logger = LoggerFactory.getLogger( EntityManagerFactoryImplIT.class );
Expand Down

0 comments on commit b9408de

Please sign in to comment.