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: move database client to tests/common #4057

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ members = [
"src/index",
"tests-fuzz",
"tests-integration",
"tests/common",
"tests/runner",
]
resolver = "2"
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/meta-srv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ url = "2.3"

[dev-dependencies]
chrono.workspace = true
client = { workspace = true, features = ["testing"] }
Copy link
Member Author

Choose a reason for hiding this comment

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

another question about this: because we already have testing feature in client, is it really necessary to move database.rs out of client?

Copy link
Member Author

Choose a reason for hiding this comment

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

and we do have only one testing function in client for which we can't remove testing from client at the moment.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree we can move this struct to client crate behind the testing feature.

IIRC previously it's in the client crate without testing feature in control.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can close this one, revert #3820, and create a new patch to feature-gate database.rs

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah. This is possible. Would you follow these changes?

client.workspace = true
common-meta = { workspace = true, features = ["testing"] }
common-procedure-test.workspace = true
session.workspace = true
Expand Down
3 changes: 1 addition & 2 deletions src/servers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/servers/tests/grpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions tests-integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
1 change: 0 additions & 1 deletion tests-integration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#![feature(assert_matches)]

pub mod cluster;
pub mod database;
mod grpc;
mod influxdb;
mod instance;
Expand Down
2 changes: 1 addition & 1 deletion tests-integration/src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion tests-integration/tests/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
33 changes: 33 additions & 0 deletions tests/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
15 changes: 15 additions & 0 deletions tests/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2024 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;
3 changes: 1 addition & 2 deletions tests/runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/runner/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading