Skip to content

Commit d3bb013

Browse files
authored
Add behaviour scenarios for clustered TypeDB (#392)
## Usage and product changes Add BDD tests for cluster driver support. - **Cluster driver tests** (`driver/cluster.feature`): server discovery, roles, terms, single-server connection, server routing modes, failover retries configuration. Expected to run against a 3-node cluster. - **Driver option tests** (`driver/connection.feature`): `request_timeout_millis` configuration and timeout failure. - **Error message update** (`user.feature`): "User does not exist" → "User not found" to match the error message pattern. ## Implementation New BDD steps requiring driver implementations: - `connection has {int} server(s)` — query server list, assert count - `connection primary server exists` — find server with primary role - `connection get server({address}) exists / does not exist` — lookup by address - `connection get server({address}) has term` — assert term is present - `connection servers have roles:` — data table of expected roles - `connection opens to single server with default authentication` — connect via single address - `set operation server routing to: {routing}` — configure `auto` or `direct(address)` routing - `set driver option {option} to: {value}` — configure `primary_failover_retries`, `request_timeout_millis`
1 parent 91ce37b commit d3bb013

8 files changed

Lines changed: 105 additions & 35 deletions

File tree

MODULE.bazel

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ register_toolchains("@rules_kotlin//kotlin/internal:default_toolchain")
3434
# TypeDB repos
3535
# ===========================================================
3636

37-
bazel_dep(name = "typedb_dependencies", version = "0.0.0")
38-
git_override(
39-
module_name = "typedb_dependencies",
40-
remote = "https://github.com/typedb/dependencies",
41-
commit = "a798dc0869d494bf0c7b033ee226df2efbef2830",
42-
)
43-
4437
bazel_dep(name = "typedb_bazel_distribution", version = "0.0.0")
4538
git_override(
4639
module_name = "typedb_bazel_distribution",
4740
remote = "https://github.com/typedb/bazel-distribution",
48-
commit = "a6363bf0b6208cabcfbf8865601e9eb03641559f",
41+
commit = "6c81a5180ed94a11c989e06a4ff8215df6da163e",
42+
)
43+
44+
bazel_dep(name = "typedb_dependencies", version = "0.0.0")
45+
git_override(
46+
module_name = "typedb_dependencies",
47+
remote = "https://github.com/typedb/dependencies",
48+
commit = "48ef6e41f9f0deadc0d59bb0e9d4a58efd0099af",
4949
)

MODULE.bazel.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dependencies/typedb/BUILD

Lines changed: 0 additions & 11 deletions
This file was deleted.

dependencies/typedb/repositories.bzl

Lines changed: 0 additions & 12 deletions
This file was deleted.

driver/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package(default_visibility = ["//visibility:public"])
77
load("@typedb_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test")
88

99
files = [
10+
"cluster.feature",
1011
"concept.feature",
1112
"connection.feature",
1213
"migration.feature",

driver/cluster.feature

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
# These tests are dedicated to test the required cluster functionality of TypeDB drivers.
6+
# NOTE: This file should be run only against cluster deployments with 3 servers.
7+
8+
#noinspection CucumberUndefinedStep
9+
Feature: Driver Cluster
10+
11+
Background: Open connection, verify cluster setup
12+
Given typedb starts
13+
Given connection opens with default authentication
14+
Given connection is open: true
15+
16+
###########
17+
# SERVER #
18+
###########
19+
20+
Scenario: Driver can discover servers in a cluster
21+
Then connection has 3 servers
22+
Then connection primary server exists
23+
Then connection get server(127.0.0.1:11729) exists
24+
Then connection get server(127.0.0.1:21729) exists
25+
Then connection get server(127.0.0.1:31729) exists
26+
27+
28+
Scenario: Driver can query server terms
29+
Then connection has 3 servers
30+
Then connection get server(127.0.0.1:11729) has term
31+
Then connection get server(127.0.0.1:21729) has term
32+
Then connection get server(127.0.0.1:31729) has term
33+
34+
35+
Scenario: Driver can inspect server roles
36+
Then connection has 3 servers
37+
Then connection servers have roles:
38+
| primary |
39+
| secondary |
40+
| secondary |
41+
42+
##################
43+
# SERVER ROUTING #
44+
##################
45+
46+
Scenario: Driver discovers all servers even when connecting to single server
47+
Given connection closes
48+
When connection opens to single server with default authentication
49+
Then connection is open: true
50+
Then connection has 3 servers
51+
Then connection primary server exists
52+
53+
54+
@ignore-typedb-http-driver
55+
Scenario Outline: Driver discovers all servers with <routing> server routing mode
56+
When set operation server routing to: <routing>
57+
Then connection has 3 servers
58+
Then connection primary server exists
59+
Examples:
60+
| routing |
61+
| auto |
62+
| direct(127.0.0.1:11729) |
63+
| direct(127.0.0.1:21729) |
64+
| direct(127.0.0.1:31729) |
65+
66+
##################
67+
# DRIVER OPTIONS #
68+
##################
69+
70+
# TODO: Test that primary_failover_retries actually works by simulating failover
71+
@ignore-typedb-http-driver
72+
Scenario: Driver can configure failover retries
73+
When connection closes
74+
When set driver option primary_failover_retries to: 5
75+
When connection opens with default authentication
76+
Then connection is open: true

driver/connection.feature

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,22 @@ Feature: Driver Connection
5959
Then connection is open: true
6060
Then connection has database: typedb
6161

62+
63+
@ignore-typedb-http
64+
Scenario: Driver can configure request timeout
65+
When connection closes
66+
When set driver option request_timeout_millis to: 7200000
67+
When connection opens with default authentication
68+
Then connection is open: true
69+
Then connection has database: typedb
70+
71+
72+
@ignore-typedb-http
73+
Scenario: Driver fails to connect with impossibly short request timeout
74+
When connection closes
75+
When set driver option request_timeout_millis to: 1
76+
Then connection opens with default authentication; fails with a message containing: "timed out"
77+
6278
#############
6379
# DATABASES #
6480
#############

driver/user.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ Feature: Driver User
170170
Given connection opens with username 'admin', password 'password'
171171
When create user with username 'user', password 'password'
172172
When delete user: user
173-
Then delete user: user; fails with a message containing: "User does not exist"
174-
Then delete user: user2; fails with a message containing: "User does not exist"
175-
Then delete user: surely-non-existing-user; fails with a message containing: "User does not exist"
173+
Then delete user: user; fails with a message containing: "User not found"
174+
Then delete user: user2; fails with a message containing: "User not found"
175+
Then delete user: surely-non-existing-user; fails with a message containing: "User not found"
176176

177177
# TODO: Not sure if it's correct, may be implemented differently
178178
Scenario: User's name is retrievable only by admin

0 commit comments

Comments
 (0)