testsuite: new test-case

This commit is contained in:
Pavel Raiskup 2019-02-22 08:39:31 +01:00
commit 4bfd32bdc7
7 changed files with 189 additions and 0 deletions

1
.fmf/version Normal file
View file

@ -0,0 +1 @@
1

6
main.fmf Normal file
View file

@ -0,0 +1,6 @@
contact: Pavel Raiskup <praiskup@redhat.com>
component: [postgresql]
test: ./runtest.sh
duration: 5m
tier: 1
tags: [classic, container, atomic]

9
tests.yml Normal file
View file

@ -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

68
testsuite/Makefile Normal file
View file

@ -0,0 +1,68 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/postgresql/testsuite
# Description: PostgreSQL testsuite wrapper
# Author: Tom Lane <tgl@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <kvolny@redhat.com>" > $(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)

6
testsuite/PURPOSE Normal file
View file

@ -0,0 +1,6 @@
PURPOSE of /CoreOS/postgresql/testsuite
Description: PostgreSQL testsuite wrapper
Author: Tom Lane <tgl@redhat.com>
Owner: Karel Volny <kvolny@redhat.com>
This is beakear wrapper around internal postgresql-tests testsuite.

3
testsuite/main.fmf Normal file
View file

@ -0,0 +1,3 @@
summary: execute testsuite from postgresql-test package
description: ssia
tier: 1

96
testsuite/runtest.sh Executable file
View file

@ -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 <tgl@redhat.com>
# Owner: Karel Volny <kvolny@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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