Commit 79e6f7b9 authored by Levin Zimmermann's avatar Levin Zimmermann Committed by Kirill Smelkov

lib/zodb: Drop client-only parameters from normalized NEO URI

We need to drop client-specific options so that NEO URI that only differ
due to client options while actually pointing to the same NEO server
are equal after normalization.

--------
kirr: See neoppod!18 for
the discussion on this subject.

/reviewed-by @kirr
/reviewed-on !28
parent 2c0968e4
...@@ -563,6 +563,8 @@ def test_zstor_2zurl(tmpdir, neo_ssl_dict): ...@@ -563,6 +563,8 @@ def test_zstor_2zurl(tmpdir, neo_ssl_dict):
# any order of options should result in the same normalized URI # any order of options should result in the same normalized URI
("neo://cluster@xyz:1?a=1&c=10&b=2", "neo://cluster@xyz:1?a=1&b=2&c=10"), ("neo://cluster@xyz:1?a=1&c=10&b=2", "neo://cluster@xyz:1?a=1&b=2&c=10"),
("neo://cluster@xyz:1?b=2&a=1&c=10", "neo://cluster@xyz:1?a=1&b=2&c=10"), ("neo://cluster@xyz:1?b=2&a=1&c=10", "neo://cluster@xyz:1?a=1&b=2&c=10"),
# client options
("neo://cluster@xyz:1?compress=1&read-only=true&logfile=abc.log&cache-size=1024", "neo://cluster@xyz:1"),
], ],
) )
def test_zurl_normalize_main(zurl, zurl_norm_ok): def test_zurl_normalize_main(zurl, zurl_norm_ok):
......
...@@ -494,6 +494,11 @@ def _znormalize_neo(scheme, netloc, path, query, frag): ...@@ -494,6 +494,11 @@ def _znormalize_neo(scheme, netloc, path, query, frag):
# ca/cert/key is different than a URL with 'neos' scheme, # ca/cert/key is different than a URL with 'neos' scheme,
# although both point to the same database. # although both point to the same database.
scheme = "neos" scheme = "neos"
# Drop client specific options.
# These options only affect the behaviour of the NEO client, but don't specify
# a different NEO server, and therefore need to be dropped.
for k in ("compress", "read-only", "logfile", "cache-size"):
q.pop(k, 0)
# Explicitly sort query before reassembling into string to insure # Explicitly sort query before reassembling into string to insure
# parameter order of input URI doesn't impact normalized URI. # parameter order of input URI doesn't impact normalized URI.
query = urlparse.urlencode(tuple((k, q[k]) for k in sorted(q.keys())), doseq=True) query = urlparse.urlencode(tuple((k, q[k]) for k in sorted(q.keys())), doseq=True)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment