Github user tnine commented on a diff in the pull request:

    https://github.com/apache/incubator-usergrid/pull/248#discussion_r30744000
  
    --- Diff: 
stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
 ---
    @@ -317,61 +256,73 @@ public void rebuildIndex() throws Exception {
     
             // ----------------- test that we can read them, should fail
     
    -        logger.debug("Reading data, should fail this time ");
    -        try {
    -            readData( em, "testTypes", entityCount, 3 );
    -            fail("should have failed to read data");
    +        logger.debug( "Reading data, should fail this time " );
    +
    +        readData( em, collectionName, 0, 0 );
    +
     
    -        } catch (Exception expected) {}
     
             // ----------------- rebuild index
     
    -        logger.debug("Preparing to rebuild all indexes");;
    +        logger.debug( "Preparing to rebuild all indexes" );
    +        ;
     
    -        final String meterName = this.getClass().getSimpleName() + 
".rebuildIndex";
    -        final Meter meter = registry.meter( meterName );
     
    -        EntityManagerFactory.ProgressObserver po = new 
EntityManagerFactory.ProgressObserver() {
    -            int counter = 0;
    +        try {
     
    -            @Override
    -            public void onProgress( final EntityRef entity ) {
    +            final ReIndexRequestBuilder builder =
    +                reIndexService.getBuilder().withApplicationId( 
em.getApplicationId() );
     
    -                meter.mark();
    -                logger.debug("Indexing {}:{}", entity.getType(), 
entity.getUuid());
    -                if ( counter % 100 == 0 ) {
    -                    logger.info("Reindexed {} entities", counter );
    -                }
    -                counter++;
    -            }
    +            ReIndexService.ReIndexStatus status = 
reIndexService.rebuildIndex( builder );
     
    +            assertNotNull( status.getJobId(), "JobId is present" );
     
    -        };
    +            logger.info( "Rebuilt index" );
     
    -        try {
     
    -            fail( "Implement index rebuild" );
    -//            setup.getEmf().rebuildInternalIndexes( po );
    -//
    -//            setup.getEmf().rebuildApplicationIndexes( 
em.getApplicationId(), po );
    +            waitForRebuild( status, reIndexService );
     
    -            reporter.report();
    -            registry.remove( meterName );
    -            logger.info("Rebuilt index");
     
    -            app.refreshIndex();
    +            logger.info( "Rebuilt index" );
     
    -        } catch (Exception ex) {
    -            logger.error("Error rebuilding index", ex);
    +            app.refreshIndex();
    +        }
    +        catch ( Exception ex ) {
    +            logger.error( "Error rebuilding index", ex );
                 fail();
             }
     
             // ----------------- test that we can read them
     
    -        Thread.sleep(2000);
    -        readData( em, "testTypes", entityCount, 3 );
    +        Thread.sleep( 2000 );
    +        readData( em, collectionName, ENTITIES_TO_INDEX, 3 );
    +    }
    +
    +
    +    /**
    +     * Wait for the rebuild to occur
    +     */
    +    private void waitForRebuild( final ReIndexService.ReIndexStatus 
status, final ReIndexService reIndexService )
    +        throws InterruptedException {
    +        while ( true ) {
    --- End diff --
    
    Yes, it could, but the test will timeout first due to the timeout 
annotation.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to