Skip to content

Commit 1839e55

Browse files
committed
Another flaky test fix
Use transaction function to write and receive bookmark. Previously `Session#run()` was used and it does not produce a bookmark.
1 parent c3272f2 commit 1839e55

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

driver/src/test/java/org/neo4j/driver/v1/integration/CausalClusteringIT.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -528,13 +528,7 @@ public void shouldAllowExistingTransactionToCompleteAfterDifferentConnectionBrea
528528
}
529529

530530
// rediscovery should happen for the new write query
531-
String session4Bookmark;
532-
try ( Session session4 = driver.session() )
533-
{
534-
session4.run( "CREATE (n:Node3 {name: 'Node3'})" ).consume();
535-
session4Bookmark = session4.lastBookmark();
536-
}
537-
531+
String session4Bookmark = createNodeAndGetBookmark( driver.session(), "Node3", "name", "Node3" );
538532
try ( Session session5 = driver.session( session4Bookmark ) )
539533
{
540534
assertEquals( 1, countNodes( session5, "Node3", "name", "Node3" ) );
@@ -810,21 +804,27 @@ private static Callable<String> createNodeAndGetBookmark( final Driver driver, f
810804
@Override
811805
public String call()
812806
{
813-
try ( Session session = driver.session() )
814-
{
815-
session.writeTransaction( new TransactionWork<Void>()
816-
{
817-
@Override
818-
public Void execute( Transaction tx )
819-
{
820-
tx.run( "CREATE (n:" + label + ") SET n." + property + " = $value",
821-
parameters( "value", value ) );
822-
return null;
823-
}
824-
} );
825-
return session.lastBookmark();
826-
}
807+
return createNodeAndGetBookmark( driver.session(), label, property, value );
827808
}
828809
};
829810
}
811+
812+
private static String createNodeAndGetBookmark( final Session session, final String label, final String property,
813+
final String value )
814+
{
815+
try ( Session localSession = session )
816+
{
817+
localSession.writeTransaction( new TransactionWork<Void>()
818+
{
819+
@Override
820+
public Void execute( Transaction tx )
821+
{
822+
tx.run( "CREATE (n:" + label + ") SET n." + property + " = $value",
823+
parameters( "value", value ) );
824+
return null;
825+
}
826+
} );
827+
return localSession.lastBookmark();
828+
}
829+
}
830830
}

0 commit comments

Comments
 (0)