Skip to content

Commit b646eb5

Browse files
committed
Added regression tests for vacuum shrinking pages.(#72)
1 parent 482c446 commit b646eb5

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

expected/restore.out

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,15 @@ OK: hard-copy option works well.
5858
0
5959
0
6060

61+
###### RESTORE COMMAND TEST-0011 ######
62+
###### vacuum shrinks a page between full and incremental backups ######
63+
0
64+
0
65+
0
66+
67+
###### RESTORE COMMAND TEST-0012 ######
68+
###### vacuum shrinks a page between full and incremental backups(compressed) ######
69+
0
70+
0
71+
0
72+

expected/restore_checksum.out

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,15 @@ OK: hard-copy option works well.
5858
0
5959
0
6060

61+
###### RESTORE COMMAND TEST-0011 ######
62+
###### vacuum shrinks a page between full and incremental backups ######
63+
0
64+
0
65+
0
66+
67+
###### RESTORE COMMAND TEST-0012 ######
68+
###### vacuum shrinks a page between full and incremental backups(compressed) ######
69+
0
70+
0
71+
0
72+

sql/restore.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,49 @@ psql --no-psqlrc -p ${TEST_PGPORT} -d db0010 -c "SELECT * FROM pgbench_branches;
307307
diff ${TEST_BASE}/TEST-0010-before.out ${TEST_BASE}/TEST-0010-after.out
308308
echo ''
309309

310+
echo '###### RESTORE COMMAND TEST-0011 ######'
311+
echo '###### vacuum shrinks a page between full and incremental backups ######'
312+
init_backup
313+
pg_ctl start -w -t 600 > /dev/null 2>&1
314+
createdb db0011 -p ${TEST_PGPORT}
315+
psql --no-psqlrc -p ${TEST_PGPORT} -d db0011 -c "CREATE TABLE t0011(i int,j int,k varchar);" > /dev/null 2>&1
316+
psql --no-psqlrc -p ${TEST_PGPORT} -d db0011 -c "INSERT INTO t0011 (i,j,k) select generate_series(1,1000),1, repeat('a', 10);" > /dev/null 2>&1
317+
pg_rman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet;echo $?
318+
pg_rman validate -B ${BACKUP_PATH} --quiet
319+
psql --no-psqlrc -p ${TEST_PGPORT} -d db0011 -c "DELETE FROM t0011 WHERE i > 10;" > /dev/null 2>&1
320+
psql --no-psqlrc -p ${TEST_PGPORT} -d db0011 -c "VACUUM t0011;" > /dev/null 2>&1
321+
pg_rman backup -B ${BACKUP_PATH} -b incremental -p ${TEST_PGPORT} -d postgres --quiet;echo $?
322+
pg_rman validate -B ${BACKUP_PATH} --quiet
323+
psql --no-psqlrc -p ${TEST_PGPORT} -d db0011 -c "SELECT * FROM t0011;" > ${TEST_BASE}/TEST-0011-before.out
324+
pg_ctl stop -m fast > /dev/null 2>&1
325+
pg_rman restore -B ${BACKUP_PATH} --quiet;echo $?
326+
pg_ctl start -w -t 600 > /dev/null 2>&1
327+
sleep 1
328+
psql --no-psqlrc -p ${TEST_PGPORT} -d db0011 -c "SELECT * FROM t0011;" > ${TEST_BASE}/TEST-0011-after.out
329+
diff ${TEST_BASE}/TEST-0011-before.out ${TEST_BASE}/TEST-0011-after.out
330+
echo ''
331+
332+
echo '###### RESTORE COMMAND TEST-0012 ######'
333+
echo '###### vacuum shrinks a page between full and incremental backups(compressed) ######'
334+
init_backup
335+
pg_ctl start -w -t 600 > /dev/null 2>&1
336+
createdb db0012 -p ${TEST_PGPORT}
337+
psql --no-psqlrc -p ${TEST_PGPORT} -d db0012 -c "CREATE TABLE t0012(i int,j int,k varchar);" > /dev/null 2>&1
338+
psql --no-psqlrc -p ${TEST_PGPORT} -d db0012 -c "INSERT INTO t0012 (i,j,k) select generate_series(1,1000),1, repeat('a', 10);" > /dev/null 2>&1
339+
pg_rman backup -B ${BACKUP_PATH} -b full -Z -p ${TEST_PGPORT} -d postgres --quiet;echo $?
340+
pg_rman validate -B ${BACKUP_PATH} --quiet
341+
psql --no-psqlrc -p ${TEST_PGPORT} -d db0012 -c "DELETE FROM t0012 WHERE i > 10;" > /dev/null 2>&1
342+
psql --no-psqlrc -p ${TEST_PGPORT} -d db0012 -c "VACUUM t0012;" > /dev/null 2>&1
343+
pg_rman backup -B ${BACKUP_PATH} -b incremental -Z -p ${TEST_PGPORT} -d postgres --quiet;echo $?
344+
pg_rman validate -B ${BACKUP_PATH} --quiet
345+
psql --no-psqlrc -p ${TEST_PGPORT} -d db0012 -c "SELECT * FROM t0012;" > ${TEST_BASE}/TEST-0012-before.out
346+
pg_ctl stop -m fast > /dev/null 2>&1
347+
pg_rman restore -B ${BACKUP_PATH} --quiet;echo $?
348+
pg_ctl start -w -t 600 > /dev/null 2>&1
349+
sleep 1
350+
psql --no-psqlrc -p ${TEST_PGPORT} -d db0012 -c "SELECT * FROM t0012;" > ${TEST_BASE}/TEST-0012-after.out
351+
diff ${TEST_BASE}/TEST-0012-before.out ${TEST_BASE}/TEST-0012-after.out
352+
echo ''
310353

311354
# clean up the temporal test data
312355
pg_ctl stop -m immediate > /dev/null 2>&1

0 commit comments

Comments
 (0)