summaryrefslogtreecommitdiffstats
path: root/lib_pgsql.sh
diff options
context:
space:
mode:
authorPavel Raiskup <praiskup@redhat.com>2014-10-22 08:54:05 +0200
committerPavel Raiskup <praiskup@redhat.com>2014-10-22 08:54:05 +0200
commit2422a081a5be0d5ac5afb122361bc283da67341f (patch)
treecb255582060af6547dd9318c56ba0e8c761846a1 /lib_pgsql.sh
parent922089746e1029de9be986672fcdeb6bc82e18d7 (diff)
downloadpostgresql-setup-tests-2422a081a5be0d5ac5afb122361bc283da67341f.tar.gz
postgresql-setup-tests-2422a081a5be0d5ac5afb122361bc283da67341f.tar.xz
postgresql-setup-tests-2422a081a5be0d5ac5afb122361bc283da67341f.zip
big reorg: prepare for generalization
Try to split into three separate components -> controller, tester, and 'tasks' (postgresql-tasks in our case). The controller component is the main part which is able to run the task remotely. Tester is more-like library for 'tasks' component (should be reusable on the raw git level). * controller: Almost separated component. * postgresql-tasks: Likewise. * tester: Likewise.
Diffstat (limited to 'lib_pgsql.sh')
-rw-r--r--lib_pgsql.sh157
1 files changed, 0 insertions, 157 deletions
diff --git a/lib_pgsql.sh b/lib_pgsql.sh
deleted file mode 100644
index 13bfc82..0000000
--- a/lib_pgsql.sh
+++ /dev/null
@@ -1,157 +0,0 @@
-# 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 -rf /var/lib/pgsql/data"
- rlPhaseEnd
-}
-
-dtf_postgresql_checkphase()
-{
- rlPhaseStart FAIL "Check"
- rlAssertRpm postgresql-server
-
- dtf_postgresql_check_stopped
-
- rlAssertNotExists "/var/lib/pgsql/data/PG_VERSION"
-
- 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
-}
-
-dtf_postgresql_unpack_remote_data()
-(
- local tarball="$1"
- cd /var/lib/pgsql || return 1
- set -o pipefail
- echo "downloading '$tarball'"
- curl "$tarball" | tar -xzf -
-)
-
-# Detect current distribution and print set of "distro version action" lines
-# where DISTRO may be rhel/fedora, VERSION may be e.g. 6.6 for rhel or 20 for
-# Fedora. ACTION is either run or upgrade and it means whether currently
-# installed PostgreSQL server is able to RUN the older data from DISTRO-VERSION
-# or it should be first UPGRADEd.
-#
-# What versions are currently in Fedoras:
-# f17(9.1.9); f18(9.2.5); f19(9.2.9); f20(9.3.5); f21(9.3.5);
-# rawhide(9.3.5)
-
-dtf_postgresql_upgrade_matrix()
-{
- if rlIsFedora 19; then
- # echo fedora 17 upgrade
- # echo fedora 18 run
- echo fedora 19 run
- elif rlIsFedora 20; then
- # echo fedora 18 upgrade
- echo fedora 19 upgrade
- echo fedora 20 run
- elif rlIsFedora 21; then
- echo fedora 19 upgrade
- echo fedora 20 run
- echo fedora 21 run
- elif rlIsFedora 22; then
- echo fedora 19 upgrade
- echo fedora 20 run
- echo fedora 21 run
- echo fedora 22 run
- fi
-}
-
-dtf_postgresql_cb_upgrade()
-{
- local dashdash=""
- if rlIsFedora 22; then
- dashdash="--"
- fi
- rlRun "postgresql-setup $dashdash""upgrade"
-}
-
-dtf_postgresql_cb_upgrade_select()
-{
- cat
-}
-
-dtf_postgresql_upgrade_tour()
-{
- local arch=$(uname -i)
- local rv=0
-
- items="$(dtf_postgresql_upgrade_matrix | dtf_postgresql_cb_upgrade_select)"
- test "$items" = "$(:)" && return 0
-
- while read distro version action; do
- echo "--> Performing upgrade: $distro-$version - $action"
-
- url="$1/$distro/$version/$arch/$2"
-
- dtf_postgresql_unpack_remote_data "$url" || return 1
-
- case "$action" in
- upgrade)
- dtf_postgresql_cb_upgrade
- if test $? -ne 0; then
- rv=1
- find /var/lib/pgsql -maxdepth 1 -name '*.log' | \
- while read line; do
- echo "====== reading log $line ======"
- cat "$line"
- done
- fi
- ;;
- *)
- ;;
- esac
-
- rlServiceStart postgresql
- dtf_postgresql_check_started
- rlServiceStop postgresql
- dtf_postgresql_check_stopped
-
- rm -rf /var/lib/pgsql/data
- done <<<"$items"
-
- return $rv
-}