From 4bfd32bdc76ab5c6e9f59e22cf26e70eaaac0092 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Feb 22 2019 09:53:55 +0000 Subject: testsuite: new test-case --- diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/main.fmf b/main.fmf new file mode 100644 index 0000000..2ce471d --- /dev/null +++ b/main.fmf @@ -0,0 +1,6 @@ +contact: Pavel Raiskup +component: [postgresql] +test: ./runtest.sh +duration: 5m +tier: 1 +tags: [classic, container, atomic] diff --git a/tests.yml b/tests.yml new file mode 100644 index 0000000..c93c64e --- /dev/null +++ b/tests.yml @@ -0,0 +1,9 @@ +# This file is here because we want to run Fedora CI also for +# pull-requests in tests/ namespace (not only rpms/). + +- hosts: localhost + roles: + - role: standard-test-beakerlib + fmf_filter: "tier: 1" + tags: + - classic diff --git a/testsuite/Makefile b/testsuite/Makefile new file mode 100644 index 0000000..128395e --- /dev/null +++ b/testsuite/Makefile @@ -0,0 +1,68 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/postgresql/testsuite +# Description: PostgreSQL testsuite wrapper +# Author: Tom Lane +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010, 2019 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# 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, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/postgresql/testsuite +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Karel Volny " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: PostgreSQL testsuite wrapper" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 20m" >> $(METADATA) + @echo "RunFor: postgresql" >> $(METADATA) + @echo "Requires: postgresql" >> $(METADATA) + @echo "Requires: postgresql-server" >> $(METADATA) + @echo "Requires: *postgresql-test" >> $(METADATA) + # RHEL4 needs this to hack around selinux denial in testdir + @echo "Requires: selinux-policy-targeted-sources" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "RhtsRequires: library(postgresql/basic)" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/testsuite/PURPOSE b/testsuite/PURPOSE new file mode 100644 index 0000000..7222da7 --- /dev/null +++ b/testsuite/PURPOSE @@ -0,0 +1,6 @@ +PURPOSE of /CoreOS/postgresql/testsuite +Description: PostgreSQL testsuite wrapper +Author: Tom Lane +Owner: Karel Volny + +This is beakear wrapper around internal postgresql-tests testsuite. diff --git a/testsuite/main.fmf b/testsuite/main.fmf new file mode 100644 index 0000000..ed91cd0 --- /dev/null +++ b/testsuite/main.fmf @@ -0,0 +1,3 @@ +summary: execute testsuite from postgresql-test package +description: ssia +tier: 1 diff --git a/testsuite/runtest.sh b/testsuite/runtest.sh new file mode 100755 index 0000000..f33a73f --- /dev/null +++ b/testsuite/runtest.sh @@ -0,0 +1,96 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/postgresql/testsuite +# Description: PostgreSQL testsuite wrapper +# Author: Tom Lane +# Owner: Karel Volny +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010-2012 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# 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, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include rhts environment +. /usr/bin/rhts-environment.sh +. /usr/lib/beakerlib/beakerlib.sh + +# TODO: This is temporary workaround till we have no /Library directory +# in this git repository. +PACKAGE=postgresql +PGDATA=/var/lib/pgsql/data +PGUSER=postgres + +ORIG_AVC_ERROR=$AVC_ERROR + +rlJournalStart + rlPhaseStartSetup "General setup" + PG_VER=$(postgres -V | cut -d " " -f3 | cut -d "." -f1); + rlLogInfo "Using postgres version: $PG_VER"; + PACKAGES="postgresql postgresql-test postgresql-server" + for PACKAGE in $PACKAGES; do + rlAssertRpm $PACKAGE + done + # stop the system's service (if any) + rlServiceStop postgresql + rlPhaseEnd + + rlPhaseStartSetup + TestingDir="$(rpm -ql "postgresql-test" | grep -E '/regress$' | head -n 1)"; + rlRun "test -d $TestingDir" + rlLogInfo "postgresql-test directory: $TestingDir" + rlRun "pushd $TestingDir" + rlRun "rlFileBackup --clean $PGDATA" + # switch to non-root to have additional protection against mistakes + rlRun "su - $PGUSER -c 'rm -rf ${PGDATA-/var/lib/pgsql/data}'" + rlRun "postgresql-setup --initdb" + # start the testing server + rlServiceStart postgresql + rlPhaseEnd + + rlPhaseStartTest + rlLogDebug "Running test from: $TestingDir"; + + pg_command="cd $TestingDir && make installcheck-parallel" + rlRun "su - $PGUSER -c '$pg_command' &> testsuite.out" 0 \ + "Running the testsuite" + + echo ":::::::::::::::::::::::::::::: TESTSUITE OUTPUT ::::::::::::::::::::::::::::::"; + cat testsuite.out + rlRun "grep -E 'All [[:digit:]]+ tests passed.' testsuite.out" 0 "Checking if All tests passed." + + if [ -f regression.diffs ]; then + rlFail "The test must have failed - 'regression.diffs' found" + rlBundleLogs $PACKAGE regression.diffs + fi + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm -f regression.diffs testsuite.out" 0 "Cleaning up files" + rlRun "make clean" + # stop the testing server + rlServiceStop postgresql + # restore the system server, if any + rlFileRestore + rlServiceRestore postgresql + rlRun "popd" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd +AVC_ERROR=$ORIG_AVC_ERROR