Skip to content

Commit 956e1c4

Browse files
authored
test: add multiple databases test for backup/restore (#326) (#339)
1 parent 2631948 commit 956e1c4

File tree

1 file changed

+44
-7
lines changed

1 file changed

+44
-7
lines changed

.github/workflows/backup-restore.yml

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ jobs:
128128
129129
# Verify replication of new data
130130
psql -h 127.0.0.1 -p 5432 -U postgres -c "SELECT 1 FROM test_table WHERE id = 3 AND name = 'new data 3';" | grep -q 1
131-
131+
132132
- name: Backup MyDuck and Insert more data into source PG
133133
run: |
134134
psql "postgres://postgres:@127.0.0.1:5432" <<-EOSQL
@@ -157,14 +157,16 @@ jobs:
157157
--restore-secret-access-key=minioadmin &
158158
159159
sleep 10
160-
160+
161161
- name: Test Replication
162162
run: |
163163
# Verify replication catches up
164164
psql -h 127.0.0.1 -p 5432 -U postgres -c "SELECT 1 FROM test_table WHERE id = 4 AND name = 'offline data 4';" | grep -q 1
165-
166-
# Kill MyDuck
167-
pkill myduckserver
165+
166+
- name: Cleanup
167+
if: always()
168+
run: |
169+
pkill myduckserver || true
168170
rm -f ./myduck.db
169171
170172
- name: Restore MyDuck at Runtime
@@ -186,8 +188,43 @@ jobs:
186188
# Verify replication catches up
187189
psql -h 127.0.0.1 -p 5432 -U postgres -d testdb2 -c "SELECT 1 FROM test_table WHERE id = 4 AND name = 'offline data 4';" | grep -q 1
188190
189-
# Kill MyDuck
190-
pkill myduckserver
191+
- name: Test Multiple Databases
192+
run: |
193+
psql "postgres://postgres:@127.0.0.1:5432" <<-EOSQL
194+
CREATE DATABASE testdb3;
195+
CREATE SCHEMA testdb3.sch3;
196+
USE testdb3.sch3;
197+
CREATE TABLE test_table3 (id int primary key, name text);
198+
INSERT INTO test_table3 VALUES (3, 'initial data 3'), (33, 'initial data 33');
199+
CREATE DATABASE testdb4;
200+
CREATE SCHEMA testdb4.sch4;
201+
USE testdb4.sch4;
202+
CREATE TABLE test_table4 (id int primary key, name text);
203+
INSERT INTO test_table4 VALUES (4, 'initial data 4'), (44, 'initial data 44');
204+
205+
BACKUP DATABASE testdb3 TO 's3c://myduck-backup/myduck/myduck3.bak'
206+
ENDPOINT = '127.0.0.1:9001'
207+
ACCESS_KEY_ID = 'minioadmin'
208+
SECRET_ACCESS_KEY = 'minioadmin';
209+
210+
BACKUP DATABASE testdb4 TO 's3c://myduck-backup/myduck/myduck4.bak'
211+
ENDPOINT = '127.0.0.1:9001'
212+
ACCESS_KEY_ID = 'minioadmin'
213+
SECRET_ACCESS_KEY = 'minioadmin';
214+
215+
RESTORE DATABASE testdb5 FROM 's3c://myduck-backup/myduck/myduck3.bak'
216+
ENDPOINT = '127.0.0.1:9001'
217+
ACCESS_KEY_ID = 'minioadmin'
218+
SECRET_ACCESS_KEY = 'minioadmin';
219+
220+
RESTORE DATABASE testdb6 FROM 's3c://myduck-backup/myduck/myduck4.bak'
221+
ENDPOINT = '127.0.0.1:9001'
222+
ACCESS_KEY_ID = 'minioadmin'
223+
SECRET_ACCESS_KEY = 'minioadmin';
224+
EOSQL
225+
226+
psql -h 127.0.0.1 -p 5432 -U postgres -d testdb5 -c "SELECT 1 FROM sch3.test_table3 WHERE id = 3 AND name = 'initial data 3';" | grep -q 1
227+
psql -h 127.0.0.1 -p 5432 -U postgres -d testdb6 -c "SELECT 1 FROM sch4.test_table4 WHERE id = 44 AND name = 'initial data 44';" | grep -q 1
191228
192229
- name: Cleanup
193230
if: always()

0 commit comments

Comments
 (0)