Skip to content
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

Refactor clickhouse admin integration tests #7017

Merged
merged 20 commits into from
Nov 14, 2024
Merged
9 changes: 8 additions & 1 deletion .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ fail-fast = false
# invocations of nextest happen.
command = 'cargo run -p crdb-seed --profile test'

[[profile.default.scripts]]
filter = 'package(omicron-clickhouse-admin)'
setup = 'clickhouse-cluster'

[script.clickhouse-cluster]
command = 'cargo run -p clickhouse-cluster-dev'

[test-groups]
# The ClickHouse cluster tests currently rely on a hard-coded set of ports for
# the nodes in the cluster. We would like to relax this in the future, at which
Expand All @@ -39,7 +46,7 @@ live-tests = { max-threads = 1 }
default-filter = 'all() - package(omicron-live-tests) - package(end-to-end-tests)'

[[profile.default.overrides]]
filter = 'package(oximeter-db) and test(replicated)'
filter = 'package(oximeter-db) and test(replicated) + package(omicron-clickhouse-admin)'
test-group = 'clickhouse-cluster'

[[profile.default.overrides]]
Expand Down
30 changes: 28 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"certificates",
"clickhouse-admin",
"clickhouse-admin/api",
"clickhouse-admin/test-utils",
"clients/bootstrap-agent-client",
"clients/clickhouse-admin-keeper-client",
"clients/clickhouse-admin-server-client",
Expand All @@ -25,6 +26,7 @@ members = [
"cockroach-admin/types",
"common",
"dev-tools/cert-dev",
"dev-tools/clickhouse-cluster-dev",
"dev-tools/ch-dev",
"dev-tools/crdb-seed",
"dev-tools/db-dev",
Expand Down Expand Up @@ -130,6 +132,7 @@ default-members = [
"clickhouse-admin",
"clickhouse-admin/api",
"clickhouse-admin/types",
"clickhouse-admin/test-utils",
"clients/bootstrap-agent-client",
"clients/clickhouse-admin-keeper-client",
"clients/clickhouse-admin-server-client",
Expand All @@ -150,6 +153,7 @@ default-members = [
"cockroach-admin/types",
"common",
"dev-tools/cert-dev",
"dev-tools/clickhouse-cluster-dev",
"dev-tools/ch-dev",
"dev-tools/crdb-seed",
"dev-tools/db-dev",
Expand Down Expand Up @@ -323,6 +327,7 @@ clickhouse-admin-api = { path = "clickhouse-admin/api" }
clickhouse-admin-keeper-client = { path = "clients/clickhouse-admin-keeper-client" }
clickhouse-admin-server-client = { path = "clients/clickhouse-admin-server-client" }
clickhouse-admin-types = { path = "clickhouse-admin/types" }
clickhouse-admin-test-utils = { path = "clickhouse-admin/test-utils" }
clickward = { git = "https://github.com/oxidecomputer/clickward", rev = "a1b342c2558e835d09e6e39a40d3de798a29c2f" }
cockroach-admin-api = { path = "cockroach-admin/api" }
cockroach-admin-client = { path = "clients/cockroach-admin-client" }
Expand Down
3 changes: 2 additions & 1 deletion clickhouse-admin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ omicron-workspace-hack.workspace = true

[dev-dependencies]
clickward.workspace = true
clickhouse-admin-test-utils.workspace = true
dropshot.workspace = true
expectorate.workspace = true
nexus-test-utils.workspace = true
omicron-test-utils.workspace = true
oximeter-db.workspace = true
oximeter-test-utils.workspace = true
openapi-lint.workspace = true
openapiv3.workspace = true
serde_json.workspace = true
slog-term.workspace = true
subprocess.workspace = true
url.workspace = true

Expand Down
15 changes: 15 additions & 0 deletions clickhouse-admin/test-utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "clickhouse-admin-test-utils"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
camino.workspace = true
clickward.workspace = true
dropshot.workspace = true

omicron-workspace-hack.workspace = true
44 changes: 44 additions & 0 deletions clickhouse-admin/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//! Integration testing facilities for clickhouse-admin

use camino::Utf8PathBuf;
use clickward::{BasePorts, Deployment, DeploymentConfig};
use dropshot::test_util::{log_prefix_for_test, LogContext};
use dropshot::{ConfigLogging, ConfigLoggingLevel};

pub const DEFAULT_CLICKHOUSE_ADMIN_BASE_PORTS: BasePorts = BasePorts {
keeper: 29000,
raft: 29100,
clickhouse_tcp: 29200,
clickhouse_http: 29300,
clickhouse_interserver_http: 29400,
};

pub fn default_clickhouse_cluster_test_deployment(
path: Utf8PathBuf,
) -> Deployment {
let base_ports = DEFAULT_CLICKHOUSE_ADMIN_BASE_PORTS;

let config = DeploymentConfig {
path,
base_ports,
cluster_name: "oximeter_cluster".to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have a constant defined for oximeter_cluster somewhere, although maybe not accessible to clickhouse-admin.

};

Deployment::new(config)
}

pub fn default_clickhouse_log_ctx_and_path() -> (LogContext, Utf8PathBuf) {
let logctx = LogContext::new(
"clickhouse_cluster",
&ConfigLogging::StderrTerminal { level: ConfigLoggingLevel::Info },
);

let (parent_dir, _prefix) = log_prefix_for_test("clickhouse_cluster");
let path = parent_dir.join("clickward_test");

(logctx, path)
}
Loading
Loading