diff options
| author | Pavel Raiskup <praiskup@redhat.com> | 2014-10-22 08:54:05 +0200 |
|---|---|---|
| committer | Pavel Raiskup <praiskup@redhat.com> | 2014-10-22 08:54:05 +0200 |
| commit | 2422a081a5be0d5ac5afb122361bc283da67341f (patch) | |
| tree | cb255582060af6547dd9318c56ba0e8c761846a1 /gen-data | |
| parent | 922089746e1029de9be986672fcdeb6bc82e18d7 (diff) | |
| download | postgresql-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 'gen-data')
| -rw-r--r-- | gen-data/databases/pagila.sh | 39 | ||||
| -rwxr-xr-x | gen-data/dist/dist | 4 | ||||
| -rw-r--r-- | gen-data/dist/dist.exclude | 1 | ||||
| -rw-r--r-- | gen-data/dist/dist.list | 5 | ||||
| -rwxr-xr-x | gen-data/generate | 129 | ||||
| -rwxr-xr-x | gen-data/prep | 5 | ||||
| -rwxr-xr-x | gen-data/remote_generate | 14 | ||||
| -rw-r--r-- | gen-data/tasks/basic/run.sh | 6 | ||||
| -rw-r--r-- | gen-data/tasks/locale-cz/run.sh | 5 | ||||
| -rw-r--r-- | gen-data/tasks/locale-utf-typo/run.sh | 5 | ||||
| -rw-r--r-- | gen-data/tasks/templates/locale-change.sh | 16 |
11 files changed, 0 insertions, 229 deletions
diff --git a/gen-data/databases/pagila.sh b/gen-data/databases/pagila.sh deleted file mode 100644 index a01d818..0000000 --- a/gen-data/databases/pagila.sh +++ /dev/null @@ -1,39 +0,0 @@ -create_pagila() -( - testit() - { - debug "testing database" - - local cmd="psql -tA -d pagila -c \"select city from city where city = 'Banjul';\"" - - out="$(admin_cmd "$cmd")" - test "$out" = Banjul || return 1 - test "$(wc -l < pagila_init.log)" -gt 335 || return 1 - - test "$({ grep ERROR | wc -l ; } < pagila_init.log)" -lt 2 - } - - debug "creating DB pagilla" - INDENT="$INDENT " - - pagila="pagila-0.10.1" - pagila_tarball="$pagila.zip" - pagila_link="http://pgfoundry.org/frs/download.php/1719/$pagila_tarball" - - cached_download $pagila_link - - debug "unzipping tarball" - unzip $pagila_tarball &>/dev/null || die "can not unzip pagila" - - pushd $pagila >/dev/null || die "can not switch directory" - admin_cmd "createdb pagila --owner postgres" || die "can't create db" - { su - postgres -c 'psql -d pagila' < pagila-schema.sql \ - && su - postgres -c 'psql -d pagila' < pagila-data.sql - } &>pagila_init.log || die "can not initialize pagila" - - cp pagila_init.log /tmp - - testit || die "can not test" - - popd >/dev/null || die "can't go back" -) diff --git a/gen-data/dist/dist b/gen-data/dist/dist deleted file mode 100755 index c9aea1b..0000000 --- a/gen-data/dist/dist +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -# !!!! creating tar-BOMB !!!! -tar -cf dist/dist.tar.gz -T dist/dist.list -X dist/dist.exclude diff --git a/gen-data/dist/dist.exclude b/gen-data/dist/dist.exclude deleted file mode 100644 index 484ab7e..0000000 --- a/gen-data/dist/dist.exclude +++ /dev/null @@ -1 +0,0 @@ -results/* diff --git a/gen-data/dist/dist.list b/gen-data/dist/dist.list deleted file mode 100644 index 832aca4..0000000 --- a/gen-data/dist/dist.list +++ /dev/null @@ -1,5 +0,0 @@ -prep -generate -databases -tasks -results diff --git a/gen-data/generate b/gen-data/generate deleted file mode 100755 index d8ead6b..0000000 --- a/gen-data/generate +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/bash - -GEN_DATADIR=/var/lib/pgsql/data -CACHEDIR=/var/cache/dbt -OUTPUTDIR="$(pwd)/results" -SRCDIR="$(pwd)" -DEBUG=1 -CHECK_LOCALE=1 - -printline() { echo "$INDENT$@" ; } - -die() { printline " ERROR $@" ; exit 1 ; } - -info() { printline " * $@"; } - -debug() { test $DEBUG -eq 1 && printline " ~ $@"; } - -admin_cmd() -{ - su - postgres -c "$@" || die "can not execute '$@'" -} - -cached_download() -{ - local link=$1 - local bn="$(basename "$1")" - local file="$CACHEDIR/$bn" - - if test ! -d "$CACHEDIR"; then - mkdir -p "$CACHEDIR" || die "can't create cachedir" - fi - - test -e "$file" && cp "$file" ./ && return - - { wget "$link" && cp "$bn" "$CACHEDIR" ; } \ - || die "can't download" -} - -is_defined_f() -{ - declare -f "$1" >/dev/null -} - -run_if_defined() -{ - is_defined_f "$1" || return 0 - "$1" -} - -locale_prereq() -{ - local default_locale="LANG=en_US.UTF-8" - local current_locale="$(cat /etc/locale.conf)" - test "$current_locale" = "$default_locale" \ - || die "bad locale '$current_locale', should be '$default_locale'" -} - -single_task() -{ - local task="$1" - - info "running task $task" - - ( - INDENT=" " - . "$SRCDIR/databases/pagila.sh" || die "pagila incl fail" - . "$SRCDIR/$task" || die "include fail" - - run_if_defined "hook_start" - - test "$CHECK_LOCALE" -eq 1 && locale_prereq - - debug "initializing database" - postgresql-setup initdb &>/dev/null || die "can not initdb" - - debug "starting server" - service postgresql start &>/dev/null || die "can't start postgresql" - - tmpdir=$(mktemp -d /tmp/dbt-XXXXXX) || die "can not create temp directory" - - debug "working in $tmpdir" - pushd "$tmpdir" >/dev/null || die "can switch to $tmpdir" - - run || die "fail" - - popd >/dev/null || die "can not switch back" - - debug "stopping server" - service postgresql stop &>/dev/null || die "can't stop postgresql" - - tarball="$OUTPUTDIR/$task_name.tar.gz" - tar -czf "$tarball" -C /var/lib/pgsql/ data - info "result tarball $tarball" - rm -rf "$tmpdir" - - - debug "data removal" - rm -rf "$GEN_DATADIR" - - run_if_defined "hook_end" - ) -} - -generate_tasks() -{ - find ./tasks -name run.sh | while read line; do - single_task "$line" - done -} - -main() -{ - test "$UID" -ne 0 && die "run under 'root' user" - - test -d "$OUTPUTDIR" || die "$OUTPUTDIR does not seem to be directory" - - service postgresql status &>/dev/null - test $? -ne 3 && die "stop the postgresql server" - - local dbdir="$GEN_DATADIR" - test -e "$dbdir" && die "the '$dbdir' should not exist" - - { rpm -qa postgresql && rpm -qa postgresql-server ; } &>/dev/null \ - || die "PostgreSQL not installed" - - generate_tasks -} - -main diff --git a/gen-data/prep b/gen-data/prep deleted file mode 100755 index b5b19b5..0000000 --- a/gen-data/prep +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -yum install -y wget postgresql-server unzip -echo "LANG=en_US.UTF-8" > /etc/locale.conf -rm -rf /var/lib/pgsql/data diff --git a/gen-data/remote_generate b/gen-data/remote_generate deleted file mode 100755 index a2ec172..0000000 --- a/gen-data/remote_generate +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -x - -where="root@$1" - -./dist/dist -tar tf dist/dist.tar.gz - -ssh_opts="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" -ssh="ssh $ssh_opts" -scp="scp $ssh_opts" - -$scp dist/dist.tar.gz "$where:/root" - -$ssh "$where" "cd /root ; tar -xf dist.tar.gz ; ./prep && ./generate" diff --git a/gen-data/tasks/basic/run.sh b/gen-data/tasks/basic/run.sh deleted file mode 100644 index 0118ad3..0000000 --- a/gen-data/tasks/basic/run.sh +++ /dev/null @@ -1,6 +0,0 @@ -export task_name="basic" - -run() -{ - create_pagila -} diff --git a/gen-data/tasks/locale-cz/run.sh b/gen-data/tasks/locale-cz/run.sh deleted file mode 100644 index 1788557..0000000 --- a/gen-data/tasks/locale-cz/run.sh +++ /dev/null @@ -1,5 +0,0 @@ -export task_name="locale-cz" - -export ___new_locale="LANG=cs_CZ.utf8" - -. ./tasks/templates/locale-change.sh diff --git a/gen-data/tasks/locale-utf-typo/run.sh b/gen-data/tasks/locale-utf-typo/run.sh deleted file mode 100644 index 9004a88..0000000 --- a/gen-data/tasks/locale-utf-typo/run.sh +++ /dev/null @@ -1,5 +0,0 @@ -export task_name="locale-utf-typo" - -export ___new_locale="LANG=en_US.utf8" - -. ./tasks/templates/locale-change.sh diff --git a/gen-data/tasks/templates/locale-change.sh b/gen-data/tasks/templates/locale-change.sh deleted file mode 100644 index 8f7964f..0000000 --- a/gen-data/tasks/templates/locale-change.sh +++ /dev/null @@ -1,16 +0,0 @@ -hook_start() -{ - export CHECK_LOCALE=0 - ___old_locale="$(cat /etc/locale.conf)" - echo "$___new_locale" > /etc/locale.conf -} - -hook_end() -{ - echo "$___old_locale" > /etc/locale.conf -} - -run() -{ - create_pagila -} |
