From a894405f31daade63b2a3bfa217fb60ad690c2ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Posp=C3=AD=C5=A1il?= Date: Wed, 27 Aug 2025 23:43:01 +0200 Subject: [PATCH] backport new gating from Fedora This mirrors: https://src.fedoraproject.org/rpms/pcs/c/dd5c28916c180b3435e82277fb59350bc109cc35 Changes to builddir structure in RPM 4.20 broke the old script for patching sources. Luckily, we can now patch sources with tmt. Gone is also list of packages needed for testing, build dependencies will be installed by tmt instead. Name of the gating plan was changed to remove confusion with gating.yaml. The prepare script was also renamed to better reflect what it does. The prepare script should be run in prepare, but TMT_SOURCE_DIR doesn't exist in that step yet. The workaround is to run the prepre script before every test to allow for running all tests by itself. However, the script can only run once because it removes pcs folder which breaks autotools. This is done by creating a stamp file that prevents the script from running if it already ran. --- gating.fmf | 49 ------------------------------------------------ plan-gating.fmf | 32 +++++++++++++++++++++++++++++++ prepare-env.sh | 18 ------------------ prepare-tests.sh | 22 ++++++++++++++++++++++ 4 files changed, 54 insertions(+), 67 deletions(-) delete mode 100644 gating.fmf create mode 100644 plan-gating.fmf delete mode 100755 prepare-env.sh create mode 100755 prepare-tests.sh diff --git a/gating.fmf b/gating.fmf deleted file mode 100644 index e948fef..0000000 --- a/gating.fmf +++ /dev/null @@ -1,49 +0,0 @@ -summary: PCS gating test plan -description: Runs upstream tier0, tier1 and smoke tests - -discover: - how: shell - dist-git-source: true - tests: - # Workaround until tmt supports patching sources - - name: Patch sources and run autotools - test: ./prepare-env.sh - duration: 30m - - name: Tier 0 tests - test: ./builddir/pcs-*/pcs_test/suite --tier0 -v --vanilla --installed - duration: 10m - - name: Tier 1 tests - test: ./builddir/pcs-*/pcs_test/suite --tier1 -v --vanilla --installed - duration: 2h - - name: Smoke tests - test: | - systemctl start pcsd - ./builddir/pcs-*/pcs_test/smoke.sh - duration: 10m -prepare: - - name: Install packages - how: install - package: - - autoconf - - automake - - make - - diffstat - - rpm-build - - ruby-devel - - git-core - - booth-site - - fence-agents-apc - - fence-agents-ipmilan - - fence-agents-scsi - - fence-virt - - openssl - - pcs - - pcs-snmp - - python3-pip - - python3-setuptools_scm - - python3-wheel - - rubygem-json - - rubygem-test-unit - - wget -execute: - how: tmt diff --git a/plan-gating.fmf b/plan-gating.fmf new file mode 100644 index 0000000..78d1116 --- /dev/null +++ b/plan-gating.fmf @@ -0,0 +1,32 @@ +summary: PCS gating test plan +description: Runs upstream tier0, tier1 and smoke tests + +discover: + dist-git-source: true + dist-git-install-builddeps: true + how: shell + tests: + - name: tier0 + test: | + ./prepare-tests.sh + $TMT_SOURCE_DIR/pcs-*/pcs_test/suite --tier0 -v --vanilla --installed + duration: 10m + tier: 0 + tag: fast + - name: tier1 + test: | + ./prepare-tests.sh + $TMT_SOURCE_DIR/pcs-*/pcs_test/suite --tier1 -v --vanilla --installed + duration: 2h + tier: 1 + - name: smoke + test: | + systemctl start pcsd + ./prepare-tests.sh + $TMT_SOURCE_DIR/pcs-*/pcs_test/smoke.sh + duration: 10m + tier: smoke + tag: fast + +execute: + how: tmt diff --git a/prepare-env.sh b/prepare-env.sh deleted file mode 100755 index d164525..0000000 --- a/prepare-env.sh +++ /dev/null @@ -1,18 +0,0 @@ -set -eo xtrace -# Rpmbuild expects patches in the _sourcedir -find *.patch &> /dev/null && mv *.patch $TMT_SOURCE_DIR -mkdir builddir -rpmbuild -bp pcs.spec --nodeps --define "_sourcedir $TMT_SOURCE_DIR" \ - --define "_builddir $(pwd)/builddir" -# Remove *SPECPARTS folders generated by rpmbuild -rm -rfv builddir/*SPECPARTS -# Remove pcs-web-ui in builddir for "cd pcs-*" to have exactly one match -rm -rf builddir/pcs-web-ui-* -cd builddir/pcs-* -# Run autotools, use bundled dependencies from the system -export PYTHONPATH=/usr/lib64/pcs/pcs_bundled/packages/ -export GEM_HOME=/usr/lib64/pcsd/vendor/bundle/ -./autogen.sh -./configure -# Remove pcs sources to make sure tests are not using any of those files -rm -rf pcs diff --git a/prepare-tests.sh b/prepare-tests.sh new file mode 100755 index 0000000..bdf43e2 --- /dev/null +++ b/prepare-tests.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +set -eo xtrace +cd $TMT_SOURCE_DIR +# Use stamp file to abort if this script already ran +if [ -e tests-prepared-stamp ]; then exit 0; fi +# RPM 4.20 changed the builddir structure - unpacked sources go to *-build but +# tmt copies them back to pcs-*, so the pcs-*-build folder is empty +# Remove pcs-web-ui, pcs-*-build for "cd pcs-*" to have exactly one match +rm -rf pcs-web-ui-* pcs-*-build +cd pcs-*/ +# Run autotools, use bundled dependencies from the system +export PYTHONPATH=/usr/lib/pcs/pcs_bundled/packages/ +export GEM_HOME=/usr/lib/pcsd/vendor/bundle/ +# We need to use cd pcs-* because when pcs-web-ui starts using autotools, running +# autogen and configure with expanded TMT_SOURCE_DIR will match that too +./autogen.sh +./configure --enable-local-build --enable-use-local-cache-only \ + --enable-individual-bundling --enable-webui --with-pcs-lib-dir=/usr/lib +# Remove pcs sources to make sure tests are not using any of those files +rm -rf pcs +touch ../tests-prepared-stamp