diff options
author | Pavel Raiskup <praiskup@redhat.com> | 2014-10-02 12:33:52 +0200 |
---|---|---|
committer | Pavel Raiskup <praiskup@redhat.com> | 2014-10-03 09:24:13 +0200 |
commit | 3a60df60e73c23730210f3706233d74597034148 (patch) | |
tree | d614b441813e0d4e2299461bf093a3129b4da42b /lib_pgsql.sh | |
download | postgresql-setup-tests-3a60df60e73c23730210f3706233d74597034148.tar.gz postgresql-setup-tests-3a60df60e73c23730210f3706233d74597034148.tar.xz postgresql-setup-tests-3a60df60e73c23730210f3706233d74597034148.zip |
Initial commit
Initializet the lib/run structure and created two basic tests for
PostgreSQL.
* README: New file.
* lib.sh: Likewise.
* lib_pgsql.sh: Likewise.
* run: Likewise.
* tasks/initdb/config.sh: Likewise.
* tasks/initdb/runtest.sh: Likewise.
* tasks/initdb_old/config.sh: Likewise.
* tasks/initdb_old/runtest.sh: Likewise.
Diffstat (limited to 'lib_pgsql.sh')
-rw-r--r-- | lib_pgsql.sh | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/lib_pgsql.sh b/lib_pgsql.sh new file mode 100644 index 0000000..6997827 --- /dev/null +++ b/lib_pgsql.sh @@ -0,0 +1,60 @@ +# PostgreSQL related helper functions. + +# PostgreSQL tests require beakerlib: +# https://fedorahosted.org/beakerlib/ + +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +dtf_postgresql_check_started() +{ + service postgresql status &>/dev/null + rlAssertEquals "service postgresql should be started" $? 0 +} + +dtf_postgresql_check_stopped() +{ + service postgresql status &>/dev/null + rlAssertEquals "service postgresql should be stopped" $? 3 +} + +dtf_postgresql_phase_cleanup() +{ + rlPhaseStartCleanup + rlServiceStop postgresql + dtf_postgresql_check_stopped + rlRun "rm -r /var/lib/pgsql/data" + rlPhaseEnd +} + +dtf_postgresql_checkphase() +{ + rlPhaseStart FAIL "Check" + rlAssertRpm postgresql-server + + dtf_postgresql_check_stopped + + rlAssertNotExists "/var/lib/pgsql/data" + + rlAssert0 "run under root user" `id -u` + + rlGetPhaseState + test $? -gt 0 \ + && echo >&2 "Check phase failed." && exit 1 + rlPhaseEnd +} + +dtf_postgresql_test_init() +{ + rlJournalStart + dtf_postgresql_checkphase + rlPhaseStartTest +} + +dtf_postgresql_test_finish() +{ + rlPhaseEnd + dtf_generate_results_tarball "$BEAKERLIB_DIR" + dtf_postgresql_phase_cleanup + rlJournalEnd + rlGetTestState || return 1 +} |