Skip to content

Commit ada8319

Browse files
authored
Introduce 3.0 cloud driver tests (#735)
## Usage and product changes We fix cloud drivers creation interfaces and introduce integration and behavior tests to cover these public methods. ## Implementation The integration tests are currently just a copypaste of the core integration tests with another interface. Not sure if we want to change it, but it would be smarter to reuse this code differently in the future. The behavior tests are actually currently similar to the core tests: they don't use encryption and they only use one node. We'll need to update it with more nodes in action when it's ready. Encryption can be added earlier in a separate PR: there are all the relevant TODOs in the code.
1 parent 0273b6c commit ada8319

File tree

14 files changed

+1197
-311
lines changed

14 files changed

+1197
-311
lines changed

.factory/automation.yml

Lines changed: 71 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,13 @@ build:
9797
export CORE_FAILED= || export CORE_FAILED=1
9898
tool/test/stop-core-server.sh
9999
if [[ -n "$CORE_FAILED" ]]; then exit 1; fi
100-
101-
# source tool/test/start-cloud-servers.sh 3 && # use source to receive export vars
102-
# bazel test //rust/tests/integration/cloud/... --test_output=streamed &&
103-
# export CLOUD_FAILED= || export CLOUD_FAILED=1
104-
# tool/test/stop-cloud-servers.sh
105-
# if [[ -n "$CLOUD_FAILED" ]]; then exit 1; fi
100+
101+
# TODO: Use cloud server artifact with 3 nodes when available
102+
tool/test/start-core-server.sh &&
103+
bazel test //rust/tests/integration/cloud/... --test_output=streamed --test_arg=--nocapture &&
104+
export CLOUD_FAILED= || export CLOUD_FAILED=1
105+
tool/test/stop-core-server.sh
106+
if [[ -n "$CORE_FAILED" ]]; then exit 1; fi
106107
107108
test-rust-behaviour-core:
108109
image: typedb-ubuntu-20.04 # Ubuntu 20.04 has GLIBC version 2.31 (2020) which we should verify to compile against
@@ -120,22 +121,22 @@ build:
120121
tool/test/stop-core-server.sh
121122
exit $TEST_SUCCESS
122123
123-
# test-rust-behaviour-cloud:
124-
# image: typedb-ubuntu-20.04 # Ubuntu 20.04 has GLIBC version 2.31 (2020) which we should verify to compile against
125-
# dependencies:
126-
# - build
127-
# command: |
128-
# export ARTIFACT_USERNAME=$REPO_TYPEDB_USERNAME
129-
# export ARTIFACT_PASSWORD=$REPO_TYPEDB_PASSWORD
130-
# bazel run @typedb_dependencies//tool/bazelinstall:remote_cache_setup.sh
131-
# bazel run @typedb_dependencies//distribution/artifact:create-netrc
132-
#
133-
# source tool/test/start-cloud-servers.sh 3 && # use source to receive export vars
134-
# bazel test //rust/tests/behaviour/... --//rust/tests/behaviour/config:mode=cloud \
135-
# --test_output=streamed --test_env=ROOT_CA=$ROOT_CA &&
136-
# export TEST_SUCCESS=0 || export TEST_SUCCESS=1
137-
# tool/test/stop-cloud-servers.sh
138-
# exit $TEST_SUCCESS
124+
test-rust-behaviour-cloud:
125+
image: typedb-ubuntu-20.04 # Ubuntu 20.04 has GLIBC version 2.31 (2020) which we should verify to compile against
126+
dependencies:
127+
- build
128+
command: |
129+
export ARTIFACT_USERNAME=$REPO_TYPEDB_USERNAME
130+
export ARTIFACT_PASSWORD=$REPO_TYPEDB_PASSWORD
131+
bazel run @typedb_dependencies//tool/bazelinstall:remote_cache_setup.sh
132+
bazel run @typedb_dependencies//distribution/artifact:create-netrc
133+
134+
# TODO: Use cloud server artifact with 3 nodes when available
135+
tool/test/start-core-server.sh &&
136+
bazel test //rust/tests/behaviour/... --//rust/tests/behaviour/config:mode=cloud --test_output=streamed --jobs=1 &&
137+
export TEST_SUCCESS=0 || export TEST_SUCCESS=1
138+
tool/test/stop-core-server.sh
139+
exit $TEST_SUCCESS
139140
140141
# test-c-integration:
141142
# image: typedb-ubuntu-20.04 # Ubuntu 20.04 has GLIBC version 2.31 (2020) which we should verify to compile against
@@ -163,16 +164,17 @@ build:
163164
bazel run @typedb_dependencies//distribution/artifact:create-netrc
164165
165166
tool/test/start-core-server.sh &&
166-
.factory/test-core.sh //java/test/integration/... --test_output=errors &&
167+
.factory/test-core.sh //java/test/integration/... --test_output=errors --jobs=1 &&
167168
export TEST_SUCCESS=0 || export TEST_SUCCESS=1
168169
tool/test/stop-core-server.sh
169170
exit $TEST_SUCCESS
170171
171-
# source tool/test/start-cloud-servers.sh 3 && # use source to receive export vars
172-
# .factory/test-cloud.sh //java/test/integration/... --test_env=ROOT_CA=$ROOT_CA --test_output=errors --jobs=1 &&
173-
# export TEST_SUCCESS=0 || export TEST_SUCCESS=1
174-
# tool/test/stop-cloud-servers.sh
175-
# exit $TEST_SUCCESS
172+
# TODO: Use cloud server artifact with 3 nodes when available
173+
tool/test/start-core-server.sh &&
174+
.factory/test-cloud.sh //java/test/integration/... --test_output=errors --jobs=1 &&
175+
export TEST_SUCCESS=0 || export TEST_SUCCESS=1
176+
tool/test/stop-core-server.sh
177+
exit $TEST_SUCCESS
176178
177179
test-java-behaviour-core:
178180
image: typedb-ubuntu-22.04
@@ -190,21 +192,22 @@ build:
190192
tool/test/stop-core-server.sh
191193
exit $TEST_SUCCESS
192194
193-
# test-java-behaviour-cloud:
194-
# image: typedb-ubuntu-22.04
195-
# dependencies:
196-
# - build
197-
# command: |
198-
# export ARTIFACT_USERNAME=$REPO_TYPEDB_USERNAME
199-
# export ARTIFACT_PASSWORD=$REPO_TYPEDB_PASSWORD
200-
# bazel run @typedb_dependencies//tool/bazelinstall:remote_cache_setup.sh
201-
# bazel run @typedb_dependencies//distribution/artifact:create-netrc
202-
#
203-
# source tool/test/start-cloud-servers.sh 3 && # use source to receive export vars
204-
# .factory/test-cloud.sh //java/test/behaviour/... --test_env=ROOT_CA=$ROOT_CA --test_output=errors --jobs=1 &&
205-
# export TEST_SUCCESS=0 || export TEST_SUCCESS=1
206-
# tool/test/stop-cloud-servers.sh
207-
# exit $TEST_SUCCESS
195+
test-java-behaviour-cloud:
196+
image: typedb-ubuntu-22.04
197+
dependencies:
198+
- build
199+
command: |
200+
export ARTIFACT_USERNAME=$REPO_TYPEDB_USERNAME
201+
export ARTIFACT_PASSWORD=$REPO_TYPEDB_PASSWORD
202+
bazel run @typedb_dependencies//tool/bazelinstall:remote_cache_setup.sh
203+
bazel run @typedb_dependencies//distribution/artifact:create-netrc
204+
205+
# TODO: Use cloud server artifact with 3 nodes when available
206+
tool/test/start-core-server.sh &&
207+
.factory/test-cloud.sh //java/test/behaviour/... --test_output=errors --jobs=1 &&
208+
export TEST_SUCCESS=0 || export TEST_SUCCESS=1
209+
tool/test/stop-core-server.sh
210+
exit $TEST_SUCCESS
208211
209212
test-python-integration:
210213
image: typedb-ubuntu-22.04
@@ -224,11 +227,12 @@ build:
224227
tool/test/stop-core-server.sh
225228
if [[ -n "$CORE_FAILED" ]]; then exit 1; fi
226229
227-
# source tool/test/start-cloud-servers.sh 3 && # use source to receive export vars
228-
# bazel test //python/tests/integration/cloud/... --test_output=streamed --jobs=1 &&
229-
# export CLOUD_FAILED= || export CLOUD_FAILED=1
230-
# tool/test/stop-cloud-servers.sh
231-
# if [[ -n "$CLOUD_FAILED" ]]; then exit 1; fi
230+
# TODO: Use cloud server artifact with 3 nodes when available
231+
tool/test/start-core-server.sh &&
232+
bazel test //python/tests/integration/cloud/... --test_output=streamed --jobs=1 &&
233+
export CLOUD_FAILED= || export CLOUD_FAILED=1
234+
tool/test/stop-core-server.sh
235+
if [[ -n "$CLOUD_FAILED" ]]; then exit 1; fi
232236
233237
test-python-behaviour-core:
234238
image: typedb-ubuntu-22.04
@@ -248,24 +252,25 @@ build:
248252
tool/test/stop-core-server.sh
249253
exit $TEST_SUCCESS
250254
251-
# test-python-behaviour-cloud:
252-
# image: typedb-ubuntu-22.04
253-
# dependencies:
254-
# - build
255-
# type: foreground
256-
# command: |
257-
# export PATH="$HOME/.local/bin:$PATH"
258-
# export ARTIFACT_USERNAME=$REPO_TYPEDB_USERNAME
259-
# export ARTIFACT_PASSWORD=$REPO_TYPEDB_PASSWORD
260-
# bazel run @typedb_dependencies//tool/bazelinstall:remote_cache_setup.sh
261-
# bazel run @typedb_dependencies//distribution/artifact:create-netrc
262-
#
263-
# source tool/test/start-cloud-servers.sh 3 && # use source to receive export vars
264-
# .factory/test-cloud.sh //python/tests/behaviour/... --test_env=ROOT_CA=$ROOT_CA --test_output=streamed --jobs=1 &&
265-
# export TEST_SUCCESS=0 || export TEST_SUCCESS=1
266-
# tool/test/stop-cloud-servers.sh
267-
# exit $TEST_SUCCESS
268-
#
255+
test-python-behaviour-cloud:
256+
image: typedb-ubuntu-22.04
257+
dependencies:
258+
- build
259+
type: foreground
260+
command: |
261+
export PATH="$HOME/.local/bin:$PATH"
262+
export ARTIFACT_USERNAME=$REPO_TYPEDB_USERNAME
263+
export ARTIFACT_PASSWORD=$REPO_TYPEDB_PASSWORD
264+
bazel run @typedb_dependencies//tool/bazelinstall:remote_cache_setup.sh
265+
bazel run @typedb_dependencies//distribution/artifact:create-netrc
266+
267+
# TODO: Use cloud server artifact with 3 nodes when available
268+
tool/test/start-core-server.sh &&
269+
.factory/test-cloud.sh //python/tests/behaviour/... --test_output=streamed --jobs=1 &&
270+
export TEST_SUCCESS=0 || export TEST_SUCCESS=1
271+
tool/test/stop-core-server.sh
272+
exit $TEST_SUCCESS
273+
269274
# test-nodejs-integration:
270275
# image: typedb-ubuntu-22.04
271276
# dependencies:

java/test/behaviour/connection/BUILD

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ java_library(
6060
deps = [
6161
# Package dependencies
6262
":steps-base",
63+
"//java/test/behaviour/config:parameters",
6364
"//java:driver-java",
6465
"//java/api",
65-
"//java/test/behaviour/util",
6666
# "@maven//:com_typedb_typedb_runner",
67-
# "@maven//:com_typedb_typedb_cloud_runner",
6867
"@maven//:io_cucumber_cucumber_java",
6968
],
7069
)

java/test/behaviour/connection/ConnectionStepsCloud.java

Lines changed: 95 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -18,107 +18,102 @@
1818
*/
1919
package com.typedb.driver.test.behaviour.connection;
2020

21-
// TODO: Uncomment and test when we have replications and encryption
22-
23-
//import com.typedb.core.tool.runner.TypeDBRunner;
24-
//import com.typedb.core.tool.runner.TypeDBSingleton;
25-
//import com.typedb.cloud.tool.runner.TypeDBCloudRunner;
26-
//import com.typedb.driver.TypeDB;
27-
//import com.typedb.driver.api.TypeDBDriver;
28-
//import com.typedb.driver.api.Credentials;
29-
//import com.typedb.driver.api.Options;
30-
//import com.typedb.driver.api.database.Database;
31-
//import io.cucumber.java.After;
32-
//import io.cucumber.java.Before;
33-
//import io.cucumber.java.en.Given;
34-
//import io.cucumber.java.en.When;
35-
//
36-
//import java.nio.file.Paths;
37-
//import java.util.HashMap;
38-
//import java.util.Map;
39-
//
40-
//import static com.typedb.driver.test.behaviour.util.Util.assertThrows;
41-
//
42-
//public class ConnectionStepsCloud extends ConnectionStepsBase {
43-
//
44-
// @Override
45-
// public void beforeAll() {
46-
// super.beforeAll();
47-
// TypeDBCloudRunner cloudRunner = TypeDBCloudRunner.create(Paths.get("."), 1, serverOptions);
48-
// TypeDBSingleton.setTypeDBRunner(cloudRunner);
49-
// cloudRunner.start();
50-
// }
51-
//
52-
// @Before
53-
// public synchronized void before() {
54-
// super.before();
55-
// }
56-
//
57-
// @After
58-
// public synchronized void after() {
59-
// super.after();
60-
// try {
61-
// // sleep for eventual consistency to catch up with database deletion on all servers
62-
// Thread.sleep(100);
63-
// } catch (InterruptedException e) {
64-
// throw new RuntimeException(e);
65-
// }
66-
// }
67-
//
68-
// @Override
69-
// TypeDBDriver createTypeDBDriver(String address) {
70-
// return createTypeDBDriver(address, DEFAULT_USERNAME, DEFAULT_PASSWORD, false); // TODO: Probably requires connection settings with tls enabled by default
71-
// }
72-
//
73-
// TypeDBDriver createTypeDBDriver(String address, String username, String password, boolean tlsEnabled) {
74-
// return TypeDB.cloudDriver(address, new Credential(username, password, tlsEnabled));
75-
// }
76-
//
21+
import com.typedb.driver.TypeDB;
22+
import com.typedb.driver.api.DriverOptions;
23+
import com.typedb.driver.api.Credentials;
24+
import com.typedb.driver.api.Driver;
25+
import com.typedb.driver.test.behaviour.config.Parameters;
26+
import io.cucumber.java.After;
27+
import io.cucumber.java.Before;
28+
import io.cucumber.java.en.Given;
29+
import io.cucumber.java.en.When;
30+
31+
public class ConnectionStepsCloud extends ConnectionStepsBase {
32+
@Override
33+
public void beforeAll() {
34+
super.beforeAll();
35+
}
36+
37+
@Before
38+
public synchronized void before() {
39+
super.before();
40+
}
41+
42+
@After
43+
public synchronized void after() {
44+
super.after();
45+
}
46+
47+
@Override
48+
Driver createTypeDBDriver(String address, Credentials credentials, DriverOptions driverOptions) {
49+
return TypeDB.cloudDriver(address, credentials, driverOptions);
50+
}
51+
52+
@Override
53+
Driver createDefaultTypeDBDriver() {
54+
// TODO: Add encryption to cloud tests
55+
return createTypeDBDriver(TypeDB.DEFAULT_ADDRESS, DEFAULT_CREDENTIALS, DEFAULT_CONNECTION_SETTINGS);
56+
}
57+
7758
// @Override
7859
// Options createOptions() {
7960
// return new Options();
8061
// }
81-
//
82-
//@When("connection opens with default authentication")
83-
//public void connection_opens_with_default_authentication() {
84-
// driver = createDefaultTypeDBDriver();
85-
//}
86-
//
87-
//@When("connection opens with username '{non_semicolon}', password '{non_semicolon}'{may_error}")
88-
//public void connection_opens_with_username_password(String username, String password, Parameters.MayError mayError) {
89-
// Credential credentials = new Credential(username, password);
90-
// mayError.check(() -> driver = createTypeDBDriver(TypeDB.DEFAULT_ADDRESS, credentials, DEFAULT_CONNECTION_SETTINGS)); // TODO: Probably requires connection settings with tls enabled by default
91-
//}
92-
//
93-
//
94-
// @Override
95-
// @Given("connection has been opened")
96-
// public void connection_has_been_opened() {
97-
// super.connection_has_been_opened();
98-
// }
99-
//
100-
// @Override
101-
// @Given("connection has {integer} database(s)")
102-
// public void connection_has_count_databases() {
103-
// super.connection_has_count_databases();
104-
// }
105-
//
106-
// @Override
107-
// @When("connection closes")
108-
// public void connection_closes() {
109-
// super.connection_closes();
110-
// }
111-
//
112-
// @Given("typedb has configuration")
113-
// public void typedb_has_configuration(Map<String, String> map) {
114-
// // no-op: configuration tests are only run on the backend themselves
115-
// }
116-
//
117-
// @When("typedb starts")
118-
// public void typedb_starts() {
119-
// TypeDBRunner runner = TypeDBSingleton.getTypeDBRunner();
120-
// if (runner != null && runner.isStopped()) {
121-
// runner.start();
122-
// }
123-
// }
124-
//}
62+
63+
@When("typedb starts")
64+
public void typedb_starts() {
65+
}
66+
67+
@When("connection opens with default authentication")
68+
public void connection_opens_with_default_authentication() {
69+
driver = createDefaultTypeDBDriver();
70+
}
71+
72+
@When("connection opens with username '{non_semicolon}', password '{non_semicolon}'{may_error}")
73+
public void connection_opens_with_username_password(String username, String password, Parameters.MayError mayError) {
74+
Credentials credentials = new Credentials(username, password);
75+
mayError.check(() -> driver = createTypeDBDriver(TypeDB.DEFAULT_ADDRESS, credentials, DEFAULT_CONNECTION_SETTINGS));
76+
}
77+
78+
@When("connection opens with a wrong host{may_error}")
79+
public void connection_opens_with_a_wrong_host(Parameters.MayError mayError) {
80+
mayError.check(() -> driver = createTypeDBDriver(
81+
TypeDB.DEFAULT_ADDRESS.replace("localhost", "surely-not-localhost"),
82+
DEFAULT_CREDENTIALS,
83+
DEFAULT_CONNECTION_SETTINGS
84+
));
85+
}
86+
87+
@When("connection opens with a wrong port{may_error}")
88+
public void connection_opens_with_a_wrong_port(Parameters.MayError mayError) {
89+
mayError.check(() -> driver = createTypeDBDriver(
90+
TypeDB.DEFAULT_ADDRESS.replace("localhost", "surely-not-localhost"),
91+
DEFAULT_CREDENTIALS,
92+
DEFAULT_CONNECTION_SETTINGS
93+
));
94+
}
95+
96+
@Override
97+
@When("connection closes")
98+
public void connection_closes() {
99+
super.connection_closes();
100+
}
101+
102+
@Override
103+
@Given("connection is open: {bool}")
104+
public void connection_is_open(boolean isOpen) {
105+
super.connection_is_open(isOpen);
106+
}
107+
108+
@Override
109+
@Given("connection has {integer} database(s)")
110+
public void connection_has_count_databases(int count) {
111+
super.connection_has_count_databases(count);
112+
}
113+
114+
@Override
115+
@Given("connection has {integer} user(s)")
116+
public void connection_has_count_users(int count) {
117+
super.connection_has_count_users(count);
118+
}
119+
}

0 commit comments

Comments
 (0)