From 77fd9d3bf63b30d1d3cbfd35960dde3e21035672 Mon Sep 17 00:00:00 2001 From: Jan Kurik Date: Jan 14 2021 08:28:26 +0000 Subject: [PATCH 1/2] Initial implementation of a gating test for Fedora --- 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/gating.yaml b/gating.yaml new file mode 100644 index 0000000..ce3cdc1 --- /dev/null +++ b/gating.yaml @@ -0,0 +1,19 @@ +--- !Policy +product_versions: + - fedora-* +decision_context: bodhi_update_push_stable +subject_type: koji_build +rules: + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional} +--- !Policy +product_versions: + - rhel-8 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional} +--- !Policy +product_versions: + - rhel-9 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional} diff --git a/plans/ci.fmf b/plans/ci.fmf new file mode 100644 index 0000000..1ad2c12 --- /dev/null +++ b/plans/ci.fmf @@ -0,0 +1,6 @@ +summary: CI Gating Plan +discover: + how: fmf + directory: tests +execute: + how: beakerlib diff --git a/tests/README b/tests/README new file mode 100644 index 0000000..9ad59d4 --- /dev/null +++ b/tests/README @@ -0,0 +1,2 @@ +The test's Makefiles are not used in Fedora CI infrastructure. But are kept here +for backward compatibility with traditional beakerlib test harness in RHEL. diff --git a/tests/Sanity/sanity-test/Makefile b/tests/Sanity/sanity-test/Makefile new file mode 100644 index 0000000..fabeb54 --- /dev/null +++ b/tests/Sanity/sanity-test/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/HdrHistogram_c/Sanity/sanity-test +# Description: Installs and builds HdrHistogram_c, then runs minimal upstream testsuite. +# Author: Jan Kuřík +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2020 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/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/tools/HdrHistogram_c/Sanity/sanity-test +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) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Jan Kuřík " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Installs and builds HdrHistogram_c, then runs minimal upstream testsuite." >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: HdrHistogram_c" >> $(METADATA) + @echo "Requires: HdrHistogram_c make cmake" >> $(METADATA) + @echo "Requires: gcc gcc-c++ rpm-build" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 1748643" >> $(METADATA) + @echo "Releases: -RHEL4 -RHEL6 -RHEL7 -RHELClient5 -RHELServer5 -RHEL-ALT-7" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Sanity/sanity-test/PURPOSE b/tests/Sanity/sanity-test/PURPOSE new file mode 100644 index 0000000..9fab7a3 --- /dev/null +++ b/tests/Sanity/sanity-test/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/HdrHistogram_c/Sanity/sanity-test +Description: Installs and builds HdrHistogram_c, then runs minimal upstream testsuite. +Author: Jan Kuřík diff --git a/tests/Sanity/sanity-test/main.fmf b/tests/Sanity/sanity-test/main.fmf new file mode 100644 index 0000000..3dfbcf7 --- /dev/null +++ b/tests/Sanity/sanity-test/main.fmf @@ -0,0 +1,18 @@ +summary: Installs and builds HdrHistogram_c, then runs minimal upstream testsuite. +description: '' +contact: +- Jan Kuřík +component: +- HdrHistogram_c +test: ./runtest.sh +framework: beakerlib +recommend: +- HdrHistogram_c +- make +- cmake +- gcc +- gcc-c++ +- rpm-build +duration: 15m +extra-summary: /tools/HdrHistogram_c/Sanity/sanity-test +extra-task: /tools/HdrHistogram_c/Sanity/sanity-test diff --git a/tests/Sanity/sanity-test/runtest.sh b/tests/Sanity/sanity-test/runtest.sh new file mode 100755 index 0000000..0b2daa6 --- /dev/null +++ b/tests/Sanity/sanity-test/runtest.sh @@ -0,0 +1,91 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/HdrHistogram_c/Sanity/sanity-test +# Description: Installs and builds HdrHistogram_c, then runs minimal upstream testsuite. +# Author: Jan Kuřík +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2020 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="HdrHistogram_c" +BUILD_USER=${BUILD_USER:-hdrbuild} + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest "Get source code and setup build environment" + rlFetchSrcForInstalled "${PACKAGE}" \ + || rlDie "Can not download SRPM of ${PACKAGE} - giving up" + rlRun "yum-builddep -y \ + $(rpm -q --qf '%{name}-%{version}-%{release}.src.rpm' ${PACKAGE}.$(arch))" \ + || rlDie "Can not install build dependencies - giving up" + rlRun "useradd -m -N $BUILD_USER" 0,9 && del="yes" + rlPhaseEnd + + rlPhaseStartTest "Build ${PACKAGE}'s upstream testsuite" + rlRun "rpm -D \"_topdir ${TmpDir}\" -U \ + $(rpm -q --qf '%{name}-%{version}-%{release}.src.rpm' ${PACKAGE}.$(arch))" + rlRun "chown -R ${BUILD_USER}:users ${TmpDir}" + rlRun -s "su -c \ + 'rpmbuild -D \"_topdir ${TmpDir}\" -bc ${TmpDir}/SPECS/${PACKAGE}.spec' \ + ${BUILD_USER}" 0-255 + rlFileSubmit "${rlRun_LOG}" "rpmbuild-${PACKAGE}.log" + rlPhaseEnd + +echo XXXXXXXXXXXXXXXX; read x + + rlPhaseStartTest "Run upstream testsuite" + BDIR=$(rpm -q --qf '%{name}-%{version}' ${PACKAGE}.$(arch)) + ARCHDIR="$(arch)-redhat-linux-gnu" + if [[ -d "${TmpDir}/BUILD/${BDIR}/${ARCHDIR}" ]]; then + # RHEL-9 builds + WD="${TmpDir}/BUILD/${BDIR}/${ARCHDIR}/test" + else + # RHEL-8 builds + WD="${TmpDir}/BUILD/${BDIR}/test" + fi + HDRLIB="$(ls -1 /usr/lib64/libhdr_histogram.so.[0-9]|head -1)" + if rlRun "pushd ${WD}"; then + rlRun "sed -i \ + 's#\s\S*libhdr_histogram\S*\.a# ${HDRLIB}#g' \ + \$(find . -name link.txt)" + rlRun -s "make clean all test" + rlAssertGrep "100% tests passed" "${rlRun_LOG}" + rlRun "popd" + else + rlFail "Error accessing ${WD} directory" + fi + rlPhaseEnd + + rlPhaseStartCleanup + [[ "${del}" == "yes" ]] && rlRun "userdel -r ${BUILD_USER}" + rlRun "popd" + rlRun "rm -r ${TmpDir}" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd From 9911fd36f86fefac950461dd5dd1331cff9b116e Mon Sep 17 00:00:00 2001 From: Jan Kurik Date: Jan 14 2021 10:39:00 +0000 Subject: [PATCH 2/2] Fixed a leftover stopping the test after the build phase. --- diff --git a/tests/Sanity/sanity-test/runtest.sh b/tests/Sanity/sanity-test/runtest.sh index 0b2daa6..4ec24a3 100755 --- a/tests/Sanity/sanity-test/runtest.sh +++ b/tests/Sanity/sanity-test/runtest.sh @@ -57,8 +57,6 @@ rlJournalStart rlFileSubmit "${rlRun_LOG}" "rpmbuild-${PACKAGE}.log" rlPhaseEnd -echo XXXXXXXXXXXXXXXX; read x - rlPhaseStartTest "Run upstream testsuite" BDIR=$(rpm -q --qf '%{name}-%{version}' ${PACKAGE}.$(arch)) ARCHDIR="$(arch)-redhat-linux-gnu"