From abb8f62a3b3d2718a42eb12fae4de8b13e697178 Mon Sep 17 00:00:00 2001 From: Jan Kurik Date: Tue, 8 Aug 2023 20:05:29 +0200 Subject: [PATCH] Reworked gating tests --- ci.fmf | 1 + gating.yaml | 14 +----- plans/{ci.fmf => gating.fmf} | 0 tests/Sanity/licence-check/epel.repo | 30 +++++++++++++ tests/Sanity/licence-check/main.fmf | 17 ++++++++ tests/Sanity/licence-check/test.sh | 62 ++++++++++++++++++++++++++ tests/Sanity/sanity-test/Makefile | 65 ---------------------------- tests/Sanity/sanity-test/PURPOSE | 3 -- tests/Sanity/sanity-test/main.fmf | 20 +++------ tests/main.fmf | 3 ++ 10 files changed, 121 insertions(+), 94 deletions(-) create mode 100644 ci.fmf rename plans/{ci.fmf => gating.fmf} (100%) create mode 100644 tests/Sanity/licence-check/epel.repo create mode 100644 tests/Sanity/licence-check/main.fmf create mode 100755 tests/Sanity/licence-check/test.sh delete mode 100644 tests/Sanity/sanity-test/Makefile delete mode 100644 tests/Sanity/sanity-test/PURPOSE create mode 100644 tests/main.fmf diff --git a/ci.fmf b/ci.fmf new file mode 100644 index 0000000..c5aa0e0 --- /dev/null +++ b/ci.fmf @@ -0,0 +1 @@ +resultsdb-testcase: separate diff --git a/gating.yaml b/gating.yaml index ce3cdc1..116ac6c 100644 --- a/gating.yaml +++ b/gating.yaml @@ -4,16 +4,4 @@ product_versions: 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} + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build./plans/gating.functional} diff --git a/plans/ci.fmf b/plans/gating.fmf similarity index 100% rename from plans/ci.fmf rename to plans/gating.fmf diff --git a/tests/Sanity/licence-check/epel.repo b/tests/Sanity/licence-check/epel.repo new file mode 100644 index 0000000..d52a962 --- /dev/null +++ b/tests/Sanity/licence-check/epel.repo @@ -0,0 +1,30 @@ +[epel] +name=Extra Packages for Enterprise Linux $releasever - $basearch +# It is much more secure to use the metalink, but if you wish to use a local mirror +# place its address here. +#baseurl=https://download.example/pub/epel/$releasever/Everything/$basearch/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir +enabled = 0 +gpgcheck=1 +countme=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever + +[epel-debuginfo] +name=Extra Packages for Enterprise Linux $releasever - $basearch - Debug +# It is much more secure to use the metalink, but if you wish to use a local mirror +# place its address here. +#baseurl=https://download.example/pub/epel/$releasever/Everything/$basearch/debug/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-$releasever&arch=$basearch&infra=$infra&content=$contentdir +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever +gpgcheck=1 + +[epel-source] +name=Extra Packages for Enterprise Linux $releasever - $basearch - Source +# It is much more secure to use the metalink, but if you wish to use a local mirror +# place its address here. +#baseurl=https://download.example/pub/epel/$releasever/Everything/source/tree/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-$releasever&arch=$basearch&infra=$infra&content=$contentdir +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever +gpgcheck=1 diff --git a/tests/Sanity/licence-check/main.fmf b/tests/Sanity/licence-check/main.fmf new file mode 100644 index 0000000..3844065 --- /dev/null +++ b/tests/Sanity/licence-check/main.fmf @@ -0,0 +1,17 @@ +summary: Check for used licenses in packages +test: ./test.sh +link: + - relates: https://fedoraproject.org/wiki/Changes/SPDX_Licenses_Phase_1 + - relates: https://fedoraproject.org/wiki/Changes/SPDX_Licenses_Phase_2 +recommend: + - HdrHistogram_c + - rpm-build + - license-validate +duration: 15m +tag: + - gating +enabled: true +adjust: + - enabled: false + continue: false + when: distro < rhel-10 diff --git a/tests/Sanity/licence-check/test.sh b/tests/Sanity/licence-check/test.sh new file mode 100755 index 0000000..debe5b5 --- /dev/null +++ b/tests/Sanity/licence-check/test.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE=HdrHistogram_c +TCWD="$(pwd)" + +rlJournalStart + rlPhaseStartSetup + rlRun "tmp=\$(mktemp -d /var/tmp/XXXXXXXXXXXXX)" 0 "Create tmp directory" + rlRun "pushd $tmp" + rlRun "set -o pipefail" + + # Ensure we have license tools available + EPELREPO= + if ! which license-fedora2spdx &>/dev/null; then + YUMPARAM= + if rlIsRHEL || rlIsCentOS; then + EPELREPO="/etc/yum.repos.d/$(basename ${tmp})" + rlRun "cp ${TCWD}/epel.repo ${EPELREPO}" + YUMPARAM="--enablerepo=epel" + else + rlDie "Can not find license-validate tool" + fi + rlRun "yum install -y ${YUMPARAM} license-validate" \ + || rlDie "Failed to install license-validate tool" + fi + + # Get list of rpms + rlFetchSrcForInstalled --quiet "${PACKAGE}" || \ + rlDie 'Can not get source package of ${PACKAGE} .... giving up...' + SOURCEPKG=$(rpm -q --qf '%{name}-%{version}-%{release}.src.rpm' ${PACKAGE}) + rlAssertExists "${tmp}/${SOURCEPKG}" + rlRun "rpm -D '_topdir ${tmp}' -i ${tmp}/${SOURCEPKG}" + rlRun "LICENSES=\"\$(rpm -q --qf '%{license}\n' --specfile ${tmp}/SPECS/${PACKAGE}.spec\ + | sed -e 's/ and /\\n/g' -e 's/^ *//' -e 's/ *$//')\"" + rlRun "TUPLE=\"\$(rpm -q --qf '%{name} %{license}\n' \ + --specfile ${tmp}/SPECS/${PACKAGE}.spec )\"" + rlPhaseEnd + +while read l; do + rlPhaseStart FAIL "License check of ${l}" + retcode= + rlRun -s "license-validate '${l}'" || retcode=Fail + # Report affected packages + if [[ -n "${retcode}" ]]; then + rlLogInfo "The following packages needs to fix the ${l} license:" + #for p in $(awk "\$0~/${l}/{print \$1;}" <<< "${TUPLE}"); do + for p in $(grep "${l}" <<< "${TUPLE}" | cut -d ' ' -f 1); do + rlLogInfo " - ${p}" + done + fi + rlPhaseEnd +done < <(sort -u <<< "${LICENSES}") + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $tmp" 0 "Remove tmp directory" + rlRun "yum clean metadata" + [[ -n "${EPELREPO}" ]] && rlRun "rm -f ${EPELREPO}" + rlPhaseEnd +rlJournalEnd diff --git a/tests/Sanity/sanity-test/Makefile b/tests/Sanity/sanity-test/Makefile deleted file mode 100644 index fabeb54..0000000 --- a/tests/Sanity/sanity-test/Makefile +++ /dev/null @@ -1,65 +0,0 @@ -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# 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 deleted file mode 100644 index 9fab7a3..0000000 --- a/tests/Sanity/sanity-test/PURPOSE +++ /dev/null @@ -1,3 +0,0 @@ -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 index 3dfbcf7..893cef6 100644 --- a/tests/Sanity/sanity-test/main.fmf +++ b/tests/Sanity/sanity-test/main.fmf @@ -1,18 +1,12 @@ -summary: Installs and builds HdrHistogram_c, then runs minimal upstream testsuite. -description: '' -contact: -- Jan Kuřík -component: -- HdrHistogram_c +summary: Install, build and run upstream test test: ./runtest.sh -framework: beakerlib recommend: -- HdrHistogram_c -- make -- cmake -- gcc -- gcc-c++ -- rpm-build + - 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/main.fmf b/tests/main.fmf new file mode 100644 index 0000000..f192133 --- /dev/null +++ b/tests/main.fmf @@ -0,0 +1,3 @@ +contact: Jan Kuřík +component: HdrHistogram_c +framework: beakerlib