Skip to content

[4.4] Remove all temporary feature flags #446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions nutkit/protocol/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,43 +113,3 @@ class Feature(Enum):
# routing table and assume all other connections to the server are dead
# as well.
CONF_HINT_CON_RECV_TIMEOUT = "ConfHint:connection.recv_timeout_seconds"

# Temporary driver feature that will be removed when all official driver
# backends have implemented the connection acquisition timeout config.
TMP_CONNECTION_ACQUISITION_TIMEOUT = \
"Temporary:ConnectionAcquisitionTimeout"
# Temporary driver feature that will be removed when all official driver
# backends have implemented path and relationship types
TMP_CYPHER_PATH_AND_RELATIONSHIP = "Temporary:CypherPathAndRelationship"
# TODO Update this once the decision has been made.
# Temporary driver feature. There is a pending decision on whether it
# should be supported in all drivers or be removed from all of them.
TMP_DRIVER_FETCH_SIZE = "Temporary:DriverFetchSize"
# Temporary driver feature that will be removed when all official driver
# backends have implemented the max connection pool size config.
TMP_DRIVER_MAX_CONNECTION_POOL_SIZE = \
"Temporary:DriverMaxConnectionPoolSize"
# Temporary driver feature that will be removed when all official driver
# backends have implemented it.
TMP_DRIVER_MAX_TX_RETRY_TIME = "Temporary:DriverMaxTxRetryTime"
# Temporary driver feature that will be removed when all official driver
# implemented failing fast and surfacing on certain error codes during
# discovery (initial fetching of a RT).
TMP_FAST_FAILING_DISCOVERY = "Temporary:FastFailingDiscovery"
# Temporary driver feature that will be removed when all official driver
# backends have implemented all summary response fields.
TMP_FULL_SUMMARY = "Temporary:FullSummary"
# Temporary driver feature that will be removed when all official driver
# backends have implemented the GetConnectionPoolMetrics request.
TMP_GET_CONNECTION_POOL_METRICS = \
"Temporary:GetConnectionPoolMetrics"
# Temporary driver feature that will be removed when all official drivers
# have been unified in their behaviour of when they return a Result object.
# We aim for drivers to not providing a Result until the server replied
# with SUCCESS so that the result keys are already known and attached to
# the Result object without further waiting or communication with the
# server.
TMP_RESULT_KEYS = "Temporary:ResultKeys"
# Temporary driver feature that will be removed when all official driver
# backends have implemented the TransactionClose request
TMP_TRANSACTION_CLOSE = "Temporary:TransactionClose"
29 changes: 5 additions & 24 deletions nutkit/protocol/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,11 @@ def __init__(
self.resolverRegistered = resolverRegistered
self.domainNameResolverRegistered = domainNameResolverRegistered
self.connectionTimeoutMs = connectionTimeoutMs
# TODO: remove assertion and condition as soon as all drivers support
# driver-scoped fetch-size config
from .feature import Feature
assert hasattr(Feature, "TMP_DRIVER_FETCH_SIZE")
if fetchSize is not None:
self.fetchSize = fetchSize
# TODO: remove assertion and condition as soon as all drivers support
# driver-scoped fetch-size config
assert hasattr(Feature, "TMP_DRIVER_MAX_TX_RETRY_TIME")
if maxTxRetryTimeMs is not None:
self.maxTxRetryTimeMs = maxTxRetryTimeMs
if liveness_check_timeout_ms is not None:
self.livenessCheckTimeoutMs = liveness_check_timeout_ms
# TODO: remove assertion and condition as soon as all drivers support
# driver-scoped max connection pool size config
assert hasattr(Feature, "TMP_DRIVER_MAX_CONNECTION_POOL_SIZE")
if max_connection_pool_size is not None:
self.maxConnectionPoolSize = max_connection_pool_size
# TODO: remove assertion and condition as soon as all drivers support
# driver-scoped connection acquisition timeout config
assert hasattr(Feature, "TMP_CONNECTION_ACQUISITION_TIMEOUT")
if connection_acquisition_timeout_ms is not None:
self.connectionAcquisitionTimeoutMs = \
connection_acquisition_timeout_ms
self.fetchSize = fetchSize
self.maxTxRetryTimeMs = maxTxRetryTimeMs
self.livenessCheckTimeoutMs = liveness_check_timeout_ms
self.maxConnectionPoolSize = max_connection_pool_size
self.connectionAcquisitionTimeoutMs = connection_acquisition_timeout_ms
# (bool) whether to enable or disable encryption
# field missing in message: use driver default (should be False)
if encrypted is not None:
Expand Down
3 changes: 2 additions & 1 deletion tests/neo4j/test_bookmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def test_can_pass_bookmark_into_next_session(self):
tx = self._session.begin_transaction()
result = tx.run("MATCH (a:Thing {uuid:$uuid}) RETURN a",
params={"uuid": types.CypherString(unique_id)})
if self.driver_supports_features(types.Feature.TMP_RESULT_KEYS):
if get_driver_name() not in ["dotnet"]:
# missing former types.Feature.TMP_RESULT_KEYS
self.assertEqual(result.keys(), ["a"])
records = [rec.values[0] for rec in result]
tx.commit()
Expand Down
11 changes: 4 additions & 7 deletions tests/neo4j/test_direct_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from ..shared import (
dns_resolve_single,
driver_feature,
get_driver_name,
TestkitTestCase,
)
Expand Down Expand Up @@ -75,7 +74,6 @@ def test_fail_nicely_when_using_http_port(self):
self.assertEqual(e.exception.errorType,
"<class 'neo4j.exceptions.ServiceUnavailable'>")

@driver_feature(types.Feature.TMP_FULL_SUMMARY)
def test_supports_multi_db(self):
def work(tx):
return tx.run("RETURN 1 as n").consume()
Expand Down Expand Up @@ -116,7 +114,6 @@ def test_multi_db_non_existing(self):
self.assertEqual(exc.errorType,
"<class 'neo4j.exceptions.ClientError'>")

@driver_feature(types.Feature.TMP_FULL_SUMMARY)
@requires_multi_db_support
@cluster_unsafe_test
def test_multi_db(self):
Expand Down Expand Up @@ -161,17 +158,17 @@ def get_names(result_, node=True):
for record in result_:
if node:
self.assertEqual(len(record.values), 1)
if self.driver_supports_features(
types.Feature.TMP_RESULT_KEYS):
if get_driver_name() not in ["dotnet"]:
# missing former types.Feature.TMP_RESULT_KEYS
self.assertEqual(result_.keys(), ["p"])
p = record.values[0]
self.assertIsInstance(p, types.CypherNode)
self.assertIsInstance(p.props, types.CypherMap)
name = p.props.value.get("name")
else:
idx = 0
if self.driver_supports_features(
types.Feature.TMP_RESULT_KEYS):
if get_driver_name() not in ["dotnet"]:
# missing former types.Feature.TMP_RESULT_KEYS
keys = result_.keys()
self.assertIn("name", keys)
idx = keys.index("name")
Expand Down
8 changes: 3 additions & 5 deletions tests/neo4j/test_session_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
get_server_info,
)
from tests.shared import (
driver_feature,
get_driver_name,
TestkitTestCase,
)
Expand Down Expand Up @@ -41,8 +40,9 @@ def test_iteration_smaller_than_fetch_size(self):
types.NullRecord(),
types.NullRecord()
]
if self.driver_supports_features(types.Feature.TMP_RESULT_KEYS):
assert result.keys() == ["x"]
if get_driver_name() not in ["dotnet"]:
# missing former types.Feature.TMP_RESULT_KEYS
self.assertEqual(result.keys(), ["x"])
for exp in expects:
rec = result.next()
self.assertEqual(rec, exp)
Expand All @@ -69,7 +69,6 @@ def test_can_return_node(self):
self.assertIsInstance(result.next(), types.NullRecord)
isinstance(result.next(), types.NullRecord)

@driver_feature(types.Feature.TMP_CYPHER_PATH_AND_RELATIONSHIP)
@cluster_unsafe_test
def test_can_return_relationship(self):
self._session1 = self._driver.session("w")
Expand All @@ -88,7 +87,6 @@ def test_can_return_relationship(self):
self.assertIsInstance(result.next(), types.NullRecord)
isinstance(result.next(), types.NullRecord)

@driver_feature(types.Feature.TMP_CYPHER_PATH_AND_RELATIONSHIP)
@cluster_unsafe_test
def test_can_return_path(self):
self._session1 = self._driver.session("w")
Expand Down
12 changes: 0 additions & 12 deletions tests/neo4j/test_summary.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from nutkit import protocol as types

from ..shared import (
driver_feature,
get_driver_name,
TestkitTestCase,
)
Expand Down Expand Up @@ -38,44 +37,37 @@ def work(tx):
self._session = self._driver.session("w")
return self._session.write_transaction(work)

@driver_feature(types.Feature.TMP_FULL_SUMMARY)
def test_can_obtain_summary_after_consuming_result(self):
summary = self.get_summary("CREATE (n) RETURN n")
self.assertEqual(summary.query.text, "CREATE (n) RETURN n")
self.assertEqual(summary.query.parameters, {})
self.assertEqual(summary.query_type, "rw")
self.assertEqual(summary.counters.nodes_created, 1)

@driver_feature(types.Feature.TMP_FULL_SUMMARY)
def test_no_plan_info(self):
summary = self.get_summary("CREATE (n) RETURN n")
self.assertIsNone(summary.plan)
self.assertIsNone(summary.profile)

@driver_feature(types.Feature.TMP_FULL_SUMMARY)
def test_can_obtain_plan_info(self):
summary = self.get_summary("EXPLAIN CREATE (n) RETURN n")
self.assertIsInstance(summary.plan, dict)

@driver_feature(types.Feature.TMP_FULL_SUMMARY)
def test_can_obtain_profile_info(self):
summary = self.get_summary("PROFILE CREATE (n) RETURN n")
self.assertIsInstance(summary.profile, dict)

@driver_feature(types.Feature.TMP_FULL_SUMMARY)
def test_no_notification_info(self):
summary = self.get_summary("CREATE (n) RETURN n")
self.assertIsNone(summary.notifications)

@driver_feature(types.Feature.TMP_FULL_SUMMARY)
def test_can_obtain_notification_info(self):
summary = self.get_summary("EXPLAIN MATCH (n), (m) RETURN n, m")
notifications = summary.notifications
self.assertIsInstance(notifications, list)
self.assertEqual(len(notifications), 1)
self.assertIsInstance(notifications[0], dict)

@driver_feature(types.Feature.TMP_FULL_SUMMARY)
def test_contains_time_information(self):
summary = self.get_summary("UNWIND range(1, 100) AS n "
"RETURN n AS number")
Expand All @@ -86,7 +78,6 @@ def test_contains_time_information(self):
self.assertGreaterEqual(summary.result_available_after, 0)
self.assertGreaterEqual(summary.result_consumed_after, 0)

@driver_feature(types.Feature.TMP_FULL_SUMMARY)
def test_protocol_version_information(self):
summary = self.get_summary("RETURN 1 AS number")

Expand Down Expand Up @@ -148,7 +139,6 @@ def _assert_counters(self, summary, nodes_created=0, nodes_deleted=0,
self.assertIsInstance(counter_val, type(val))
self.assertEqual(counter_val, val)

@driver_feature(types.Feature.TMP_FULL_SUMMARY)
def test_summary_counters_case_1(self):
params = {"number": types.CypherInt(3)}

Expand All @@ -161,8 +151,6 @@ def test_summary_counters_case_1(self):

self._assert_counters(summary)

@driver_feature(types.Feature.TMP_RESULT_KEYS,
types.Feature.TMP_FULL_SUMMARY)
@requires_multi_db_support
@cluster_unsafe_test
def test_summary_counters_case_2(self):
Expand Down
3 changes: 2 additions & 1 deletion tests/neo4j/test_tx_func_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ def test_tx_func_configuration(self):
def run(tx):
values = []
result = tx.run("UNWIND [1,2,3,4] AS x RETURN x")
if self.driver_supports_features(types.Feature.TMP_RESULT_KEYS):
if get_driver_name() not in ["dotnet"]:
# missing former types.Feature.TMP_RESULT_KEYS
self.assertEqual(result.keys(), ["x"])
for record in result:
values.append(record.values[0])
Expand Down
15 changes: 10 additions & 5 deletions tests/neo4j/test_tx_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ def test_tx_configuration(self):
)
result = tx.run("UNWIND [1,2,3,4] AS x RETURN x")
values = []
if self.driver_supports_features(types.Feature.TMP_RESULT_KEYS):
if get_driver_name() not in ["dotnet"]:
# missing former types.Feature.TMP_RESULT_KEYS
self.assertEqual(result.keys(), ["x"])
for record in result:
values.append(record.values[0])
Expand Down Expand Up @@ -368,7 +369,8 @@ def test_consume_after_commit(self):
self._session1 = self._driver.session("w", fetch_size=2)
tx = self._session1.begin_transaction()
result = tx.run("UNWIND [1,2,3,4] AS x RETURN x")
if self.driver_supports_features(types.Feature.TMP_RESULT_KEYS):
if get_driver_name() not in ["dotnet"]:
# missing former types.Feature.TMP_RESULT_KEYS
self.assertEqual(result.keys(), ["x"])
values = []
for _ in range(2):
Expand All @@ -390,7 +392,8 @@ def _test():
tx = self._session1.begin_transaction()
result1 = tx.run("UNWIND [1,2,3,4] AS x RETURN x")
result2 = tx.run("UNWIND [5,6,7,8] AS x RETURN x")
if self.driver_supports_features(types.Feature.TMP_RESULT_KEYS):
if get_driver_name() not in ["dotnet"]:
# missing former types.Feature.TMP_RESULT_KEYS
self.assertEqual(result1.keys(), ["x"])
self.assertEqual(result2.keys(), ["x"])
if invert_fetching:
Expand Down Expand Up @@ -419,13 +422,15 @@ def _test():
if run_q2_before_q1_fetch:
result2 = tx.run("UNWIND [5,6,7,8] AS y RETURN y")

if self.driver_supports_features(types.Feature.TMP_RESULT_KEYS):
if get_driver_name() not in ["dotnet"]:
# missing former types.Feature.TMP_RESULT_KEYS
self.assertEqual(result1.keys(), ["x"])
values1 = [result1.next().values[0]]

if not run_q2_before_q1_fetch:
result2 = tx.run("UNWIND [5,6,7,8] AS y RETURN y")
if self.driver_supports_features(types.Feature.TMP_RESULT_KEYS):
if get_driver_name() not in ["dotnet"]:
# missing former types.Feature.TMP_RESULT_KEYS
self.assertEqual(result2.keys(), ["y"])
values2 = list(map(lambda rec: rec.values[0], result2))

Expand Down
3 changes: 1 addition & 2 deletions tests/stub/routing/test_no_routing_v3.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from nutkit import protocol as types

from .test_no_routing_v4x1 import NoRoutingV4x1
from tests.stub.routing.test_no_routing_v4x1 import NoRoutingV4x1


class NoRoutingV3(NoRoutingV4x1):
Expand Down
3 changes: 0 additions & 3 deletions tests/stub/routing/test_no_routing_v4x1.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ def test_should_error_on_rollback_failure_using_tx_rollback(self):
self._server.address])
self._server.done()

@driver_feature(types.Feature.TMP_TRANSACTION_CLOSE)
def test_should_error_on_rollback_failure_using_tx_close(self):
uri = "bolt://%s" % self._server.address
self._server.start(
Expand Down Expand Up @@ -252,7 +251,6 @@ def test_should_error_on_rollback_failure_using_session_close(
self._server.address])
self._server.done()

@driver_feature(types.Feature.TMP_DRIVER_FETCH_SIZE)
def test_should_accept_custom_fetch_size_using_driver_configuration(
self):
uri = "bolt://%s" % self._server.address
Expand Down Expand Up @@ -338,7 +336,6 @@ def test_should_pull_custom_size_and_then_all_using_session_configuration(
for i in (1, 3, 5, 7, 9)])
self._server.done()

@driver_feature(types.Feature.TMP_DRIVER_FETCH_SIZE)
def test_should_pull_all_when_fetch_is_minus_one_using_driver_configuration( # noqa: E501
self):
uri = "bolt://%s" % self._server.address
Expand Down
5 changes: 2 additions & 3 deletions tests/stub/routing/test_routing_v3.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from nutkit.frontend import Driver
import nutkit.protocol as types

from ...shared import get_driver_name
from .test_routing_v4x4 import RoutingV4x4
from tests.shared import get_driver_name
from tests.stub.routing.test_routing_v4x4 import RoutingV4x4


class RoutingV3(RoutingV4x4):
Expand Down
3 changes: 1 addition & 2 deletions tests/stub/routing/test_routing_v4x1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

from nutkit import protocol as types
from nutkit.frontend import Driver

from .test_routing_v4x4 import RoutingV4x4
from tests.stub.routing.test_routing_v4x4 import RoutingV4x4


class RoutingV4x1(RoutingV4x4):
Expand Down
3 changes: 1 addition & 2 deletions tests/stub/routing/test_routing_v4x3.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import nutkit.protocol as types
from tests.shared import driver_feature

from .test_routing_v4x4 import RoutingV4x4
from tests.stub.routing.test_routing_v4x4 import RoutingV4x4


class RoutingV4x3(RoutingV4x4):
Expand Down
Loading