test: Neo4j docker containers are misconfigured with respect to the advertised addresses #235
Open
Description
When inspecting the routing table in Neo4jConnectionPool::routingTable()
, we get the following result on the call to $bolt->route()
:
[
{
"addresses": [
"localhost:7687"
],
"role": "WRITE"
},
{
"addresses": [
"localhost:7687"
],
"role": "READ"
},
{
"addresses": [
"localhost:7687"
],
"role": "ROUTE"
}
]
Since we are running the Neo4j server in a docker container, localhost
should not be accessible. But due to a check in Neo4jConnectionPool::getNextServer()
, where we get the list of addresses, deduplicate it and return null
if the count is one, we use the default URI to connect which shouldn't be the case. Below is a snippet of the code in question:
private function getNextServer(RoutingTable $table, AccessMode $mode): ?Uri
{
$servers = array_unique($table->getWithRole()); // Results in `["localhost:7687"]`
if (count($servers) === 1) {
return null;
}
// ...
}
This is unexpected behavior and should be resolved once we have the local containers advertise the correct addresses