Skip to content

Commit

Permalink
Added debug output to diagnose flakiness of StartClientIT
Browse files Browse the repository at this point in the history
  • Loading branch information
lutovich committed Sep 8, 2017
1 parent b507702 commit 46a6840
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions community/shell/src/test/java/org/neo4j/shell/StartClientIT.java
Expand Up @@ -34,6 +34,7 @@
import java.rmi.RemoteException;

import org.neo4j.bolt.v1.runtime.WorkerFactory;
import org.neo4j.graphdb.NotFoundException;
import org.neo4j.graphdb.Transaction;
import org.neo4j.logging.AssertableLogProvider;
import org.neo4j.shell.impl.AbstractClient;
Expand Down Expand Up @@ -77,11 +78,7 @@ public void givenShellClientWhenOpenFileThenExecuteFileCommands()
StartClient.main( new String[]{"-file", getClass().getResource( "/testshell.txt" ).getFile()} );

// Then
try ( Transaction tx = db.beginTx() )
{
assertThat( db.getNodeById( 0 ).getProperty( "foo" ), equalTo( "bar" ) );
tx.success();
}
assertNodeExists( 0, "foo", "bar" );
}

@Test
Expand All @@ -103,11 +100,7 @@ public void givenShellClientWhenReadFromStdinThenExecutePipedCommands() throws I
}

// Then
try ( Transaction tx = db.beginTx() )
{
assertThat( db.getNodeById( 0 ).getProperty( "foo" ), equalTo( "bar" ) );
tx.success();
}
assertNodeExists( 0, "foo", "bar" );
}

@Test
Expand Down Expand Up @@ -233,6 +226,30 @@ protected GraphDatabaseShellServer getGraphDatabaseShellServer( File path, boole
}
}

private void assertNodeExists( long id, String property, Object value )
{
try ( Transaction tx = db.beginTx() )
{
assertThat( db.getNodeById( id ).getProperty( property ), equalTo( value ) );
tx.success();
}
catch ( NotFoundException e )
{
System.out.println( "Unable to find either node with id 0 of it's property 'foo'" );
e.printStackTrace( System.out );

System.out.println( "Printing database content:" );
try ( Transaction tx = db.beginTx() )
{
db.getAllNodes().forEach( node ->
System.out.println( "Node [" + node.getId() + "] with props: " + node.getAllProperties() ) );
tx.success();
}

throw e;
}
}

private String runAndCaptureOutput( String[] arguments )
{
ByteArrayOutputStream buf = new ByteArrayOutputStream();
Expand Down

0 comments on commit 46a6840

Please sign in to comment.