Skip to content

Commit e99e622

Browse files
authored
ci: ttc test with nginx and minio. (#18657)
* ci: ttc test with nginx and minio. * up tests.
1 parent 41be3f7 commit e99e622

16 files changed

+184
-3
lines changed

.github/workflows/reuse.sqllogic.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,40 @@ jobs:
187187
with:
188188
name: test-sqllogic-standalone-minio-tpch-http-with-bendsave
189189

190+
cluster_with_minio_and_nginx:
191+
runs-on:
192+
- self-hosted
193+
- ${{ inputs.runner_arch }}
194+
- Linux
195+
- 2c8g
196+
- "${{ inputs.runner_provider }}"
197+
strategy:
198+
fail-fast: false
199+
matrix:
200+
dirs:
201+
- "http_handler"
202+
handler:
203+
- "ttc-rust"
204+
- "ttc-go"
205+
steps:
206+
- uses: actions/checkout@v4
207+
- uses: ./.github/actions/setup_test
208+
with:
209+
artifacts: sqllogictests,meta,query
210+
211+
- uses: ./.github/actions/setup_minio
212+
213+
- name: Run sqllogic Tests with Cluster behind Nginx
214+
shell: bash
215+
env:
216+
TEST_HANDLERS: ${{ matrix.handler }}
217+
run: bash ./scripts/ci/ci-run-sqllogic-tests-cluster-nginx.sh ${{ matrix.dirs }}
218+
- name: Upload failure
219+
if: failure()
220+
uses: ./.github/actions/artifact_failure
221+
with:
222+
name: test-sqllogic-cluster-minio-${{ matrix.dirs }}-${{ matrix.handler }}
223+
190224
# TODO: tmp disable since iceberg image not running on arm64
191225
# standalone_iceberg_tpch:
192226
# runs-on:
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
# Copyright 2020-2021 The Databend Authors.
3+
# SPDX-License-Identifier: Apache-2.0.
4+
5+
set -e
6+
7+
export STORAGE_ALLOW_INSECURE=true
8+
9+
echo "Starting Cluster databend-query"
10+
./scripts/ci/deploy/databend-query-cluster-3-nodes-nginx.sh
11+
12+
export RUST_BACKTRACE=1
13+
14+
TEST_HANDLERS=${TEST_HANDLERS:-"mysql,http"}
15+
TEST_PARALLEL=${TEST_PARALLEL:-8}
16+
BUILD_PROFILE=${BUILD_PROFILE:-debug}
17+
18+
RUN_DIR=""
19+
if [ $# -gt 0 ]; then
20+
RUN_DIR="--run_dir $*"
21+
fi
22+
echo "Run suites using argument: $RUN_DIR"
23+
24+
echo "Starting databend-sqllogic tests"
25+
target/${BUILD_PROFILE}/databend-sqllogictests --handlers ${TEST_HANDLERS} ${RUN_DIR} --enable_sandbox --parallel ${TEST_PARALLEL} ${TEST_EXT_ARGS}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
events {
2+
worker_connections 1024;
3+
}
4+
5+
http {
6+
upstream backend {
7+
server localhost:8001;
8+
server localhost:8002;
9+
server localhost:8003;
10+
}
11+
12+
server {
13+
listen 8000;
14+
15+
location / {
16+
proxy_pass http://backend;
17+
}
18+
}
19+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
# Copyright 2022 The Databend Authors.
3+
# SPDX-License-Identifier: Apache-2.0.
4+
5+
set -ex
6+
7+
SCRIPT_PATH="$(cd "$(dirname "$0")" >/dev/null 2>&1 && pwd)"
8+
cd "$SCRIPT_PATH/../../.." || exit
9+
BUILD_PROFILE=${BUILD_PROFILE:-debug}
10+
11+
# Caveat: has to kill query first.
12+
# `query` tries to remove its liveness record from meta before shutting down.
13+
# If meta is stopped, `query` will receive an error that hangs graceful
14+
# shutdown.
15+
killall databend-query || true
16+
sleep 3
17+
18+
killall databend-meta || true
19+
sleep 3
20+
21+
for bin in databend-query databend-meta; do
22+
if test -n "$(pgrep $bin)"; then
23+
echo "The $bin is not killed. force killing."
24+
killall -9 $bin || true
25+
fi
26+
done
27+
28+
# Wait for killed process to cleanup resources
29+
sleep 1
30+
31+
echo 'Start Meta service HA cluster(3 nodes)...'
32+
33+
mkdir -p ./.databend/
34+
35+
nohup ./target/${BUILD_PROFILE}/databend-meta -c scripts/ci/deploy/config/databend-meta-node-1.toml >./.databend/meta-1.out 2>&1 &
36+
python3 scripts/ci/wait_tcp.py --timeout 30 --port 9191
37+
38+
# wait for cluster formation to complete.
39+
sleep 1
40+
41+
nohup ./target/${BUILD_PROFILE}/databend-meta -c scripts/ci/deploy/config/databend-meta-node-2.toml >./.databend/meta-2.out 2>&1 &
42+
python3 scripts/ci/wait_tcp.py --timeout 30 --port 28202
43+
44+
# wait for cluster formation to complete.
45+
sleep 1
46+
47+
nohup ./target/${BUILD_PROFILE}/databend-meta -c scripts/ci/deploy/config/databend-meta-node-3.toml >./.databend/meta-3.out 2>&1 &
48+
python3 scripts/ci/wait_tcp.py --timeout 30 --port 28302
49+
50+
# wait for cluster formation to complete.
51+
sleep 1
52+
53+
echo 'Start databend-query node-1'
54+
nohup env RUST_BACKTRACE=1 QUERY_HTTP_HANDLER_PORT=8081 target/${BUILD_PROFILE}/databend-query -c scripts/ci/deploy/config/databend-query-node-1.toml --internal-enable-sandbox-tenant >./.databend/query-1.out 2>&1 &
55+
56+
echo "Waiting on node-1..."
57+
python3 scripts/ci/wait_tcp.py --timeout 30 --port 9091
58+
59+
echo 'Start databend-query node-2'
60+
env "RUST_BACKTRACE=1" nohup target/${BUILD_PROFILE}/databend-query -c scripts/ci/deploy/config/databend-query-node-2.toml --internal-enable-sandbox-tenant >./.databend/query-2.out 2>&1 &
61+
62+
echo "Waiting on node-2..."
63+
python3 scripts/ci/wait_tcp.py --timeout 30 --port 9092
64+
65+
echo 'Start databend-query node-3'
66+
env "RUST_BACKTRACE=1" nohup target/${BUILD_PROFILE}/databend-query -c scripts/ci/deploy/config/databend-query-node-3.toml --internal-enable-sandbox-tenant >./.databend/query-3.out 2>&1 &
67+
68+
echo "Waiting on node-3..."
69+
python3 scripts/ci/wait_tcp.py --timeout 30 --port 9093
70+
71+
echo 'Start Nginx'
72+
if docker inspect nginx_db >/dev/null 2>&1; then
73+
docker rm -f nginx_db
74+
fi
75+
docker run -d --network host --name nginx_db -v "$(pwd)/scripts/ci/deploy/config/nginx.conf":/etc/nginx/nginx.conf:ro nginx
76+
77+
docker logs nginx_db
78+
79+
curl -s -u root: -XPOST "http://localhost:8000/v1/query" -H 'Content-Type: application/json' -d '{"sql": "select * from system.clusters"}'
80+
81+
echo
82+
83+
curl -s -u root: -XPOST "http://localhost:8000/v1/query" -H 'Content-Type: application/json' -d "{\"sql\": \"create user databend IDENTIFIED BY 'databend'\"}"
84+
85+
echo
86+
87+
echo "All done..."

tests/sqllogictests/src/main.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ mod util;
5555
const HANDLER_MYSQL: &str = "mysql";
5656
const HANDLER_HTTP: &str = "http";
5757
const HANDLER_HYBRID: &str = "hybrid";
58+
const HANDLER_TTC_RUST: &str = "ttc_rust";
5859
const TTC_PORT_START: u16 = 9902;
5960

6061
use std::sync::LazyLock;
@@ -133,6 +134,16 @@ pub async fn main() -> Result<()> {
133134
HANDLER_HYBRID => {
134135
run_hybrid_client(args.clone(), &mut containers).await?;
135136
}
137+
HANDLER_TTC_RUST => {}
138+
handler if handler.starts_with("ttc") => {
139+
let image = format!("ghcr.io/databendlabs/{handler}:latest");
140+
run_ttc_container(&image, TTC_PORT_START, args.port, &mut containers).await?;
141+
run_ttc_client(
142+
args.clone(),
143+
ClientType::Ttc(handler.to_string(), TTC_PORT_START),
144+
)
145+
.await?;
146+
}
136147
_ => {
137148
return Err(format!("Unknown test handler: {handler}").into());
138149
}
@@ -153,6 +164,11 @@ async fn run_http_client(args: SqlLogicTestArgs) -> Result<()> {
153164
run_suits(args, ClientType::Http).await?;
154165
Ok(())
155166
}
167+
async fn run_ttc_client(args: SqlLogicTestArgs, client_type: ClientType) -> Result<()> {
168+
println!("Http client starts to run with: {:?}", args);
169+
run_suits(args, client_type).await?;
170+
Ok(())
171+
}
156172

157173
async fn run_hybrid_client(
158174
args: SqlLogicTestArgs,

tests/sqllogictests/suites/temp_table/alter_temp_tables.test renamed to tests/sqllogictests/suites/http_handler/temp_table/alter_temp_tables.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ INSERT INTO TABLE `05_0003_at_t4` values('a', 'b', ['c1', 'c2'], ('d1', 'd2'))
118118
query TT
119119
SHOW CREATE TABLE `05_0003_at_t4`
120120
----
121-
05_0003_at_t4 CREATE TEMP TABLE "05_0003_at_t4" ( a VARCHAR NOT NULL, b VARCHAR NULL, c ARRAY(STRING) NULL, d TUPLE(1 STRING, 2 STRING) NULL ) ENGINE=FUSE
121+
05_0003_at_t4 CREATE TEMP TABLE "05_0003_at_t4" ( a VARCHAR NOT NULL, b VARCHAR NULL, c ARRAY(VARCHAR NULL) NULL, d TUPLE(1 VARCHAR NULL, 2 VARCHAR NULL) NULL ) ENGINE=FUSE
122122

123123
query TTTT
124124
SELECT * FROM `05_0003_at_t4`
@@ -140,7 +140,7 @@ ALTER TABLE `05_0003_at_t4` MODIFY COLUMN d tuple(binary, binary) null
140140
query TT
141141
SHOW CREATE TABLE `05_0003_at_t4`
142142
----
143-
05_0003_at_t4 CREATE TEMP TABLE "05_0003_at_t4" ( a BINARY NOT NULL, b BINARY NULL, c ARRAY(BINARY) NULL, d TUPLE(1 BINARY, 2 BINARY) NULL ) ENGINE=FUSE
143+
05_0003_at_t4 CREATE TEMP TABLE "05_0003_at_t4" ( a BINARY NOT NULL, b BINARY NULL, c ARRAY(BINARY NULL) NULL, d TUPLE(1 BINARY NULL, 2 BINARY NULL) NULL ) ENGINE=FUSE
144144

145145
query
146146
SELECT * FROM `05_0003_at_t4`
@@ -162,7 +162,7 @@ ALTER TABLE `05_0003_at_t4` MODIFY COLUMN d tuple(string, string) null
162162
query TT
163163
SHOW CREATE TABLE `05_0003_at_t4`
164164
----
165-
05_0003_at_t4 CREATE TEMP TABLE "05_0003_at_t4" ( a VARCHAR NOT NULL, b VARCHAR NULL, c ARRAY(STRING) NULL, d TUPLE(1 STRING, 2 STRING) NULL ) ENGINE=FUSE
165+
05_0003_at_t4 CREATE TEMP TABLE "05_0003_at_t4" ( a VARCHAR NOT NULL, b VARCHAR NULL, c ARRAY(VARCHAR NULL) NULL, d TUPLE(1 VARCHAR NULL, 2 VARCHAR NULL) NULL ) ENGINE=FUSE
166166

167167
query TTTT
168168
SELECT * FROM `05_0003_at_t4`

tests/sqllogictests/suites/temp_table/create_temp_tables.test renamed to tests/sqllogictests/suites/http_handler/temp_table/create_temp_tables.test

File renamed without changes.

tests/sqllogictests/suites/temp_table/drop_temp_tables.test renamed to tests/sqllogictests/suites/http_handler/temp_table/drop_temp_tables.test

File renamed without changes.

tests/sqllogictests/suites/temp_table/rename_temp_tables.test renamed to tests/sqllogictests/suites/http_handler/temp_table/rename_temp_tables.test

File renamed without changes.

tests/sqllogictests/suites/temp_table/temp_memory_tables.test renamed to tests/sqllogictests/suites/http_handler/temp_table/temp_memory_tables.test

File renamed without changes.

0 commit comments

Comments
 (0)