Skip to content

Commit 76be8f7

Browse files
committed
Fixed flaky test
That tried to count inserted nodes in the cluster using read transaction and no bookmarks.
1 parent c8488bf commit 76be8f7

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -519,17 +519,26 @@ public void shouldAllowExistingTransactionToCompleteAfterDifferentConnectionBrea
519519
closeTx( tx2 );
520520
closeTx( tx1 );
521521

522-
// tx1 should not be terminated and should commit successfully
523-
assertEquals( 1, countNodes( session1, "Node1", "name", "Node1" ) );
524-
// tx2 should not commit because of a connection failure
525-
assertEquals( 0, countNodes( session1, "Node2", "name", "Node2" ) );
522+
try ( Session session3 = driver.session( session1.lastBookmark() ) )
523+
{
524+
// tx1 should not be terminated and should commit successfully
525+
assertEquals( 1, countNodes( session3, "Node1", "name", "Node1" ) );
526+
// tx2 should not commit because of a connection failure
527+
assertEquals( 0, countNodes( session3, "Node2", "name", "Node2" ) );
528+
}
526529

527530
// rediscovery should happen for the new write query
528-
try ( Session session3 = driver.session() )
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+
538+
try ( Session session5 = driver.session( session4Bookmark ) )
529539
{
530-
session3.run( "CREATE (n:Node3 {name: 'Node3'})" ).consume();
540+
assertEquals( 1, countNodes( session5, "Node3", "name", "Node3" ) );
531541
}
532-
assertEquals( 1, countNodes( session1, "Node3", "name", "Node3" ) );
533542
}
534543
}
535544

0 commit comments

Comments
 (0)