Skip to content

Commit b12fdb2

Browse files
committed
Merge branch '4.4' into impersonation
2 parents c88f2d3 + 4427536 commit b12fdb2

File tree

4 files changed

+30
-32
lines changed

4 files changed

+30
-32
lines changed

neo4j/addressing.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ def host(self):
138138
def port(self):
139139
return self[1]
140140

141+
@property
142+
def unresolved(self):
143+
return self
144+
141145
@classmethod
142146
def _dns_resolve(cls, address, family=0):
143147
""" Regular DNS resolver. Takes an address object and optional
@@ -226,6 +230,10 @@ class ResolvedAddress(Address):
226230
def host_name(self):
227231
return self._host_name
228232

233+
@property
234+
def unresolved(self):
235+
return super().__new__(Address, (self._host_name, *self[1:]))
236+
229237
def resolve(self, family=0, resolver=None):
230238
return [self]
231239

neo4j/io/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ def update_routing_table(self, *, database, imp_user, bookmarks,
11121112
def update_connection_pool(self, *, database):
11131113
servers = self.get_or_create_routing_table(database).servers()
11141114
for address in list(self.connections):
1115-
if address not in servers:
1115+
if address.unresolved not in servers:
11161116
super(Neo4jPool, self).deactivate(address)
11171117

11181118
def ensure_routing_table_is_fresh(self, *, access_mode, database, imp_user,

testkitbackend/test_config.json

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,5 @@
11
{
22
"skips": {
3-
"stub.routing.test_routing_v4x1.RoutingV4x1.test_should_retry_write_until_success_with_leader_change_using_tx_function":
4-
"Driver closes connection to router if DNS resolved name not in routing table",
5-
"stub.routing.test_routing_v3.RoutingV3.test_should_retry_write_until_success_with_leader_change_using_tx_function":
6-
"Driver closes connection to router if DNS resolved name not in routing table",
7-
"stub.routing.test_routing_v4x3.RoutingV4x3.test_should_retry_write_until_success_with_leader_change_using_tx_function":
8-
"Driver closes connection to router if DNS resolved name not in routing table",
9-
"stub.routing.test_routing_v4x4.RoutingV4x4.test_should_retry_write_until_success_with_leader_change_using_tx_function":
10-
"Driver closes connection to router if DNS resolved name not in routing table",
11-
"stub.routing.test_routing_v4x1.RoutingV4x1.test_should_retry_write_until_success_with_leader_change_on_run_using_tx_function":
12-
"Driver closes connection to router if DNS resolved name not in routing table",
13-
"stub.routing.test_routing_v3.RoutingV3.test_should_retry_write_until_success_with_leader_change_on_run_using_tx_function":
14-
"Driver closes connection to router if DNS resolved name not in routing table",
15-
"stub.routing.test_routing_v4x3.RoutingV4x3.test_should_retry_write_until_success_with_leader_change_on_run_using_tx_function":
16-
"Driver closes connection to router if DNS resolved name not in routing table",
17-
"stub.routing.test_routing_v4x4.RoutingV4x4.test_should_retry_write_until_success_with_leader_change_on_run_using_tx_function":
18-
"Driver closes connection to router if DNS resolved name not in routing table",
19-
"stub.routing.test_routing_v4x1.RoutingV4x1.test_should_retry_write_until_success_with_leader_shutdown_during_tx_using_tx_function":
20-
"Driver closes connection to router if DNS resolved name not in routing table",
21-
"stub.routing.test_routing_v3.RoutingV3.test_should_retry_write_until_success_with_leader_shutdown_during_tx_using_tx_function":
22-
"Driver closes connection to router if DNS resolved name not in routing table",
23-
"stub.routing.test_routing_v4x3.RoutingV4x3.test_should_retry_write_until_success_with_leader_shutdown_during_tx_using_tx_function":
24-
"Driver closes connection to router if DNS resolved name not in routing table",
25-
"stub.routing.test_routing_v4x4.RoutingV4x4.test_should_retry_write_until_success_with_leader_shutdown_during_tx_using_tx_function":
26-
"Driver closes connection to router if DNS resolved name not in routing table",
273
"stub.routing.test_routing_v4x1.RoutingV4x1.test_should_successfully_acquire_rt_when_router_ip_changes":
284
"Test makes assumptions about how verify_connectivity is implemented",
295
"stub.routing.test_routing_v3.RoutingV3.test_should_successfully_acquire_rt_when_router_ip_changes":

tests/unit/test_addressing.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,29 @@ def test_address_resolve_with_unresolvable_address(test_input, expected):
230230

231231
def test_address_resolve_with_custom_resolver():
232232
# python -m pytest tests/unit/test_addressing.py -s -k test_address_resolve_with_custom_resolver
233-
custom_resolver = lambda a: [("127.0.0.1", 7687), ("localhost", 1234)]
233+
custom_resolver = lambda _: [("127.0.0.1", 7687), ("localhost", 1234)]
234234

235235
address = Address(("127.0.0.1", 7687))
236236
resolved = address.resolve(family=AF_INET, resolver=custom_resolver)
237237
assert isinstance(resolved, Address) is False
238238
assert isinstance(resolved, list) is True
239-
if len(resolved) == 2:
240-
# IPv4 only
241-
assert resolved[0] == IPv4Address(('127.0.0.1', 7687))
242-
assert resolved[1] == IPv4Address(('127.0.0.1', 1234))
243-
else:
244-
assert False
239+
assert len(resolved) == 2 # IPv4 only
240+
assert resolved[0] == IPv4Address(('127.0.0.1', 7687))
241+
assert resolved[1] == IPv4Address(('127.0.0.1', 1234))
242+
243+
244+
def test_address_unresolve():
245+
# python -m pytest tests/unit/test_addressing.py -s -k test_address_unresolve
246+
custom_resolved = [("127.0.0.1", 7687), ("localhost", 4321)]
247+
custom_resolver = lambda _: custom_resolved
248+
249+
address = Address(("foobar", 1234))
250+
unresolved = address.unresolved
251+
assert address.__class__ == unresolved.__class__
252+
assert address == unresolved
253+
resolved = address.resolve(family=AF_INET, resolver=custom_resolver)
254+
custom_resolved = sorted(Address(a) for a in custom_resolved)
255+
unresolved = sorted(a.unresolved for a in resolved)
256+
assert custom_resolved == unresolved
257+
assert (list(map(lambda a: a.__class__, custom_resolved))
258+
== list(map(lambda a: a.__class__, unresolved)))

0 commit comments

Comments
 (0)