Skip to content

feat: support Arrow FlightSQL (#300) #32

feat: support Arrow FlightSQL (#300)

feat: support Arrow FlightSQL (#300) #32

Workflow file for this run

name: Docker Server Mode Test
on:
push:
branches: [ "main" ]
jobs:
test-server:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install system packages
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: mysql-client postgresql-client
version: 1.0
- name: Start MyDuck Server in server mode
run: |
docker run -d --name myduck \
-p 13306:3306 \
-p 15432:5432 \
--env=SETUP_MODE=SERVER \
apecloud/myduckserver:latest
# Wait for MyDuck to be ready
sleep 10
- name: Test MySQL protocol
run: |
# Test connection and create/insert/query data
mysql -h127.0.0.1 -P13306 -uroot -e "
CREATE DATABASE test;
USE test;
CREATE TABLE items (id INT PRIMARY KEY, name VARCHAR(50));
INSERT INTO items VALUES (1, 'test1'), (2, 'test2');
SELECT * FROM items ORDER BY id;" | tee mysql_results.txt
# Verify results
if grep -q "test1" mysql_results.txt && grep -q "test2" mysql_results.txt; then
echo "MySQL protocol test successful"
else
echo "MySQL protocol test failed"
exit 1
fi
- name: Test PostgreSQL protocol
run: |
# Test connection and query data
psql -h 127.0.0.1 -p 15432 -U postgres -c "
SELECT * FROM test.items ORDER BY id;" | tee pg_results.txt
# Verify results
if grep -q "test1" pg_results.txt && grep -q "test2" pg_results.txt; then
echo "PostgreSQL protocol test successful"
else
echo "PostgreSQL protocol test failed"
exit 1
fi
- name: Test DuckDB SQL features
run: |
# Test some DuckDB-specific features through PostgreSQL protocol
psql -h 127.0.0.1 -p 15432 -U postgres -c "CREATE TABLE numbers AS SELECT * FROM range(1, 5) t(n);"
psql -h 127.0.0.1 -p 15432 -U postgres -c "
SELECT list_aggregate(list(n), 'sum') as list_sum FROM numbers;" | tee duckdb_results.txt
# Verify results (sum should be 10)
if grep -q "10" duckdb_results.txt; then
echo "DuckDB features test successful"
else
echo "DuckDB features test failed"
exit 1
fi
- name: Check the loaded extensions, created secrets and global variables
run: |
# Check AWS extension status
if ! psql -h 127.0.0.1 -p 15432 -U postgres -c "SELECT extension_name, installed, description FROM duckdb_extensions() where extension_name = 'aws'" | grep -q "aws.*f"; then
echo "AWS extension check failed, extension is installed"
psql -h 127.0.0.1 -p 15432 -U postgres -c "SELECT extension_name, installed, description FROM duckdb_extensions() where extension_name = 'aws'"
exit 1
fi
# Check secrets
if [ $(psql -h 127.0.0.1 -p 15432 -U postgres -c "SELECT name, type, provider, persistent, storage, secret_string FROM duckdb_secrets()" | grep -c ".") -gt 3 ]; then
echo "Secrets check failed - unexpected secrets found"
psql -h 127.0.0.1 -p 15432 -U postgres -c "SELECT name, type, provider, persistent, storage, secret_string FROM duckdb_secrets()"
exit 1
fi
# Check if binlog_expire_logs_seconds equals '12345'
if mysql -h127.0.0.1 -P13306 -uroot -e "SHOW VARIABLES LIKE 'binlog_expire_logs_seconds'" | grep -q "12345"; then
echo "MySQL variable check failed"
mysql -h127.0.0.1 -P13306 -uroot -e "SHOW VARIABLES LIKE 'binlog_expire_logs_seconds'"
exit 1
fi
echo "Extension, secrets and global variable check successful"
- name: Stop MyDuck Server
run: |
docker rm -f myduck
- name: Start MyDuck Server in server mode with initialization SQLs
run: |
# This will be executed on PostgreSQL protocol.
cat <<EOF > init_duckdb.sql
INSTALL aws;
CREATE SECRET my_secret (
TYPE S3,
KEY_ID 'my_secret_key',
SECRET 'my_secret_value',
REGION 'my_region'
);
EOF
# This will be executed on MySQL protocol.
cat <<EOF > init_mysql.sql
SET GLOBAL binlog_expire_logs_seconds = 12345;
EOF
docker run -d --name myduck \
-p 13306:3306 \
-p 15432:5432 \
--env=SETUP_MODE=SERVER \
-v ./init_duckdb.sql:/docker-entrypoint-initdb.d/postgres/init_duckdb.sql \
-v ./init_mysql.sql:/docker-entrypoint-initdb.d/mysql/init_mysql.sql \
apecloud/myduckserver:latest
# Wait for MyDuck to be ready
sleep 10
- name: Check the loaded extensions, created secrets and global variables after initialization
run: |
# Check AWS extension status
if ! psql -h 127.0.0.1 -p 15432 -U postgres -c "SELECT extension_name, installed, description FROM duckdb_extensions() where extension_name = 'aws'" | grep -q "aws.*t"; then
echo "AWS extension check failed, extension is not installed"
psql -h 127.0.0.1 -p 15432 -U postgres -c "SELECT extension_name, installed, description FROM duckdb_extensions() where extension_name = 'aws'"
exit 1
fi
# Check secrets
if [ $(psql -h 127.0.0.1 -p 15432 -U postgres -c "SELECT name, type, provider, persistent, storage, secret_string FROM duckdb_secrets()" | grep -c ".") -ne 4 ]; then
echo "Secrets check failed - expected 4 secrets"
psql -h 127.0.0.1 -p 15432 -U postgres -c "SELECT name, type, provider, persistent, storage, secret_string FROM duckdb_secrets()"
exit 1
fi
# Check if binlog_expire_logs_seconds equals '12345'
if ! mysql -h127.0.0.1 -P13306 -uroot -e "SHOW VARIABLES LIKE 'binlog_expire_logs_seconds'" | grep -q "12345"; then
echo "MySQL variable check failed"
mysql -h127.0.0.1 -P13306 -uroot -e "SHOW VARIABLES LIKE 'binlog_expire_logs_seconds'"
exit 1
fi
echo "Extension, secrets and global variable check successful"
- name: Cleanup
if: always()
run: |
docker rm -f myduck || true