From 8d57ebc5c7ebf40b6d59f2b6d345b39ec24caaf4 Mon Sep 17 00:00:00 2001 From: Boyang Xue Date: Wed, 27 Nov 2024 14:08:39 +0800 Subject: [PATCH] gating: import the fuse3 gating test and merge internal/public plans. Resolves: RHELMISC-7595 Signed-off-by: Boyang Xue --- ci.fmf | 2 - gating.yaml | 6 +- plans/public.fmf => plan.fmf | 2 +- plans/internal.fmf | 20 --- tests/fuse3-sanity-test/Makefile | 83 +++++---- tests/fuse3-sanity-test/PURPOSE | 6 +- tests/fuse3-sanity-test/config/3.10.2 | 2 + tests/fuse3-sanity-test/config/3.2.1 | 4 + tests/fuse3-sanity-test/config/3.3.0 | 2 + tests/fuse3-sanity-test/config/DEFAULT | 3 + tests/fuse3-sanity-test/main.fmf | 28 ++- tests/fuse3-sanity-test/runtest.sh | 233 +++++++++++++++++++++++-- 12 files changed, 303 insertions(+), 88 deletions(-) delete mode 100644 ci.fmf rename plans/public.fmf => plan.fmf (73%) delete mode 100644 plans/internal.fmf create mode 100644 tests/fuse3-sanity-test/config/3.10.2 create mode 100644 tests/fuse3-sanity-test/config/3.2.1 create mode 100644 tests/fuse3-sanity-test/config/3.3.0 create mode 100644 tests/fuse3-sanity-test/config/DEFAULT diff --git a/ci.fmf b/ci.fmf deleted file mode 100644 index da04079..0000000 --- a/ci.fmf +++ /dev/null @@ -1,2 +0,0 @@ -resultsdb-testcase: separate - diff --git a/gating.yaml b/gating.yaml index 43d7d46..dd6ed2b 100644 --- a/gating.yaml +++ b/gating.yaml @@ -1,7 +1,5 @@ --- !Policy -product_versions: - - rhel-9 + decision_context: osci_compose_gate rules: - - !PassingTestCaseRule {test_case_name: osci.brew-build./plans/internal.functional} - - !PassingTestCaseRule {test_case_name: osci.brew-build./plans/public.functional} + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} diff --git a/plans/public.fmf b/plan.fmf similarity index 73% rename from plans/public.fmf rename to plan.fmf index 962b12b..bbfcfe8 100644 --- a/plans/public.fmf +++ b/plan.fmf @@ -1,4 +1,4 @@ -summary: Public fuse3 gating test +summary: fuse3 gating test execute: how: tmt discover: diff --git a/plans/internal.fmf b/plans/internal.fmf deleted file mode 100644 index ccb0fff..0000000 --- a/plans/internal.fmf +++ /dev/null @@ -1,20 +0,0 @@ -summary: Private (RHEL) fuse3 gating test -enabled: false -adjust: - - when: distro == rhel - enabled: true - because: private tests are accesible only within rhel pipline -discover: - - name: rhel-fuse3 - how: fmf - url: https://gitlab.cee.redhat.com/kernel-qe/kernel.git - test: [ - "filesystems/fuse/gating/fuse3", - ] -environment: - FSTYP: ext4 - TEST_GROUP: fuse3 - AVC_ERROR: +no_avc_check -execute: - how: tmt - diff --git a/tests/fuse3-sanity-test/Makefile b/tests/fuse3-sanity-test/Makefile index 612ae4b..a3ab2b0 100644 --- a/tests/fuse3-sanity-test/Makefile +++ b/tests/fuse3-sanity-test/Makefile @@ -1,60 +1,79 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # -# Makefile of fuse3-sanity-test -# Description: fuse3-sanity-test -# Author: Boyang Xue +# Makefile of /kernel/filesystems/fuse/gating/fuse3 # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # -# Copyright (c) 2024 Red Hat, Inc. +# Copyright (c) 2022 Red Hat, Inc. All rights reserved. # -# 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 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. +# 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/. +# 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. # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Author and description of the test +AUTHOR=Zorro Lang +DESCRIPTION=The gating test case of fuse3 + +# The name of the test. export TEST=/kernel/filesystems/fuse/gating/fuse3 -export TESTVERSION=0.1 -FILES=$(METADATA) runtest.sh Makefile PURPOSE +# Version of the test. Used with make tag. +export TESTVERSION=1.0 -.PHONY: all install download clean +# data files, .c files, scripts anything needed to either compile the test and/or run it. +FILES=$(METADATA) runtest.sh PURPOSE config run: $(FILES) build ./runtest.sh -build: $(BUILT_FILES) - test -x runtest.sh || chmod a+x runtest.sh +build: $(BUILT_FILES) $(FILES) + chmod a+x ./runtest.sh clean: - rm -f *~ $(BUILT_FILES) + rm -f *~ +# Include Common Makefile include /usr/share/rhts/lib/rhts-make.include +# Generate the testinfo.desc here: $(METADATA): Makefile - @echo "Owner: Boyang Xue " > $(METADATA) - @echo "Name: $(TEST)" >> $(METADATA) - @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) - @echo "Path: $(TEST_DIR)" >> $(METADATA) - @echo "Description: fuse3-sanity-test" >> $(METADATA) - @echo "Type: Regression" >> $(METADATA) - @echo "TestTime: 15m" >> $(METADATA) - @echo "RunFor: fuse3" >> $(METADATA) - @echo "Requires: fuse3-libs" >> $(METADATA) - @echo "Requires: fuse3-devel" >> $(METADATA) - @echo "Priority: Normal" >> $(METADATA) - @echo "License: GPLv2+" >> $(METADATA) - @echo "Confidential: no" >> $(METADATA) - @echo "Destructive: no" >> $(METADATA) - + @echo "Owner: $(AUTHOR)" > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Description: $(DESCRIPTION)" >> $(METADATA) + @echo "TestTime: 2h" >> $(METADATA) + @echo "RunFor: fuse3" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "Requires: fuse3" >> $(METADATA) + @echo "Requires: fuse3-devel" >> $(METADATA) + @echo "Requires: fuse3-libs" >> $(METADATA) + @echo "Requires: rpm-build" >> $(METADATA) + @echo "Requires: gcc" >> $(METADATA) + @echo "Requires: gcc-c++" >> $(METADATA) + @echo "Requires: autoconf" >> $(METADATA) + @echo "Requires: automake" >> $(METADATA) + @echo "Requires: gettext-devel" >> $(METADATA) + @echo "Requires: libselinux-devel" >> $(METADATA) + @echo "Requires: libtool" >> $(METADATA) + @echo "Requires: meson" >> $(METADATA) + @echo "Requires: ninja-build" >> $(METADATA) + @echo "Requires: yum-utils" >> $(METADATA) + @echo "Requires: redhat-lsb-core" >> $(METADATA) + @echo "Requires: python3-pip" >> $(METADATA) rhts-lint $(METADATA) +# The include package trys to install all the potential dependencies. +# Not each them are available on all RHEL old/new systems. diff --git a/tests/fuse3-sanity-test/PURPOSE b/tests/fuse3-sanity-test/PURPOSE index a4c4033..08d796a 100644 --- a/tests/fuse3-sanity-test/PURPOSE +++ b/tests/fuse3-sanity-test/PURPOSE @@ -1,5 +1,3 @@ -PURPOSE of fuse3-sanity-test -Description: fuse3-sanity-test -Author: Boyang Xue +Description: -Note: +This's a simple gating test case for fuse-3.x. \ No newline at end of file diff --git a/tests/fuse3-sanity-test/config/3.10.2 b/tests/fuse3-sanity-test/config/3.10.2 new file mode 100644 index 0000000..26bb887 --- /dev/null +++ b/tests/fuse3-sanity-test/config/3.10.2 @@ -0,0 +1,2 @@ +# The cuse module isn't loaded by default, so don't run cuse related test at here. +not cuse diff --git a/tests/fuse3-sanity-test/config/3.2.1 b/tests/fuse3-sanity-test/config/3.2.1 new file mode 100644 index 0000000..4613690 --- /dev/null +++ b/tests/fuse3-sanity-test/config/3.2.1 @@ -0,0 +1,4 @@ +# The cuse module isn't loaded by default, so don't run cuse related test at here. +# passthrough_ll[True-True] always fails as "[Errno 38] Function not implemented" +# passthrough_ll[False-True] sometimes fails as "[Errno 38] Function not implemented" +not test_passthrough_ll[True-True] and not test_passthrough_ll[False-True] and not cuse diff --git a/tests/fuse3-sanity-test/config/3.3.0 b/tests/fuse3-sanity-test/config/3.3.0 new file mode 100644 index 0000000..26bb887 --- /dev/null +++ b/tests/fuse3-sanity-test/config/3.3.0 @@ -0,0 +1,2 @@ +# The cuse module isn't loaded by default, so don't run cuse related test at here. +not cuse diff --git a/tests/fuse3-sanity-test/config/DEFAULT b/tests/fuse3-sanity-test/config/DEFAULT new file mode 100644 index 0000000..3607d9b --- /dev/null +++ b/tests/fuse3-sanity-test/config/DEFAULT @@ -0,0 +1,3 @@ +# The cuse module isn't loaded by default, so don't run cuse related test at here. +# The passthrough test isn't stable, always fail. So skip it for gating test +not passthrough and not cuse diff --git a/tests/fuse3-sanity-test/main.fmf b/tests/fuse3-sanity-test/main.fmf index c9e1d60..f0b0d01 100644 --- a/tests/fuse3-sanity-test/main.fmf +++ b/tests/fuse3-sanity-test/main.fmf @@ -1,12 +1,26 @@ -summary: fuse3-sanity-test -description: | - Note: -contact: Boyang Xue +summary: The gating test case of fuse3 +description: This's a simple gating test case for fuse-3.x. +contact: Zorro Lang component: - fuse3 test: ./runtest.sh -framework: beakerlib +framework: shell recommend: - - fuse3-libs + - fuse3 - fuse3-devel -duration: 15m + - fuse3-libs + - rpm-build + - gcc + - gcc-c++ + - autoconf + - automake + - gettext-devel + - libselinux-devel + - libtool + - meson + - ninja-build + - yum-utils + - redhat-lsb-core + - python3-pip + - beakerlib +duration: 2h diff --git a/tests/fuse3-sanity-test/runtest.sh b/tests/fuse3-sanity-test/runtest.sh index df4ebef..dc36c8a 100755 --- a/tests/fuse3-sanity-test/runtest.sh +++ b/tests/fuse3-sanity-test/runtest.sh @@ -1,37 +1,234 @@ #!/bin/bash -# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # -# runtest.sh of fuse3-sanity-test -# Description: fuse3-sanity-test -# Author: Boyang Xue +# Description: Run for fuse-3.x CI gating test +# Author: Zorro Lang # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # -# Copyright (c) 2024 Red Hat, Inc. +# Copyright (c) 2022 Red Hat, Inc. All rights reserved. # -# 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 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. +# 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/. +# 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 Beaker environment . /usr/share/beakerlib/beakerlib.sh || exit 1 -set -o pipefail +status=1 +trap "cleanup;" 0 1 2 3 9 15 -rlJournalStart - rlPhaseStartTest Test - rlRun "fusermount3 --version" - rlPhaseEnd -rlJournalEnd +# Enable all repos by default, to try our best to get some packages +YUM_PROG="yum --enablerepo=*" +WORK_DIR=`pwd` + +# test exits here +cleanup() +{ + if [ $status -eq 0 ];then + _report "CLEAN" PASS + else + _report "CLEAN" FAIL + fi + exit $status +} + +if [ -z "$RECIPEID" -o -z "$TASKID" ]; then + OUTPUTFILE=`pwd`/output.log +fi + +function echoo() +{ + echo $@ | tee -a $OUTPUTFILE +} + +# Wrapper to log the output of the command +function xlog() +{ + echoo "$@" + $@ 2>&1 | tee -a $OUTPUTFILE + return $? +} + +# Wrapper to report_result, clears $OUTPUTFILE +function _report() +{ + local what="$FSTYP:$1" + local status="$2" + local score="$3" + test -z "$score" && score=0 + echoo "---------------------------------------------" + echoo -e "|Report:\t" "$what\t" "$status\t" "$score|" + echoo "---------------------------------------------" + rhts-report-result "$what" "$status" "$OUTPUTFILE" "$score" + if [ -f "$OUTPUTFILE" ];then + rm -f $OUTPUTFILE + touch $OUTPUTFILE + fi +} + +function prepare_test() +{ + local pkgname + local specfile + + echoo "* Get building and running dependences" + $YUM_PROG install -y --nogpgcheck fuse3 fuse3-libs fuse3-devel rpm-build gcc \ + autoconf automake gettext-devel libselinux-devel libtool yum-utils \ + python3 gcc-c++ python3-pip meson ninja-build + + echoo "* Get fuse3 srpm" + rm -rf downloaddir + mkdir downloaddir + pushd downloaddir + rlFetchSrcForInstalled fuse3 + if [ $? -ne 0 ];then + _report prepare_test:download FAIL + exit 1 + fi + + echoo "* Install fuse3 srpm" + pkgname=$(ls *.src.rpm 2>/dev/null | head -1) + echoo "Install $pkgname ..." + rpm -ivh $pkgname + specfile=`rpm -ql $pkgname 2>/dev/null | grep .spec` + specfile="$(ls ~/rpmbuild/SPECS/$specfile 2>/dev/null)" + popd + if [ ! -f "$specfile" ];then + _report prepare_test:specfile FAIL + exit 1 + fi + + echoo "* Unpack and patch fuse3 source" + + FUSE3_BUILD_DIR=`rpmbuild --eval %{_builddir}` + # Remove all old build directory, to avoid they affect later testing. + rm -rf $FUSE3_BUILD_DIR/*fuse* + rpmbuild -bp $specfile + if [ $? -eq 0 ];then + FUSE3_BUILD_DIR=`realpath $FUSE3_BUILD_DIR/* | head -n 1` + else + # unset FUSE3_BUILD_DIR to stop later testing, if rpmbuild fails + unset FUSE3_BUILD_DIR + fi + echoo "FUSE3_BUILD_DIR = $FUSE3_BUILD_DIR" + if [ ! -d "$FUSE3_BUILD_DIR" ];then + _report prepare_test:fuse3_unpack FAIL + exit 1 + fi + + echoo "* Build fuse3 source locally" + pushd $FUSE3_BUILD_DIR + rm -rf build + mkdir build + pushd build + meson .. && ninja + if [ $? -ne 0 ];then + echoo "build fuse3 failed!" + _report prepare_test:fuse3_build FAIL + exit 1 + fi + popd + popd + + echoo "* Get pytest and looseversion" + which pip3 && which python3 + if [ $? -ne 0 ];then + echoo "missing pip3 or python3" + _report prepare_test:python FAIL + exit 1 + fi + if ! pip3 install pytest;then + echoo "install pytest failed!" + _report prepare_test:pytest FAIL + exit 1 + fi + + if ! pip3 install looseversion;then + echoo "install looseversion failed!" + _report prepare_test:looseversion FAIL + exit 1 + fi + + + _report prepare_test PASS +} + +function do_test() +{ + local rc=0 + local ver="DEFAULT" + local expression + local logfile="$WORK_DIR/pytest.log" + local nfail=0 + local npass=0 + + pushd $FUSE3_BUILD_DIR/build + if [ -f ./util/fusermount3 ];then + chown root:root util/fusermount3 + chmod 4755 util/fusermount3 + ver=`./util/fusermount3 -V|awk '{print $3}'` + fi + if [ ! -f "$WORK_DIR/config/$ver" ];then + ver="DEFAULT" + fi + expression=`cat $WORK_DIR/config/$ver|grep -v ^#` + + # remove -x option of pytest, avoid the test exits instantly on first + # error + sed -i /addopts/s/-x// test/pytest.ini + + if [ -n "$expression" ];then + echoo "python3 -m pytest -k \"$expression\" test" + python3 -m pytest -k "$expression" test 2>&1 | tee $logfile + else + echoo "python3 -m pytest test" + python3 -m pytest test 2>&1 | tee $logfile + fi + rc=$? + popd + + tail -1 $logfile + if [ $rc -eq 0 ];then + if ( tail -1 $logfile | grep -q failed);then + nfail=`tail -1 $logfile | sed -n 's/.* \([0-9]\+\) failed.*/\1/p'` + fi + if ( tail -1 $logfile | grep -q passed);then + npass=`tail -1 $logfile | sed -n 's/.* \([0-9]\+\) passed.*/\1/p'` + fi + else + echoo "pytest failed, please check the log file" + _report do_test:pytest FAIL + exit 1 + fi + + if [ "$nfail" != "0" ];then + _report do_test:$npass:$nfail FAIL + exit 1 + elif [ "$npass" == "0" ];then + echoo "If there's not PASSED test, must be something wrong" + _report do_test:nopass FAIL + exit 1 + else + _report do_test:$npass:$nfail PASS + fi + return 0 +} + +prepare_test +do_test +status=0 +exit 0