Skip to content

Commit

Permalink
Try and fix flaky IndexPopulationIT
Browse files Browse the repository at this point in the history
By asserting that we can find expected data in index and don't care
about exact output.
  • Loading branch information
burqen committed Mar 4, 2019
1 parent 9d178d1 commit 8bcb986
Showing 1 changed file with 16 additions and 17 deletions.
Expand Up @@ -47,9 +47,9 @@
import org.neo4j.test.rule.TestDirectory;
import org.neo4j.values.storable.RandomValues;

import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.neo4j.logging.AssertableLogProvider.inLog;

public class IndexPopulationIT
{
Expand Down Expand Up @@ -166,36 +166,35 @@ public void shutdownDatabaseDuringIndexPopulations()
public void mustLogPhaseTracker()
{
Label nodeLabel = Label.label( "testLabel5" );
String key = "key";
String value = "hej";
try ( Transaction transaction = database.beginTx() )
{
database.createNode( nodeLabel ).setProperty( "key", "hej" );
database.createNode( nodeLabel ).setProperty( key, value );
transaction.success();
}

// when
try ( Transaction tx = database.beginTx() )
{
database.schema().indexFor( nodeLabel ).on( "key" ).create();
database.schema().indexFor( nodeLabel ).on( key ).create();
tx.success();
}
waitForOnlineIndexes();

// then
long indexCount = countIndexes();
assertEquals( "expected exactly one index to exist but there was " + indexCount, 1, indexCount );
try ( Transaction tx = database.beginTx() )
{
database.schema().awaitIndexesOnline( 1, TimeUnit.MINUTES );
ResourceIterator<Node> nodes = database.findNodes( nodeLabel, key, value );
long nodeCount = Iterators.count( nodes );
assertEquals( "expected exactly one hit in index but was ",1, nodeCount );
nodes.close();
tx.success();
}

// then
//noinspection unchecked
logProvider.assertContainsMessageMatching( allOf(
containsString( "TIME/PHASE" ),
containsString( "Final: " ),
containsString( "SCAN" ),
containsString( "WRITE" ),
containsString( "MERGE" ),
containsString( "BUILD" ),
containsString( "FLIP" ),
containsString( "totalTime=" )
) );
AssertableLogProvider.LogMatcher matcher = inLog( IndexPopulationJob.class ).info( containsString( "TIME/PHASE Final:" ) );
logProvider.assertAtLeastOnce( matcher );
}

private void prePopulateDatabase( GraphDatabaseService database, Label testLabel, String propertyName )
Expand Down

0 comments on commit 8bcb986

Please sign in to comment.