Skip to content

Commit

Permalink
Migrate Java IT test to Testkit (#1095)
Browse files Browse the repository at this point in the history
The following IT test has been replaced by stub test:
- `CausalClusteringIT.shouldAllowExistingTransactionToCompleteAfterDifferentConnectionBreaks` -> `Routing.test_should_succeed_when_another_conn_fails_and_discover_using_tx_run`
  • Loading branch information
injectives authored Dec 3, 2021
1 parent 4e92394 commit ea9ce62
Showing 1 changed file with 0 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
import org.neo4j.driver.internal.cluster.RoutingSettings;
import org.neo4j.driver.internal.retry.RetrySettings;
import org.neo4j.driver.internal.security.SecurityPlanImpl;
import org.neo4j.driver.internal.util.FailingConnectionDriverFactory;
import org.neo4j.driver.internal.util.FakeClock;
import org.neo4j.driver.internal.util.ThrowingMessageEncoder;
import org.neo4j.driver.internal.util.io.ChannelTrackingDriverFactory;
Expand Down Expand Up @@ -430,48 +429,6 @@ void shouldRespectMaxConnectionPoolSizePerClusterMember()
}
}

@Test
void shouldAllowExistingTransactionToCompleteAfterDifferentConnectionBreaks()
{
Cluster cluster = clusterRule.getCluster();

FailingConnectionDriverFactory driverFactory = new FailingConnectionDriverFactory();

try ( Driver driver = driverFactory.newInstance( cluster.getRoutingUri(), clusterRule.getDefaultAuthToken(),
RoutingSettings.DEFAULT, RetrySettings.DEFAULT, configWithoutLogging(), SecurityPlanImpl.insecure() ) )
{
Session session1 = driver.session();
Transaction tx1 = session1.beginTransaction();
tx1.run( "CREATE (n:Node1 {name: 'Node1'})" ).consume();

Session session2 = driver.session();
Transaction tx2 = session2.beginTransaction();
tx2.run( "CREATE (n:Node2 {name: 'Node2'})" ).consume();

ServiceUnavailableException error = new ServiceUnavailableException( "Connection broke!" );
driverFactory.setNextRunFailure( error );
assertUnableToRunMoreQueriesInTx( tx2, error );

tx2.close();
tx1.commit();

try ( Session session3 = driver.session( builder().withBookmarks( session1.lastBookmark() ).build() ) )
{
// tx1 should not be terminated and should commit successfully
assertEquals( 1, countNodes( session3, "Node1", "name", "Node1" ) );
// tx2 should not commit because of a connection failure
assertEquals( 0, countNodes( session3, "Node2", "name", "Node2" ) );
}

// rediscovery should happen for the new write query
Bookmark session4Bookmark = createNodeAndGetBookmark( driver.session(), "Node3", "name", "Node3" );
try ( Session session5 = driver.session( builder().withBookmarks( session4Bookmark ).build() ) )
{
assertEquals( 1, countNodes( session5, "Node3", "name", "Node3" ) );
}
}
}

@Test
void shouldKeepOperatingWhenConnectionsBreak() throws Exception
{
Expand Down Expand Up @@ -530,12 +487,6 @@ private void assertRoutingNotAvailableOnReadReplica()
assumeFalse( driver.supportsMultiDb() );
}

private static void assertUnableToRunMoreQueriesInTx(Transaction tx, ServiceUnavailableException cause )
{
SessionExpiredException e = assertThrows( SessionExpiredException.class, () -> tx.run( "CREATE (n:Node3 {name: 'Node3'})" ).consume() );
assertEquals( cause, e.getCause() );
}

private CompletionStage<List<RecordAndSummary>> combineCursors( ResultCursor cursor1,
ResultCursor cursor2 )
{
Expand Down

0 comments on commit ea9ce62

Please sign in to comment.