postgresql/Sanity/libecpg/runtest.sh
Ondřej Sloup f5317bdf87 Fix permission issue with tmp folder
Due to permission issues with creating a temporary folder, the two custom tests from PostgreSQL documentation failed as they could not write their results to the temp log file. The issue was resolved by changing the owner of the temporary folder while creating it.
While looking for the issue, the varDump command was commented out as it was not needed and not even found. Also, two tests taken from the documentation were edited; therefore, the slight changes which were made to them to work in our scenario can be highlighted.
2022-08-11 12:20:48 +02:00

90 lines
3.4 KiB
Bash
Executable file

#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/postgresql/Sanity/libecpg
# Description: Sanity test for libecpg library
# Author: Honza Horak <hhorak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2015 Red Hat, Inc.
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="postgresql"
PACKAGE_LIBECPG_DEVEL="libecpg-devel"
rlJournalStart
rlPhaseStart FAIL "Setup"
rlRun "rlImport database/postgresql"
PGDATA="$(postgresqlDataDir)";
PACKAGES="$PACKAGES ${postgresqlPackagePrefix}${PACKAGE_LIBECPG_DEVEL} \
${postgresqlPackagePrefix}${PACKAGE} \
${postgresqlPackagePrefix}${PACKAGE}-server";
for PACKAGE in $PACKAGES; do
rlAssertRpm $PACKAGE
done
rlRun "TestDir=$PWD"
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "chown postgres:postgres $TmpDir"
rlRun "pushd $TmpDir"
rlPhaseEnd
rlPhaseStartSetup "Database setup"
# varDump postgresqlDataDir;
[[ -d $postgresqlDataDir ]] && rlFileBackup $postgresqlDataDir;
postgresqlCleanup;
postgresqlInitDB;
rlRun "postgresqlChangeAuth trust" 0 "Allow 'trust' authentication"
#rlRun "sed -i -e 's/ident/trust/' ${postgresqlDataDir}/pg_hba.conf" 0 "Allow 'trust' authentication"
cat /var/lib/pgsql/data/pg_hba.conf
postgresqlStart;
rlPhaseEnd
rlPhaseStartTest
postgresqlExec "createdb testdb" "postgres"
rlRun "cp $TestDir/testecpg-decimal.pgc ."
rlRun "ecpg testecpg-decimal.pgc"
rlRun "cc -o testecpg-decimal testecpg-decimal.c -lecpg -lpgtypes"
rlRun "chown postgres:postgres *"
rlRun -s "./testecpg-decimal"
rlAssertGrep "numeric = 12" $rlRun_LOG
rlAssertGrep "numeric = 12.4" $rlRun_LOG
rlAssertGrep "numeric = 12.35" $rlRun_LOG
rlAssertGrep "decimal = 23" $rlRun_LOG
rlAssertGrep "decimal = 23.5" $rlRun_LOG
rlAssertGrep "decimal = 23.46" $rlRun_LOG
rlRun "cp $TestDir/testecpg-interval.pgc ."
rlRun "ecpg testecpg-interval.pgc"
rlRun "cc -o testecpg-interval testecpg-interval.c -lecpg -lpgtypes"
rlRun -s "./testecpg-interval"
rlAssertGrep "interval = @ 1 min" $rlRun_LOG
rlPhaseEnd
rlPhaseStart WARN "Cleanup";
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rm -f $rlRun_LOG;
rlRun "postgresqlCleanup";
rlFileRestore;
rlPhaseEnd
rlJournalPrintText
rlJournalEnd