Skip to content

Commit

Permalink
ci: fix cargo target dir for integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
everpcpc committed Apr 15, 2023
1 parent 34a3e22 commit b9ccac4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 deletions.
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
39 changes: 26 additions & 13 deletions cli/test.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
#!/bin/sh

port=8000
extra=""
if [ $1 = "flight" ];then
port=8900
extra="--flight"
fi
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 "Testing Flight SQL handler"
export BENDSQL_DSN="databend+flight://${DATABEND_USER}:${DATABEND_PASSWORD}@${DATABEND_HOST}:8900/?sslmode=disable"
;;
"http")
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
for tf in cli/tests/*.sql; do
echo "Testing -- ${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"

ret_code=$?
if [ $ret_code -ne 0 ]; then
exit 1
fi
done

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

echo "Tests $1 passed"
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

0 comments on commit b9ccac4

Please sign in to comment.