-
Notifications
You must be signed in to change notification settings - Fork 14
164 lines (138 loc) · 6.42 KB
/
server-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
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