-
Notifications
You must be signed in to change notification settings - Fork 24
Don't delete response collectors in a transaction #250
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.6.2 | ||
2.6.3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,6 @@ load("//tools:cluster_test_rule.bzl", "typedb_cluster_py_test") | |
load("@vaticle_bazel_distribution//artifact:rules.bzl", "artifact_extractor") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We restructured the test package a little, introducing a specific BUILD file for the integration tests only which did not exist before |
||
load("@vaticle_typedb_common//test:rules.bzl", "native_typedb_artifact") | ||
load("@vaticle_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") | ||
load("@rules_python//python:defs.bzl", "py_library", "py_test") | ||
|
||
native_typedb_artifact( | ||
name = "native-typedb-artifact", | ||
|
@@ -49,46 +48,11 @@ checkstyle_test( | |
include = glob([ | ||
"*", | ||
"deployment/*", | ||
"integration/*", | ||
]), | ||
license_type = "apache", | ||
size = "small", | ||
) | ||
|
||
py_test( | ||
name = "test_debug", | ||
srcs = [ | ||
"integration/test_debug.py", | ||
], | ||
deps = [ | ||
"//:client_python", | ||
], | ||
python_version = "PY3" | ||
) | ||
|
||
typedb_cluster_py_test( | ||
name = "test_cluster_failover", | ||
srcs = [ | ||
"integration/test_cluster_failover.py", | ||
], | ||
deps = [ | ||
"//:client_python", | ||
], | ||
size = "medium", | ||
native_typedb_cluster_artifact = ":native-typedb-cluster-artifact", | ||
) | ||
|
||
py_test( | ||
name = "test_concurrent", | ||
srcs = [ | ||
"integration/test_concurrent.py", | ||
], | ||
deps = [ | ||
"//:client_python", | ||
], | ||
python_version = "PY3" | ||
) | ||
|
||
artifact_extractor( | ||
name = "typedb-extractor", | ||
artifact = ":native-typedb-artifact", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the new BUILD file that was introduced specifically for integration tests |
||
# Copyright (C) 2021 Vaticle | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
|
||
load("//tools:cluster_test_rule.bzl", "typedb_cluster_py_test") | ||
load("@vaticle_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") | ||
load("@rules_python//python:defs.bzl", "py_test") | ||
|
||
typedb_cluster_py_test( | ||
name = "test_cluster_failover", | ||
srcs = ["test_cluster_failover.py"], | ||
deps = ["//:client_python"], | ||
size = "medium", | ||
native_typedb_cluster_artifact = "//tests:native-typedb-cluster-artifact", | ||
) | ||
|
||
py_test( | ||
name = "test_debug", | ||
srcs = ["test_debug.py"], | ||
deps = ["//:client_python"], | ||
python_version = "PY3" | ||
) | ||
|
||
py_test( | ||
name = "test_stream", | ||
srcs = ["test_stream.py"], | ||
deps = ["//:client_python"], | ||
python_version = "PY3" | ||
) | ||
|
||
checkstyle_test( | ||
name = "checkstyle", | ||
include = glob(["*"]), | ||
license_type = "apache", | ||
size = "small", | ||
) |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We deleted |
||
# Copyright (C) 2021 Vaticle | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
|
||
import unittest | ||
from unittest import TestCase | ||
|
||
from typedb.client import * | ||
|
||
TYPEDB = "typedb" | ||
SCHEMA = SessionType.SCHEMA | ||
DATA = SessionType.DATA | ||
READ = TransactionType.READ | ||
WRITE = TransactionType.WRITE | ||
|
||
|
||
class TestStream(TestCase): | ||
|
||
def setUp(self): | ||
with TypeDB.core_client("127.0.0.1:1729") as client: | ||
if TYPEDB not in [db.name() for db in client.databases().all()]: | ||
client.databases().create(TYPEDB) | ||
|
||
def test_multiple_done_response_handling(self): | ||
with TypeDB.core_client(TypeDB.DEFAULT_ADDRESS) as client: | ||
with client.session(TYPEDB, SCHEMA) as session, session.transaction(WRITE) as tx: | ||
for i in range(51): | ||
tx.query().define(f"define person sub entity, owns name{i}; name{i} sub attribute, value string;") | ||
tx.commit() | ||
# With these options (the default in TypeDB at time of writing), the server may respond with: | ||
# 50 answers -> CONTINUE -> 1 answer [compensating for latency] -> DONE. The client will respond to | ||
# CONTINUE with STREAM to keep iterating, and the server responds to STREAM with a 2nd DONE message. | ||
# This is expected and should be handled correctly (ie: ignored) by the client. | ||
tx_options = TypeDBOptions.core().set_prefetch(True).set_prefetch_size(50) | ||
for i in range(50): | ||
with client.session(TYPEDB, DATA) as session, session.transaction(READ, tx_options) as tx: | ||
person_type = tx.concepts().get_thing_type("person").as_entity_type().as_remote(tx) | ||
_attrs = list(person_type.get_owns(keys_only=False)) | ||
next(tx.query().match("match $x sub thing; limit 1;")) | ||
|
||
if __name__ == "__main__": | ||
unittest.main(verbosity=2) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,7 +84,7 @@ def __init__(self, code: int, message: str): | |
MISSING_DB_NAME = ClientErrorMessage(7, "Database name cannot be empty.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If Of course, if it ends up printing sensitive data, the reporter can mask it when reporting the error. |
||
DB_DOES_NOT_EXIST = ClientErrorMessage(8, "The database '%s' does not exist.") | ||
MISSING_RESPONSE = ClientErrorMessage(9, "Unexpected empty response for request ID '%s'.") | ||
UNKNOWN_REQUEST_ID = ClientErrorMessage(10, "Received a response with unknown request id '%s'.") | ||
UNKNOWN_REQUEST_ID = ClientErrorMessage(10, "Received a response with unknown request id '%s':\n%s") | ||
CLUSTER_NO_PRIMARY_REPLICA_YET = ClientErrorMessage(11, "No replica has been marked as the primary replica for latest known term '%d'.") | ||
CLUSTER_UNABLE_TO_CONNECT = ClientErrorMessage(12, "Unable to connect to TypeDB Cluster. Attempted connecting to the cluster members, but none are available: '%s'.") | ||
CLUSTER_REPLICA_NOT_PRIMARY = ClientErrorMessage(13, "The replica is not the primary replica.") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,9 +63,6 @@ def stream(self, req: transaction_proto.Transaction.Req) -> Iterator[transaction | |
self._dispatcher.dispatch(req) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we remove |
||
return ResponsePartIterator(request_id, self) | ||
|
||
def done(self, request_id: UUID): | ||
self._response_collector.remove(request_id) | ||
|
||
def is_open(self) -> bool: | ||
return self._is_open.get() | ||
|
||
|
@@ -103,7 +100,7 @@ def _collect(self, response: Union[transaction_proto.Transaction.Res, transactio | |
if collector: | ||
collector.put(response) | ||
else: | ||
raise TypeDBClientException.of(UNKNOWN_REQUEST_ID, request_id) | ||
raise TypeDBClientException.of(UNKNOWN_REQUEST_ID, (request_id, str(response))) | ||
|
||
def dispatcher(self): | ||
return self._dispatcher | ||
|
@@ -137,7 +134,6 @@ def __init__(self, request_id: UUID, stream: "BidirectionalStream"): | |
|
||
def get(self) -> T: | ||
value = self._stream.fetch(self._request_id) | ||
self._stream.done(self._request_id) | ||
return value | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Temporarily comment these tests while they are failing due to unreleased Cluster