bzr branch
/loggerhead/pkg-postgresql/postgresql-common/trunk
| Line | Revision | Contents |
| 1 | 1218 | # Check for proper ENOSPC handling |
| 2 | ||
| 3 | use strict; |
|
| 4 | ||
| 5 | require File::Temp; |
|
| 6 | ||
| 7 | use lib 't'; |
|
| 8 | use TestLib; |
|
| 9 | 1233 | use Test::More tests => 16; |
| 10 | 1218 | |
| 11 | my $outref; |
|
| 12 | ||
| 13 | # check that a failed pg_createcluster leaves no cruft behind: try creating a |
|
| 14 | # cluster on a 10 MB tmpfs |
|
| 15 | my $cmd = <<EOF; |
|
| 16 | exec 2>&1 |
|
| 17 | set -e |
|
| 18 | mkdir -p /var/lib/postgresql |
|
| 19 | mount -t tmpfs -o size=10000000 none /var/lib/postgresql |
|
| 20 | # this is supposed to fail |
|
| 21 | LC_MESSAGES=C pg_createcluster $MAJORS[-1] test && exit 1 || true |
|
| 22 | echo -n "ls>" |
|
| 23 | # should not output anything |
|
| 24 | ls /etc/postgresql |
|
| 25 | ls /var/lib/postgresql |
|
| 26 | echo "<ls" |
|
| 27 | EOF |
|
| 28 | ||
| 29 | my $result; |
|
| 30 | $result = exec_as 'root', "echo '$cmd' | unshare -m sh", $outref; |
|
| 31 | ||
| 32 | is $result, 0, 'script failed'; |
|
| 33 | like $$outref, qr/No space left on device/i, |
|
| 34 | 'pg_createcluster fails due to insufficient disk space'; |
|
| 35 | like $$outref, qr/\nls><ls\n/, 'does not leave files behind'; |
|
| 36 | ||
| 37 | ||
| 38 | # check disk full conditions on startup |
|
| 39 | my $cmd = <<EOF; |
|
| 40 | set -e |
|
| 41 | export LC_MESSAGES=C |
|
| 42 | mkdir -p /etc/postgresql /var/lib/postgresql /var/log/postgresql |
|
| 43 | mount -t tmpfs -o size=1000000 none /etc/postgresql |
|
| 44 | mount -t tmpfs -o size=50000000 none /var/lib/postgresql |
|
| 45 | mount -t tmpfs -o size=1000000 none /var/log/postgresql |
|
| 46 | pg_createcluster $MAJORS[-1] test |
|
| 47 | ||
| 48 | # fill up /var/lib/postgresql |
|
| 49 | ! cat < /dev/zero > /var/lib/postgresql/cruft 2>/dev/null |
|
| 50 | echo '-- full lib --' |
|
| 51 | ! pg_ctlcluster $MAJORS[-1] test start |
|
| 52 | echo '-- end full lib --' |
|
| 53 | echo '-- full lib log --' |
|
| 54 | cat /var/log/postgresql/postgresql-$MAJORS[-1]-test.log |
|
| 55 | echo '-- end full lib log --' |
|
| 56 | EOF |
|
| 57 | ||
| 58 | $result = exec_as 'root', "echo '$cmd' | unshare -m sh", $outref; |
|
| 59 | is $result, 0, 'script failed'; |
|
| 60 | like $$outref, qr/^-- full lib --.*No space left on device.*^-- end full lib --/ims, |
|
| 61 | 'pg_ctlcluster prints error message'; |
|
| 62 | like $$outref, qr/^-- full lib log --.*No space left on device.*^-- end full lib log --/ims, |
|
| 63 | 'log file has error message'; |
|
| 64 | ||
| 65 | check_clean; |
|
| 66 | ||
| 67 | # vim: filetype=perl |
Loggerhead 1.17 is a web-based interface for Bazaar branches