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

ci: fix cargo target dir for integration test #59

Merged
merged 1 commit into from
Apr 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ target/
Cargo.lock

/tests/data
*.output

/dist
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ integration-tests:

integration-tests-flight-sql:
make -C tests test-flight-sql

integration-bendsql:
make -C tests test-bendsql
48 changes: 30 additions & 18 deletions cli/test.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
#!/bin/sh

port=8000
extra=""
if [ $1 = "flight" ];then
port=8900
extra="--flight"
fi
set -e

CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-./target}
DATABEND_USER=${DATABEND_USER:-root}
DATABEND_PASSWORD=${DATABEND_PASSWORD:-}
DATABEND_HOST=${DATABEND_HOST:-localhost}

case $1 in
"flight")
echo
echo "==> Testing Flight SQL handler"
export BENDSQL_DSN="databend+flight://${DATABEND_USER}:${DATABEND_PASSWORD}@${DATABEND_HOST}:8900/?sslmode=disable"
;;
"http")
echo
echo "==> Testing REST API handler"
export BENDSQL_DSN="databend+http://${DATABEND_USER}:${DATABEND_PASSWORD}@${DATABEND_HOST}:8000/?sslmode=disable"
;;
*)
echo "Usage: $0 [flight|http]"
exit 1
;;
esac

cargo build --bin bendsql

for f in `ls cli/tests/*.sql`;do
echo "Testing -- ${f}"
suite=`echo $f | sed -e 's#cli/tests/##' | sed -e 's#.sql##'`
cat $f | ./target/debug/bendsql -u ${DATABEND_USER} -p ${DATABEND_PASSWORD} --port ${port} -h${DATABEND_HOST} ${extra} > /tmp/${suite}.output 2>&1
diff /tmp/${suite}.output cli/tests/${suite}.result

ret_code=$?
if [ $ret_code -ne 0 ]; then
exit 1
fi
for tf in cli/tests/*.sql; do
echo " Running test -- ${tf}"
suite=$(basename "${tf}" | sed -e 's#.sql##')
"${CARGO_TARGET_DIR}/debug/bendsql" <"${tf}" >"cli/tests/${suite}.output" 2>&1
diff "cli/tests/${suite}.output" "cli/tests/${suite}.result"
done

rm /tmp/*.output
rm cli/tests/*.output

echo "Tests $1 passed"
echo "--> Tests $1 passed"
2 changes: 1 addition & 1 deletion cli/tests/base.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
create table test(a string, b int, d boolean);
insert into test values('a', 1, true);
insert into test values('b', 2, false);
select * from test;
select * from test order by a desc;

truncate table test;
insert into test select to_string(number), number, false from numbers(100000);
Expand Down
4 changes: 0 additions & 4 deletions cli/tests/base.sql.output

This file was deleted.

9 changes: 6 additions & 3 deletions tests/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ services:
timeout: 1s
test:
image: rust
command: cargo test --target-dir /target --test *
command: cargo test --test *
working_dir: /workspace
environment:
- CARGO_TARGET_DIR=/target
- RUST_BACKTRACE=1
- TEST_DATABEND_DSN=databend://databend:databend@databend:8000/default?sslmode=disable
volumes:
Expand All @@ -39,9 +40,10 @@ services:
condition: service_healthy
test-flight-sql:
image: rust
command: cargo test --target-dir /target --features flight-sql --test driver
command: cargo test --features flight-sql --test driver
working_dir: /workspace
environment:
- CARGO_TARGET_DIR=/target
- RUST_BACKTRACE=1
- TEST_DATABEND_DSN=databend+flight://databend:databend@databend:8900/default?sslmode=disable
volumes:
Expand All @@ -54,9 +56,10 @@ services:
condition: service_healthy
test-bendsql:
image: rust
command: bash cli/test.sh http && bash cli/test.sh flight
command: bash -c './cli/test.sh http && ./cli/test.sh flight'
working_dir: /workspace
environment:
- CARGO_TARGET_DIR=/target
- RUST_BACKTRACE=1
- DATABEND_USER=databend
- DATABEND_PASSWORD=databend
Expand Down