Use osci and tmt for gating

This commit is contained in:
Lukáš Zachar 2026-08-14 11:38:14 +02:00
parent 39ae929aff
commit 436b191467
8 changed files with 186 additions and 1 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

View File

@ -3,4 +3,4 @@ product_versions:
- rhel-8 - rhel-8
decision_context: osci_compose_gate decision_context: osci_compose_gate
rules: rules:
- !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional} - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

7
plan.fmf Normal file
View File

@ -0,0 +1,7 @@
environment:
PYTHON: /usr/libexec/platform-python
execute:
how: tmt
discover:
how: fmf

6
tests/smoke/main.fmf Normal file
View File

@ -0,0 +1,6 @@
summary: Basic sanity test for python-requests
test: ./runtest.sh
framework: beakerlib
require:
- python3-requests
duration: 5m

61
tests/smoke/runtest.sh Executable file
View File

@ -0,0 +1,61 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/python-requests/Sanity/smoke
# Description: Basic sanity test for python-requests module.
# Author: Adam Kolar <akolar@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2013 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 Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGES=${PACKAGES:-"python3-requests"}
PYTHON=${PYTHON:-"python3"}
TEST="test.py"
PORT=8901
cleanup(){
if [[ -n $SERVER_PID ]]; then
kill -9 $SERVER_PID
fi
}
trap cleanup EXIT
rlJournalStart
rlPhaseStartSetup
rlAssertRpm --all
rlWaitForSocket $PORT --close -t 5 || rlDie "Port $PORT not available"
# start server
$PYTHON -m http.server $PORT &
export SERVER_PID="$!"
rlWaitForSocket $PORT -t 5 || rlDie "Couldn't start the server"
rlPhaseEnd
rlPhaseStartTest
rlRun "$PYTHON $TEST $PORT" 0 "Running sanity test for python requests"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

12
tests/smoke/test.py Normal file
View File

@ -0,0 +1,12 @@
import requests
import sys
from requests import *
class ExceptionRequests(Exception):
pass
if __name__=="__main__":
port = sys.argv[1]
r=requests.get('http://localhost:'+port)
if r.status_code!=200 or not r.text:
raise ExceptionRequests("Sanity error")

13
tests/upstream/main.fmf Normal file
View File

@ -0,0 +1,13 @@
summary: Runs upstream test suite
require:
- python3-requests
- python3-pip
- python3-pytest
- python3-cryptography
- platform-python-devel
- rpm-build
- gcc
- gcc-c++
test: ./runtest.sh
framework: beakerlib
duration: 30m

85
tests/upstream/runtest.sh Executable file
View File

@ -0,0 +1,85 @@
#!/bin/bash
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/python-requests/Sanity/upstream
# Description: Runs upstream test suite
# Author: Lukas Zachar <lzachar@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2019 Red Hat, Inc.
#
# 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 Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGES="${PACKAGES:-python3-requests}"
PYTHON="${PYTHON:-python3}"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm --all
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
# So we can inject version of srpm
if [[ -z "$FORCE_SRPM" ]]; then
rlRun "rlFetchSrcForInstalled $(rpm --qf '%{name}' -qf $($PYTHON -c 'import requests;print(requests.__file__)'))"
else
rlRun "rlRpmDownload $FORCE_SRPM"
fi
rlRun "rpm -i --define '_topdir $TmpDir' --nodeps *rpm"
rlRun "rpmbuild -bp --define '_topdir $TmpDir' --nodeps $TmpDir/SPECS/*"
# Remove module from extracted sources so installed one is used
rlRun "rm -rf $TmpDir/BUILD/*requests*/requests*"
rlRun "$PYTHON -m venv --system-site-packages $TmpDir/VENV"
rlRun "source $TmpDir/VENV/bin/activate"
# pip-install libraries not in the repos
# pytest is installed in fmf requirement
# MarkupSafe>=2.0 needed for pytest-httpbin, system one is much older
rlRun "$PYTHON -m pip install pytest-mock==3.2.0 pytest-httpbin==0.0.7 MarkupSafe==2.0"
# Move to test dir, print what is there
rlRun "cd $(dirname $TmpDir/BUILD/*requests*/tests)"
rlRun "touch tests/requirements-dev.txt"
rlRun "find . -type f"
rlRun "dnf repolist"
rlRun "$PYTHON -m pip list"
rlPhaseEnd
rlPhaseStartTest
# These fail:
# test_should_bypass_proxies_no_proxy[http://google.com:5000/v1.0/-False]
# test_should_bypass_proxies_no_proxy[http://172.16.1.12:5000/-False]
# test_should_bypass_proxies_no_proxy[http://172.16.1.12/-False]
rlRun 'pytest-3 -v -p no:warnings --junit-xml $TmpDir/result.xml -k "not test_should_bypass_proxies_no_proxy"'
rlAssertGrep '<testcase' $TmpDir/result.xml
rlPhaseEnd
rlPhaseStartCleanup
# upload log if test failed
rlGetTestState || rlRun "rlFileSubmit $TmpDir/result.xml"
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd