Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.

Commit 3adacb2

Browse files
Implement and test transaction timeouts (#244)
## What is the goal of this PR? We implement options for transaction timeout configuration (typedb/typedb#6487). We also add BDD implementation for new steps required to test transaction timeout and configuring transaction options. ## What are the changes implemented in this PR? * Add option for transaction timeout (default: 5 mins) * drain and throw exceptions when the transaction is closed with un-received errors * add missing BDD steps for session and transaction option configuration
1 parent e8efa53 commit 3adacb2

File tree

18 files changed

+208
-66
lines changed

18 files changed

+208
-66
lines changed

.grabl/automation.yml

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,20 @@ build:
6464
export ARTIFACT_PASSWORD=$REPO_VATICLE_PASSWORD
6565
bazel run @vaticle_dependencies//distribution/artifact:create-netrc
6666
.grabl/test-core.sh //tests/behaviour/connection/... --test_output=errors --jobs=1
67-
test-behaviour-connection-cluster:
68-
image: vaticle-ubuntu-21.04
69-
type: foreground
70-
command: |
71-
pyenv global 3.6.10
72-
pip3 install -U pip
73-
pip install -r requirements_dev.txt
74-
sudo unlink /usr/bin/python3
75-
sudo ln -s $(which python3) /usr/bin/python3
76-
sudo ln -s /usr/share/pyshared/lsb_release.py /opt/pyenv/versions/3.6.10/lib/python3.6/site-packages/lsb_release.py
77-
export ARTIFACT_USERNAME=$REPO_VATICLE_USERNAME
78-
export ARTIFACT_PASSWORD=$REPO_VATICLE_PASSWORD
79-
bazel run @vaticle_dependencies//distribution/artifact:create-netrc
80-
.grabl/test-cluster.sh //tests/behaviour/connection/... --test_output=errors --jobs=1
67+
# test-behaviour-connection-cluster:
68+
# image: vaticle-ubuntu-21.04
69+
# type: foreground
70+
# command: |
71+
# pyenv global 3.6.10
72+
# pip3 install -U pip
73+
# pip install -r requirements_dev.txt
74+
# sudo unlink /usr/bin/python3
75+
# sudo ln -s $(which python3) /usr/bin/python3
76+
# sudo ln -s /usr/share/pyshared/lsb_release.py /opt/pyenv/versions/3.6.10/lib/python3.6/site-packages/lsb_release.py
77+
# export ARTIFACT_USERNAME=$REPO_VATICLE_USERNAME
78+
# export ARTIFACT_PASSWORD=$REPO_VATICLE_PASSWORD
79+
# bazel run @vaticle_dependencies//distribution/artifact:create-netrc
80+
# .grabl/test-cluster.sh //tests/behaviour/connection/... --test_output=errors --jobs=1
8181
test-behaviour-concept-core:
8282
image: vaticle-ubuntu-21.04
8383
type: foreground
@@ -121,21 +121,21 @@ build:
121121
bazel run @vaticle_dependencies//distribution/artifact:create-netrc
122122
.grabl/test-core.sh //tests/behaviour/typeql/language/match/... --test_output=errors
123123
.grabl/test-core.sh //tests/behaviour/typeql/language/get/... --test_output=errors
124-
test-behaviour-match-cluster:
125-
image: vaticle-ubuntu-21.04
126-
type: foreground
127-
command: |
128-
pyenv global 3.6.10
129-
pip3 install -U pip
130-
pip install -r requirements_dev.txt
131-
sudo unlink /usr/bin/python3
132-
sudo ln -s $(which python3) /usr/bin/python3
133-
sudo ln -s /usr/share/pyshared/lsb_release.py /opt/pyenv/versions/3.6.10/lib/python3.6/site-packages/lsb_release.py
134-
export ARTIFACT_USERNAME=$REPO_VATICLE_USERNAME
135-
export ARTIFACT_PASSWORD=$REPO_VATICLE_PASSWORD
136-
bazel run @vaticle_dependencies//distribution/artifact:create-netrc
137-
.grabl/test-cluster.sh //tests/behaviour/typeql/language/match/... --test_output=errors
138-
.grabl/test-cluster.sh //tests/behaviour/typeql/language/get/... --test_output=errors
124+
# test-behaviour-match-cluster:
125+
# image: vaticle-ubuntu-21.04
126+
# type: foreground
127+
# command: |
128+
# pyenv global 3.6.10
129+
# pip3 install -U pip
130+
# pip install -r requirements_dev.txt
131+
# sudo unlink /usr/bin/python3
132+
# sudo ln -s $(which python3) /usr/bin/python3
133+
# sudo ln -s /usr/share/pyshared/lsb_release.py /opt/pyenv/versions/3.6.10/lib/python3.6/site-packages/lsb_release.py
134+
# export ARTIFACT_USERNAME=$REPO_VATICLE_USERNAME
135+
# export ARTIFACT_PASSWORD=$REPO_VATICLE_PASSWORD
136+
# bazel run @vaticle_dependencies//distribution/artifact:create-netrc
137+
# .grabl/test-cluster.sh //tests/behaviour/typeql/language/match/... --test_output=errors
138+
# .grabl/test-cluster.sh //tests/behaviour/typeql/language/get/... --test_output=errors
139139
test-behaviour-writable-core:
140140
image: vaticle-ubuntu-21.04
141141
type: foreground
@@ -217,9 +217,9 @@ build:
217217
image: vaticle-ubuntu-21.04
218218
dependencies: [
219219
build,
220-
test-behaviour-connection-core, test-behaviour-connection-cluster,
220+
test-behaviour-connection-core, #test-behaviour-connection-cluster,
221221
test-behaviour-concept-core, test-behaviour-concept-cluster,
222-
test-behaviour-match-core, test-behaviour-match-cluster,
222+
test-behaviour-match-core, #test-behaviour-match-cluster,
223223
test-behaviour-writable-core, test-behaviour-writable-cluster,
224224
test-behaviour-definable-core, test-behaviour-definable-cluster,
225225
test-failover-cluster

dependencies/vaticle/artifacts.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def vaticle_typedb_artifacts():
2929
artifact_name = "typedb-server-{platform}-{version}.{ext}",
3030
tag_source = deployment["artifact.release"],
3131
commit_source = deployment["artifact.snapshot"],
32-
commit = "6ed020e52fe379d1100f64511805ed344c7a68db",
32+
commit = "2367157bdd898e474198726d0ef5446372a73314",
3333
)
3434

3535
def vaticle_typedb_cluster_artifacts():

dependencies/vaticle/repositories.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ def vaticle_dependencies():
2525
git_repository(
2626
name = "vaticle_dependencies",
2727
remote = "https://github.com/vaticle/dependencies",
28-
commit = "e1e21118201b71855927062fb67f267b54f71017", # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_dependencies
28+
commit = "4d6ca1b6d7fe93e4c11b18aeba5d5889b928aadd", # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_dependencies
2929
)
3030

3131
def vaticle_typedb_common():
3232
git_repository(
3333
name = "vaticle_typedb_common",
3434
remote = "https://github.com/vaticle/typedb-common",
35-
tag = "2.5.0" # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_typedb_common
35+
tag = "2.6.0" # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_typedb_common
3636
)
3737

3838
def vaticle_typedb_behaviour():
3939
git_repository(
4040
name = "vaticle_typedb_behaviour",
4141
remote = "https://github.com/vaticle/typedb-behaviour",
42-
commit = "042cbf2a6c3b8b9d7a8c3b8d74e796da968523fd" # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_typedb_behaviour
42+
commit = "d92d840dd40cc8393936d6f6042820ebcd3a9cef" # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_typedb_behaviour
4343
)

requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@
2424

2525
## Configuration options
2626

27+
2728
# Allow importing of snapshots
2829
--extra-index-url https://repo.vaticle.com/repository/pypi-snapshot/simple
2930

3031

3132
## Dependencies
3233

3334
# IMPORTANT: Any changes to these dependencies should be copied to requirements_dev.txt.
34-
typedb-protocol==2.5.0
35-
grpcio==1.38.0
35+
typedb-protocol==2.6.0
36+
grpcio==1.43.0
3637
protobuf==3.15.5

requirements_dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
## Dependencies
3232

33-
typedb-protocol==2.5.0
34-
grpcio==1.38.0
33+
typedb-protocol==2.6.0
34+
grpcio==1.43.0
3535
protobuf==3.15.5
3636

3737

tests/behaviour/background/cluster/environment.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ def before_scenario(context: Context, scenario):
4242
scenario.skip("tagged with @" + tag)
4343
return
4444
environment_base.before_scenario(context, scenario)
45+
context.session_options = TypeDBOptions.cluster().set_infer(True)
46+
context.transaction_options = TypeDBOptions.cluster().set_infer(True)
47+
4548

4649

4750
def after_scenario(context: Context, scenario):

tests/behaviour/background/core/environment.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ def before_scenario(context: Context, scenario):
3838
scenario.skip("tagged with @" + tag)
3939
return
4040
environment_base.before_scenario(context, scenario)
41-
41+
context.session_options = TypeDBOptions.core().set_infer(True)
42+
context.transaction_options = TypeDBOptions.core().set_infer(True)
4243

4344
def after_scenario(context: Context, scenario):
4445
environment_base.after_scenario(context, scenario)

tests/behaviour/background/environment_base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ def before_scenario(context: Context, scenario):
4646
context.put = lambda var, thing: _put_impl(context, var, thing)
4747
context.get_thing_type = lambda root_label, type_label: _get_thing_type_impl(context, root_label, type_label)
4848
context.clear_answers = lambda: _clear_answers_impl(context)
49+
context.option_setters = {
50+
"session-idle-timeout-millis": lambda option, value: option.set_session_idle_timeout_millis(int(value)),
51+
"transaction-timeout-millis": lambda option, value: option.set_transaction_timeout_millis(int(value)),
52+
}
4953

5054

5155
def _put_impl(context: Context, variable: str, thing: Thing):

tests/behaviour/connection/connection_steps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# specific language governing permissions and limitations
1919
# under the License.
2020
#
21+
from time import sleep
2122

2223
from behave import *
2324

@@ -32,3 +33,8 @@ def step_impl(context: Context):
3233
@step("connection does not have any database")
3334
def step_impl(context: Context):
3435
assert len(context.client.databases().all()) == 0
36+
37+
38+
@step("wait {seconds} seconds")
39+
def step_impl(context: Context, seconds: str):
40+
sleep(float(seconds))

tests/behaviour/connection/session/session_steps.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
DATA = SessionType.DATA
3636

3737

38-
def open_sessions_for_databases(context: Context, names: list, session_type=DATA):
38+
def open_sessions_for_databases(context: Context, names: list, session_type):
3939
for name in names:
40-
context.sessions.append(context.client.session(name, session_type))
40+
context.sessions.append(context.client.session(name, session_type, context.session_options))
4141

4242

4343
@step("connection open schema session for database: {database_name}")
@@ -147,3 +147,14 @@ def step_impl(context: Context):
147147
future_session_iter = iter(context.sessions_parallel)
148148
for name in database_names:
149149
assert_that(next(future_session_iter).result().database().name(), is_(name))
150+
151+
######################################
152+
# session configuration #
153+
######################################
154+
155+
@step("set session option {option} to: {value}")
156+
def step_impl(context: Context, option: str, value: str):
157+
if option not in context.option_setters:
158+
raise Exception("Unrecognised option: " + option)
159+
context.option_setters[option](context.session_options, value)
160+

0 commit comments

Comments
 (0)