Skip to content

Commit 46d8534

Browse files
author
Zhen Li
committed
Fixed BoltKit tests due to server version
1 parent 6fd2384 commit 46d8534

15 files changed

+48
-22
lines changed

driver/src/main/java/org/neo4j/driver/internal/async/pool/NettyChannelTracker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void channelReleased( Channel channel )
7171
@Override
7272
public void channelAcquired( Channel channel )
7373
{
74-
log.debug( "Channel [%s] acquired from the pool. Local address: %s, remote address: %s",
74+
log.debug( "Channel [0x%s] acquired from the pool. Local address: %s, remote address: %s",
7575
channel.id(), channel.localAddress(), channel.remoteAddress() );
7676

7777
incrementInUse( channel );
@@ -87,7 +87,7 @@ public void channelCreated( Channel channel )
8787

8888
public void channelCreated( Channel channel, ListenerEvent creatingEvent )
8989
{
90-
log.debug( "Channel [%s] created. Local address: %s, remote address: %s",
90+
log.debug( "Channel [0x%s] created. Local address: %s, remote address: %s",
9191
channel.id(), channel.localAddress(), channel.remoteAddress() );
9292

9393
incrementInUse( channel );

driver/src/main/java/org/neo4j/driver/internal/cluster/RoutingProcedureRunner.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public CompletionStage<RoutingProcedureResponse> run( CompletionStage<Connection
6161
{
6262
ServerVersion serverVersion = connection.serverVersion();
6363
// As the connection can connect to any router (a.k.a. any core members), this connection strictly speaking is a read connection.
64-
DirectConnection delegate = new DirectConnection( connection, SYSTEM_DB_NAME, AccessMode.READ );
64+
DirectConnection delegate = connection( serverVersion, connection );
6565
Statement procedure = procedureStatement( serverVersion, databaseName );
6666
return runProcedure( delegate, procedure )
6767
.thenCompose( records -> releaseConnection( delegate, records ) )
@@ -76,6 +76,18 @@ CompletionStage<List<Record>> runProcedure( Connection connection, Statement pro
7676
.asyncResult().thenCompose( StatementResultCursor::listAsync );
7777
}
7878

79+
private DirectConnection connection( ServerVersion serverVersion, Connection connection )
80+
{
81+
if ( serverVersion.greaterThanOrEqual( v4_0_0 ))
82+
{
83+
return new DirectConnection( connection, SYSTEM_DB_NAME, AccessMode.READ );
84+
}
85+
else
86+
{
87+
return new DirectConnection( connection, ABSENT_DB_NAME, AccessMode.WRITE );
88+
}
89+
}
90+
7991
private Statement procedureStatement( ServerVersion serverVersion, String databaseName )
8092
{
8193
/*

driver/src/main/java/org/neo4j/driver/internal/cluster/RoutingTableHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public RoutingTableHandler( RoutingTable routingTable, Rediscovery rediscovery,
5454
@Override
5555
public void onConnectionFailure( BoltServerAddress address )
5656
{
57-
// remove from the routing table, to prevent concurrent threads from making connections to this address
57+
// remove server from the routing table, to prevent concurrent threads from making connections to this address
5858
routingTable.forget( address );
5959
}
6060

@@ -130,7 +130,7 @@ private synchronized void clusterCompositionLookupFailed( Throwable error )
130130
routingTableFuture.completeExceptionally( error );
131131
}
132132

133-
// This method cannot be synchronized as it will visited by all routing table's threads concurrently
133+
// This method cannot be synchronized as it will be visited by all routing table's threads concurrently
134134
public Set<BoltServerAddress> servers()
135135
{
136136
return routingTable.servers();

driver/src/main/java/org/neo4j/driver/internal/cluster/RoutingTables.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,13 @@ public interface RoutingTables
4444
Set<BoltServerAddress> allServers();
4545

4646
/**
47-
* The routing error handler removes stale servers from routing table.
47+
* The routing error handler used to remove stale servers from routing table.
4848
* @return the routing error handler of the given database
4949
*/
5050
RoutingErrorHandler routingErrorHandler( String databaseName );
5151

52+
/**
53+
* Removes a routing table of the given database from all tables.
54+
*/
5255
void remove( String databaseName );
5356
}

driver/src/test/java/org/neo4j/driver/integration/ChannelConnectorImplIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*/
19-
package org.neo4j.driver.integration.async;
19+
package org.neo4j.driver.integration;
2020

2121
import io.netty.bootstrap.Bootstrap;
2222
import io.netty.channel.Channel;

driver/src/test/java/org/neo4j/driver/integration/RoutingDriverBoltKitTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
3131
import java.util.concurrent.atomic.AtomicBoolean;
3232
import java.util.concurrent.atomic.AtomicInteger;
3333

34-
import org.neo4j.driver.internal.DriverFactory;
35-
import org.neo4j.driver.internal.cluster.RoutingSettings;
36-
import org.neo4j.driver.internal.retry.RetrySettings;
37-
import org.neo4j.driver.internal.util.DriverFactoryWithClock;
38-
import org.neo4j.driver.internal.util.DriverFactoryWithFixedRetryLogic;
39-
import org.neo4j.driver.internal.util.SleeplessClock;
4034
import org.neo4j.driver.AccessMode;
4135
import org.neo4j.driver.AuthToken;
4236
import org.neo4j.driver.AuthTokens;
@@ -53,6 +47,12 @@
5347
import org.neo4j.driver.exceptions.ServiceUnavailableException;
5448
import org.neo4j.driver.exceptions.SessionExpiredException;
5549
import org.neo4j.driver.exceptions.TransientException;
50+
import org.neo4j.driver.internal.DriverFactory;
51+
import org.neo4j.driver.internal.cluster.RoutingSettings;
52+
import org.neo4j.driver.internal.retry.RetrySettings;
53+
import org.neo4j.driver.internal.util.DriverFactoryWithClock;
54+
import org.neo4j.driver.internal.util.DriverFactoryWithFixedRetryLogic;
55+
import org.neo4j.driver.internal.util.SleeplessClock;
5656
import org.neo4j.driver.net.ServerAddress;
5757
import org.neo4j.driver.net.ServerAddressResolver;
5858
import org.neo4j.driver.util.StubServer;

driver/src/test/java/org/neo4j/driver/integration/async/AsyncSessionIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*/
19-
package org.neo4j.driver.integration;
19+
package org.neo4j.driver.integration.async;
2020

2121
import org.junit.jupiter.api.AfterEach;
2222
import org.junit.jupiter.api.BeforeEach;

driver/src/test/java/org/neo4j/driver/integration/async/AsyncTransactionIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*/
19-
package org.neo4j.driver.integration;
19+
package org.neo4j.driver.integration.async;
2020

2121
import org.junit.jupiter.api.AfterEach;
2222
import org.junit.jupiter.api.BeforeEach;

driver/src/test/java/org/neo4j/driver/stress/CausalClusteringIT.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*/
19-
package org.neo4j.driver;
19+
package org.neo4j.driver.stress;
2020

2121
import io.netty.channel.Channel;
2222
import org.junit.jupiter.api.AfterEach;
@@ -39,6 +39,17 @@
3939
import java.util.concurrent.atomic.AtomicBoolean;
4040
import java.util.function.Function;
4141

42+
import org.neo4j.driver.AccessMode;
43+
import org.neo4j.driver.AuthToken;
44+
import org.neo4j.driver.Config;
45+
import org.neo4j.driver.Driver;
46+
import org.neo4j.driver.GraphDatabase;
47+
import org.neo4j.driver.Record;
48+
import org.neo4j.driver.Session;
49+
import org.neo4j.driver.StatementResult;
50+
import org.neo4j.driver.StatementRunner;
51+
import org.neo4j.driver.Transaction;
52+
import org.neo4j.driver.Values;
4253
import org.neo4j.driver.async.AsyncSession;
4354
import org.neo4j.driver.async.StatementResultCursor;
4455
import org.neo4j.driver.exceptions.ClientException;

driver/src/test/resources/acquire_endpoints_v3.script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
!: AUTO HELLO
44
!: AUTO GOODBYE
55

6-
C: RUN "CALL dbms.cluster.routing.getRoutingTable({context})" {"context": {}} {"mode": "r"}
6+
C: RUN "CALL dbms.cluster.routing.getRoutingTable({context})" {"context": {}} {}
77
PULL_ALL
88
S: SUCCESS {"fields": ["ttl", "servers"]}
99
RECORD [9223372036854775807, [{"addresses": ["127.0.0.1:9007","127.0.0.1:9008"],"role": "WRITE"}, {"addresses": ["127.0.0.1:9005","127.0.0.1:9006"], "role": "READ"},{"addresses": ["127.0.0.1:9001","127.0.0.1:9002","127.0.0.1:9003"], "role": "ROUTE"}]]

driver/src/test/resources/discover_no_writers.script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
!: AUTO HELLO
44
!: AUTO GOODBYE
55

6-
C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}} {}
6+
C: RUN "CALL dbms.cluster.routing.getRoutingTable({context})" {"context": {}} {}
77
PULL_ALL
88
S: SUCCESS {"fields": ["ttl", "servers"]}
99
RECORD [9223372036854775807, [{"addresses": [],"role": "WRITE"}, {"addresses": ["127.0.0.1:9002","127.0.0.1:9003"], "role": "READ"},{"addresses": ["127.0.0.1:9004","127.0.0.1:9005"], "role": "ROUTE"}]]

driver/src/test/resources/discover_one_router.script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
!: AUTO HELLO
44
!: AUTO GOODBYE
55

6-
C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}} {}
6+
C: RUN "CALL dbms.cluster.routing.getRoutingTable({context})" {"context": {}} {}
77
PULL_ALL
88
S: SUCCESS {"fields": ["ttl", "servers"]}
99
RECORD [9223372036854775807, [{"addresses": ["127.0.0.1:9001","127.0.0.1:9002"],"role": "WRITE"}, {"addresses": ["127.0.0.1:9003","127.0.0.1:9004"], "role": "READ"},{"addresses": ["127.0.0.1:9005"], "role": "ROUTE"}]]

driver/src/test/resources/discover_servers.script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
!: AUTO HELLO
44
!: AUTO GOODBYE
55

6-
C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}} {}
6+
C: RUN "CALL dbms.cluster.routing.getRoutingTable({context})" {"context": {}} {}
77
PULL_ALL
88
S: SUCCESS {"fields": ["ttl", "servers"]}
99
RECORD [9223372036854775807, [{"addresses": ["127.0.0.1:9001"],"role": "WRITE"}, {"addresses": ["127.0.0.1:9002","127.0.0.1:9003","127.0.0.1:9004"], "role": "READ"},{"addresses": ["127.0.0.1:9001","127.0.0.1:9002","127.0.0.1:9003"], "role": "ROUTE"}]]

driver/src/test/resources/get_routing_table_with_context.script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
!: AUTO HELLO
44
!: AUTO GOODBYE
55

6-
C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {"policy": "my_policy", "region": "china"}} {}
6+
C: RUN "CALL dbms.cluster.routing.getRoutingTable({context})" {"context": {"policy": "my_policy", "region": "china"}} {}
77
PULL_ALL
88
S: SUCCESS {"fields": ["ttl", "servers"]}
99
RECORD [9223372036854775807, [{"addresses": ["127.0.0.1:9001", "127.0.0.1:9002"],"role": "WRITE"}, {"addresses": ["127.0.0.1:9001", "127.0.0.1:9002"], "role": "READ"},{"addresses": ["127.0.0.1:9001", "127.0.0.1:9002"], "role": "ROUTE"}]]

driver/src/test/resources/rediscover_using_initial_router.script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
!: AUTO BEGIN
66
!: AUTO COMMIT
77

8-
C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}} {}
8+
C: RUN "CALL dbms.cluster.routing.getRoutingTable({context})" {"context": {}} {}
99
PULL_ALL
1010
S: SUCCESS {"fields": ["ttl", "servers"]}
1111
RECORD [9223372036854775807, [{"addresses": ["127.0.0.1:9008"],"role": "WRITE"}, {"addresses": ["127.0.0.1:9001","127.0.0.1:9009","127.0.0.1:9010"], "role": "READ"},{"addresses": ["127.0.0.1:9001","127.0.0.1:9011"], "role": "ROUTE"}]]

0 commit comments

Comments
 (0)