From 70910323d008736eac598db5210de5fbb2b02cb0 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Fri, 17 Oct 2014 10:15:43 +0200 Subject: gen-data: add infrastructure for data generation Add also first task 'basic' which generates simple 'pagila' database. * generate: New file. * databases/pagila.sh: New database file. * tasks/basic/run.sh: New task file. --- gen-data/databases/pagila.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 gen-data/databases/pagila.sh (limited to 'gen-data/databases') diff --git a/gen-data/databases/pagila.sh b/gen-data/databases/pagila.sh new file mode 100644 index 0000000..a01d818 --- /dev/null +++ b/gen-data/databases/pagila.sh @@ -0,0 +1,39 @@ +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" +) -- cgit