diff --git a/Cargo.lock b/Cargo.lock index 62261bce1688..8b469394eeda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -904,7 +904,6 @@ dependencies = [ "rskafka", "serde", "store-api", - "tests-integration", "tokio", "toml 0.8.12", "uuid", @@ -9631,7 +9630,7 @@ dependencies = [ "strum 0.25.0", "table", "tempfile", - "tests-integration", + "tests-common", "tikv-jemalloc-ctl", "tokio", "tokio-postgres", @@ -9996,7 +9995,7 @@ dependencies = [ "serde_json", "sqlness", "tempfile", - "tests-integration", + "tests-common", "tinytemplate", "tokio", ] @@ -10668,6 +10667,32 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" +[[package]] +name = "tests-common" +version = "0.8.0" +dependencies = [ + "api", + "arrow-flight", + "async-stream", + "async-trait", + "clap 4.5.4", + "client", + "cmd", + "common-catalog", + "common-error", + "common-grpc", + "common-query", + "common-recordbatch", + "common-telemetry", + "futures", + "futures-util", + "prost 0.12.4", + "snafu 0.8.2", + "tempfile", + "tokio", + "tonic 0.11.0", +] + [[package]] name = "tests-fuzz" version = "0.8.0" @@ -10765,6 +10790,7 @@ dependencies = [ "substrait 0.8.0", "table", "tempfile", + "tests-common", "time", "tokio", "tokio-postgres", diff --git a/Cargo.toml b/Cargo.toml index 8b02b3f0ce96..04017065f366 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,6 +59,7 @@ members = [ "src/index", "tests-fuzz", "tests-integration", + "tests/common", "tests/runner", ] resolver = "2" @@ -233,8 +234,7 @@ sql = { path = "src/sql" } store-api = { path = "src/store-api" } substrait = { path = "src/common/substrait" } table = { path = "src/table" } -# TODO some code depends on this -tests-integration = { path = "tests-integration" } +tests-common = { path = "tests/common" } [workspace.dependencies.meter-macros] git = "https://github.com/GreptimeTeam/greptime-meter.git" diff --git a/benchmarks/Cargo.toml b/benchmarks/Cargo.toml index ed7f038596e3..18b44e944858 100644 --- a/benchmarks/Cargo.toml +++ b/benchmarks/Cargo.toml @@ -33,8 +33,6 @@ rand.workspace = true rskafka.workspace = true serde.workspace = true store-api.workspace = true -# TODO depend `Database` client -tests-integration.workspace = true tokio.workspace = true toml.workspace = true uuid.workspace = true diff --git a/src/meta-srv/Cargo.toml b/src/meta-srv/Cargo.toml index 458832b34d43..98351107a457 100644 --- a/src/meta-srv/Cargo.toml +++ b/src/meta-srv/Cargo.toml @@ -61,7 +61,7 @@ url = "2.3" [dev-dependencies] chrono.workspace = true -client = { workspace = true, features = ["testing"] } +client.workspace = true common-meta = { workspace = true, features = ["testing"] } common-procedure-test.workspace = true session.workspace = true diff --git a/src/servers/Cargo.toml b/src/servers/Cargo.toml index b355539ea713..f4ae7eb59692 100644 --- a/src/servers/Cargo.toml +++ b/src/servers/Cargo.toml @@ -125,8 +125,7 @@ serde_json.workspace = true session = { workspace = true, features = ["testing"] } table.workspace = true tempfile = "3.0.0" -# TODO depend `Database` client -tests-integration.workspace = true +tests-common.workspace = true tokio-postgres = "0.7" tokio-postgres-rustls = "0.11" tokio-test = "0.4" diff --git a/src/servers/tests/grpc/mod.rs b/src/servers/tests/grpc/mod.rs index 4155f5eac738..8f0a0e2672bf 100644 --- a/src/servers/tests/grpc/mod.rs +++ b/src/servers/tests/grpc/mod.rs @@ -31,7 +31,7 @@ use servers::server::Server; use snafu::ResultExt; use table::test_util::MemTable; use table::TableRef; -use tests_integration::database::Database; +use tests_common::database::Database; use tokio::net::TcpListener; use tokio_stream::wrappers::TcpListenerStream; use tonic::codec::CompressionEncoding; diff --git a/tests-integration/Cargo.toml b/tests-integration/Cargo.toml index 2473cfc320ad..fe54b02e5257 100644 --- a/tests-integration/Cargo.toml +++ b/tests-integration/Cargo.toml @@ -69,6 +69,7 @@ sqlx = { version = "0.6", features = [ substrait.workspace = true table.workspace = true tempfile.workspace = true +tests-common.workspace = true time = "0.3" tokio.workspace = true tokio-stream = { workspace = true, features = ["net"] } diff --git a/tests-integration/src/lib.rs b/tests-integration/src/lib.rs index e4db599fd5e7..d3e700151345 100644 --- a/tests-integration/src/lib.rs +++ b/tests-integration/src/lib.rs @@ -15,7 +15,6 @@ #![feature(assert_matches)] pub mod cluster; -pub mod database; mod grpc; mod influxdb; mod instance; diff --git a/tests-integration/src/test_util.rs b/tests-integration/src/test_util.rs index 35ce52e273bd..3d03e259b540 100644 --- a/tests-integration/src/test_util.rs +++ b/tests-integration/src/test_util.rs @@ -55,8 +55,8 @@ use servers::server::Server; use servers::tls::ReloadableTlsServerConfig; use servers::Mode; use session::context::QueryContext; +use tests_common::database::Database; -use crate::database::Database; use crate::standalone::{GreptimeDbStandalone, GreptimeDbStandaloneBuilder}; pub const PEER_PLACEHOLDER_ADDR: &str = "127.0.0.1:3001"; diff --git a/tests-integration/tests/grpc.rs b/tests-integration/tests/grpc.rs index 48419498e726..b4a54d5c2198 100644 --- a/tests-integration/tests/grpc.rs +++ b/tests-integration/tests/grpc.rs @@ -36,7 +36,7 @@ use servers::http::prometheus::{ }; use servers::server::Server; use servers::tls::{TlsMode, TlsOption}; -use tests_integration::database::Database; +use tests_common::database::Database; use tests_integration::test_util::{ setup_grpc_server, setup_grpc_server_with, setup_grpc_server_with_user_provider, StorageType, }; diff --git a/tests/common/Cargo.toml b/tests/common/Cargo.toml new file mode 100644 index 000000000000..697775c59525 --- /dev/null +++ b/tests/common/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "tests-common" +version.workspace = true +edition.workspace = true +license.workspace = true + +[lints] +workspace = true + +[dependencies] +api.workspace = true +arrow-flight.workspace = true +async-stream.workspace = true +async-trait = "0.1" +client.workspace = true +common-error.workspace = true +common-grpc.workspace = true +common-query.workspace = true +common-recordbatch.workspace = true +common-telemetry.workspace = true +futures.workspace = true +futures-util.workspace = true +prost.workspace = true +snafu.workspace = true +tonic.workspace = true + +[dev-dependencies] +clap.workspace = true +cmd.workspace = true +common-catalog.workspace = true +common-telemetry.workspace = true +tempfile.workspace = true +tokio.workspace = true diff --git a/tests-integration/src/database.rs b/tests/common/src/database.rs similarity index 100% rename from tests-integration/src/database.rs rename to tests/common/src/database.rs diff --git a/tests/common/src/lib.rs b/tests/common/src/lib.rs new file mode 100644 index 000000000000..ae51bf01b1c8 --- /dev/null +++ b/tests/common/src/lib.rs @@ -0,0 +1,15 @@ +// Copyright 2023 Greptime Team +// +// Licensed 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. + +pub mod database; diff --git a/tests/runner/Cargo.toml b/tests/runner/Cargo.toml index 7cb36c1645cb..5a4bef3e950b 100644 --- a/tests/runner/Cargo.toml +++ b/tests/runner/Cargo.toml @@ -19,7 +19,6 @@ serde.workspace = true serde_json.workspace = true sqlness = { version = "0.5" } tempfile.workspace = true -# TODO depend `Database` client -tests-integration.workspace = true +tests-common.workspace = true tinytemplate = "1.2" tokio.workspace = true diff --git a/tests/runner/src/env.rs b/tests/runner/src/env.rs index 399f65840b9c..ed9699a0324c 100644 --- a/tests/runner/src/env.rs +++ b/tests/runner/src/env.rs @@ -30,7 +30,7 @@ use common_query::{Output, OutputData}; use common_recordbatch::RecordBatches; use serde::Serialize; use sqlness::{Database, EnvController, QueryContext}; -use tests_integration::database::Database as DB; +use tests_common::database::Database as DB; use tinytemplate::TinyTemplate; use tokio::sync::Mutex as TokioMutex;