Skip to content

Commit 24fc348

Browse files
committed
add end to end tests on sharing
1 parent a045127 commit 24fc348

File tree

23 files changed

+343
-146
lines changed

23 files changed

+343
-146
lines changed

scripts/build/build-debug.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ SCRIPT_PATH="$(cd "$(dirname "$0")" >/dev/null 2>&1 && pwd)"
88
cd "$SCRIPT_PATH/../.." || exit
99

1010
echo "Build(DEBUG) start..."
11-
cargo build --bin=databend-query --bin=databend-meta --bin=databend-metactl
11+
cargo build --bin=databend-query --bin=databend-meta --bin=databend-metactl --bin=open-sharing
1212
echo "All done..."

scripts/build/build-release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ SCRIPT_PATH="$(cd "$(dirname "$0")" >/dev/null 2>&1 && pwd)"
88
cd "$SCRIPT_PATH/../.." || exit
99

1010
echo "Build(RELEASE) start..."
11-
cargo build --bin=databend-query --bin=databend-meta --bin=databend-metactl --release
11+
cargo build --bin=databend-query --bin=databend-meta --bin=databend-metactl --bin=open-sharing --release
1212
echo "All done..."

scripts/ci/ci-run-stateful-tests-standalone-s3.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export STORAGE_S3_ENDPOINT_URL=http://127.0.0.1:9900
1717
export STORAGE_S3_ACCESS_KEY_ID=minioadmin
1818
export STORAGE_S3_SECRET_ACCESS_KEY=minioadmin
1919
export STORAGE_ALLOW_INSECURE=true
20+
export ALLOW_SHARING=true
2021

2122
echo "Install dependence"
2223
python3 -m pip install --quiet mysql-connector-python
@@ -25,6 +26,8 @@ echo "calling test suite"
2526
echo "Starting standalone DatabendQuery(debug)"
2627
./scripts/ci/deploy/databend-query-standalone.sh
2728

29+
export ALLOW_SHARING=false
30+
2831
SCRIPT_PATH="$(cd "$(dirname "$0")" >/dev/null 2>&1 && pwd)"
2932
cd "$SCRIPT_PATH/../../tests" || exit
3033

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Usage:
2+
# databend-query -c databend_query_config_spec.toml
3+
4+
[query]
5+
max_active_sessions = 256
6+
wait_timeout_mills = 5000
7+
8+
# For flight rpc.
9+
flight_api_address = "0.0.0.0:59091"
10+
11+
# Databend Query http address.
12+
# For admin RESET API.
13+
admin_api_address = "0.0.0.0:58080"
14+
15+
# Databend Query metrics RESET API.
16+
metric_api_address = "0.0.0.0:57070"
17+
18+
# Databend Query MySQL Handler.
19+
mysql_handler_host = "0.0.0.0"
20+
mysql_handler_port = 53307
21+
22+
# Databend Query ClickHouse Handler.
23+
clickhouse_http_handler_host = "0.0.0.0"
24+
clickhouse_http_handler_port = 58124
25+
26+
# Databend Query HTTP Handler.
27+
http_handler_host = "0.0.0.0"
28+
http_handler_port = 58000
29+
30+
tenant_id = "shared_tenant"
31+
cluster_id = "test_cluster"
32+
33+
table_engine_memory_enabled = true
34+
database_engine_github_enabled = true
35+
36+
table_cache_enabled = true
37+
table_memory_cache_mb_size = 1024
38+
table_disk_cache_root = "_cache"
39+
table_disk_cache_mb_size = 10240
40+
table_cache_bloom_index_meta_count=3000
41+
table_cache_bloom_index_data_bytes=1073741824
42+
43+
share_endpoint_address = "127.0.0.1:33003" # receive shared information from open sharing
44+
# [[query.users]]
45+
# name = "admin"
46+
# auth_type = "no_password"
47+
48+
# [[query.users]]
49+
# name = "databend"
50+
# auth_type = "double_sha1_password"
51+
# # echo -n "databend" | sha1sum | cut -d' ' -f1 | xxd -r -p | sha1sum
52+
# auth_string = "3081f32caef285c232d066033c89a78d88a6d8a5"
53+
54+
# [[query.users]]
55+
# name = "datafuselabs"
56+
# auth_type = "sha256_password"
57+
# # echo -n "datafuselabs" | sha256sum
58+
# auth_string = "6db1a2f5da402b43c066fcadcbf78f04260b3236d9035e44dd463f21e29e6f3b"
59+
60+
61+
[log]
62+
63+
[log.file]
64+
level = "ERROR"
65+
format = "text"
66+
dir = "./.databend/logs_1"
67+
68+
[meta]
69+
endpoints = ["0.0.0.0:9191"]
70+
username = "root"
71+
password = "root"
72+
client_timeout_in_second = 60
73+
auto_sync_interval = 60
74+
75+
# Storage config.
76+
[storage]
77+
# fs | s3 | azblob | obs | oss
78+
type = "fs"
79+
80+
# Set a local folder to store your data.
81+
# Comment out this block if you're NOT using local file system as storage.
82+
[storage.fs]
83+
data_path = "./.databend/stateless_test_data"
84+
85+
# To use S3-compatible object storage, uncomment this block and set your values.
86+
# [storage.s3]
87+
# bucket = "<your-bucket-name>"
88+
# endpoint_url = "<your-endpoint>"
89+
# access_key_id = "<your-key-id>"
90+
# secret_access_key = "<your-account-key>"
91+
# enable_virtual_host_style = false
92+
93+
# To use Azure Blob storage, uncomment this block and set your values.
94+
# [storage.azblob]
95+
# endpoint_url = "https://<your-storage-account-name>.blob.core.windows.net"
96+
# container = "<your-azure-storage-container-name>"
97+
# account_name = "<your-storage-account-name>"
98+
# account_key = "<your-account-key>"
99+
100+
# To use OBS object storage, uncomment this block and set your values.
101+
# [storage.obs]
102+
# bucket = "<your-bucket-name>"
103+
# endpoint_url = "<your-endpoint>"
104+
# access_key_id = "<your-key-id>"
105+
# secret_access_key = "<your-account-key>"
106+
107+
# To use OSS object storage, uncomment this block and set your values.
108+
# [storage.oss]
109+
# bucket = "<your-bucket-name>"
110+
# endpoint_url = "<your-endpoint>"
111+
# access_key_id = "<your-key-id>"
112+
# access_key_secret = "<your-account-key>"

scripts/ci/deploy/databend-query-standalone.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ BUILD_PROFILE=${BUILD_PROFILE:-debug}
1010

1111
killall databend-query || true
1212
killall databend-meta || true
13+
killall open-sharing || true
1314
sleep 1
1415

1516
for bin in databend-query databend-meta; do
@@ -29,3 +30,24 @@ nohup target/${BUILD_PROFILE}/databend-query -c scripts/ci/deploy/config/databen
2930

3031
echo "Waiting on databend-query 10 seconds..."
3132
python3 scripts/ci/wait_tcp.py --timeout 5 --port 3307
33+
34+
# only expected to get adopted in stateful tests
35+
if [[ "$ALLOW_SHARING" == "true" ]]; then
36+
echo "*************************************"
37+
echo "* Test on Databend openSharing endpoint *"
38+
echo "* it will start a node from another tenant *"
39+
echo "* Please make sure that S3 backend *"
40+
echo "* is ready, and configured properly. *"
41+
echo "*************************************"
42+
echo "Start open-sharing..."
43+
export TENANT=test_tenant
44+
nohup target/${BUILD_PROFILE}/open-sharing &
45+
python3 scripts/ci/wait_tcp.py --timeout 5 --port 33003
46+
47+
echo 'Start databend-query...'
48+
export STORAGE_S3_ROOT=shared
49+
50+
nohup target/${BUILD_PROFILE}/databend-query -c scripts/ci/deploy/config/databend-query-node-shared.toml &
51+
52+
python3 scripts/ci/wait_tcp.py --timeout 5 --port 53307
53+
fi

src/binaries/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ anyhow = { workspace = true }
5151
clap = { workspace = true }
5252
limits-rs = "0.1.0"
5353
openraft = { workspace = true }
54+
poem = { version = "1", features = ["rustls", "multipart", "compression"] }
5455
sentry = "0.27.0"
5556
serde = { workspace = true }
5657
serde_json = { workspace = true }
5758
tokio-stream = "0.1.10"
5859
tonic = "0.8.1"
5960
tracing = "0.1.36"
6061
url = "2.3.1"
61-
poem = { version = "1", features = ["rustls", "multipart", "compression"] }
6262

6363
[[bin]]
6464
name = "databend-meta"

src/binaries/opensharing/main.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,28 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use poem::{EndpointExt, Route, Server};
1615
use common_base::base::tokio;
1716
use poem::listener::TcpListener;
17+
use poem::EndpointExt;
18+
use poem::Route;
19+
use poem::Server;
20+
use sharing_endpoint::configs::Config;
1821
use sharing_endpoint::handlers::presign_files;
1922
use sharing_endpoint::middlewares::SharingAuth;
20-
use sharing_endpoint::configs::Config;
2123
use sharing_endpoint::services::SharingServices;
2224
#[tokio::main]
23-
async fn main() ->Result<(), std::io::Error> {
25+
async fn main() -> Result<(), std::io::Error> {
2426
let config = Config::load().expect("cfgs");
2527
println!("config: {:?}", config);
26-
SharingServices::init(config).await.expect("failed to init sharing service");
27-
let app = Route::new().at("/tenant/:tenant_id/:share_name/table/:table_name/presign", poem::post(presign_files)).with(SharingAuth);
28+
SharingServices::init(config)
29+
.await
30+
.expect("failed to init sharing service");
31+
let app = Route::new()
32+
.at(
33+
"/tenant/:tenant_id/:share_name/table/:table_name/presign",
34+
poem::post(presign_files),
35+
)
36+
.with(SharingAuth);
2837

2938
// TODO(zhihanz): remove the hard coded port into a config
3039
Server::new(TcpListener::bind("127.0.0.1:33003"))

src/query/config/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ pub use inner::CatalogHiveConfig;
3232
pub use inner::Config;
3333
pub use inner::QueryConfig;
3434
pub use inner::ThriftProtocol;
35-
3635
pub use outer_v0::StorageConfig;
37-
3836
pub use version::DATABEND_COMMIT_VERSION;
3937
pub use version::QUERY_SEMVER;

src/query/sharing-endpoint/Cargo.toml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,21 @@ edition = { workspace = true }
1010
doctest = false
1111

1212
[dependencies]
13-
common-exception = { path = "../../common/exception" }
1413
common-base = { path = "../../common/base" }
15-
common-storage = { path = "../../common/storage" }
1614
common-config = { path = "../../query/config" }
17-
uuid = { version = "1.1.2", features = ["serde", "v4"] }
15+
common-exception = { path = "../../common/exception" }
16+
common-storage = { path = "../../common/storage" }
1817
once_cell = "1.15.0"
18+
uuid = { version = "1.1.2", features = ["serde", "v4"] }
1919

2020
time = { version = "0.3", features = ["serde"] }
2121

2222
anyhow = { workspace = true }
23-
serde = { workspace = true }
24-
serde_json = { workspace = true }
25-
thiserror = { version = "1" }
23+
base64 = "0.13.0"
24+
clap = { workspace = true }
2625
opendal = "0.22.2"
2726
poem = { version = "1", features = ["rustls", "multipart", "compression"] }
28-
clap = { workspace = true }
27+
serde = { workspace = true }
28+
serde_json = { workspace = true }
2929
serfig = "0.0.3"
30-
base64 = "0.13.0"
31-
30+
thiserror = { version = "1" }

0 commit comments

Comments
 (0)